提交 2a491514 编写于 作者: E Eric Seidel

Remove a bunch of dead files found by missing_from_gn

I also fixed several errors in our BUILD.gn files
including bad script dependencies found by
missing_from_gn and gn check.

Still need to figure out how best to handle
:libraries deps being private to :core, etc.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/678703004
上级 f8c270e1
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
(function () {
var DebuggerScript = {};
DebuggerScript.PauseOnExceptionsState = {
DontPauseOnExceptions: 0,
PauseOnAllExceptions: 1,
PauseOnUncaughtExceptions: 2
};
DebuggerScript.ScopeInfoDetails = {
AllScopes: 0,
FastAsyncScopes: 1,
NoScopes: 2
};
DebuggerScript._pauseOnExceptionsState = DebuggerScript.PauseOnExceptionsState.DontPauseOnExceptions;
Debug.clearBreakOnException();
Debug.clearBreakOnUncaughtException();
DebuggerScript.getAfterCompileScript = function(eventData)
{
return DebuggerScript._formatScript(eventData.script_.script_);
}
DebuggerScript.getWorkerScripts = function()
{
var result = [];
var scripts = Debug.scripts();
for (var i = 0; i < scripts.length; ++i) {
var script = scripts[i];
// Workers don't share same V8 heap now so there is no need to complicate stuff with
// the context id like we do to discriminate between scripts from different pages.
// However we need to filter out v8 native scripts.
if (script.context_data && script.context_data === "worker")
result.push(DebuggerScript._formatScript(script));
}
return result;
}
DebuggerScript.getFunctionScopes = function(fun)
{
var mirror = MakeMirror(fun);
var count = mirror.scopeCount();
if (count == 0)
return null;
var result = [];
for (var i = 0; i < count; i++) {
var scopeDetails = mirror.scope(i).details();
result[i] = {
type: scopeDetails.type(),
object: DebuggerScript._buildScopeObject(scopeDetails.type(), scopeDetails.object())
};
}
return result;
}
DebuggerScript.getCollectionEntries = function(object)
{
var mirror = MakeMirror(object, true /* transient */);
if (mirror.isMap())
return mirror.entries();
if (mirror.isSet()) {
var result = [];
var values = mirror.values();
for (var i = 0; i < values.length; ++i)
result.push({ value: values[i] });
return result;
}
}
DebuggerScript.getInternalProperties = function(value)
{
var properties = ObjectMirror.GetInternalProperties(value);
var result = [];
for (var i = 0; i < properties.length; i++) {
var mirror = properties[i];
result.push({
name: mirror.name(),
value: mirror.value().value()
});
}
return result;
}
DebuggerScript.setFunctionVariableValue = function(functionValue, scopeIndex, variableName, newValue)
{
var mirror = MakeMirror(functionValue);
if (!mirror.isFunction())
throw new Error("Function value has incorrect type");
return DebuggerScript._setScopeVariableValue(mirror, scopeIndex, variableName, newValue);
}
DebuggerScript._setScopeVariableValue = function(scopeHolder, scopeIndex, variableName, newValue)
{
var scopeMirror = scopeHolder.scope(scopeIndex);
if (!scopeMirror)
throw new Error("Incorrect scope index");
scopeMirror.setVariableValue(variableName, newValue);
return undefined;
}
DebuggerScript.getScripts = function(contextData)
{
var result = [];
if (!contextData)
return result;
var comma = contextData.indexOf(",");
if (comma === -1)
return result;
// Context data is a string in the following format:
// ("page"|"injected")","<page id>
var idSuffix = contextData.substring(comma); // including the comma
var scripts = Debug.scripts();
for (var i = 0; i < scripts.length; ++i) {
var script = scripts[i];
if (script.context_data && script.context_data.lastIndexOf(idSuffix) != -1)
result.push(DebuggerScript._formatScript(script));
}
return result;
}
DebuggerScript._formatScript = function(script)
{
var lineEnds = script.line_ends;
var lineCount = lineEnds.length;
var endLine = script.line_offset + lineCount - 1;
var endColumn;
// V8 will not count last line if script source ends with \n.
if (script.source[script.source.length - 1] === '\n') {
endLine += 1;
endColumn = 0;
} else {
if (lineCount === 1)
endColumn = script.source.length + script.column_offset;
else
endColumn = script.source.length - (lineEnds[lineCount - 2] + 1);
}
return {
id: script.id,
name: script.nameOrSourceURL(),
sourceURL: script.source_url,
sourceMappingURL: script.source_mapping_url,
source: script.source,
startLine: script.line_offset,
startColumn: script.column_offset,
endLine: endLine,
endColumn: endColumn,
isContentScript: !!script.context_data && script.context_data.indexOf("injected") == 0
};
}
DebuggerScript.setBreakpoint = function(execState, info)
{
var positionAlignment = info.interstatementLocation ? Debug.BreakPositionAlignment.BreakPosition : Debug.BreakPositionAlignment.Statement;
var breakId = Debug.setScriptBreakPointById(info.sourceID, info.lineNumber, info.columnNumber, info.condition, undefined, positionAlignment);
var locations = Debug.findBreakPointActualLocations(breakId);
if (!locations.length)
return undefined;
info.lineNumber = locations[0].line;
info.columnNumber = locations[0].column;
return breakId.toString();
}
DebuggerScript.removeBreakpoint = function(execState, info)
{
Debug.findBreakPoint(info.breakpointId, true);
}
DebuggerScript.pauseOnExceptionsState = function()
{
return DebuggerScript._pauseOnExceptionsState;
}
DebuggerScript.setPauseOnExceptionsState = function(newState)
{
DebuggerScript._pauseOnExceptionsState = newState;
if (DebuggerScript.PauseOnExceptionsState.PauseOnAllExceptions === newState)
Debug.setBreakOnException();
else
Debug.clearBreakOnException();
if (DebuggerScript.PauseOnExceptionsState.PauseOnUncaughtExceptions === newState)
Debug.setBreakOnUncaughtException();
else
Debug.clearBreakOnUncaughtException();
}
DebuggerScript.frameCount = function(execState)
{
return execState.frameCount();
}
DebuggerScript.currentCallFrame = function(execState, data)
{
var maximumLimit = data >> 2;
var scopeDetailsLevel = data & 3;
var frameCount = execState.frameCount();
if (maximumLimit && maximumLimit < frameCount)
frameCount = maximumLimit;
var topFrame = undefined;
for (var i = frameCount - 1; i >= 0; i--) {
var frameMirror = execState.frame(i);
topFrame = DebuggerScript._frameMirrorToJSCallFrame(frameMirror, topFrame, scopeDetailsLevel);
}
return topFrame;
}
DebuggerScript.currentCallFrameByIndex = function(execState, index)
{
if (index < 0)
return undefined;
var frameCount = execState.frameCount();
if (index >= frameCount)
return undefined;
return DebuggerScript._frameMirrorToJSCallFrame(execState.frame(index), undefined, DebuggerScript.ScopeInfoDetails.NoScopes);
}
DebuggerScript.stepIntoStatement = function(execState)
{
execState.prepareStep(Debug.StepAction.StepIn, 1);
}
DebuggerScript.stepOverStatement = function(execState, callFrame)
{
execState.prepareStep(Debug.StepAction.StepNext, 1);
}
DebuggerScript.stepOutOfFunction = function(execState, callFrame)
{
execState.prepareStep(Debug.StepAction.StepOut, 1);
}
// Returns array in form:
// [ 0, <v8_result_report> ] in case of success
// or [ 1, <general_error_message>, <compiler_message>, <line_number>, <column_number> ] in case of compile error, numbers are 1-based.
// or throws exception with message.
DebuggerScript.liveEditScriptSource = function(scriptId, newSource, preview)
{
var scripts = Debug.scripts();
var scriptToEdit = null;
for (var i = 0; i < scripts.length; i++) {
if (scripts[i].id == scriptId) {
scriptToEdit = scripts[i];
break;
}
}
if (!scriptToEdit)
throw("Script not found");
var changeLog = [];
try {
var result = Debug.LiveEdit.SetScriptSource(scriptToEdit, newSource, preview, changeLog);
return [0, result];
} catch (e) {
if (e instanceof Debug.LiveEdit.Failure && "details" in e) {
var details = e.details;
if (details.type === "liveedit_compile_error") {
var startPosition = details.position.start;
return [1, String(e), String(details.syntaxErrorMessage), Number(startPosition.line), Number(startPosition.column)];
}
}
throw e;
}
}
DebuggerScript.clearBreakpoints = function(execState, info)
{
Debug.clearAllBreakPoints();
}
DebuggerScript.setBreakpointsActivated = function(execState, info)
{
Debug.debuggerFlags().breakPointsActive.setValue(info.enabled);
}
DebuggerScript.getScriptSource = function(eventData)
{
return eventData.script().source();
}
DebuggerScript.setScriptSource = function(eventData, source)
{
if (eventData.script().data() === "injected-script")
return;
eventData.script().setSource(source);
}
DebuggerScript.getScriptName = function(eventData)
{
return eventData.script().script_.nameOrSourceURL();
}
DebuggerScript.getBreakpointNumbers = function(eventData)
{
var breakpoints = eventData.breakPointsHit();
var numbers = [];
if (!breakpoints)
return numbers;
for (var i = 0; i < breakpoints.length; i++) {
var breakpoint = breakpoints[i];
var scriptBreakPoint = breakpoint.script_break_point();
numbers.push(scriptBreakPoint ? scriptBreakPoint.number() : breakpoint.number());
}
return numbers;
}
DebuggerScript.isEvalCompilation = function(eventData)
{
var script = eventData.script();
return (script.compilationType() === Debug.ScriptCompilationType.Eval);
}
// NOTE: This function is performance critical, as it can be run on every
// statement that generates an async event (like addEventListener) to support
// asynchronous call stacks. Thus, when possible, initialize the data lazily.
DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame, scopeDetailsLevel)
{
// Stuff that can not be initialized lazily (i.e. valid while paused with a valid break_id).
// The frameMirror and scopeMirror can be accessed only while paused on the debugger.
var frameDetails = frameMirror.details();
var funcObject = frameDetails.func();
var sourcePosition = frameDetails.sourcePosition();
var thisObject = frameDetails.receiver();
var isAtReturn = !!frameDetails.isAtReturn();
var returnValue = isAtReturn ? frameDetails.returnValue() : undefined;
var scopeMirrors = (scopeDetailsLevel === DebuggerScript.ScopeInfoDetails.NoScopes ? [] : frameMirror.allScopes(scopeDetailsLevel === DebuggerScript.ScopeInfoDetails.FastAsyncScopes));
var scopeTypes = new Array(scopeMirrors.length);
var scopeObjects = new Array(scopeMirrors.length);
for (var i = 0; i < scopeMirrors.length; ++i) {
var scopeDetails = scopeMirrors[i].details();
scopeTypes[i] = scopeDetails.type();
scopeObjects[i] = scopeDetails.object();
}
// Calculated lazily.
var scopeChain;
var funcMirror;
var location;
function lazyScopeChain()
{
if (!scopeChain) {
scopeChain = [];
for (var i = 0; i < scopeObjects.length; ++i)
scopeChain.push(DebuggerScript._buildScopeObject(scopeTypes[i], scopeObjects[i]));
scopeObjects = null; // Free for GC.
}
return scopeChain;
}
function ensureFuncMirror()
{
if (!funcMirror) {
funcMirror = MakeMirror(funcObject);
if (!funcMirror.isFunction())
funcMirror = new UnresolvedFunctionMirror(funcObject);
}
return funcMirror;
}
function ensureLocation()
{
if (!location) {
var script = ensureFuncMirror().script();
if (script)
location = script.locationFromPosition(sourcePosition, true);
if (!location)
location = { line: 0, column: 0 };
}
return location;
}
function line()
{
return ensureLocation().line;
}
function column()
{
return ensureLocation().column;
}
function sourceID()
{
var script = ensureFuncMirror().script();
return script && script.id();
}
function scriptName()
{
var script = ensureFuncMirror().script();
return script && script.name();
}
function functionName()
{
var func = ensureFuncMirror();
if (!func.resolved())
return undefined;
var displayName;
var valueMirror = func.property("displayName").value();
if (valueMirror && valueMirror.isString())
displayName = valueMirror.value();
return displayName || func.name() || func.inferredName();
}
function evaluate(expression)
{
return frameMirror.evaluate(expression, false).value();
}
function restart()
{
return Debug.LiveEdit.RestartFrame(frameMirror);
}
function setVariableValue(scopeNumber, variableName, newValue)
{
return DebuggerScript._setScopeVariableValue(frameMirror, scopeNumber, variableName, newValue);
}
function stepInPositions()
{
var stepInPositionsV8 = frameMirror.stepInPositions();
var stepInPositionsProtocol;
if (stepInPositionsV8) {
stepInPositionsProtocol = [];
var script = ensureFuncMirror().script();
if (script) {
var scriptId = String(script.id());
for (var i = 0; i < stepInPositionsV8.length; i++) {
var item = {
scriptId: scriptId,
lineNumber: stepInPositionsV8[i].position.line,
columnNumber: stepInPositionsV8[i].position.column
};
stepInPositionsProtocol.push(item);
}
}
}
return JSON.stringify(stepInPositionsProtocol);
}
return {
"sourceID": sourceID,
"line": line,
"column": column,
"scriptName": scriptName,
"functionName": functionName,
"thisObject": thisObject,
"scopeChain": lazyScopeChain,
"scopeType": scopeTypes,
"evaluate": evaluate,
"caller": callerFrame,
"restart": restart,
"setVariableValue": setVariableValue,
"stepInPositions": stepInPositions,
"isAtReturn": isAtReturn,
"returnValue": returnValue
};
}
DebuggerScript._buildScopeObject = function(scopeType, scopeObject)
{
var result;
switch (scopeType) {
case ScopeType.Local:
case ScopeType.Closure:
case ScopeType.Catch:
// For transient objects we create a "persistent" copy that contains
// the same properties.
// Reset scope object prototype to null so that the proto properties
// don't appear in the local scope section.
result = { __proto__: null };
var properties = MakeMirror(scopeObject, true /* transient */).properties();
for (var j = 0; j < properties.length; j++) {
var name = properties[j].name();
if (name.charAt(0) === ".")
continue; // Skip internal variables like ".arguments"
result[name] = properties[j].value_;
}
break;
case ScopeType.Global:
case ScopeType.With:
result = scopeObject;
break;
case ScopeType.Block:
// Unsupported yet. Mustn't be reachable.
break;
}
return result;
}
DebuggerScript.getPromiseDetails = function(eventData)
{
return {
"promise": eventData.promise().value(),
"parentPromise": eventData.parentPromise().value(),
"status": eventData.status()
};
}
// We never resolve Mirror by its handle so to avoid memory leaks caused by Mirrors in the cache we disable it.
ToggleMirrorCache(false);
return DebuggerScript;
})();
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "bindings/core/v8/V8JavaScriptCallFrame.h"
#include "bindings/core/v8/V8Binding.h"
namespace blink {
void V8JavaScriptCallFrame::evaluateWithExceptionDetailsMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
JavaScriptCallFrame* impl = V8JavaScriptCallFrame::toNative(info.Holder());
String expression = toCoreStringWithUndefinedOrNullCheck(info[0]);
v8SetReturnValue(info, impl->evaluateWithExceptionDetails(expression));
}
void V8JavaScriptCallFrame::restartMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
JavaScriptCallFrame* impl = V8JavaScriptCallFrame::toNative(info.Holder());
v8SetReturnValue(info, impl->restart());
}
void V8JavaScriptCallFrame::scopeChainAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
JavaScriptCallFrame* impl = V8JavaScriptCallFrame::toNative(info.Holder());
v8SetReturnValue(info, impl->scopeChain());
}
void V8JavaScriptCallFrame::scopeTypeMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
JavaScriptCallFrame* impl = V8JavaScriptCallFrame::toNative(info.Holder());
int scopeIndex = info[0]->Int32Value();
v8SetReturnValue(info, impl->scopeType(scopeIndex));
}
void V8JavaScriptCallFrame::thisObjectAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
JavaScriptCallFrame* impl = V8JavaScriptCallFrame::toNative(info.Holder());
v8SetReturnValue(info, impl->thisObject());
}
void V8JavaScriptCallFrame::returnValueAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
JavaScriptCallFrame* impl = V8JavaScriptCallFrame::toNative(info.Holder());
v8SetReturnValue(info, impl->returnValue());
}
void V8JavaScriptCallFrame::typeAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
v8SetReturnValue(info, v8AtomicString(info.GetIsolate(), "function"));
}
} // namespace blink
#!/bin/bash
#
# Copyright (C) 2011 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# This script checks a WebCore static library for potential Objective-C
# class name collisions with the system's copy of the WebCore framework.
# See the postbuild action that calls it from ../WebCore.gyp for details.
set -e
set -o pipefail
if [[ $# -ne 2 ]]; then
echo "usage: ${0} class_whitelist_pattern category_whitelist_pattern" >& 2
exit 1
fi
lib="${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}"
nm_pattern='[atsATS] ([+-]\[|\.objc_class_name_)'
class_whitelist_pattern="${1}"
category_whitelist_pattern="${2}"
# Send nm's stderr in the pipeline to /dev/null to avoid spewing
# "nm: no name list" messages. This means that if the pipelined nm fails, there
# won't be any output, so if the entire assignment fails, run nm again to get
# some output.
violators=$(nm -p "${lib}" 2> /dev/null | \
(grep -E "${nm_pattern}" || true) | \
(grep -Ev "${nm_pattern}(${class_whitelist_pattern})" || true) | \
(grep -Ev "\((${category_whitelist_pattern})\)" || true)) || nm -p "${lib}"
if [[ -z "${violators}" ]]; then
# An empty list means that everything's clean.
exit 0
fi
cat << __EOF__ >&2
These Objective-C symbols may clash with those provided by the system's own
WebCore framework:
${violators}
These symbols were found in:
${lib}
This should be corrected by adding the appropriate definitions to
$(dirname ${0})/../WebCore.gyp
or by updating the whitelist in
${0}
__EOF__
exit 1
......@@ -12,13 +12,14 @@ rel_sky_core_gen_dir = rebase_path(sky_core_output_dir, root_build_dir)
source_set("libraries") {
deps = [
"//base:base",
"//gin",
"//gpu/command_buffer/client:gles2_c_lib",
"//mojo/common",
"//mojo/application",
"//mojo/common",
"//mojo/public/c/system:for_shared_library",
"//mojo/public/cpp/bindings",
"//mojo/public/cpp/utility",
"//mojo/public/c/system:for_shared_library",
"//skia",
"//sky/engine/wtf",
"//third_party/angle:translator",
......@@ -110,9 +111,6 @@ source_set("core_generated") {
# Additional .cpp files from the make_core_generated rules.
"$sky_core_output_dir/CSSGrammar.cpp",
# Generated from make_css_property_metadata.py
"$sky_core_output_dir/CSSPropertyMetadata.cpp",
]
configs += [
......@@ -191,20 +189,21 @@ group("core_names") {
group("make_core_generated") {
deps = [
":core_names",
":make_core_generated_bison",
":make_core_generated_css_property_metadata",
":make_core_generated_css_value_keywords",
":make_core_generated_event_factory",
":make_core_generated_html_element_lookup_trie",
":make_core_generated_html_element_type_helpers",
":make_core_generated_html_entity_table",
":make_core_generated_make_parser",
":make_core_generated_make_token_matcher",
":make_core_generated_make_token_matcher_for_viewport",
":make_core_generated_media_feature_names",
":make_core_generated_media_features",
":make_core_generated_media_query_tokenizer_codepoints",
":make_core_generated_style_property_shorthand",
":make_core_generated_style_builder",
":make_core_generated_css_value_keywords",
":make_core_generated_html_element_type_helpers",
":make_core_generated_event_factory",
":make_core_generated_make_token_matcher",
":make_core_generated_make_parser",
":make_core_generated_make_token_matcher_for_viewport",
":make_core_generated_html_element_lookup_trie",
":make_core_generated_bison",
":make_core_generated_style_property_shorthand",
]
}
......
......@@ -989,6 +989,8 @@ sky_core_files = [
"inspector/IdentifiersFactory.h",
"inspector/InspectorTraceEvents.cpp",
"inspector/InspectorTraceEvents.h",
"inspector/ScriptProfile.cpp",
"inspector/ScriptProfile.h",
"inspector/ScriptArguments.cpp",
"inspector/ScriptArguments.h",
"inspector/ScriptAsyncCallStack.cpp",
......
......@@ -20,4 +20,4 @@ public:
} // namespace blink
#endif // CSSPropertyMetadata
#endif // CSSPropertyMetadata_h
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "core/inspector/TraceEventDispatcher.h"
#include "wtf/CurrentTime.h"
#include "wtf/Functional.h"
#include "wtf/MainThread.h"
#include "wtf/text/StringHash.h"
namespace blink {
void TraceEventDispatcher::dispatchEventOnAnyThread(char phase, const unsigned char*, const char* name, unsigned long long id,
int numArgs, const char* const* argNames, const unsigned char* argTypes, const unsigned long long* argValues,
unsigned char flags, double timestamp)
{
TraceEventDispatcher* self = instance();
{
MutexLocker locker(self->m_mutex);
if (self->m_listeners->find(std::make_pair(name, phase)) == self->m_listeners->end())
return;
}
self->enqueueEvent(TraceEvent(timestamp, phase, name, id, currentThread(), numArgs, argNames, argTypes, argValues));
if (isMainThread())
self->processBackgroundEvents();
}
void TraceEventDispatcher::enqueueEvent(const TraceEvent& event)
{
const float eventProcessingThresholdInSeconds = 0.1;
{
MutexLocker locker(m_mutex);
m_backgroundEvents.append(event);
if (m_processEventsTaskInFlight || event.timestamp() - m_lastEventProcessingTime <= eventProcessingThresholdInSeconds)
return;
}
m_processEventsTaskInFlight = true;
callOnMainThread(bind(&TraceEventDispatcher::processBackgroundEventsTask, this));
}
void TraceEventDispatcher::processBackgroundEventsTask()
{
m_processEventsTaskInFlight = false;
processBackgroundEvents();
}
void TraceEventDispatcher::processBackgroundEvents()
{
ASSERT(isMainThread());
Vector<TraceEvent> events;
{
MutexLocker locker(m_mutex);
m_lastEventProcessingTime = WTF::monotonicallyIncreasingTime();
if (m_backgroundEvents.isEmpty())
return;
events.reserveCapacity(m_backgroundEvents.capacity());
m_backgroundEvents.swap(events);
}
for (size_t eventIndex = 0, size = events.size(); eventIndex < size; ++eventIndex) {
const TraceEvent& event = events[eventIndex];
ListenersMap::iterator it = m_listeners->find(std::make_pair(event.name(), event.phase()));
if (it == m_listeners->end())
continue;
WillBeHeapVector<OwnPtrWillBeMember<TraceEventListener> >& listeners = *it->value.get();
for (size_t listenerIndex = 0; listenerIndex < listeners.size(); ++listenerIndex)
listeners[listenerIndex]->call(event);
}
}
void TraceEventDispatcher::addListener(const char* name, char phase, PassOwnPtrWillBeRawPtr<TraceEventListener> listener, InspectorClient* client)
{
static const char CategoryFilter[] = "-*," TRACE_DISABLED_BY_DEFAULT("devtools.timeline") "," TRACE_DISABLED_BY_DEFAULT("devtools.timeline.frame");
ASSERT(isMainThread());
MutexLocker locker(m_mutex);
if (m_listeners->isEmpty())
client->setTraceEventCallback(CategoryFilter, dispatchEventOnAnyThread);
ListenersMap::iterator it = m_listeners->find(std::make_pair(name, phase));
if (it == m_listeners->end())
m_listeners->add(std::make_pair(name, phase), adoptPtrWillBeNoop(new WillBeHeapVector<OwnPtrWillBeMember<TraceEventListener> >())).storedValue->value->append(listener);
else
it->value->append(listener);
}
void TraceEventDispatcher::removeAllListeners(void* eventTarget, InspectorClient* client)
{
ASSERT(isMainThread());
processBackgroundEvents();
{
MutexLocker locker(m_mutex);
ListenersMap remainingListeners;
for (ListenersMap::iterator it = m_listeners->begin(); it != m_listeners->end(); ++it) {
WillBeHeapVector<OwnPtrWillBeMember<TraceEventListener> >& listeners = *it->value.get();
for (size_t j = 0; j < listeners.size();) {
if (listeners[j]->target() == eventTarget)
listeners.remove(j);
else
++j;
}
if (!listeners.isEmpty())
remainingListeners.add(it->key, it->value.release());
}
m_listeners->swap(remainingListeners);
}
if (m_listeners->isEmpty())
client->resetTraceEventCallback();
}
size_t TraceEventDispatcher::TraceEvent::findParameter(const char* name) const
{
for (int i = 0; i < m_argumentCount; ++i) {
if (!strcmp(name, m_argumentNames[i]))
return i;
}
return kNotFound;
}
const TraceEvent::TraceValueUnion& TraceEventDispatcher::TraceEvent::parameter(const char* name, unsigned char expectedType) const
{
static blink::TraceEvent::TraceValueUnion missingValue;
size_t index = findParameter(name);
ASSERT(isMainThread());
if (index == kNotFound || m_argumentTypes[index] != expectedType) {
ASSERT_NOT_REACHED();
return missingValue;
}
return m_argumentValues[index];
}
} // namespace blink
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TraceEventDispatcher_h
#define TraceEventDispatcher_h
#include "platform/TraceEvent.h"
#include "platform/heap/Handle.h"
#include "wtf/HashMap.h"
#include "wtf/Threading.h"
#include "wtf/ThreadingPrimitives.h"
#include "wtf/Vector.h"
#include "wtf/text/StringHash.h"
#include "wtf/text/WTFString.h"
namespace blink {
class InspectorClient;
class TraceEventDispatcher {
WTF_MAKE_NONCOPYABLE(TraceEventDispatcher);
public:
class TraceEvent {
public:
TraceEvent()
: m_name(0)
, m_argumentCount(0)
{
}
TraceEvent(double timestamp, char phase, const char* name, unsigned long long id, ThreadIdentifier threadIdentifier,
int argumentCount, const char* const* argumentNames, const unsigned char* argumentTypes, const unsigned long long* argumentValues)
: m_timestamp(timestamp)
, m_phase(phase)
, m_name(name)
, m_id(id)
, m_threadIdentifier(threadIdentifier)
, m_argumentCount(argumentCount)
{
if (m_argumentCount > MaxArguments) {
ASSERT_NOT_REACHED();
m_argumentCount = MaxArguments;
}
for (int i = 0; i < m_argumentCount; ++i) {
m_argumentNames[i] = argumentNames[i];
if (argumentTypes[i] == TRACE_VALUE_TYPE_COPY_STRING) {
m_stringArguments[i] = reinterpret_cast<const char*>(argumentValues[i]);
m_argumentValues[i].m_string = reinterpret_cast<const char*>(m_stringArguments[i].characters8());
m_argumentTypes[i] = TRACE_VALUE_TYPE_STRING;
} else {
m_argumentValues[i].m_int = argumentValues[i];
m_argumentTypes[i] = argumentTypes[i];
}
}
}
double timestamp() const { return m_timestamp; }
char phase() const { return m_phase; }
const char* name() const { return m_name; }
unsigned long long id() const { return m_id; }
ThreadIdentifier threadIdentifier() const { return m_threadIdentifier; }
int argumentCount() const { return m_argumentCount; }
bool isNull() const { return !m_name; }
bool asBool(const char* name) const
{
return parameter(name, TRACE_VALUE_TYPE_BOOL).m_bool;
}
long long asInt(const char* name) const
{
size_t index = findParameter(name);
if (index == kNotFound || (m_argumentTypes[index] != TRACE_VALUE_TYPE_INT && m_argumentTypes[index] != TRACE_VALUE_TYPE_UINT)) {
ASSERT_NOT_REACHED();
return 0;
}
return reinterpret_cast<const blink::TraceEvent::TraceValueUnion*>(m_argumentValues + index)->m_int;
}
unsigned long long asUInt(const char* name) const
{
return asInt(name);
}
double asDouble(const char* name) const
{
return parameter(name, TRACE_VALUE_TYPE_DOUBLE).m_double;
}
const char* asString(const char* name) const
{
return parameter(name, TRACE_VALUE_TYPE_STRING).m_string;
}
private:
enum { MaxArguments = 2 };
size_t findParameter(const char*) const;
const blink::TraceEvent::TraceValueUnion& parameter(const char* name, unsigned char expectedType) const;
double m_timestamp;
char m_phase;
const char* m_name;
unsigned long long m_id;
ThreadIdentifier m_threadIdentifier;
int m_argumentCount;
const char* m_argumentNames[MaxArguments];
unsigned char m_argumentTypes[MaxArguments];
blink::TraceEvent::TraceValueUnion m_argumentValues[MaxArguments];
// These are only used as buffers for TRACE_VALUE_TYPE_COPY_STRING.
// Consider allocating the entire vector of buffered trace events and their copied arguments out of a special arena
// to make things more compact.
String m_stringArguments[MaxArguments];
};
class TraceEventListener : public NoBaseWillBeGarbageCollected<TraceEventListener> {
public:
#if !ENABLE(OILPAN)
virtual ~TraceEventListener() { }
#endif
virtual void call(const TraceEventDispatcher::TraceEvent&) = 0;
virtual void* target() = 0;
virtual void trace(Visitor*) { }
};
static TraceEventDispatcher* instance()
{
DEFINE_STATIC_LOCAL(TraceEventDispatcher, instance, ());
return &instance;
}
void addListener(const char* name, char phase, PassOwnPtrWillBeRawPtr<TraceEventListener>, InspectorClient*);
void removeAllListeners(void*, InspectorClient*);
void processBackgroundEvents();
private:
typedef std::pair<String, int> EventSelector;
typedef WillBeHeapHashMap<EventSelector, OwnPtrWillBeMember<WillBeHeapVector<OwnPtrWillBeMember<TraceEventListener> > > > ListenersMap;
TraceEventDispatcher()
: m_listeners(adoptPtrWillBeNoop(new ListenersMap()))
, m_processEventsTaskInFlight(false)
, m_lastEventProcessingTime(0)
{
}
static void dispatchEventOnAnyThread(char phase, const unsigned char*, const char* name, unsigned long long id,
int numArgs, const char* const* argNames, const unsigned char* argTypes, const unsigned long long* argValues,
unsigned char flags, double timestamp);
void enqueueEvent(const TraceEvent&);
void processBackgroundEventsTask();
Mutex m_mutex;
OwnPtrWillBePersistent<ListenersMap> m_listeners;
Vector<TraceEvent> m_backgroundEvents;
bool m_processEventsTaskInFlight;
double m_lastEventProcessingTime;
};
} // namespace blink
#endif // TraceEventDispatcher_h
......@@ -212,7 +212,6 @@ component("platform") {
"clipboard/ClipboardUtilities.cpp",
"clipboard/ClipboardUtilities.h",
"clipboard/ClipboardUtilitiesPosix.cpp",
"clipboard/ClipboardUtilitiesWin.cpp",
"exported/Platform.cpp",
"exported/WebActiveGestureAnimation.cpp",
"exported/WebActiveGestureAnimation.h",
......@@ -306,8 +305,6 @@ component("platform") {
"fonts/opentype/OpenTypeSanitizer.cpp",
"fonts/opentype/OpenTypeSanitizer.h",
"fonts/opentype/OpenTypeTypes.h",
"fonts/opentype/OpenTypeUtilities.cpp",
"fonts/opentype/OpenTypeUtilities.h",
"fonts/opentype/OpenTypeVerticalData.cpp",
"fonts/opentype/OpenTypeVerticalData.h",
"fonts/skia/FontCacheSkia.cpp",
......@@ -582,8 +579,6 @@ component("platform") {
"text/LocaleICU.h",
"text/LocaleToScriptMapping.cpp",
"text/LocaleToScriptMapping.h",
"text/LocaleWin.cpp",
"text/LocaleWin.h",
"text/NonCJKGlyphOrientation.h",
"text/ParserUtilities.h",
"text/PlatformLocale.cpp",
......@@ -715,26 +710,6 @@ component("platform") {
"fonts/harfbuzz/HarfBuzzFaceCoreText.cpp",
]
if (is_win) {
sources -= [
# Uses LocaleWin instead.
"text/LocaleICU.cpp",
"text/LocaleICU.h",
]
cflags = [
"/wd4267", # Conversion from 'size_t' to 'type', possible loss of data.
"/wd4334", # Result of 32-bit shift implicitly converted to 64 bits.
"/wd4724", # Modulo by 0.
]
} else {
sources -= [
"clipboard/ClipboardUtilitiesWin.cpp",
"fonts/opentype/OpenTypeUtilities.cpp",
"fonts/opentype/OpenTypeUtilities.h",
"text/LocaleWin.cpp",
]
}
if (is_android) {
# Add in some Linux files also shared with Android.
set_sources_assignment_filter([])
......
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
* Copyright (C) 2009 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "platform/clipboard/ClipboardUtilities.h"
#include "wtf/text/StringBuilder.h"
#include "wtf/text/WTFString.h"
#include <shlwapi.h>
namespace blink {
// FAT32 and NTFS both limit filenames to a maximum of 255 characters.
static const unsigned maxFilenameLength = 255;
// Returns true if the specified character is not valid in a file name. This
// is intended for use with removeCharacters.
static bool isInvalidFileCharacter(UChar c)
{
return !(PathGetCharType(c) & (GCT_LFNCHAR | GCT_SHORTCHAR));
}
void replaceNewlinesWithWindowsStyleNewlines(String& str)
{
DEFINE_STATIC_LOCAL(String, windowsNewline, ("\r\n"));
StringBuilder result;
for (unsigned index = 0; index < str.length(); ++index) {
if (str[index] != '\n' || (index > 0 && str[index - 1] == '\r'))
result.append(str[index]);
else
result.append(windowsNewline);
}
str = result.toString();
}
void validateFilename(String& name, String& extension)
{
// Remove any invalid file system characters.
name = name.removeCharacters(&isInvalidFileCharacter);
extension = extension.removeCharacters(&isInvalidFileCharacter);
if (extension.length() >= maxFilenameLength)
extension = String();
// Truncate overly-long filenames, reserving one character for a dot.
name.truncate(maxFilenameLength - extension.length() - 1);
}
} // namespace blink
/*
* Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2009 Torch Mobile, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "platform/fonts/opentype/OpenTypeUtilities.h"
#include "platform/SharedBuffer.h"
namespace blink {
struct BigEndianUShort {
operator unsigned short() const { return (v & 0x00ff) << 8 | v >> 8; }
BigEndianUShort(unsigned short u) : v((u & 0x00ff) << 8 | u >> 8) { }
unsigned short v;
};
struct BigEndianULong {
operator unsigned() const { return (v & 0xff) << 24 | (v & 0xff00) << 8 | (v & 0xff0000) >> 8 | v >> 24; }
BigEndianULong(unsigned u) : v((u & 0xff) << 24 | (u & 0xff00) << 8 | (u & 0xff0000) >> 8 | u >> 24) { }
unsigned v;
};
#pragma pack(1)
struct TableDirectoryEntry {
BigEndianULong tag;
BigEndianULong checkSum;
BigEndianULong offset;
BigEndianULong length;
};
// Fixed type is not defined on non-CG and Windows platforms. |version| in sfntHeader
// and headTable and |fontRevision| in headTable are of Fixed, but they're
// not actually refered to anywhere. Therefore, we just have to match
// the size (4 bytes). For the definition of Fixed type, see
// http://developer.apple.com/documentation/mac/Legacy/GXEnvironment/GXEnvironment-356.html#HEADING356-6.
typedef int32_t Fixed;
struct sfntHeader {
Fixed version;
BigEndianUShort numTables;
BigEndianUShort searchRange;
BigEndianUShort entrySelector;
BigEndianUShort rangeShift;
TableDirectoryEntry tables[1];
};
struct OS2Table {
BigEndianUShort version;
BigEndianUShort avgCharWidth;
BigEndianUShort weightClass;
BigEndianUShort widthClass;
BigEndianUShort fsType;
BigEndianUShort subscriptXSize;
BigEndianUShort subscriptYSize;
BigEndianUShort subscriptXOffset;
BigEndianUShort subscriptYOffset;
BigEndianUShort superscriptXSize;
BigEndianUShort superscriptYSize;
BigEndianUShort superscriptXOffset;
BigEndianUShort superscriptYOffset;
BigEndianUShort strikeoutSize;
BigEndianUShort strikeoutPosition;
BigEndianUShort familyClass;
uint8_t panose[10];
BigEndianULong unicodeRange[4];
uint8_t vendID[4];
BigEndianUShort fsSelection;
BigEndianUShort firstCharIndex;
BigEndianUShort lastCharIndex;
BigEndianUShort typoAscender;
BigEndianUShort typoDescender;
BigEndianUShort typoLineGap;
BigEndianUShort winAscent;
BigEndianUShort winDescent;
BigEndianULong codePageRange[2];
BigEndianUShort xHeight;
BigEndianUShort capHeight;
BigEndianUShort defaultChar;
BigEndianUShort breakChar;
BigEndianUShort maxContext;
};
struct headTable {
Fixed version;
Fixed fontRevision;
BigEndianULong checkSumAdjustment;
BigEndianULong magicNumber;
BigEndianUShort flags;
BigEndianUShort unitsPerEm;
long long created;
long long modified;
BigEndianUShort xMin;
BigEndianUShort xMax;
BigEndianUShort yMin;
BigEndianUShort yMax;
BigEndianUShort macStyle;
BigEndianUShort lowestRectPPEM;
BigEndianUShort fontDirectionHint;
BigEndianUShort indexToLocFormat;
BigEndianUShort glyphDataFormat;
};
struct nameRecord {
BigEndianUShort platformID;
BigEndianUShort encodingID;
BigEndianUShort languageID;
BigEndianUShort nameID;
BigEndianUShort length;
BigEndianUShort offset;
};
struct nameTable {
BigEndianUShort format;
BigEndianUShort count;
BigEndianUShort stringOffset;
nameRecord nameRecords[1];
};
#pragma pack()
// adds fontName to the font table in fontData, and writes the new font table to rewrittenFontTable
// returns the size of the name table (which is used by renameAndActivateFont), or 0 on early abort
static size_t renameFont(SharedBuffer* fontData, const String& fontName, Vector<char> &rewrittenFontData)
{
size_t originalDataSize = fontData->size();
const sfntHeader* sfnt = reinterpret_cast<const sfntHeader*>(fontData->data());
unsigned t;
for (t = 0; t < sfnt->numTables; ++t) {
if (sfnt->tables[t].tag == 'name')
break;
}
if (t == sfnt->numTables)
return 0;
const int nameRecordCount = 5;
// Rounded up to a multiple of 4 to simplify the checksum calculation.
size_t nameTableSize = ((offsetof(nameTable, nameRecords) + nameRecordCount * sizeof(nameRecord) + fontName.length() * sizeof(UChar)) & ~3) + 4;
rewrittenFontData.resize(fontData->size() + nameTableSize);
char* data = rewrittenFontData.data();
memcpy(data, fontData->data(), originalDataSize);
// Make the table directory entry point to the new 'name' table.
sfntHeader* rewrittenSfnt = reinterpret_cast<sfntHeader*>(data);
rewrittenSfnt->tables[t].length = nameTableSize;
rewrittenSfnt->tables[t].offset = originalDataSize;
// Write the new 'name' table after the original font data.
nameTable* name = reinterpret_cast<nameTable*>(data + originalDataSize);
name->format = 0;
name->count = nameRecordCount;
name->stringOffset = offsetof(nameTable, nameRecords) + nameRecordCount * sizeof(nameRecord);
for (unsigned i = 0; i < nameRecordCount; ++i) {
name->nameRecords[i].platformID = 3;
name->nameRecords[i].encodingID = 1;
name->nameRecords[i].languageID = 0x0409;
name->nameRecords[i].offset = 0;
name->nameRecords[i].length = fontName.length() * sizeof(UChar);
}
// The required 'name' record types: Family, Style, Unique, Full and PostScript.
name->nameRecords[0].nameID = 1;
name->nameRecords[1].nameID = 2;
name->nameRecords[2].nameID = 3;
name->nameRecords[3].nameID = 4;
name->nameRecords[4].nameID = 6;
for (unsigned i = 0; i < fontName.length(); ++i)
reinterpret_cast<BigEndianUShort*>(data + originalDataSize + name->stringOffset)[i] = fontName[i];
// Update the table checksum in the directory entry.
rewrittenSfnt->tables[t].checkSum = 0;
for (unsigned i = 0; i * sizeof(BigEndianULong) < nameTableSize; ++i)
rewrittenSfnt->tables[t].checkSum = rewrittenSfnt->tables[t].checkSum + reinterpret_cast<BigEndianULong*>(name)[i];
return nameTableSize;
}
// Rename the font and install the new font data into the system
HANDLE renameAndActivateFont(SharedBuffer* fontData, const String& fontName)
{
Vector<char> rewrittenFontData;
size_t nameTableSize = renameFont(fontData, fontName, rewrittenFontData);
if (!nameTableSize)
return 0;
DWORD numFonts = 0;
HANDLE fontHandle = AddFontMemResourceEx(rewrittenFontData.data(), fontData->size() + nameTableSize, 0, &numFonts);
if (fontHandle && numFonts < 1) {
RemoveFontMemResourceEx(fontHandle);
return 0;
}
return fontHandle;
}
} // namespace blink
/*
* Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2009 Torch Mobile, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OpenTypeUtilities_h
#define OpenTypeUtilities_h
#include <windows.h>
#include "wtf/text/WTFString.h"
namespace blink {
class SharedBuffer;
HANDLE renameAndActivateFont(SharedBuffer*, const String&);
} // namespace blink
#endif // OpenTypeUtilities_h
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "platform/text/LocaleWin.h"
#include <limits>
#include "platform/DateComponents.h"
#include "platform/Language.h"
#include "platform/LayoutTestSupport.h"
#include "platform/text/DateTimeFormat.h"
#include "wtf/CurrentTime.h"
#include "wtf/DateMath.h"
#include "wtf/HashMap.h"
#include "wtf/OwnPtr.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/text/StringBuffer.h"
#include "wtf/text/StringBuilder.h"
#include "wtf/text/StringHash.h"
namespace blink {
typedef LCID (WINAPI* LocaleNameToLCIDPtr)(LPCWSTR, DWORD);
typedef HashMap<String, LCID> NameToLCIDMap;
static String extractLanguageCode(const String& locale)
{
size_t dashPosition = locale.find('-');
if (dashPosition == kNotFound)
return locale;
return locale.left(dashPosition);
}
static String removeLastComponent(const String& name)
{
size_t lastSeparator = name.reverseFind('-');
if (lastSeparator == kNotFound)
return emptyString();
return name.left(lastSeparator);
}
static void ensureNameToLCIDMap(NameToLCIDMap& map)
{
if (!map.isEmpty())
return;
// http://www.microsoft.com/resources/msdn/goglobal/default.mspx
// We add only locales used in layout tests for now.
map.add("ar", 0x0001);
map.add("ar-eg", 0x0C01);
map.add("de", 0x0007);
map.add("de-de", 0x0407);
map.add("el", 0x0008);
map.add("el-gr", 0x0408);
map.add("en", 0x0009);
map.add("en-gb", 0x0809);
map.add("en-us", 0x0409);
map.add("fr", 0x000C);
map.add("fr-fr", 0x040C);
map.add("he", 0x000D);
map.add("he-il", 0x040D);
map.add("hi", 0x0039);
map.add("hi-in", 0x0439);
map.add("ja", 0x0011);
map.add("ja-jp", 0x0411);
map.add("ko", 0x0012);
map.add("ko-kr", 0x0412);
map.add("ru", 0x0019);
map.add("ru-ru", 0x0419);
map.add("zh-cn", 0x0804);
map.add("zh-tw", 0x0404);
}
// Fallback implementation of LocaleNameToLCID API. This is used for
// testing on Windows XP.
// FIXME: Remove this, ensureNameToLCIDMap, and removeLastComponent when we drop
// Windows XP support.
static LCID WINAPI convertLocaleNameToLCID(LPCWSTR name, DWORD)
{
if (!name || !name[0])
return LOCALE_USER_DEFAULT;
DEFINE_STATIC_LOCAL(NameToLCIDMap, map, ());
ensureNameToLCIDMap(map);
String localeName = String(name).replace('_', '-');
localeName = localeName.lower();
do {
NameToLCIDMap::const_iterator iterator = map.find(localeName);
if (iterator != map.end())
return iterator->value;
localeName = removeLastComponent(localeName);
} while (!localeName.isEmpty());
return LOCALE_USER_DEFAULT;
}
static LCID LCIDFromLocaleInternal(LCID userDefaultLCID, const String& userDefaultLanguageCode, LocaleNameToLCIDPtr localeNameToLCID, const String& locale)
{
String localeLanguageCode = extractLanguageCode(locale);
if (equalIgnoringCase(localeLanguageCode, userDefaultLanguageCode))
return userDefaultLCID;
return localeNameToLCID(locale.charactersWithNullTermination().data(), 0);
}
static LCID LCIDFromLocale(const String& locale, bool defaultsForLocale)
{
// LocaleNameToLCID() is available since Windows Vista.
LocaleNameToLCIDPtr localeNameToLCID = reinterpret_cast<LocaleNameToLCIDPtr>(::GetProcAddress(::GetModuleHandle(L"kernel32"), "LocaleNameToLCID"));
if (!localeNameToLCID)
localeNameToLCID = convertLocaleNameToLCID;
// According to MSDN, 9 is enough for LOCALE_SISO639LANGNAME.
const size_t languageCodeBufferSize = 9;
WCHAR lowercaseLanguageCode[languageCodeBufferSize];
::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME | (defaultsForLocale ? LOCALE_NOUSEROVERRIDE : 0), lowercaseLanguageCode, languageCodeBufferSize);
String userDefaultLanguageCode = String(lowercaseLanguageCode);
LCID lcid = LCIDFromLocaleInternal(LOCALE_USER_DEFAULT, userDefaultLanguageCode, localeNameToLCID, locale);
if (!lcid)
lcid = LCIDFromLocaleInternal(LOCALE_USER_DEFAULT, userDefaultLanguageCode, localeNameToLCID, defaultLanguage());
return lcid;
}
PassOwnPtr<Locale> Locale::create(const String& locale)
{
// Whether the default settings for the locale should be used, ignoring user overrides.
bool defaultsForLocale = LayoutTestSupport::isRunningLayoutTest();
return LocaleWin::create(LCIDFromLocale(locale, defaultsForLocale), defaultsForLocale);
}
inline LocaleWin::LocaleWin(LCID lcid, bool defaultsForLocale)
: m_lcid(lcid)
, m_didInitializeNumberData(false)
, m_defaultsForLocale(defaultsForLocale)
{
DWORD value = 0;
getLocaleInfo(LOCALE_IFIRSTDAYOFWEEK | (defaultsForLocale ? LOCALE_NOUSEROVERRIDE : 0), value);
// 0:Monday, ..., 6:Sunday.
// We need 1 for Monday, 0 for Sunday.
m_firstDayOfWeek = (value + 1) % 7;
}
PassOwnPtr<LocaleWin> LocaleWin::create(LCID lcid, bool defaultsForLocale)
{
return adoptPtr(new LocaleWin(lcid, defaultsForLocale));
}
LocaleWin::~LocaleWin()
{
}
String LocaleWin::getLocaleInfoString(LCTYPE type)
{
int bufferSizeWithNUL = ::GetLocaleInfo(m_lcid, type | (m_defaultsForLocale ? LOCALE_NOUSEROVERRIDE : 0), 0, 0);
if (bufferSizeWithNUL <= 0)
return String();
StringBuffer<UChar> buffer(bufferSizeWithNUL);
::GetLocaleInfo(m_lcid, type | (m_defaultsForLocale ? LOCALE_NOUSEROVERRIDE : 0), buffer.characters(), bufferSizeWithNUL);
buffer.shrink(bufferSizeWithNUL - 1);
return String::adopt(buffer);
}
void LocaleWin::getLocaleInfo(LCTYPE type, DWORD& result)
{
::GetLocaleInfo(m_lcid, type | LOCALE_RETURN_NUMBER, reinterpret_cast<LPWSTR>(&result), sizeof(DWORD) / sizeof(TCHAR));
}
void LocaleWin::ensureShortMonthLabels()
{
if (!m_shortMonthLabels.isEmpty())
return;
const LCTYPE types[12] = {
LOCALE_SABBREVMONTHNAME1,
LOCALE_SABBREVMONTHNAME2,
LOCALE_SABBREVMONTHNAME3,
LOCALE_SABBREVMONTHNAME4,
LOCALE_SABBREVMONTHNAME5,
LOCALE_SABBREVMONTHNAME6,
LOCALE_SABBREVMONTHNAME7,
LOCALE_SABBREVMONTHNAME8,
LOCALE_SABBREVMONTHNAME9,
LOCALE_SABBREVMONTHNAME10,
LOCALE_SABBREVMONTHNAME11,
LOCALE_SABBREVMONTHNAME12,
};
m_shortMonthLabels.reserveCapacity(WTF_ARRAY_LENGTH(types));
for (unsigned i = 0; i < WTF_ARRAY_LENGTH(types); ++i) {
m_shortMonthLabels.append(getLocaleInfoString(types[i]));
if (m_shortMonthLabels.last().isEmpty()) {
m_shortMonthLabels.shrink(0);
m_shortMonthLabels.reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthName));
for (unsigned m = 0; m < WTF_ARRAY_LENGTH(WTF::monthName); ++m)
m_shortMonthLabels.append(WTF::monthName[m]);
return;
}
}
}
// -------------------------------- Tokenized date format
static unsigned countContinuousLetters(const String& format, unsigned index)
{
unsigned count = 1;
UChar reference = format[index];
while (index + 1 < format.length()) {
if (format[++index] != reference)
break;
++count;
}
return count;
}
static void commitLiteralToken(StringBuilder& literalBuffer, StringBuilder& converted)
{
if (literalBuffer.length() <= 0)
return;
DateTimeFormat::quoteAndAppendLiteral(literalBuffer.toString(), converted);
literalBuffer.clear();
}
// This function converts Windows date/time pattern format [1][2] into LDML date
// format pattern [3].
//
// i.e.
// We set h, H, m, s, d, dd, M, or y as is. They have same meaning in both of
// Windows and LDML.
// We need to convert the following patterns:
// t -> a
// tt -> a
// ddd -> EEE
// dddd -> EEEE
// g -> G
// gg -> ignore
//
// [1] http://msdn.microsoft.com/en-us/library/dd317787(v=vs.85).aspx
// [2] http://msdn.microsoft.com/en-us/library/dd318148(v=vs.85).aspx
// [3] LDML http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns
static String convertWindowsDateTimeFormat(const String& format)
{
StringBuilder converted;
StringBuilder literalBuffer;
bool inQuote = false;
bool lastQuoteCanBeLiteral = false;
for (unsigned i = 0; i < format.length(); ++i) {
UChar ch = format[i];
if (inQuote) {
if (ch == '\'') {
inQuote = false;
ASSERT(i);
if (lastQuoteCanBeLiteral && format[i - 1] == '\'') {
literalBuffer.append('\'');
lastQuoteCanBeLiteral = false;
} else {
lastQuoteCanBeLiteral = true;
}
} else {
literalBuffer.append(ch);
}
continue;
}
if (ch == '\'') {
inQuote = true;
if (lastQuoteCanBeLiteral && i > 0 && format[i - 1] == '\'') {
literalBuffer.append(ch);
lastQuoteCanBeLiteral = false;
} else {
lastQuoteCanBeLiteral = true;
}
} else if (isASCIIAlpha(ch)) {
commitLiteralToken(literalBuffer, converted);
unsigned symbolStart = i;
unsigned count = countContinuousLetters(format, i);
i += count - 1;
if (ch == 'h' || ch == 'H' || ch == 'm' || ch == 's' || ch == 'M' || ch == 'y') {
converted.append(format, symbolStart, count);
} else if (ch == 'd') {
if (count <= 2)
converted.append(format, symbolStart, count);
else if (count == 3)
converted.appendLiteral("EEE");
else
converted.appendLiteral("EEEE");
} else if (ch == 'g') {
if (count == 1) {
converted.append('G');
} else {
// gg means imperial era in Windows.
// Just ignore it.
}
} else if (ch == 't') {
converted.append('a');
} else {
literalBuffer.append(format, symbolStart, count);
}
} else {
literalBuffer.append(ch);
}
}
commitLiteralToken(literalBuffer, converted);
return converted.toString();
}
void LocaleWin::ensureMonthLabels()
{
if (!m_monthLabels.isEmpty())
return;
const LCTYPE types[12] = {
LOCALE_SMONTHNAME1,
LOCALE_SMONTHNAME2,
LOCALE_SMONTHNAME3,
LOCALE_SMONTHNAME4,
LOCALE_SMONTHNAME5,
LOCALE_SMONTHNAME6,
LOCALE_SMONTHNAME7,
LOCALE_SMONTHNAME8,
LOCALE_SMONTHNAME9,
LOCALE_SMONTHNAME10,
LOCALE_SMONTHNAME11,
LOCALE_SMONTHNAME12,
};
m_monthLabels.reserveCapacity(WTF_ARRAY_LENGTH(types));
for (unsigned i = 0; i < WTF_ARRAY_LENGTH(types); ++i) {
m_monthLabels.append(getLocaleInfoString(types[i]));
if (m_monthLabels.last().isEmpty()) {
m_monthLabels.shrink(0);
m_monthLabels.reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthFullName));
for (unsigned m = 0; m < WTF_ARRAY_LENGTH(WTF::monthFullName); ++m)
m_monthLabels.append(WTF::monthFullName[m]);
return;
}
}
}
void LocaleWin::ensureWeekDayShortLabels()
{
if (!m_weekDayShortLabels.isEmpty())
return;
const LCTYPE types[7] = {
LOCALE_SABBREVDAYNAME7, // Sunday
LOCALE_SABBREVDAYNAME1, // Monday
LOCALE_SABBREVDAYNAME2,
LOCALE_SABBREVDAYNAME3,
LOCALE_SABBREVDAYNAME4,
LOCALE_SABBREVDAYNAME5,
LOCALE_SABBREVDAYNAME6
};
m_weekDayShortLabels.reserveCapacity(WTF_ARRAY_LENGTH(types));
for (unsigned i = 0; i < WTF_ARRAY_LENGTH(types); ++i) {
m_weekDayShortLabels.append(getLocaleInfoString(types[i]));
if (m_weekDayShortLabels.last().isEmpty()) {
m_weekDayShortLabels.shrink(0);
m_weekDayShortLabels.reserveCapacity(WTF_ARRAY_LENGTH(WTF::weekdayName));
for (unsigned w = 0; w < WTF_ARRAY_LENGTH(WTF::weekdayName); ++w) {
// weekdayName starts with Monday.
m_weekDayShortLabels.append(WTF::weekdayName[(w + 6) % 7]);
}
return;
}
}
}
const Vector<String>& LocaleWin::monthLabels()
{
ensureMonthLabels();
return m_monthLabels;
}
const Vector<String>& LocaleWin::weekDayShortLabels()
{
ensureWeekDayShortLabels();
return m_weekDayShortLabels;
}
unsigned LocaleWin::firstDayOfWeek()
{
return m_firstDayOfWeek;
}
bool LocaleWin::isRTL()
{
WTF::Unicode::Direction dir = WTF::Unicode::direction(monthLabels()[0][0]);
return dir == WTF::Unicode::RightToLeft || dir == WTF::Unicode::RightToLeftArabic;
}
String LocaleWin::dateFormat()
{
if (m_dateFormat.isNull())
m_dateFormat = convertWindowsDateTimeFormat(getLocaleInfoString(LOCALE_SSHORTDATE));
return m_dateFormat;
}
String LocaleWin::dateFormat(const String& windowsFormat)
{
return convertWindowsDateTimeFormat(windowsFormat);
}
String LocaleWin::monthFormat()
{
if (m_monthFormat.isNull())
m_monthFormat = convertWindowsDateTimeFormat(getLocaleInfoString(LOCALE_SYEARMONTH));
return m_monthFormat;
}
String LocaleWin::shortMonthFormat()
{
if (m_shortMonthFormat.isNull())
m_shortMonthFormat = convertWindowsDateTimeFormat(getLocaleInfoString(LOCALE_SYEARMONTH)).replace("MMMM", "MMM");
return m_shortMonthFormat;
}
String LocaleWin::timeFormat()
{
if (m_timeFormatWithSeconds.isNull())
m_timeFormatWithSeconds = convertWindowsDateTimeFormat(getLocaleInfoString(LOCALE_STIMEFORMAT));
return m_timeFormatWithSeconds;
}
String LocaleWin::shortTimeFormat()
{
if (!m_timeFormatWithoutSeconds.isNull())
return m_timeFormatWithoutSeconds;
String format = getLocaleInfoString(LOCALE_SSHORTTIME);
// Vista or older Windows doesn't support LOCALE_SSHORTTIME.
if (format.isEmpty()) {
format = getLocaleInfoString(LOCALE_STIMEFORMAT);
StringBuilder builder;
builder.append(getLocaleInfoString(LOCALE_STIME));
builder.appendLiteral("ss");
size_t pos = format.reverseFind(builder.toString());
if (pos != kNotFound)
format.remove(pos, builder.length());
}
m_timeFormatWithoutSeconds = convertWindowsDateTimeFormat(format);
return m_timeFormatWithoutSeconds;
}
String LocaleWin::dateTimeFormatWithSeconds()
{
if (!m_dateTimeFormatWithSeconds.isNull())
return m_dateTimeFormatWithSeconds;
StringBuilder builder;
builder.append(dateFormat());
builder.append(' ');
builder.append(timeFormat());
m_dateTimeFormatWithSeconds = builder.toString();
return m_dateTimeFormatWithSeconds;
}
String LocaleWin::dateTimeFormatWithoutSeconds()
{
if (!m_dateTimeFormatWithoutSeconds.isNull())
return m_dateTimeFormatWithoutSeconds;
StringBuilder builder;
builder.append(dateFormat());
builder.append(' ');
builder.append(shortTimeFormat());
m_dateTimeFormatWithoutSeconds = builder.toString();
return m_dateTimeFormatWithoutSeconds;
}
const Vector<String>& LocaleWin::shortMonthLabels()
{
ensureShortMonthLabels();
return m_shortMonthLabels;
}
const Vector<String>& LocaleWin::standAloneMonthLabels()
{
// Windows doesn't provide a way to get stand-alone month labels.
return monthLabels();
}
const Vector<String>& LocaleWin::shortStandAloneMonthLabels()
{
// Windows doesn't provide a way to get stand-alone month labels.
return shortMonthLabels();
}
const Vector<String>& LocaleWin::timeAMPMLabels()
{
if (m_timeAMPMLabels.isEmpty()) {
m_timeAMPMLabels.append(getLocaleInfoString(LOCALE_S1159));
m_timeAMPMLabels.append(getLocaleInfoString(LOCALE_S2359));
}
return m_timeAMPMLabels;
}
void LocaleWin::initializeLocaleData()
{
if (m_didInitializeNumberData)
return;
Vector<String, DecimalSymbolsSize> symbols;
enum DigitSubstitution {
DigitSubstitutionContext = 0,
DigitSubstitution0to9 = 1,
DigitSubstitutionNative = 2,
};
DWORD digitSubstitution = DigitSubstitution0to9;
getLocaleInfo(LOCALE_IDIGITSUBSTITUTION, digitSubstitution);
if (digitSubstitution == DigitSubstitution0to9) {
symbols.append("0");
symbols.append("1");
symbols.append("2");
symbols.append("3");
symbols.append("4");
symbols.append("5");
symbols.append("6");
symbols.append("7");
symbols.append("8");
symbols.append("9");
} else {
String digits = getLocaleInfoString(LOCALE_SNATIVEDIGITS);
ASSERT(digits.length() >= 10);
for (unsigned i = 0; i < 10; ++i)
symbols.append(digits.substring(i, 1));
}
ASSERT(symbols.size() == DecimalSeparatorIndex);
symbols.append(getLocaleInfoString(LOCALE_SDECIMAL));
ASSERT(symbols.size() == GroupSeparatorIndex);
symbols.append(getLocaleInfoString(LOCALE_STHOUSAND));
ASSERT(symbols.size() == DecimalSymbolsSize);
String negativeSign = getLocaleInfoString(LOCALE_SNEGATIVESIGN);
enum NegativeFormat {
NegativeFormatParenthesis = 0,
NegativeFormatSignPrefix = 1,
NegativeFormatSignSpacePrefix = 2,
NegativeFormatSignSuffix = 3,
NegativeFormatSpaceSignSuffix = 4,
};
DWORD negativeFormat = NegativeFormatSignPrefix;
getLocaleInfo(LOCALE_INEGNUMBER, negativeFormat);
String negativePrefix = emptyString();
String negativeSuffix = emptyString();
switch (negativeFormat) {
case NegativeFormatParenthesis:
negativePrefix = "(";
negativeSuffix = ")";
break;
case NegativeFormatSignSpacePrefix:
negativePrefix = negativeSign + " ";
break;
case NegativeFormatSignSuffix:
negativeSuffix = negativeSign;
break;
case NegativeFormatSpaceSignSuffix:
negativeSuffix = " " + negativeSign;
break;
case NegativeFormatSignPrefix: // Fall through.
default:
negativePrefix = negativeSign;
break;
}
m_didInitializeNumberData = true;
setLocaleData(symbols, emptyString(), emptyString(), negativePrefix, negativeSuffix);
}
}
......@@ -23,11 +23,9 @@ def stripped_lines_from_command(cmd, cwd=None):
def gn_desc(*args):
# GN doesn't understand absolute paths yet, so use a relative BUILD_DIR
# and pass ROOT_DIR as the CWD.
cmd = [
'gn', 'desc',
# Hard-coding Debug for now:
os.path.join('out', 'Debug'),
] + list(args)
# Hard-coding Debug for now:
BUILD_DIR = '//out/Debug' # // means repository root-relative.
cmd = ['gn', 'desc', BUILD_DIR] + list(args)
return stripped_lines_from_command(cmd, cwd=ROOT_DIR)
......@@ -40,7 +38,9 @@ def used_files(target):
logging.info(target)
sources = map(lambda s: s[2:], gn_desc(target, 'sources'))
inputs = map(lambda s: s[2:], gn_desc(target, 'inputs'))
return sources + inputs
public = map(lambda s: s[2:], gn_desc(target, 'public'))
script = map(lambda s: s[2:], gn_desc(target, 'script'))
return sources + inputs + public + script
def find_on_disk(path):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册