Commit d671ccdc authored by bashi@chromium.org's avatar bashi@chromium.org

Add FontFaceDescriptors IDL dictionary

To follow the spec[1]. This is the first place to use IDL dictionary
execept for testing, so this CL also includes build related changes.
Existing tests(e.g. fast/css/fontface-constructor-error.html) should
cover this change.

[1] http://dev.w3.org/csswg/css-font-loading/#fontface-interface

BUG=403150

Review URL: https://codereview.chromium.org/481453003

git-svn-id: svn://svn.chromium.org/blink/trunk@181610 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent b9a99728
...@@ -8,6 +8,10 @@ import("//third_party/WebKit/Source/core/core.gni") ...@@ -8,6 +8,10 @@ import("//third_party/WebKit/Source/core/core.gni")
# Don't actually read idl.gypi since that just defines variables in terms of # Don't actually read idl.gypi since that just defines variables in terms of
# others, which gypi_to_gn doesn't handle. # others, which gypi_to_gn doesn't handle.
core_definition_idl_files =
core_dictionary_idl_files +
core_idl_files
core_testing_definition_idl_files = core_testing_definition_idl_files =
core_testing_dictionary_idl_files + core_testing_dictionary_idl_files +
webcore_testing_idl_files webcore_testing_idl_files
...@@ -15,13 +19,13 @@ core_testing_definition_idl_files = ...@@ -15,13 +19,13 @@ core_testing_definition_idl_files =
# IDL file lists; see: http://www.chromium.org/developers/web-idl-interfaces # IDL file lists; see: http://www.chromium.org/developers/web-idl-interfaces
# Interface IDL files: generate individual bindings (includes testing) # Interface IDL files: generate individual bindings (includes testing)
core_interface_idl_files = core_interface_idl_files =
core_idl_files + core_definition_idl_files +
core_testing_definition_idl_files + core_testing_definition_idl_files +
generated_webcore_testing_idl_files generated_webcore_testing_idl_files
# Static IDL files # Static IDL files
core_static_interface_idl_files = core_static_interface_idl_files =
core_idl_files + core_definition_idl_files +
core_testing_definition_idl_files core_testing_definition_idl_files
core_static_dependency_idl_files = core_static_dependency_idl_files =
core_dependency_idl_files + core_dependency_idl_files +
......
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
], ],
'variables': { 'variables': {
'core_definition_idl_files': [
'<@(core_dictionary_idl_files)',
'<@(core_idl_files)',
],
'core_testing_definition_idl_files': [ 'core_testing_definition_idl_files': [
'<@(core_testing_dictionary_idl_files)', '<@(core_testing_dictionary_idl_files)',
'<@(webcore_testing_idl_files)', '<@(webcore_testing_idl_files)',
...@@ -19,15 +23,15 @@ ...@@ -19,15 +23,15 @@
# IDL file lists; see: http://www.chromium.org/developers/web-idl-interfaces # IDL file lists; see: http://www.chromium.org/developers/web-idl-interfaces
# Interface IDL files: generate individual bindings (includes testing) # Interface IDL files: generate individual bindings (includes testing)
'core_interface_idl_files': [ 'core_interface_idl_files': [
'<@(core_idl_files)', '<@(core_definition_idl_files)',
'<@(core_testing_definition_idl_files)', '<@(core_testing_definition_idl_files)',
'<@(generated_webcore_testing_idl_files)', '<@(generated_webcore_testing_idl_files)',
], ],
# Write lists of main IDL files to a file, so that the command lines don't # Write lists of main IDL files to a file, so that the command lines don't
# exceed OS length limits. # exceed OS length limits.
'core_idl_files_list': '<|(core_idl_files_list.tmp <@(core_idl_files))', 'core_idl_files_list': '<|(core_idl_files_list.tmp <@(core_definition_idl_files))',
'core_dictionary_idl_files_list': '<|(core_dictionary_idl_files_list.tmp <@(core_testing_dictionary_idl_files))', 'core_dictionary_idl_files_list': '<|(core_dictionary_idl_files_list.tmp <@(core_dictionary_idl_files) <@(core_testing_dictionary_idl_files))',
# Dependency IDL files: don't generate individual bindings, but do process # Dependency IDL files: don't generate individual bindings, but do process
# in IDL dependency computation, and count as build dependencies # in IDL dependency computation, and count as build dependencies
...@@ -58,7 +62,7 @@ ...@@ -58,7 +62,7 @@
# Static IDL files # Static IDL files
'core_static_interface_idl_files': [ 'core_static_interface_idl_files': [
'<@(core_idl_files)', '<@(core_definition_idl_files)',
'<@(core_testing_definition_idl_files)', '<@(core_testing_definition_idl_files)',
], ],
'core_static_dependency_idl_files': [ 'core_static_dependency_idl_files': [
......
...@@ -21,7 +21,7 @@ group("bindings_core_v8_generated") { ...@@ -21,7 +21,7 @@ group("bindings_core_v8_generated") {
# bindings_core_generated_aggregate in Source/bindings/core/v8/generated.gyp # bindings_core_generated_aggregate in Source/bindings/core/v8/generated.gyp
aggregate_generated_bindings("bindings_core_v8_generated_aggregate") { aggregate_generated_bindings("bindings_core_v8_generated_aggregate") {
sources = core_idl_files sources = core_definition_idl_files
component_dir = "core" component_dir = "core"
outputs = bindings_core_generated_aggregate_files outputs = bindings_core_generated_aggregate_files
} }
...@@ -34,10 +34,7 @@ idl_compiler("bindings_core_v8_generated_individual") { ...@@ -34,10 +34,7 @@ idl_compiler("bindings_core_v8_generated_individual") {
# bindings_core_dictionary_impl_generated in Source/bindings/core/v8/generated.gyp # bindings_core_dictionary_impl_generated in Source/bindings/core/v8/generated.gyp
idl_dictionary("bindings_core_dictionary_impl_generated") { idl_dictionary("bindings_core_dictionary_impl_generated") {
# FIXME: Add 'core_dictionary_idl_files' to sources sources = core_dictionary_idl_files + core_testing_dictionary_idl_files
# See comment on core/core.gypi outputs = generated_core_dictionary_files +
sources = core_testing_dictionary_idl_files generated_core_testing_dictionary_files
# FIXME: Add 'generated_core_dictionary_files' to outputs
# See comment on core/core.gypi
outputs = generated_core_testing_dictionary_files
} }
...@@ -131,8 +131,7 @@ ...@@ -131,8 +131,7 @@
'../../modules/generated.gyp:interfaces_info', '../../modules/generated.gyp:interfaces_info',
], ],
'sources': [ 'sources': [
# FIXME: Add '<@(core_dictionary_idl_files)', '<@(core_dictionary_idl_files)',
# See comment on core/core.gypi
'<@(core_testing_dictionary_idl_files)', '<@(core_testing_dictionary_idl_files)',
], ],
'actions': [{ 'actions': [{
...@@ -149,8 +148,7 @@ ...@@ -149,8 +148,7 @@
'<(bindings_modules_output_dir)/InterfacesInfoModules.pickle', '<(bindings_modules_output_dir)/InterfacesInfoModules.pickle',
], ],
'outputs': [ 'outputs': [
# FIXME: Add '<@(generated_core_dictionary_files)', '<@(generated_core_dictionary_files)',
# See comment on core/core.gypi
'<@(generated_core_testing_dictionary_files)', '<@(generated_core_testing_dictionary_files)',
], ],
'action': [ 'action': [
......
...@@ -342,6 +342,8 @@ source_set("core_generated") { ...@@ -342,6 +342,8 @@ source_set("core_generated") {
# These files include all the .cpp files generated from the .idl files # These files include all the .cpp files generated from the .idl files
# in webcore_files. # in webcore_files.
sources += bindings_core_generated_aggregate_files sources += bindings_core_generated_aggregate_files
# IDL dictionary impl files generated by IDL compiler
sources += generated_core_dictionary_files
sources += [ sources += [
# Additional .cpp files for HashTools.h # Additional .cpp files for HashTools.h
......
...@@ -18,6 +18,8 @@ _gypi = exec_script( ...@@ -18,6 +18,8 @@ _gypi = exec_script(
# Files for which bindings (.cpp and .h files) will be generated. # Files for which bindings (.cpp and .h files) will be generated.
core_idl_files = get_path_info(_gypi.core_idl_files, "abspath") core_idl_files = get_path_info(_gypi.core_idl_files, "abspath")
core_dictionary_idl_files =
get_path_info(_gypi.core_dictionary_idl_files, "abspath")
core_testing_dictionary_idl_files = core_testing_dictionary_idl_files =
get_path_info(_gypi.core_testing_dictionary_idl_files, "abspath") get_path_info(_gypi.core_testing_dictionary_idl_files, "abspath")
...@@ -37,6 +39,8 @@ webcore_testing_idl_files = ...@@ -37,6 +39,8 @@ webcore_testing_idl_files =
get_path_info(_gypi.webcore_testing_idl_files, "abspath") get_path_info(_gypi.webcore_testing_idl_files, "abspath")
webcore_testing_dependency_idl_files = webcore_testing_dependency_idl_files =
get_path_info(_gypi.webcore_testing_dependency_idl_files, "abspath") get_path_info(_gypi.webcore_testing_dependency_idl_files, "abspath")
generated_core_dictionary_files =
get_path_info(_gypi.generated_core_dictionary_files, "abspath")
generated_core_testing_dictionary_files = generated_core_testing_dictionary_files =
get_path_info(_gypi.generated_core_testing_dictionary_files, "abspath") get_path_info(_gypi.generated_core_testing_dictionary_files, "abspath")
generated_webcore_testing_idl_files = generated_webcore_testing_idl_files =
......
...@@ -281,8 +281,7 @@ ...@@ -281,8 +281,7 @@
'<(blink_core_output_dir)/CSSPropertyMetadata.cpp', '<(blink_core_output_dir)/CSSPropertyMetadata.cpp',
# IDL dictionary impl files generated by IDL compiler # IDL dictionary impl files generated by IDL compiler
# FIXME: Add '<@(generated_core_dictionary_files)', '<@(generated_core_dictionary_files)',
# See comment on core/core.gypi
], ],
'conditions': [ 'conditions': [
['OS=="win" and component=="shared_library"', { ['OS=="win" and component=="shared_library"', {
......
...@@ -3336,18 +3336,13 @@ ...@@ -3336,18 +3336,13 @@
'svg/properties/SVGAnimatedProperty.cpp', 'svg/properties/SVGAnimatedProperty.cpp',
'svg/properties/SVGPropertyTearOff.cpp', 'svg/properties/SVGPropertyTearOff.cpp',
], ],
# FIXME: http://crbug.com/403150 'core_dictionary_idl_files': [
# Add 'core_dictionary_idl_files' and 'css/FontFaceDescriptors.idl',
# 'generated_core_dictionary_files' variables. ],
# The variables should contain IDL dictionary files and generated files 'generated_core_dictionary_files': [
# They would look like below: '<(blink_core_output_dir)/css/FontFaceDescriptors.cpp',
# 'core_dictionary_idl_files': [ '<(blink_core_output_dir)/css/FontFaceDescriptors.h',
# 'css/FontFaceDescriptors.idl', ],
# ],
# 'generated_core_dictionary_files': [
# '<(blink_core_output_dir)/css/FontFaceDescriptors.cpp',
# '<(blink_core_output_dir)/css/FontFaceDescriptors.h',
# ],
'core_testing_dictionary_idl_files': [ 'core_testing_dictionary_idl_files': [
'testing/InternalDictionary.idl', 'testing/InternalDictionary.idl',
], ],
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "config.h" #include "config.h"
#include "core/css/FontFace.h" #include "core/css/FontFace.h"
#include "bindings/core/v8/Dictionary.h"
#include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/ScriptState.h" #include "bindings/core/v8/ScriptState.h"
#include "core/CSSValueKeywords.h" #include "core/CSSValueKeywords.h"
...@@ -42,6 +41,7 @@ ...@@ -42,6 +41,7 @@
#include "core/css/CSSPrimitiveValue.h" #include "core/css/CSSPrimitiveValue.h"
#include "core/css/CSSUnicodeRangeValue.h" #include "core/css/CSSUnicodeRangeValue.h"
#include "core/css/CSSValueList.h" #include "core/css/CSSValueList.h"
#include "core/css/FontFaceDescriptors.h"
#include "core/css/LocalFontFaceSource.h" #include "core/css/LocalFontFaceSource.h"
#include "core/css/RemoteFontFaceSource.h" #include "core/css/RemoteFontFaceSource.h"
#include "core/css/StylePropertySet.h" #include "core/css/StylePropertySet.h"
...@@ -70,7 +70,7 @@ static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document, ...@@ -70,7 +70,7 @@ static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document,
return parsedStyle->getPropertyCSSValue(propertyID); return parsedStyle->getPropertyCSSValue(propertyID);
} }
PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicString& family, const String& source, const Dictionary& descriptors) PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicString& family, const String& source, const FontFaceDescriptors* descriptors)
{ {
RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(context, family, descriptors)); RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(context, family, descriptors));
...@@ -82,14 +82,14 @@ PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con ...@@ -82,14 +82,14 @@ PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con
return fontFace.release(); return fontFace.release();
} }
PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicString& family, PassRefPtr<ArrayBuffer> source, const Dictionary& descriptors) PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicString& family, PassRefPtr<ArrayBuffer> source, const FontFaceDescriptors* descriptors)
{ {
RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(context, family, descriptors)); RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(context, family, descriptors));
fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->data()), source->byteLength()); fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->data()), source->byteLength());
return fontFace.release(); return fontFace.release();
} }
PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicString& family, PassRefPtr<ArrayBufferView> source, const Dictionary& descriptors) PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicString& family, PassRefPtr<ArrayBufferView> source, const FontFaceDescriptors* descriptors)
{ {
RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(context, family, descriptors)); RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(context, family, descriptors));
fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->baseAddress()), source->byteLength()); fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->baseAddress()), source->byteLength());
...@@ -130,24 +130,17 @@ FontFace::FontFace() ...@@ -130,24 +130,17 @@ FontFace::FontFace()
{ {
} }
FontFace::FontFace(ExecutionContext* context, const AtomicString& family, const Dictionary& descriptors) FontFace::FontFace(ExecutionContext* context, const AtomicString& family, const FontFaceDescriptors* descriptors)
: m_family(family) : m_family(family)
, m_status(Unloaded) , m_status(Unloaded)
{ {
Document* document = toDocument(context); Document* document = toDocument(context);
String value; setPropertyFromString(document, descriptors->style(), CSSPropertyFontStyle);
if (DictionaryHelper::get(descriptors, "style", value)) setPropertyFromString(document, descriptors->weight(), CSSPropertyFontWeight);
setPropertyFromString(document, value, CSSPropertyFontStyle); // FIXME: we don't implement 'font-strech' property yet so we can't set the property.
if (DictionaryHelper::get(descriptors, "weight", value)) setPropertyFromString(document, descriptors->unicodeRange(), CSSPropertyUnicodeRange);
setPropertyFromString(document, value, CSSPropertyFontWeight); setPropertyFromString(document, descriptors->variant(), CSSPropertyFontVariant);
if (DictionaryHelper::get(descriptors, "stretch", value)) setPropertyFromString(document, descriptors->featureSettings(), CSSPropertyWebkitFontFeatureSettings);
setPropertyFromString(document, value, CSSPropertyFontStretch);
if (DictionaryHelper::get(descriptors, "unicodeRange", value))
setPropertyFromString(document, value, CSSPropertyUnicodeRange);
if (DictionaryHelper::get(descriptors, "variant", value))
setPropertyFromString(document, value, CSSPropertyFontVariant);
if (DictionaryHelper::get(descriptors, "featureSettings", value))
setPropertyFromString(document, value, CSSPropertyWebkitFontFeatureSettings);
} }
FontFace::~FontFace() FontFace::~FontFace()
......
...@@ -49,6 +49,7 @@ class CSSValueList; ...@@ -49,6 +49,7 @@ class CSSValueList;
class Dictionary; class Dictionary;
class Document; class Document;
class ExceptionState; class ExceptionState;
class FontFaceDescriptors;
class StylePropertySet; class StylePropertySet;
class StyleRuleFontFace; class StyleRuleFontFace;
...@@ -57,9 +58,9 @@ class FontFace : public RefCountedWillBeGarbageCollectedFinalized<FontFace>, pub ...@@ -57,9 +58,9 @@ class FontFace : public RefCountedWillBeGarbageCollectedFinalized<FontFace>, pub
public: public:
enum LoadStatus { Unloaded, Loading, Loaded, Error }; enum LoadStatus { Unloaded, Loading, Loaded, Error };
static PassRefPtrWillBeRawPtr<FontFace> create(ExecutionContext*, const AtomicString& family, PassRefPtr<ArrayBuffer> source, const Dictionary&); static PassRefPtrWillBeRawPtr<FontFace> create(ExecutionContext*, const AtomicString& family, PassRefPtr<ArrayBuffer> source, const FontFaceDescriptors*);
static PassRefPtrWillBeRawPtr<FontFace> create(ExecutionContext*, const AtomicString& family, PassRefPtr<ArrayBufferView>, const Dictionary&); static PassRefPtrWillBeRawPtr<FontFace> create(ExecutionContext*, const AtomicString& family, PassRefPtr<ArrayBufferView>, const FontFaceDescriptors*);
static PassRefPtrWillBeRawPtr<FontFace> create(ExecutionContext*, const AtomicString& family, const String& source, const Dictionary&); static PassRefPtrWillBeRawPtr<FontFace> create(ExecutionContext*, const AtomicString& family, const String& source, const FontFaceDescriptors*);
static PassRefPtrWillBeRawPtr<FontFace> create(Document*, const StyleRuleFontFace*); static PassRefPtrWillBeRawPtr<FontFace> create(Document*, const StyleRuleFontFace*);
~FontFace(); ~FontFace();
...@@ -108,7 +109,7 @@ public: ...@@ -108,7 +109,7 @@ public:
private: private:
FontFace(); FontFace();
FontFace(ExecutionContext*, const AtomicString& family, const Dictionary& descriptors); FontFace(ExecutionContext*, const AtomicString& family, const FontFaceDescriptors*);
void initCSSFontFace(Document*, PassRefPtrWillBeRawPtr<CSSValue> src); void initCSSFontFace(Document*, PassRefPtrWillBeRawPtr<CSSValue> src);
void initCSSFontFace(const unsigned char* data, unsigned size); void initCSSFontFace(const unsigned char* data, unsigned size);
......
...@@ -39,9 +39,9 @@ enum FontFaceLoadStatus { ...@@ -39,9 +39,9 @@ enum FontFaceLoadStatus {
[ [
// FIXME: should be union type http://crbug.com/240176 // FIXME: should be union type http://crbug.com/240176
Constructor(DOMString family, DOMString source, optional Dictionary descriptors), Constructor(DOMString family, DOMString source, optional FontFaceDescriptors descriptors),
Constructor(DOMString family, ArrayBuffer source, optional Dictionary descriptors), Constructor(DOMString family, ArrayBuffer source, optional FontFaceDescriptors descriptors),
Constructor(DOMString family, ArrayBufferView source, optional Dictionary descriptors), Constructor(DOMString family, ArrayBufferView source, optional FontFaceDescriptors descriptors),
ConstructorCallWith=ExecutionContext, ConstructorCallWith=ExecutionContext,
WillBeGarbageCollected, WillBeGarbageCollected,
] interface FontFace { ] interface FontFace {
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
[
GarbageCollected
] dictionary FontFaceDescriptors {
DOMString style = "normal";
DOMString weight = "normal";
DOMString stretch = "normal";
DOMString unicodeRange = "U+0-10FFFF";
DOMString variant = "normal";
DOMString featureSettings = "normal";
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment