From 6bcc09dbd0a1883e0079ad05a78b51faa3c1866e Mon Sep 17 00:00:00 2001 From: Hixie Date: Fri, 17 Jul 2015 15:40:00 -0700 Subject: [PATCH] Remove shadow trees and custom elements from sky/engine/. Remove all code relating to shadow trees, insertion points, shadow boundaries, traversing composed trees, distribution, template documents, custom elements, registering elements, element registries, element factories, shadow roots, etc. Remove the following features from the IDLs and from the binding generators: CustomElementCallbacks, Reflect*, EventHandler. Remove the CSS custom pseudo-element concept, since we no longer have a UA style sheet worth talking about, no longer have shadow trees or custom elements, no longer use pseudo-elements, and generally therefore don't use this code at all. --- sky/engine/bindings/IDLExtendedAttributes.txt | 6 - .../bindings/scripts/dart_attributes.py | 25 +- sky/engine/bindings/scripts/dart_types.py | 13 +- .../scripts/templates/attributes_cpp.template | 9 +- .../scripts/templates/interface_h.template | 3 - .../scripts/templates/methods_cpp.template | 3 - sky/engine/bindings/scripts/v8_attributes.py | 32 +- sky/engine/bindings/scripts/v8_interface.py | 4 +- sky/engine/bindings/scripts/v8_methods.py | 4 - sky/engine/bindings/scripts/v8_types.py | 9 - .../build/scripts/make_element_factory.py | 86 +----- .../build/scripts/make_element_lookup_trie.py | 134 -------- .../scripts/make_element_type_helpers.py | 89 ------ sky/engine/build/scripts/scripts.gni | 10 - sky/engine/build/scripts/scripts.gypi | 8 - .../scripts/templates/ElementFactory.cpp.tmpl | 61 ---- .../scripts/templates/ElementFactory.h.tmpl | 25 -- .../templates/ElementLookupTrie.cpp.tmpl | 44 --- .../templates/ElementLookupTrie.h.tmpl | 15 - .../templates/ElementTypeHelpers.h.tmpl | 46 --- .../templates/ElementWrapperFactory.cpp.tmpl | 91 ------ .../templates/ElementWrapperFactory.h.tmpl | 29 -- sky/engine/core/BUILD.gn | 32 -- sky/engine/core/core.gni | 22 -- .../core/css/CSSComputedStyleDeclaration.cpp | 2 +- sky/engine/core/css/CSSSelector.cpp | 29 +- sky/engine/core/css/CSSSelector.h | 12 - sky/engine/core/css/ElementRuleCollector.cpp | 1 - sky/engine/core/css/RuleSet.cpp | 2 - sky/engine/core/css/SelectorChecker.cpp | 2 - sky/engine/core/css/parser/CSSParserValues.h | 1 - .../css/resolver/ElementResolveContext.cpp | 7 +- .../core/css/resolver/ElementResolveContext.h | 2 - .../core/css/resolver/ScopedStyleResolver.cpp | 6 - .../core/css/resolver/SharedStyleFinder.cpp | 17 +- .../core/css/resolver/SharedStyleFinder.h | 1 - .../core/css/resolver/StyleAdjuster.cpp | 2 +- .../core/css/resolver/StyleResolver.cpp | 21 +- .../core/css/resolver/StyleResolverState.h | 2 - sky/engine/core/dom/ContainerNode.cpp | 50 +-- sky/engine/core/dom/ContainerNode.h | 6 +- sky/engine/core/dom/DOMTokenList.idl | 6 +- sky/engine/core/dom/Document.cpp | 109 +------ sky/engine/core/dom/Document.h | 17 -- sky/engine/core/dom/Document.idl | 12 +- sky/engine/core/dom/DocumentInit.cpp | 9 - sky/engine/core/dom/DocumentInit.h | 7 - sky/engine/core/dom/DocumentOrderedList.cpp | 4 +- sky/engine/core/dom/Element.cpp | 117 +------ sky/engine/core/dom/Element.h | 44 --- sky/engine/core/dom/Element.idl | 7 +- sky/engine/core/dom/ElementRareData.h | 20 -- sky/engine/core/dom/Node.cpp | 221 +------------- sky/engine/core/dom/Node.h | 92 +----- sky/engine/core/dom/Node.idl | 8 +- sky/engine/core/dom/NodeRenderStyle.h | 3 +- .../core/dom/NodeRenderingTraversal.cpp | 178 ----------- sky/engine/core/dom/NodeRenderingTraversal.h | 78 ----- sky/engine/core/dom/ParentNode.idl | 14 +- sky/engine/core/dom/Position.cpp | 7 +- sky/engine/core/dom/Range.cpp | 19 +- sky/engine/core/dom/Range.h | 2 - sky/engine/core/dom/Range.idl | 10 +- sky/engine/core/dom/RenderTreeBuilder.cpp | 10 +- sky/engine/core/dom/RenderTreeBuilder.h | 4 +- sky/engine/core/dom/StyleEngine.cpp | 3 - .../dom/TemplateContentDocumentFragment.h | 60 ---- sky/engine/core/dom/Text.cpp | 27 +- sky/engine/core/dom/Text.idl | 1 - sky/engine/core/dom/TreeScope.cpp | 57 +--- sky/engine/core/dom/TreeScope.h | 2 - sky/engine/core/dom/TreeScopeAdopter.cpp | 14 - sky/engine/core/dom/TreeScopeTest.cpp | 66 ---- sky/engine/core/dom/custom/custom_element.cc | 86 ------ sky/engine/core/dom/custom/custom_element.h | 26 -- .../custom/custom_element_callback_scope.cc | 38 --- .../custom/custom_element_callback_scope.h | 29 -- .../dom/custom/custom_element_registry.cc | 47 --- .../core/dom/custom/custom_element_registry.h | 46 --- .../core/dom/shadow/ComposedTreeWalker.cpp | 139 --------- .../core/dom/shadow/ComposedTreeWalker.h | 213 ------------- .../core/dom/shadow/ContentDistribution.cpp | 73 ----- .../core/dom/shadow/ContentDistribution.h | 72 ----- sky/engine/core/dom/shadow/ElementShadow.cpp | 288 ------------------ sky/engine/core/dom/shadow/ElementShadow.h | 114 ------- sky/engine/core/dom/shadow/InsertionPoint.cpp | 249 --------------- sky/engine/core/dom/shadow/InsertionPoint.h | 111 ------- .../core/dom/shadow/SelectRuleFeatureSet.cpp | 107 ------- .../core/dom/shadow/SelectRuleFeatureSet.h | 81 ----- sky/engine/core/dom/shadow/ShadowRoot.cpp | 203 ------------ sky/engine/core/dom/shadow/ShadowRoot.h | 107 ------- sky/engine/core/dom/shadow/ShadowRoot.idl | 37 --- sky/engine/core/editing/TextIterator.cpp | 82 +---- sky/engine/core/editing/TextIterator.h | 8 +- sky/engine/core/editing/VisibleUnits.cpp | 5 +- sky/engine/core/editing/htmlediting.cpp | 40 +-- sky/engine/core/html/HTMLElement.h | 2 - sky/engine/core/html/HTMLTagNames.in | 2 - sky/engine/core/page/FocusController.cpp | 87 +----- sky/engine/core/page/FocusController.h | 2 - sky/engine/core/rendering/HitTestResult.cpp | 4 +- sky/engine/core/rendering/RenderBlock.cpp | 1 - sky/engine/core/rendering/RenderLayer.cpp | 1 - sky/engine/core/rendering/RenderObject.cpp | 1 - sky/engine/core/rendering/RenderTheme.cpp | 1 - .../core/rendering/RenderTreeAsText.cpp | 18 +- .../core/rendering/style/RenderStyle.cpp | 12 +- sky/engine/core/rendering/style/RenderStyle.h | 7 +- sky/tests/dom/appendChild.dart | 16 - sky/tests/dom/ownerScope-expected.txt | 5 +- sky/tests/dom/ownerScope.dart | 27 -- sky/tests/dom/replaceChild.dart | 15 - 112 files changed, 205 insertions(+), 4388 deletions(-) delete mode 100755 sky/engine/build/scripts/make_element_lookup_trie.py delete mode 100755 sky/engine/build/scripts/make_element_type_helpers.py delete mode 100644 sky/engine/build/scripts/templates/ElementFactory.cpp.tmpl delete mode 100644 sky/engine/build/scripts/templates/ElementFactory.h.tmpl delete mode 100644 sky/engine/build/scripts/templates/ElementLookupTrie.cpp.tmpl delete mode 100644 sky/engine/build/scripts/templates/ElementLookupTrie.h.tmpl delete mode 100644 sky/engine/build/scripts/templates/ElementTypeHelpers.h.tmpl delete mode 100644 sky/engine/build/scripts/templates/ElementWrapperFactory.cpp.tmpl delete mode 100644 sky/engine/build/scripts/templates/ElementWrapperFactory.h.tmpl delete mode 100644 sky/engine/core/dom/NodeRenderingTraversal.cpp delete mode 100644 sky/engine/core/dom/NodeRenderingTraversal.h delete mode 100644 sky/engine/core/dom/TemplateContentDocumentFragment.h delete mode 100644 sky/engine/core/dom/custom/custom_element.cc delete mode 100644 sky/engine/core/dom/custom/custom_element.h delete mode 100644 sky/engine/core/dom/custom/custom_element_callback_scope.cc delete mode 100644 sky/engine/core/dom/custom/custom_element_callback_scope.h delete mode 100644 sky/engine/core/dom/custom/custom_element_registry.cc delete mode 100644 sky/engine/core/dom/custom/custom_element_registry.h delete mode 100644 sky/engine/core/dom/shadow/ComposedTreeWalker.cpp delete mode 100644 sky/engine/core/dom/shadow/ComposedTreeWalker.h delete mode 100644 sky/engine/core/dom/shadow/ContentDistribution.cpp delete mode 100644 sky/engine/core/dom/shadow/ContentDistribution.h delete mode 100644 sky/engine/core/dom/shadow/ElementShadow.cpp delete mode 100644 sky/engine/core/dom/shadow/ElementShadow.h delete mode 100644 sky/engine/core/dom/shadow/InsertionPoint.cpp delete mode 100644 sky/engine/core/dom/shadow/InsertionPoint.h delete mode 100644 sky/engine/core/dom/shadow/SelectRuleFeatureSet.cpp delete mode 100644 sky/engine/core/dom/shadow/SelectRuleFeatureSet.h delete mode 100644 sky/engine/core/dom/shadow/ShadowRoot.cpp delete mode 100644 sky/engine/core/dom/shadow/ShadowRoot.h delete mode 100644 sky/engine/core/dom/shadow/ShadowRoot.idl delete mode 100644 sky/engine/core/html/HTMLTagNames.in diff --git a/sky/engine/bindings/IDLExtendedAttributes.txt b/sky/engine/bindings/IDLExtendedAttributes.txt index 8d9914b9e95c1..76f516eb5deb2 100644 --- a/sky/engine/bindings/IDLExtendedAttributes.txt +++ b/sky/engine/bindings/IDLExtendedAttributes.txt @@ -38,7 +38,6 @@ CallWith=ScriptState|ScriptArguments|ActiveWindow|FirstWindow|ThisValue Constructor Custom=|Getter|Setter|VisitDOMWrapper|Wrap|PropertyGetter|PropertyEnumerator|PropertyQuery CustomConstructor -CustomElementCallbacks Default=Undefined DependentLifetime DoNotCheckConstants @@ -64,11 +63,6 @@ PartialInterfaceImplementedAs=* PrivateDart PutForwards=* RaisesException=|Getter|Setter|Constructor -Reflect=|* -ReflectEmpty=* -ReflectInvalid=* -ReflectMissing=* -ReflectOnly=* Replaceable SetterCallWith=ExecutionContext|ScriptArguments|ActiveWindow|FirstWindow SetWrapperReferenceFrom=* diff --git a/sky/engine/bindings/scripts/dart_attributes.py b/sky/engine/bindings/scripts/dart_attributes.py index 8ed32c07982d3..4409bc314c400 100644 --- a/sky/engine/bindings/scripts/dart_attributes.py +++ b/sky/engine/bindings/scripts/dart_attributes.py @@ -114,22 +114,19 @@ def getter_context(interface, attribute, context): extended_attributes = attribute.extended_attributes cpp_value = getter_expression(interface, attribute, context) - # Normally we can inline the function call into the return statement to - # avoid the overhead of using a Ref<> temporary, but for some cases - # (nullable types, EventHandler, [CachedAttribute], or if there are - # exceptions), we need to use a local variable. + # Normally we can inline the function call into the return + # statement to avoid the overhead of using a Ref<> temporary, but + # for some cases (nullable types, [CachedAttribute], or if there + # are exceptions), we need to use a local variable. # FIXME: check if compilers are smart enough to inline this, and if so, # always use a local variable (for readability and CG simplicity). release = False if (idl_type.is_nullable or - base_idl_type == 'EventHandler' or 'CachedAttribute' in extended_attributes or - 'ReflectOnly' in extended_attributes or context['is_getter_raises_exception']): context['cpp_value_original'] = cpp_value cpp_value = 'result' - # EventHandler has special handling - if base_idl_type != 'EventHandler' and idl_type.is_interface_type: + if idl_type.is_interface_type: release = True dart_set_return_value = \ @@ -229,16 +226,8 @@ def setter_expression(interface, attribute, context): not attribute.is_static): arguments.append('*receiver') idl_type = attribute.idl_type - if idl_type.base_type == 'EventHandler': - getter_name = DartUtilities.scoped_name(interface, attribute, DartUtilities.cpp_name(attribute)) - context['event_handler_getter_expression'] = '%s(%s)' % ( - getter_name, ', '.join(arguments)) - # FIXME(vsm): Do we need to support this? If so, what's our analogue of - # V8EventListenerList? - arguments.append('nullptr') - else: - attribute_name = dart_types.check_reserved_name(attribute.name) - arguments.append(attribute_name) + attribute_name = dart_types.check_reserved_name(attribute.name) + arguments.append(attribute_name) if context['is_setter_raises_exception']: arguments.append('es') diff --git a/sky/engine/bindings/scripts/dart_types.py b/sky/engine/bindings/scripts/dart_types.py index c1cf1043ee16b..b24f2bab0da25 100644 --- a/sky/engine/bindings/scripts/dart_types.py +++ b/sky/engine/bindings/scripts/dart_types.py @@ -500,15 +500,6 @@ def preprocess_idl_type_and_value(idl_type, cpp_value, extended_attributes): # FIXME(vsm): V8 maps 'long long' and 'unsigned long long' to double # as they are not representable in ECMAScript. Should we do the same? - # HTML5 says that unsigned reflected attributes should be in the range - # [0, 2^31). When a value isn't in this range, a default value (or 0) - # should be returned instead. - extended_attributes = extended_attributes or {} - if ('Reflect' in extended_attributes and - idl_type.base_type in ['unsigned long', 'unsigned short']): - cpp_value = cpp_value.replace('getUnsignedIntegralAttribute', - 'getIntegralAttribute') - cpp_value = 'std::max(0, %s)' % cpp_value return idl_type, cpp_value @@ -645,8 +636,8 @@ def dart_conversion_type(idl_type, extended_attributes): # TODO(terry): Remove ForMainWorld stuff. 'DOMWrapperForMainWorld': DART_FIX_ME, # FIXME(vsm): V8 has a fast path. Do we? - 'DOMWrapperFast': 'DartConverter<{implemented_as}*>::SetReturnValue(args, WTF::getPtr({cpp_value}), {auto_scope})', - 'DOMWrapperDefault': 'DartConverter<{implemented_as}*>::SetReturnValue(args, WTF::getPtr({cpp_value}), {auto_scope})', + 'DOMWrapperFast': '/*DOMWrapperFast*/ DartConverter<{implemented_as}*>::SetReturnValue(args, WTF::getPtr({cpp_value}), {auto_scope})', + 'DOMWrapperDefault': '/*DOMWrapperDefault*/ DartConverter<{implemented_as}*>::SetReturnValue(args, WTF::getPtr({cpp_value}), {auto_scope})', # Typed arrays don't have special Dart* classes for Dart. 'ArrayBuffer': 'Dart_SetReturnValue(args, DartUtilities::arrayBufferToDart({cpp_value}))', 'TypedList': 'Dart_SetReturnValue(args, DartUtilities::arrayBufferViewToDart({cpp_value}))', diff --git a/sky/engine/bindings/scripts/templates/attributes_cpp.template b/sky/engine/bindings/scripts/templates/attributes_cpp.template index febec81c7377d..d5c5e115eea58 100644 --- a/sky/engine/bindings/scripts/templates/attributes_cpp.template +++ b/sky/engine/bindings/scripts/templates/attributes_cpp.template @@ -48,8 +48,7 @@ ExceptionState es; {% endif %} {% if attribute.cached_attribute_validation_method or attribute.is_getter_raises_exception or - attribute.is_nullable or - attribute.idl_type == 'EventHandler' %} + attribute.is_nullable %} {{attribute.cpp_type}} {{attribute.cpp_value}} = {{attribute.cpp_value_original}}; {% endif %} {% if attribute.is_nullable %} @@ -74,7 +73,7 @@ DART_UNIMPLEMENTED(); {% macro attribute_setter(cpp_class, attribute) %} static void {{static_attribute_name(attribute, 'Setter')}}(Dart_NativeArguments args) { -{% if attribute.idl_type == "EventHandler" or not attribute.cpp_setter %} +{% if not attribute.cpp_setter %} {# TODO(terry): Need to fix properly. #} // FIXME: proper implementation. DART_UNIMPLEMENTED(); @@ -82,9 +81,6 @@ static void {{static_attribute_name(attribute, 'Setter')}}(Dart_NativeArguments Dart_Handle exception = nullptr; { {{cpp_class}}* receiver = GetReceiver<{{cpp_class}}>(args); -{% if attribute.is_custom_element_callbacks %} - CustomElementCallbackScope deliveryScope; -{% endif %} {% set attribute_name = attribute.name if not attribute.put_forwards else 'value' %} {{attribute.local_cpp_type}} {{attribute.setter_lvalue}} = {{attribute.dart_value_to_local_cpp_value}}; @@ -151,7 +147,6 @@ if (result.isNull()) { result = "{{reflect_empty}}"; {% else %} if (result.isEmpty()) { -{# FIXME: should use [ReflectEmpty] instead; need to change IDL files #} {% if reflect_missing %} result = "{{reflect_missing}}"; {% else %} diff --git a/sky/engine/bindings/scripts/templates/interface_h.template b/sky/engine/bindings/scripts/templates/interface_h.template index a5f823269a03b..fea038a3b4c85 100644 --- a/sky/engine/bindings/scripts/templates/interface_h.template +++ b/sky/engine/bindings/scripts/templates/interface_h.template @@ -36,9 +36,6 @@ namespace {{dart_class}}Internal { {% if has_event_constructor %} void initialize{{interface_name}}ForDart({{interface_name}}Init&, const String&, const HashMap&, Dart_Handle&); {% endif %} - {% for method in methods if method.is_custom_element_callbacks and not method.suppressed %} - void {{method.name}}_{{method.number_of_arguments}}(Dart_NativeArguments); - {% endfor %} {% for method in methods if method.is_custom or method.custom_dart_new %} void {{static_method_name(method.name)}}(Dart_NativeArguments args); {% if method.overload_index == 1 %} diff --git a/sky/engine/bindings/scripts/templates/methods_cpp.template b/sky/engine/bindings/scripts/templates/methods_cpp.template index c074f3f508026..1a8960f3a54de 100644 --- a/sky/engine/bindings/scripts/templates/methods_cpp.template +++ b/sky/engine/bindings/scripts/templates/methods_cpp.template @@ -80,9 +80,6 @@ static void {{static_method_name(method.name, overload_index)}}(Dart_NativeArgum {% if not method.is_static %} {{cpp_class}}* /* FIXME(vsm): Remove this. */ ALLOW_UNUSED receiver = GetReceiver<{{cpp_class}}>(args); {% endif %} -{% if method.is_custom_element_callbacks %} - CustomElementCallbackScope deliveryScope; -{% endif %} {% if arguments_count > 0 or method.has_exception_state or method.is_call_with_script_state or diff --git a/sky/engine/bindings/scripts/v8_attributes.py b/sky/engine/bindings/scripts/v8_attributes.py index 60d72e2305a49..b3b06c7adf803 100644 --- a/sky/engine/bindings/scripts/v8_attributes.py +++ b/sky/engine/bindings/scripts/v8_attributes.py @@ -50,22 +50,12 @@ def attribute_context(interface, attribute): idl_type.add_includes_for_type() - # [CustomElementCallbacks], [Reflect] - is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attributes - is_reflect = 'Reflect' in extended_attributes - if is_custom_element_callbacks or is_reflect: - includes.add('sky/engine/core/dom/custom/custom_element_callback_scope.h') # [TypeChecking] has_type_checking_unrestricted = ( (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted') or has_extended_attribute_value(attribute, 'TypeChecking', 'Unrestricted')) and idl_type.name in ('Float', 'Double')) - if (base_idl_type == 'EventHandler' and - interface.name in ['Window'] and - attribute.name == 'onerror'): - includes.add('bindings/core/v8/V8ErrorHandler.h') - context = { 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), 'cached_attribute_validation_method': extended_attributes.get('CachedAttribute'), @@ -82,7 +72,6 @@ def attribute_context(interface, attribute): 'idl_type': str(idl_type), # need trailing [] on array for Dictionary::ConversionContext::setConversionType 'is_call_with_execution_context': v8_utilities.has_extended_attribute_value(attribute, 'CallWith', 'ExecutionContext'), 'is_call_with_script_state': v8_utilities.has_extended_attribute_value(attribute, 'CallWith', 'ScriptState'), - 'is_custom_element_callbacks': is_custom_element_callbacks, 'is_getter_raises_exception': # [RaisesException] 'RaisesException' in extended_attributes and extended_attributes['RaisesException'] in (None, 'Getter'), @@ -94,16 +83,11 @@ def attribute_context(interface, attribute): 'is_partial_interface_member': 'PartialInterfaceImplementedAs' in extended_attributes, 'is_read_only': attribute.is_read_only, - 'is_reflect': is_reflect, 'is_replaceable': 'Replaceable' in attribute.extended_attributes, 'is_static': attribute.is_static, 'is_url': 'URL' in extended_attributes, 'name': attribute.name, 'put_forwards': 'PutForwards' in extended_attributes, - 'reflect_empty': extended_attributes.get('ReflectEmpty'), - 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), - 'reflect_missing': extended_attributes.get('ReflectMissing'), - 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly'), 'setter_callback': setter_callback_name(interface, attribute), } @@ -161,10 +145,9 @@ def getter_expression(interface, attribute, context): def getter_base_name(interface, attribute, arguments): extended_attributes = attribute.extended_attributes - if 'Reflect' not in extended_attributes: - return uncapitalize(cpp_name(attribute)) + return uncapitalize(cpp_name(attribute)) - content_attribute_name = extended_attributes['Reflect'] or attribute.name.lower() + content_attribute_name = attribute.name.lower() if content_attribute_name in ['class', 'id']: # Special-case for performance optimization. return 'get%sAttribute' % content_attribute_name.capitalize() @@ -254,18 +237,11 @@ def setter_context(interface, attribute, context): def setter_base_name(interface, attribute, arguments): - if 'Reflect' not in attribute.extended_attributes: - return 'set%s' % capitalize(cpp_name(attribute)) - arguments.append(scoped_content_attribute_name(interface, attribute)) - - base_idl_type = attribute.idl_type.base_type - if base_idl_type in CONTENT_ATTRIBUTE_SETTER_NAMES: - return CONTENT_ATTRIBUTE_SETTER_NAMES[base_idl_type] - return 'setAttribute' + return 'set%s' % capitalize(cpp_name(attribute)) def scoped_content_attribute_name(interface, attribute): - content_attribute_name = attribute.extended_attributes['Reflect'] or attribute.name.lower() + content_attribute_name = attribute.name.lower() namespace = 'HTMLNames' includes.add('gen/sky/core/%s.h' % namespace) return '%s::%sAttr' % (namespace, content_attribute_name) diff --git a/sky/engine/bindings/scripts/v8_interface.py b/sky/engine/bindings/scripts/v8_interface.py index 442cc56b2a84c..315c9b2d729fb 100644 --- a/sky/engine/bindings/scripts/v8_interface.py +++ b/sky/engine/bindings/scripts/v8_interface.py @@ -282,7 +282,7 @@ def interface_context(interface): return context -# [DeprecateAs], [Reflect] +# [DeprecateAs] def constant_context(constant): # (Blink-only) string literals are unquoted in tokenizer, must be re-quoted # in C++. @@ -296,8 +296,6 @@ def constant_context(constant): 'cpp_class': extended_attributes.get('PartialInterfaceImplementedAs'), 'idl_type': constant.idl_type.name, 'name': constant.name, - # FIXME: use 'reflected_name' as correct 'name' - 'reflected_name': extended_attributes.get('Reflect', constant.name), 'value': value, } diff --git a/sky/engine/bindings/scripts/v8_methods.py b/sky/engine/bindings/scripts/v8_methods.py index 5cd6bf8eeb9a1..14216fb54603c 100644 --- a/sky/engine/bindings/scripts/v8_methods.py +++ b/sky/engine/bindings/scripts/v8_methods.py @@ -99,9 +99,6 @@ def function_template(): is_call_with_script_state = has_extended_attribute_value(method, 'CallWith', 'ScriptState') if is_call_with_script_state: includes.add('bindings/core/v8/ScriptState.h') - is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attributes - if is_custom_element_callbacks: - includes.add('sky/engine/core/dom/custom/custom_element_callback_scope.h') is_raises_exception = 'RaisesException' in extended_attributes @@ -135,7 +132,6 @@ def function_template(): 'is_call_with_script_arguments': is_call_with_script_arguments, 'is_call_with_script_state': is_call_with_script_state, 'is_custom': 'Custom' in extended_attributes, - 'is_custom_element_callbacks': is_custom_element_callbacks, 'is_explicit_nullable': idl_type.is_explicit_nullable, 'is_partial_interface_member': 'PartialInterfaceImplementedAs' in extended_attributes, diff --git a/sky/engine/bindings/scripts/v8_types.py b/sky/engine/bindings/scripts/v8_types.py index 4420f0ed3f849..3abf44e0d61ca 100644 --- a/sky/engine/bindings/scripts/v8_types.py +++ b/sky/engine/bindings/scripts/v8_types.py @@ -319,15 +319,6 @@ def preprocess_idl_type_and_value(idl_type, cpp_value, extended_attributes): if is_nullable: idl_type = IdlNullableType(idl_type) cpp_value = 'static_cast(%s)' % cpp_value - # HTML5 says that unsigned reflected attributes should be in the range - # [0, 2^31). When a value isn't in this range, a default value (or 0) - # should be returned instead. - extended_attributes = extended_attributes or {} - if ('Reflect' in extended_attributes and - idl_type.base_type in ['unsigned long', 'unsigned short']): - cpp_value = cpp_value.replace('getUnsignedIntegralAttribute', - 'getIntegralAttribute') - cpp_value = 'std::max(0, static_cast(%s))' % cpp_value return idl_type, cpp_value diff --git a/sky/engine/build/scripts/make_element_factory.py b/sky/engine/build/scripts/make_element_factory.py index a6a3e8cc1d00b..7908504b14297 100755 --- a/sky/engine/build/scripts/make_element_factory.py +++ b/sky/engine/build/scripts/make_element_factory.py @@ -36,92 +36,8 @@ from make_qualified_names import MakeQualifiedNamesWriter - class MakeElementFactoryWriter(MakeQualifiedNamesWriter): - defaults = dict(MakeQualifiedNamesWriter.default_parameters, **{ - 'JSInterfaceName': None, - 'Conditional': None, - 'constructorNeedsCreatedByParser': None, - 'interfaceName': None, - 'noConstructor': None, - 'noTypeHelpers': None, - 'runtimeEnabled': None, - }) - default_parameters = dict(MakeQualifiedNamesWriter.default_parameters, **{ - 'fallbackInterfaceName': '', - 'fallbackJSInterfaceName': '', - }) - filters = MakeQualifiedNamesWriter.filters - - def __init__(self, in_file_paths): - super(MakeElementFactoryWriter, self).__init__(in_file_paths) - - # FIXME: When we start using these element factories, we'll want to - # remove the "new" prefix and also have our base class generate - # *Names.h and *Names.cpp. - self._outputs.update({ - (self.namespace + 'ElementFactory.h'): self.generate_factory_header, - (self.namespace + 'ElementFactory.cpp'): self.generate_factory_implementation, - ('V8' + self.namespace + 'ElementWrapperFactory.h'): self.generate_wrapper_factory_header, - ('V8' + self.namespace + 'ElementWrapperFactory.cpp'): self.generate_wrapper_factory_implementation, - }) - - fallback_interface = self.tags_in_file.parameters['fallbackInterfaceName'].strip('"') - fallback_js_interface = self.tags_in_file.parameters['fallbackJSInterfaceName'].strip('"') or fallback_interface - - interface_counts = defaultdict(int) - tags = self._template_context['tags'] - for tag in tags: - tag['has_js_interface'] = self._has_js_interface(tag) - tag['js_interface'] = self._js_interface(tag) - tag['interface'] = self._interface(tag) - interface_counts[tag['interface']] += 1 - - for tag in tags: - tag['multipleTagNames'] = (interface_counts[tag['interface']] > 1 or tag['interface'] == fallback_interface) - - self._template_context.update({ - 'fallback_interface': fallback_interface, - 'fallback_js_interface': fallback_js_interface, - }) - - @template_expander.use_jinja('ElementFactory.h.tmpl', filters=filters) - def generate_factory_header(self): - return self._template_context - - @template_expander.use_jinja('ElementFactory.cpp.tmpl', filters=filters) - def generate_factory_implementation(self): - return self._template_context - - @template_expander.use_jinja('ElementWrapperFactory.h.tmpl', filters=filters) - def generate_wrapper_factory_header(self): - return self._template_context - - @template_expander.use_jinja('ElementWrapperFactory.cpp.tmpl', filters=filters) - def generate_wrapper_factory_implementation(self): - return self._template_context - - def _interface(self, tag): - if tag['interfaceName']: - return tag['interfaceName'] - name = name_utilities.upper_first(tag['name']) - # FIXME: We shouldn't hard-code HTML here. - if name == 'HTML': - name = 'Html' - dash = name.find('-') - while dash != -1: - name = name[:dash] + name[dash + 1].upper() + name[dash + 2:] - dash = name.find('-') - return '%s%sElement' % (self.namespace, name) - - def _js_interface(self, tag): - if tag['JSInterfaceName']: - return tag['JSInterfaceName'] - return self._interface(tag) - - def _has_js_interface(self, tag): - return not tag['noConstructor'] and self._js_interface(tag) != ('%sElement' % self.namespace) - + pass if __name__ == "__main__": in_generator.Maker(MakeElementFactoryWriter).main(sys.argv) diff --git a/sky/engine/build/scripts/make_element_lookup_trie.py b/sky/engine/build/scripts/make_element_lookup_trie.py deleted file mode 100755 index a8077ebb61f3c..0000000000000 --- a/sky/engine/build/scripts/make_element_lookup_trie.py +++ /dev/null @@ -1,134 +0,0 @@ -#!/usr/bin/env python -# 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. - -from itertools import groupby, islice -import sys - -import in_generator -import template_expander - -PARAMETER_NAME = 'data' - - -def _trie(tags, index): - """Make a trie from list of tags, starting at index. - - Resulting trie is partly space-optimized (semi-radix tree): once have only - one string left, compact the entire branch to one leaf node. - However, does not compact branch nodes with a single child. (FIXME) - - Returns: - (char, subtrie, tag, conditions): (char, trie, str, list) - code generation differs between branch nodes and leaf nodes, - hence need different data for each. - - Arguments: - tags: sorted list - (sorted needed by groupby, list needed by len) - index: index at which to branch - (assumes prior to this index strings have a common prefix) - """ - def trie_node(char, subtags_iter): - # Pass in |char| so we can include in same tuple without unpacking - subtags = list(subtags_iter) # need list for len - if len(subtags) == 1: # terminal node, no subtrie - subtrie = None - tag = subtags[0] - conditions = _conditions(tag, index + 1) - else: - subtrie = _trie(subtags, index + 1) - tag = None - conditions = None - return char, subtrie, tag, conditions - - # Group by char at index - def char_at_index(tag): - return tag[index].lower() - - char_subtags = ((k, g) for k, g in groupby(tags, char_at_index)) - - # FIXME: if all subtags have a common prefix, merge with child - # and skip the switch in the generated code - - return (trie_node(char, subtags) for char, subtags in char_subtags) - - -def _conditions(tag, index): - # boolean conditions to check suffix; corresponds to compacting branch - # with a single leaf - return ["%s[%d] == '%c'" % (PARAMETER_NAME, i, c.lower()) - for i, c in islice(enumerate(tag), index, None)] - - -class ElementLookupTrieWriter(in_generator.Writer): - # FIXME: Inherit all these from somewhere. - defaults = { - 'JSInterfaceName': None, - 'constructorNeedsCreatedByParser': None, - 'interfaceName': None, - 'noConstructor': None, - 'runtimeEnabled': None, - } - default_parameters = { - 'namespace': '', - 'fallbackInterfaceName': '', - 'fallbackJSInterfaceName': '', - } - - def __init__(self, in_file_paths): - super(ElementLookupTrieWriter, self).__init__(in_file_paths) - self._tags = [entry['name'] for entry in self.in_file.name_dictionaries] - self._namespace = self.in_file.parameters['namespace'].strip('"') - self._outputs = { - (self._namespace + 'ElementLookupTrie.h'): self.generate_header, - (self._namespace + 'ElementLookupTrie.cpp'): self.generate_implementation, - } - - @template_expander.use_jinja('ElementLookupTrie.h.tmpl') - def generate_header(self): - return { - 'namespace': self._namespace, - } - - @template_expander.use_jinja('ElementLookupTrie.cpp.tmpl') - def generate_implementation(self): - # First sort, so groupby works - self._tags.sort(key=lambda tag: (len(tag), tag)) - # Group tags by length - length_tags = ((k, g) for k, g in groupby(self._tags, len)) - - return { - 'namespace': self._namespace, - 'length_tries': ((length, _trie(tags, 0)) - for length, tags in length_tags), - } - - -if __name__ == '__main__': - in_generator.Maker(ElementLookupTrieWriter).main(sys.argv) diff --git a/sky/engine/build/scripts/make_element_type_helpers.py b/sky/engine/build/scripts/make_element_type_helpers.py deleted file mode 100755 index 212000a99087b..0000000000000 --- a/sky/engine/build/scripts/make_element_type_helpers.py +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env python -# 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. - -import sys -from collections import defaultdict - -import hasher -import in_generator -import name_utilities -import template_expander - -from in_file import InFile - - -def _symbol(tag): - # FIXME: Remove this special case for the ugly x-webkit-foo attributes. - if tag['name'].startswith('-webkit-'): - return tag['name'].replace('-', '_')[1:] - return name_utilities.cpp_name(tag).replace('-', '_') - -class MakeElementTypeHelpersWriter(in_generator.Writer): - defaults = { - 'Conditional': None, - 'ImplementedAs': None, - 'JSInterfaceName': None, - 'constructorNeedsCreatedByParser': None, - 'interfaceName': None, - 'noConstructor': None, - 'noTypeHelpers': None, - 'runtimeEnabled': None, - } - default_parameters = { - 'fallbackInterfaceName': '', - 'namespace': '', - 'fallbackJSInterfaceName': '', - } - filters = { - 'enable_conditional': name_utilities.enable_conditional_if_endif, - 'hash': hasher.hash, - 'symbol': _symbol, - } - - def __init__(self, in_file_path): - super(MakeElementTypeHelpersWriter, self).__init__(in_file_path) - - self.namespace = self.in_file.parameters['namespace'].strip('"') - self.fallbackInterface = self.in_file.parameters['fallbackInterfaceName'].strip('"') - - assert self.namespace, 'A namespace is required.' - - self._outputs = { - (self.namespace + "ElementTypeHelpers.h"): self.generate_helper_header, - } - - self._template_context = { - 'namespace': self.namespace, - 'tags': self.in_file.name_dictionaries, - } - - tags = self._template_context['tags'] - interface_counts = defaultdict(int) - for tag in tags: - tag['interface'] = self._interface(tag) - interface_counts[tag['interface']] += 1 - - for tag in tags: - tag['multipleTagNames'] = (interface_counts[tag['interface']] > 1 or tag['interface'] == self.fallbackInterface) - - @template_expander.use_jinja("ElementTypeHelpers.h.tmpl", filters=filters) - def generate_helper_header(self): - return self._template_context - - def _interface(self, tag): - if tag['interfaceName']: - return tag['interfaceName'] - name = name_utilities.upper_first(tag['name']) - # FIXME: We shouldn't hard-code HTML here. - if name == 'HTML': - name = 'Html' - dash = name.find('-') - while dash != -1: - name = name[:dash] + name[dash + 1].upper() + name[dash + 2:] - dash = name.find('-') - return '%s%sElement' % (self.namespace, name) - -if __name__ == "__main__": - in_generator.Maker(MakeElementTypeHelpersWriter).main(sys.argv) diff --git a/sky/engine/build/scripts/scripts.gni b/sky/engine/build/scripts/scripts.gni index b6cd5e2ed2183..2e0aa0719ccac 100644 --- a/sky/engine/build/scripts/scripts.gni +++ b/sky/engine/build/scripts/scripts.gni @@ -45,16 +45,6 @@ make_qualified_names_files = make_element_factory_files = make_qualified_names_files + [ "$_scripts_dir/make_element_factory.py", - "$_scripts_dir/templates/ElementFactory.cpp.tmpl", - "$_scripts_dir/templates/ElementFactory.h.tmpl", - "$_scripts_dir/templates/ElementWrapperFactory.cpp.tmpl", - "$_scripts_dir/templates/ElementWrapperFactory.h.tmpl", - ] - -make_element_type_helpers_files = - make_qualified_names_files + [ - "$_scripts_dir/make_element_type_helpers.py", - "$_scripts_dir/templates/ElementTypeHelpers.h.tmpl", ] # The executables are relative to the build directory. Don't rebase it because diff --git a/sky/engine/build/scripts/scripts.gypi b/sky/engine/build/scripts/scripts.gypi index 9ac67538f2acd..16828d4446ea5 100644 --- a/sky/engine/build/scripts/scripts.gypi +++ b/sky/engine/build/scripts/scripts.gypi @@ -36,14 +36,6 @@ 'templates/MakeQualifiedNames.cpp.tmpl', 'templates/MakeQualifiedNames.h.tmpl', ], - 'make_element_factory_files': [ - '<@(make_qualified_names_files)', - 'make_element_factory.py', - 'templates/ElementFactory.cpp.tmpl', - 'templates/ElementFactory.h.tmpl', - 'templates/ElementWrapperFactory.cpp.tmpl', - 'templates/ElementWrapperFactory.h.tmpl', - ], 'make_element_type_helpers_files': [ '<@(make_qualified_names_files)', 'make_element_type_helpers.py', diff --git a/sky/engine/build/scripts/templates/ElementFactory.cpp.tmpl b/sky/engine/build/scripts/templates/ElementFactory.cpp.tmpl deleted file mode 100644 index 849cef0978e8c..0000000000000 --- a/sky/engine/build/scripts/templates/ElementFactory.cpp.tmpl +++ /dev/null @@ -1,61 +0,0 @@ -{% from "macros.tmpl" import license %} -{{ license() }} - -#include "{{namespace}}ElementFactory.h" - -#include "{{namespace}}Names.h" -{% for tag in tags|sort %} -#include "core/{{namespace|lower}}/{{tag.interface}}.h" -{% endfor %} -{% if fallback_interface %} -#include "core/{{namespace|lower}}/{{fallback_interface}}.h" -{% endif %} -#include "core/dom/custom/custom_element_registry.h" -#include "core/dom/Document.h" -#include "core/frame/Settings.h" -#include "gen/sky/platform/RuntimeEnabledFeatures.h" -#include "wtf/HashMap.h" - -namespace blink { - -using namespace {{namespace}}Names; - -typedef PassRefPtr<{{namespace}}Element> (*ConstructorFunction)( - Document&, - bool createdByParser); - -typedef HashMap FunctionMap; - -{% for tag in tags|sort if not tag.noConstructor %} -{% filter enable_conditional(tag.Conditional) %} -static PassRefPtr<{{namespace}}Element> {{tag|symbol}}Constructor( - Document& document, - bool createdByParser) -{ - {% if tag.runtimeEnabled %} - if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled()) - return {{fallback_interface}}::create({{tag|symbol}}Tag, document); - {% endif %} - return {{tag.interface}}::create( - {%- if tag.multipleTagNames %}{{tag|symbol}}Tag, {% endif -%} - document - {%- if tag.constructorNeedsCreatedByParser %}, createdByParser{% endif -%} - ); -} -{% endfilter %} -{% endfor %} - -struct Create{{namespace}}FunctionMapData { - const QualifiedName& tag; - ConstructorFunction func; -}; - -PassRefPtr {{namespace}}ElementFactory::createElement( - const AtomicString& localName, - Document& document, - bool createdByParser) -{ - return document.elementRegistry().CreateElement(document, localName); -} - -} // namespace blink diff --git a/sky/engine/build/scripts/templates/ElementFactory.h.tmpl b/sky/engine/build/scripts/templates/ElementFactory.h.tmpl deleted file mode 100644 index 296d71aa55e9b..0000000000000 --- a/sky/engine/build/scripts/templates/ElementFactory.h.tmpl +++ /dev/null @@ -1,25 +0,0 @@ -{% from "macros.tmpl" import license %} -{{ license() }} - -#ifndef {{namespace}}ElementFactory_h -#define {{namespace}}ElementFactory_h - -#include "sky/engine/wtf/Forward.h" -#include "sky/engine/wtf/PassRefPtr.h" - -namespace blink { - -class Document; -class Element; - -class {{namespace}}ElementFactory { -public: - static PassRefPtr createElement( - const AtomicString& localName, - Document&, - bool createdByParser = true); -}; - -} // namespace blink - -#endif diff --git a/sky/engine/build/scripts/templates/ElementLookupTrie.cpp.tmpl b/sky/engine/build/scripts/templates/ElementLookupTrie.cpp.tmpl deleted file mode 100644 index d2e2acb8c4034..0000000000000 --- a/sky/engine/build/scripts/templates/ElementLookupTrie.cpp.tmpl +++ /dev/null @@ -1,44 +0,0 @@ -{% from 'macros.tmpl' import license %} -{{license()}} -{% macro trie_switch(trie, index) %} -{# FIXME: No need to switch if there's only a single item in the subtrie: - can just have an if statement as we're currently doing for leaves. #} -switch (data[{{index}}]) { -{% for char, subtrie, tag, conditions in trie %} -case '{{char}}': - {% if subtrie %}{# Recurse on subtrie #} - {{trie_switch(subtrie, index + 1) | indent}} - {% elif conditions %}{# Check suffix #} - if ({{conditions | join(' && ')}}) - return {{tag}}Tag.localName().impl(); - return 0; - {% else %}{# Terminal node (no suffix) #} - return {{tag}}Tag.localName().impl(); - {% endif %} -{% endfor %} -} -return 0; -{% endmacro %} - -#include "{{namespace}}ElementLookupTrie.h" - -#include "{{namespace}}Names.h" - -namespace blink { - -using namespace {{namespace}}Names; - -StringImpl* lookup{{namespace}}Tag(const UChar* data, unsigned length) -{ - ASSERT(data); - ASSERT(length); - switch (length) { - {% for length, trie in length_tries %} - case {{length}}: - {{trie_switch(trie, 0) | indent(8)}} - {% endfor %} - } - return 0; -} - -} // namespace blink diff --git a/sky/engine/build/scripts/templates/ElementLookupTrie.h.tmpl b/sky/engine/build/scripts/templates/ElementLookupTrie.h.tmpl deleted file mode 100644 index c207cf57677fd..0000000000000 --- a/sky/engine/build/scripts/templates/ElementLookupTrie.h.tmpl +++ /dev/null @@ -1,15 +0,0 @@ -{% from "macros.tmpl" import license %} -{{ license() }} - -#ifndef {{namespace}}ElementLookupTrie_h -#define {{namespace}}ElementLookupTrie_h - -#include "wtf/text/StringImpl.h" - -namespace blink { - -StringImpl* lookup{{namespace}}Tag(const UChar* data, unsigned length); - -} // namespace blink - -#endif diff --git a/sky/engine/build/scripts/templates/ElementTypeHelpers.h.tmpl b/sky/engine/build/scripts/templates/ElementTypeHelpers.h.tmpl deleted file mode 100644 index 37f4f1603fc56..0000000000000 --- a/sky/engine/build/scripts/templates/ElementTypeHelpers.h.tmpl +++ /dev/null @@ -1,46 +0,0 @@ -{% from "macros.tmpl" import license %} -{{ license() }} - -#ifndef {{namespace}}ElementTypeHelpers_h -#define {{namespace}}ElementTypeHelpers_h - -#include "core/dom/Element.h" -#include "{{namespace}}Names.h" -#include "gen/sky/platform/RuntimeEnabledFeatures.h" - -namespace blink { -// Type checking. -{% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %} -{% filter enable_conditional(tag.Conditional) %} -class {{tag.interface}}; -void is{{tag.interface}}(const {{tag.interface}}&); // Catch unnecessary runtime check of type known at compile time. -void is{{tag.interface}}(const {{tag.interface}}*); // Catch unnecessary runtime check of type known at compile time. - -inline bool is{{tag.interface}}(const {{namespace}}Element& element) { - {% if tag.runtimeEnabled %} - if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled()) - return false; - {% endif %} - return element.hasTagName({{namespace}}Names::{{tag|symbol}}Tag); -} -inline bool is{{tag.interface}}(const {{namespace}}Element* element) { return element && is{{tag.interface}}(*element); } -template inline bool is{{tag.interface}}(const PassRefPtr& node) { return is{{tag.interface}}(node.get()); } -template inline bool is{{tag.interface}}(const RefPtr& node) { return is{{tag.interface}}(node.get()); } -inline bool is{{tag.interface}}(const Node& node) { return node.is{{namespace}}Element() && is{{tag.interface}}(to{{namespace}}Element(node)); } -inline bool is{{tag.interface}}(const Node* node) { return node && is{{tag.interface}}(*node); } -template <> inline bool isElementOfType(const Node& node) { return is{{tag.interface}}(node); } -template <> inline bool isElementOfType(const {{namespace}}Element& element) { return is{{tag.interface}}(element); } -{% endfilter %} - -{% endfor %} -// Using macros because the types are forward-declared and we don't want to use reinterpret_cast in the -// casting functions above. reinterpret_cast would be unsafe due to multiple inheritence. - -{% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %} -{% filter enable_conditional(tag.Conditional) %} -#define to{{tag.interface}}(x) blink::toElement(x) -{% endfilter %} -{% endfor %} -} // namespace blink - -#endif diff --git a/sky/engine/build/scripts/templates/ElementWrapperFactory.cpp.tmpl b/sky/engine/build/scripts/templates/ElementWrapperFactory.cpp.tmpl deleted file mode 100644 index 87138cf3e279f..0000000000000 --- a/sky/engine/build/scripts/templates/ElementWrapperFactory.cpp.tmpl +++ /dev/null @@ -1,91 +0,0 @@ -{% from "macros.tmpl" import license %} -{{ license() }} - -#include "V8{{namespace}}ElementWrapperFactory.h" - -#include "{{namespace}}Names.h" -#include "bindings/core/v8/CustomElementWrapper.h" -{% for tag in tags|sort if tag.has_js_interface %} -#include "bindings/core/v8/V8{{tag.interface}}.h" -{% endfor %} -{% for tag in tags|sort if tag.has_js_interface %} -#include "core/{{namespace|lower}}/{{tag.js_interface}}.h" -{% endfor %} -#include "core/{{namespace|lower}}/{{fallback_js_interface}}.h" -#include "core/dom/Document.h" -#include "core/frame/Settings.h" -#include "gen/sky/platform/RuntimeEnabledFeatures.h" -#include "wtf/StdLibExtras.h" - -namespace blink { - -using namespace {{namespace}}Names; - -typedef v8::Handle (*Create{{namespace}}ElementWrapperFunction)({{namespace}}Element*, v8::Handle creationContext, v8::Isolate*); - -static v8::Handle create{{namespace}}ElementWrapper({{namespace}}Element*, v8::Handle, v8::Isolate*) -{ - ASSERT_NOT_REACHED(); - return v8::Handle(); -} -{% for js_interface, list in tags|sort|selectattr('has_js_interface')|groupby('js_interface') %} -{% filter enable_conditional(list[0].Conditional) %} -static v8::Handle create{{js_interface}}Wrapper({{namespace}}Element* element, v8::Handle creationContext, v8::Isolate* isolate) -{ - {% if list[0].runtimeEnabled %} - if (!RuntimeEnabledFeatures::{{list[0].runtimeEnabled}}Enabled()) - return createV8{{namespace}}FallbackWrapper(to{{fallback_js_interface}}(element), creationContext, isolate); - {% endif %} - return wrap(static_cast<{{js_interface}}*>(element), creationContext, isolate); -} -{% endfilter %} -{% endfor %} - -v8::Handle createV8{{namespace}}Wrapper({{namespace}}Element* element, v8::Handle creationContext, v8::Isolate* isolate) -{ - typedef HashMap FunctionMap; - DEFINE_STATIC_LOCAL(FunctionMap, map, ()); - if (map.isEmpty()) { - {% for tag in tags|sort %} - {% filter enable_conditional(tag.Conditional) %} - map.set({{tag|symbol}}Tag.localName().impl(), create{{tag.js_interface}}Wrapper); - {% endfilter %} - {% endfor %} - } - - Create{{namespace}}ElementWrapperFunction createWrapperFunction = map.get(element->localName().impl()); - if (createWrapperFunction == create{{namespace}}ElementWrapper) - createWrapperFunction = createV8{{namespace}}DirectWrapper; - if (element->isCustomElement()) - return CustomElementWrapper<{{namespace}}Element, V8{{namespace}}Element>::wrap(element, creationContext, isolate, createWrapperFunction); - - if (createWrapperFunction) - return createWrapperFunction(element, creationContext, isolate); - {% if fallback_js_interface == namespace + 'Element' %} - return V8{{fallback_js_interface}}::createWrapper(element, creationContext, isolate); - {% else %} - return wrap(to{{fallback_js_interface}}(element), creationContext, isolate); - {% endif %} -} - -const WrapperTypeInfo* findWrapperTypeFor{{namespace}}TagName(const AtomicString& name) -{ - typedef HashMap NameTypeMap; - DEFINE_STATIC_LOCAL(NameTypeMap, map, ()); - if (map.isEmpty()) { - // FIXME: This seems wrong. We should list every interface here, not - // just the ones that have specialized JavaScript interfaces. - {% for tag in tags|sort if tag.has_js_interface %} - {% filter enable_conditional(tag.Conditional) %} - map.set({{tag|symbol}}Tag.localName().impl(), &V8{{tag.js_interface}}::wrapperTypeInfo); - {% endfilter %} - {% endfor %} - } - - if (const WrapperTypeInfo* result = map.get(name.impl())) - return result; - - return &V8{{fallback_js_interface}}::wrapperTypeInfo; -} - -} diff --git a/sky/engine/build/scripts/templates/ElementWrapperFactory.h.tmpl b/sky/engine/build/scripts/templates/ElementWrapperFactory.h.tmpl deleted file mode 100644 index 56688fe852e14..0000000000000 --- a/sky/engine/build/scripts/templates/ElementWrapperFactory.h.tmpl +++ /dev/null @@ -1,29 +0,0 @@ -{% from "macros.tmpl" import license %} -{{ license() }} - -#ifndef V8{{namespace}}ElementWrapperFactory_h -#define V8{{namespace}}ElementWrapperFactory_h - -#include "bindings/core/v8/V8{{namespace}}Element.h" -#include "bindings/core/v8/V8{{fallback_js_interface}}.h" -#include "v8/include/v8.h" - -namespace blink { - -class {{namespace}}Element; - -const WrapperTypeInfo* findWrapperTypeFor{{namespace}}TagName(const AtomicString& name); - -v8::Handle createV8{{namespace}}Wrapper({{namespace}}Element*, v8::Handle creationContext, v8::Isolate*); -inline v8::Handle createV8{{namespace}}DirectWrapper({{namespace}}Element* element, v8::Handle creationContext, v8::Isolate* isolate) -{ - return V8{{namespace}}Element::createWrapper(element, creationContext, isolate); -} -inline v8::Handle createV8{{namespace}}FallbackWrapper({{fallback_js_interface}}* element, v8::Handle creationContext, v8::Isolate* isolate) -{ - return V8{{fallback_js_interface}}::createWrapper(element, creationContext, isolate); -} - -} - -#endif diff --git a/sky/engine/core/BUILD.gn b/sky/engine/core/BUILD.gn index eb7c730fc59d9..57edbfa8a1b65 100644 --- a/sky/engine/core/BUILD.gn +++ b/sky/engine/core/BUILD.gn @@ -237,8 +237,6 @@ group("make_core_generated") { ":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_make_parser", ":make_core_generated_make_token_matcher", ":make_core_generated_media_feature_names", @@ -340,13 +338,10 @@ process_in_files("make_core_generated_html_element_factory") { script = "../build/scripts/make_element_factory.py" in_files = [ - "html/HTMLTagNames.in", "html/HTMLAttributeNames.in", ] other_inputs = make_element_factory_files outputs = [ - "$sky_core_output_dir/HTMLElementFactory.cpp", - "$sky_core_output_dir/HTMLElementFactory.h", "$sky_core_output_dir/HTMLNames.cpp", "$sky_core_output_dir/HTMLNames.h", ] @@ -355,16 +350,6 @@ process_in_files("make_core_generated_html_element_factory") { ] } -process_in_files("make_core_generated_html_element_type_helpers") { - script = "../build/scripts/make_element_type_helpers.py" - - in_files = [ "html/HTMLTagNames.in" ] - other_inputs = make_element_type_helpers_files - outputs = [ - "$sky_core_output_dir/HTMLElementTypeHelpers.h", - ] -} - process_in_files("make_core_generated_event_factory") { script = "../build/scripts/make_event_factory.py" @@ -451,23 +436,6 @@ action("make_core_generated_media_query_tokenizer_codepoints") { deps = make_core_generated_deps } -process_in_files("make_core_generated_html_element_lookup_trie") { - script = "../build/scripts/make_element_lookup_trie.py" - in_files = [ "html/HTMLTagNames.in" ] - other_inputs = [ - "../build/scripts/templates/ElementLookupTrie.cpp.tmpl", - "../build/scripts/templates/ElementLookupTrie.h.tmpl", - ] - outputs = [ - "$sky_core_output_dir/HTMLElementLookupTrie.cpp", - "$sky_core_output_dir/HTMLElementLookupTrie.h", - ] - deps = [ - ":core_names", - ":libraries", - ] -} - action_foreach("make_core_generated_bison") { script = "../build/scripts/rule_bison.py" sources = [ diff --git a/sky/engine/core/core.gni b/sky/engine/core/core.gni index d99a7df51fb01..5f858edb57f93 100644 --- a/sky/engine/core/core.gni +++ b/sky/engine/core/core.gni @@ -265,8 +265,6 @@ sky_core_files = [ "dom/NodeRareData.cpp", "dom/NodeRareData.h", "dom/NodeRenderStyle.h", - "dom/NodeRenderingTraversal.cpp", - "dom/NodeRenderingTraversal.h", "dom/NodeTraversal.cpp", "dom/NodeTraversal.h", "dom/NodeWithIndex.h", @@ -292,7 +290,6 @@ sky_core_files = [ "dom/StaticNodeList.h", "dom/StyleEngine.cpp", "dom/StyleEngine.h", - "dom/TemplateContentDocumentFragment.h", "dom/Text.cpp", "dom/Text.h", "dom/TextLinkColors.cpp", @@ -306,24 +303,6 @@ sky_core_files = [ "dom/UserActionElementSet.h", "dom/WeakNodeMap.cpp", "dom/WeakNodeMap.h", - "dom/custom/custom_element.cc", - "dom/custom/custom_element.h", - "dom/custom/custom_element_callback_scope.cc", - "dom/custom/custom_element_callback_scope.h", - "dom/custom/custom_element_registry.cc", - "dom/custom/custom_element_registry.h", - "dom/shadow/ComposedTreeWalker.cpp", - "dom/shadow/ComposedTreeWalker.h", - "dom/shadow/ContentDistribution.cpp", - "dom/shadow/ContentDistribution.h", - "dom/shadow/ElementShadow.cpp", - "dom/shadow/ElementShadow.h", - "dom/shadow/InsertionPoint.cpp", - "dom/shadow/InsertionPoint.h", - "dom/shadow/SelectRuleFeatureSet.cpp", - "dom/shadow/SelectRuleFeatureSet.h", - "dom/shadow/ShadowRoot.cpp", - "dom/shadow/ShadowRoot.h", "editing/CompositionUnderline.h", "editing/CompositionUnderlineRangeFilter.cpp", "editing/CompositionUnderlineRangeFilter.h", @@ -682,7 +661,6 @@ core_idl_files = get_path_info([ "dom/RequestAnimationFrameCallback.idl", "dom/Text.idl", "dom/URL.idl", - "dom/shadow/ShadowRoot.idl", "events/ErrorEvent.idl", "events/Event.idl", "events/GestureEvent.idl", diff --git a/sky/engine/core/css/CSSComputedStyleDeclaration.cpp b/sky/engine/core/css/CSSComputedStyleDeclaration.cpp index 55398cb95096c..1d3497704e920 100644 --- a/sky/engine/core/css/CSSComputedStyleDeclaration.cpp +++ b/sky/engine/core/css/CSSComputedStyleDeclaration.cpp @@ -859,7 +859,7 @@ PassRefPtr CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert style = computeRenderStyle(propertyID); - bool forceFullLayout = isLayoutDependent(propertyID, style, renderer) || m_node->isInShadowTree(); + bool forceFullLayout = isLayoutDependent(propertyID, style, renderer); if (forceFullLayout) { document.updateLayout(); diff --git a/sky/engine/core/css/CSSSelector.cpp b/sky/engine/core/css/CSSSelector.cpp index c4d3d0b5afc91..edf64150baa71 100644 --- a/sky/engine/core/css/CSSSelector.cpp +++ b/sky/engine/core/css/CSSSelector.cpp @@ -111,7 +111,6 @@ void CSSSelector::show(int indent) const { printf("%*sselectorText(): %s\n", indent, "", selectorText().ascii().data()); printf("%*sm_match: %d\n", indent, "", m_match); - printf("%*sisCustomPseudoElement(): %d\n", indent, "", isCustomPseudoElement()); if (m_match != Tag) printf("%*svalue(): %s\n", indent, "", value().ascii().data()); printf("%*spseudoType(): %d\n", indent, "", pseudoType()); @@ -140,33 +139,7 @@ void CSSSelector::extractPseudoType() const { if (m_match != PseudoClass && m_match != PseudoElement) return; - - m_pseudoType = parsePseudoType(value()); - - bool element = false; // pseudo-element - bool compat = false; // single colon compatbility mode - - switch (m_pseudoType) { - case PseudoUserAgentCustomElement: - element = true; - break; - case PseudoUnknown: - case PseudoHover: - case PseudoFocus: - case PseudoActive: - case PseudoLang: - case PseudoNotParsed: - case PseudoHost: - break; - } - - if (m_match == PseudoClass && element) { - if (!compat) - m_pseudoType = PseudoUnknown; - else - m_match = PseudoElement; - } else if (m_match == PseudoElement && !element) - m_pseudoType = PseudoUnknown; + m_pseudoType = PseudoUnknown; } bool CSSSelector::operator==(const CSSSelector& other) const diff --git a/sky/engine/core/css/CSSSelector.h b/sky/engine/core/css/CSSSelector.h index 292005fa39926..42351428e96ec 100644 --- a/sky/engine/core/css/CSSSelector.h +++ b/sky/engine/core/css/CSSSelector.h @@ -75,11 +75,6 @@ namespace blink { // // Attribute selectors return the attribute name in the attribute() method. The value() method returns the value matched against // in case of selectors like [attr="value"]. - // - // ** isCustomPseudoElement(): - // - // It appears this is used only for pseudo elements that appear in user-agent shadow DOM. They are not exposed to author-created - // shadow DOM. class CSSSelector { WTF_MAKE_FAST_ALLOCATED; @@ -120,7 +115,6 @@ namespace blink { PseudoFocus, PseudoActive, PseudoLang, - PseudoUserAgentCustomElement, PseudoHost, }; @@ -167,7 +161,6 @@ namespace blink { void setSelectorList(PassOwnPtr); bool matchesPseudoElement() const; - bool isCustomPseudoElement() const; bool isAttributeSelector() const; bool isHostPseudoClass() const; @@ -245,11 +238,6 @@ inline bool CSSSelector::matchesPseudoElement() const return m_match == PseudoElement; } -inline bool CSSSelector::isCustomPseudoElement() const -{ - return m_match == PseudoElement && (m_pseudoType == PseudoUserAgentCustomElement); -} - inline bool CSSSelector::isHostPseudoClass() const { return m_match == PseudoClass && m_pseudoType == PseudoHost; diff --git a/sky/engine/core/css/ElementRuleCollector.cpp b/sky/engine/core/css/ElementRuleCollector.cpp index ca9f4cdd48a38..6969437290a88 100644 --- a/sky/engine/core/css/ElementRuleCollector.cpp +++ b/sky/engine/core/css/ElementRuleCollector.cpp @@ -32,7 +32,6 @@ #include "sky/engine/core/css/CSSStyleSheet.h" #include "sky/engine/core/css/StylePropertySet.h" #include "sky/engine/core/css/resolver/StyleResolver.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/rendering/style/RenderStyle.h" #include "sky/engine/core/rendering/style/StyleInheritedData.h" diff --git a/sky/engine/core/css/RuleSet.cpp b/sky/engine/core/css/RuleSet.cpp index 39db63672a892..9e8dfed37b017 100644 --- a/sky/engine/core/css/RuleSet.cpp +++ b/sky/engine/core/css/RuleSet.cpp @@ -75,8 +75,6 @@ static void extractValuesforSelector(const CSSSelector* selector, AtomicString& default: break; } - if (selector->isCustomPseudoElement()) - customPseudoElementName = selector->value(); } bool RuleSet::findBestRuleSetAndAdd(const CSSSelector& component, RuleData& ruleData) diff --git a/sky/engine/core/css/SelectorChecker.cpp b/sky/engine/core/css/SelectorChecker.cpp index b41fdd2fa6d53..0aa8901a59016 100644 --- a/sky/engine/core/css/SelectorChecker.cpp +++ b/sky/engine/core/css/SelectorChecker.cpp @@ -30,7 +30,6 @@ #include "sky/engine/core/css/CSSSelector.h" #include "sky/engine/core/css/CSSSelectorList.h" #include "sky/engine/core/dom/Document.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/html/parser/HTMLParserIdioms.h" #include "sky/engine/core/page/FocusController.h" @@ -163,7 +162,6 @@ bool SelectorChecker::checkPseudoClass(const CSSSelector& selector) case CSSSelector::PseudoUnknown: case CSSSelector::PseudoNotParsed: - case CSSSelector::PseudoUserAgentCustomElement: return false; } ASSERT_NOT_REACHED(); diff --git a/sky/engine/core/css/parser/CSSParserValues.h b/sky/engine/core/css/parser/CSSParserValues.h index 572cb7fc41564..b950962e2905d 100644 --- a/sky/engine/core/css/parser/CSSParserValues.h +++ b/sky/engine/core/css/parser/CSSParserValues.h @@ -227,7 +227,6 @@ class CSSParserSelector { bool hasHostPseudoSelector() const; CSSSelector::PseudoType pseudoType() const { return m_selector->pseudoType(); } - bool isCustomPseudoElement() const { return m_selector->isCustomPseudoElement(); } bool isSimple() const; diff --git a/sky/engine/core/css/resolver/ElementResolveContext.cpp b/sky/engine/core/css/resolver/ElementResolveContext.cpp index 9554540b6b6f6..ee0dbe5c6e2a7 100644 --- a/sky/engine/core/css/resolver/ElementResolveContext.cpp +++ b/sky/engine/core/css/resolver/ElementResolveContext.cpp @@ -23,24 +23,19 @@ #include "sky/engine/core/dom/Node.h" #include "sky/engine/core/dom/NodeRenderStyle.h" -#include "sky/engine/core/dom/NodeRenderingTraversal.h" namespace blink { ElementResolveContext::ElementResolveContext(const Document& document) : m_element(nullptr) , m_parentNode(nullptr) - , m_distributedToInsertionPoint(false) { } ElementResolveContext::ElementResolveContext(Element& element) : m_element(&element) - , m_distributedToInsertionPoint(false) { - NodeRenderingTraversal::ParentDetails parentDetails; - m_parentNode = NodeRenderingTraversal::parent(&element, &parentDetails); - m_distributedToInsertionPoint = parentDetails.insertionPoint(); + m_parentNode = element.parentNode(); } } // namespace blink diff --git a/sky/engine/core/css/resolver/ElementResolveContext.h b/sky/engine/core/css/resolver/ElementResolveContext.h index 0e360c85e3877..657c69e31cd93 100644 --- a/sky/engine/core/css/resolver/ElementResolveContext.h +++ b/sky/engine/core/css/resolver/ElementResolveContext.h @@ -42,12 +42,10 @@ class ElementResolveContext { Element* element() const { return m_element; } const ContainerNode* parentNode() const { return m_parentNode; } - bool distributedToInsertionPoint() const { return m_distributedToInsertionPoint; } private: RawPtr m_element; RawPtr m_parentNode; - bool m_distributedToInsertionPoint; }; } // namespace blink diff --git a/sky/engine/core/css/resolver/ScopedStyleResolver.cpp b/sky/engine/core/css/resolver/ScopedStyleResolver.cpp index 1a5ada90f6598..4b57a3763f5eb 100644 --- a/sky/engine/core/css/resolver/ScopedStyleResolver.cpp +++ b/sky/engine/core/css/resolver/ScopedStyleResolver.cpp @@ -33,7 +33,6 @@ #include "sky/engine/core/dom/Document.h" #include "sky/engine/core/dom/StyleEngine.h" #include "sky/engine/core/dom/TreeScope.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" namespace blink { @@ -53,11 +52,6 @@ void ScopedStyleResolver::updateActiveStyleSheets() // TODO(esprehn): We should avoid subtree recalcs in sky when rules change // and only recalc specific tree scopes. root.setNeedsStyleRecalc(SubtreeStyleChange); - - // TODO(esprehn): We should use LocalStyleChange, :host rule changes - // can only impact the host directly as Sky has no descendant selectors. - if (root.isShadowRoot()) - toShadowRoot(root).host()->setNeedsStyleRecalc(SubtreeStyleChange); } bool ScopedStyleResolver::hasSelectorForId(const AtomicString& id) const diff --git a/sky/engine/core/css/resolver/SharedStyleFinder.cpp b/sky/engine/core/css/resolver/SharedStyleFinder.cpp index ffb4a5cfecbd4..ab7bdf352d5cb 100644 --- a/sky/engine/core/css/resolver/SharedStyleFinder.cpp +++ b/sky/engine/core/css/resolver/SharedStyleFinder.cpp @@ -38,8 +38,6 @@ #include "sky/engine/core/dom/NodeRenderStyle.h" #include "sky/engine/core/dom/QualifiedName.h" #include "sky/engine/core/dom/SpaceSplitString.h" -#include "sky/engine/core/dom/shadow/ElementShadow.h" -#include "sky/engine/core/dom/shadow/InsertionPoint.h" #include "sky/engine/core/html/HTMLElement.h" #include "sky/engine/core/rendering/style/RenderStyle.h" #include "sky/engine/wtf/HashSet.h" @@ -89,16 +87,7 @@ bool SharedStyleFinder::sharingCandidateHasIdenticalStyleAffectingAttributes(Ele bool SharedStyleFinder::sharingCandidateCanShareHostStyles(Element& candidate) const { - const ElementShadow* elementShadow = element().shadow(); - const ElementShadow* candidateShadow = candidate.shadow(); - - if (!elementShadow && !candidateShadow) - return true; - - if (static_cast(elementShadow) != static_cast(candidateShadow)) - return false; - - return elementShadow->hasSameStyles(candidateShadow); + return true; } bool SharedStyleFinder::canShareStyleWithElement(Element& candidate) const @@ -116,7 +105,7 @@ bool SharedStyleFinder::canShareStyleWithElement(Element& candidate) const return false; if (!style->isSharable()) return false; - ContainerNode* parent = NodeRenderingTraversal::parent(&candidate); + ContainerNode* parent = candidate.parentNode(); if (!parent) return false; RenderStyle* parentStyle = parent->renderStyle(); @@ -181,7 +170,7 @@ RenderStyle* SharedStyleFinder::findSharedStyle() // Cache whether context.element() is affected by any known class selectors. m_elementAffectedByClassRules = element().hasClass() && classNamesAffectedByRules(element()); - m_renderingParent = NodeRenderingTraversal::parent(&element()); + m_renderingParent = element().parentNode(); Element* shareElement = findElementForStyleSharing(); diff --git a/sky/engine/core/css/resolver/SharedStyleFinder.h b/sky/engine/core/css/resolver/SharedStyleFinder.h index 585ee020361a3..53ebf15a979e8 100644 --- a/sky/engine/core/css/resolver/SharedStyleFinder.h +++ b/sky/engine/core/css/resolver/SharedStyleFinder.h @@ -58,7 +58,6 @@ class SharedStyleFinder { bool canShareStyleWithElement(Element& candidate) const; bool sharingCandidateHasIdenticalStyleAffectingAttributes(Element& candidate) const; bool sharingCandidateCanShareHostStyles(Element& candidate) const; - bool sharingCandidateDistributedToSameInsertionPoint(Element& candidate) const; Element& element() const { return *m_context.element(); } Document& document() const { return element().document(); } diff --git a/sky/engine/core/css/resolver/StyleAdjuster.cpp b/sky/engine/core/css/resolver/StyleAdjuster.cpp index fa65ac7062acf..db332a0790cea 100644 --- a/sky/engine/core/css/resolver/StyleAdjuster.cpp +++ b/sky/engine/core/css/resolver/StyleAdjuster.cpp @@ -88,7 +88,7 @@ static EDisplay equivalentBlockDisplay(EDisplay display) // and absolute or relatively positioned elements. static bool doesNotInheritTextDecoration(const RenderStyle* style, const Element& e) { - return isAtShadowBoundary(&e) || style->hasOutOfFlowPosition(); + return style->hasOutOfFlowPosition(); } static bool parentStyleForcesZIndexToCreateStackingContext(const RenderStyle* parentStyle) diff --git a/sky/engine/core/css/resolver/StyleResolver.cpp b/sky/engine/core/css/resolver/StyleResolver.cpp index d45fa9649de83..98144daf50a97 100644 --- a/sky/engine/core/css/resolver/StyleResolver.cpp +++ b/sky/engine/core/css/resolver/StyleResolver.cpp @@ -53,8 +53,6 @@ #include "sky/engine/core/dom/NodeRenderStyle.h" #include "sky/engine/core/dom/StyleEngine.h" #include "sky/engine/core/dom/Text.h" -#include "sky/engine/core/dom/shadow/ElementShadow.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/frame/FrameView.h" #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/rendering/RenderView.h" @@ -133,9 +131,6 @@ void StyleResolver::matchRules(Element& element, ElementRuleCollector& collector collector.collectMatchingRules(MatchRequest(&defaultStyles()), ++cascadeOrder); - if (ShadowRoot* shadowRoot = element.shadowRoot()) - shadowRoot->scopedStyleResolver().collectMatchingHostRules(collector, ++cascadeOrder); - ScopedStyleResolver& resolver = element.treeScope().scopedStyleResolver(); resolver.collectMatchingAuthorRules(collector, ++cascadeOrder); @@ -176,19 +171,11 @@ PassRefPtr StyleResolver::styleForElement(Element* element, RenderS if (state.parentStyle()) { state.setStyle(RenderStyle::create()); - state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); + state.style()->inheritFrom(state.parentStyle()); } else { state.setStyle(defaultStyleForElement()); state.setParentStyle(RenderStyle::clone(state.style())); } - // contenteditable attribute (implemented by -webkit-user-modify) should - // be propagated from shadow host to distributed node. - if (state.distributedToInsertionPoint()) { - if (Element* parent = element->parentElement()) { - if (RenderStyle* styleOfShadowHost = parent->renderStyle()) - state.style()->setUserModify(styleOfShadowHost->userModify()); - } - } state.fontBuilder().initForStyleResolve(state.document(), state.style()); @@ -229,7 +216,7 @@ PassRefPtr StyleResolver::styleForText(Text* textNode) { ASSERT(textNode); - Node* parentNode = NodeRenderingTraversal::parent(textNode); + Node* parentNode = textNode->parentNode(); if (!parentNode || !parentNode->renderStyle()) return defaultStyleForElement(); return parentNode->renderStyle(); @@ -353,8 +340,8 @@ void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc // style declarations. We then only need to apply the inherited properties, if any, as their values can depend on the // element context. This is fast and saves memory by reusing the style data structures. state.style()->copyNonInheritedFrom(cachedMatchedProperties->renderStyle.get()); - if (state.parentStyle()->inheritedDataShared(cachedMatchedProperties->parentRenderStyle.get()) && !isAtShadowBoundary(element) - && (!state.distributedToInsertionPoint() || state.style()->userModify() == READ_ONLY)) { + if (state.parentStyle()->inheritedDataShared(cachedMatchedProperties->parentRenderStyle.get()) && + (state.style()->userModify() == READ_ONLY)) { INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheInheritedHit); // If the cache item parent style has identical inherited properties to the current parent style then the diff --git a/sky/engine/core/css/resolver/StyleResolverState.h b/sky/engine/core/css/resolver/StyleResolverState.h index a8841f6823963..613d31d4cddcb 100644 --- a/sky/engine/core/css/resolver/StyleResolverState.h +++ b/sky/engine/core/css/resolver/StyleResolverState.h @@ -53,8 +53,6 @@ class StyleResolverState { Element* element() const { return m_elementContext.element(); } const ContainerNode* parentNode() const { return m_elementContext.parentNode(); } - bool distributedToInsertionPoint() const { return m_elementContext.distributedToInsertionPoint(); } - const ElementResolveContext& elementContext() const { return m_elementContext; } void setStyle(PassRefPtr style) { m_style = style; m_cssToLengthConversionData.setStyle(m_style.get()); } diff --git a/sky/engine/core/dom/ContainerNode.cpp b/sky/engine/core/dom/ContainerNode.cpp index 1c284b1f3636a..f0db0842dcf5a 100644 --- a/sky/engine/core/dom/ContainerNode.cpp +++ b/sky/engine/core/dom/ContainerNode.cpp @@ -24,6 +24,7 @@ #include "sky/engine/bindings/exception_state.h" #include "sky/engine/core/dom/ChildListMutationScope.h" +#include "sky/engine/core/dom/DocumentFragment.h" #include "sky/engine/core/dom/ElementTraversal.h" #include "sky/engine/core/dom/ExceptionCode.h" #include "sky/engine/core/dom/NodeRareData.h" @@ -32,8 +33,6 @@ #include "sky/engine/core/dom/SelectorQuery.h" #include "sky/engine/core/dom/StaticNodeList.h" #include "sky/engine/core/dom/StyleEngine.h" -#include "sky/engine/core/dom/shadow/ElementShadow.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/rendering/InlineTextBox.h" #include "sky/engine/core/rendering/RenderText.h" #include "sky/engine/core/rendering/RenderView.h" @@ -72,13 +71,6 @@ ContainerNode::~ContainerNode() removeDetachedChildren(); } -bool ContainerNode::containsConsideringHostElements(const Node& newChild) const -{ - if (isInShadowTree() || document().isTemplateDocument()) - return newChild.containsIncludingHostElements(*this); - return newChild.contains(this); -} - void ContainerNode::checkAcceptChildType(const Node* newChild, ExceptionState& exceptionState) const { if (!newChild) { @@ -94,7 +86,7 @@ void ContainerNode::checkAcceptChildType(const Node* newChild, ExceptionState& e void ContainerNode::checkAcceptChildHierarchy(const Node& newChild, const Node* oldChild, ExceptionState& exceptionState) const { - if (containsConsideringHostElements(newChild)) { + if (newChild.contains(this)) { exceptionState.ThrowDOMException(HierarchyRequestError, "The new child element contains the parent."); return; } @@ -104,7 +96,7 @@ PassRefPtr ContainerNode::insertBefore(PassRefPtr newChild, Node* re { // Check that this node is not "floating". // If it is, it can be deleted as a side effect of sending mutation events. - ASSERT(refCount() || parentOrShadowHostNode()); + ASSERT(refCount() || parentNode()); RefPtr protect(this); @@ -180,7 +172,6 @@ void ContainerNode::insertBeforeCommon(Node& nextChild, Node& newChild) ASSERT(!newChild.parentNode()); // Use insertBefore if you need to handle reparenting (and want DOM mutation events). ASSERT(!newChild.nextSibling()); ASSERT(!newChild.previousSibling()); - ASSERT(!newChild.isShadowRoot()); Node* prev = nextChild.previousSibling(); ASSERT(m_lastChild != prev); @@ -193,14 +184,14 @@ void ContainerNode::insertBeforeCommon(Node& nextChild, Node& newChild) ASSERT(firstChild() == nextChild); m_firstChild = &newChild; } - newChild.setParentOrShadowHostNode(this); + newChild.setParentNode(this); newChild.setPreviousSibling(prev); newChild.setNextSibling(&nextChild); } void ContainerNode::appendChildCommon(Node& child) { - child.setParentOrShadowHostNode(this); + child.setParentNode(this); if (m_lastChild) { child.setPreviousSibling(m_lastChild); @@ -216,7 +207,7 @@ PassRefPtr ContainerNode::replaceChild(PassRefPtr newChild, PassRefP { // Check that this node is not "floating". // If it is, it can be deleted as a side effect of sending mutation events. - ASSERT(refCount() || parentOrShadowHostNode()); + ASSERT(refCount() || parentNode()); RefPtr protect(this); @@ -356,7 +347,7 @@ void ContainerNode::addChildNodesToDeletionQueue(Node*& head, Node*& tail, Conta next = n->nextSibling(); n->setNextSibling(0); - n->setParentOrShadowHostNode(0); + n->setParentNode(0); container.setFirstChild(next); if (next) next->setPreviousSibling(0); @@ -388,7 +379,7 @@ PassRefPtr ContainerNode::removeChild(PassRefPtr oldChild, Exception { // Check that this node is not "floating". // If it is, it can be deleted as a side effect of sending mutation events. - ASSERT(refCount() || parentOrShadowHostNode()); + ASSERT(refCount() || parentNode()); RefPtr protect(this); RefPtr child = oldChild; @@ -439,7 +430,7 @@ void ContainerNode::removeBetween(Node* previousChild, Node* nextChild, Node& ol oldChild.setPreviousSibling(0); oldChild.setNextSibling(0); - oldChild.setParentOrShadowHostNode(0); + oldChild.setParentNode(0); document().adoptIfNeeded(oldChild); } @@ -498,7 +489,7 @@ PassRefPtr ContainerNode::appendChild(PassRefPtr newChild, Exception // Check that this node is not "floating". // If it is, it can be deleted as a side effect of sending mutation events. - ASSERT(refCount() || parentOrShadowHostNode()); + ASSERT(refCount() || parentNode()); checkAcceptChildType(newChild.get(), exceptionState); if (exceptionState.had_exception()) @@ -579,7 +570,6 @@ void ContainerNode::parserAppendChild(PassRefPtr newChild) void ContainerNode::notifyNodeInserted(Node& root, ChildrenChangeSource source) { ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); - ASSERT(!root.isShadowRoot()); RefPtr protect(this); RefPtr protectNode(root); @@ -600,8 +590,6 @@ void ContainerNode::notifyNodeInsertedInternal(Node& root) if (!inDocument() && !node->isContainerNode()) continue; node->insertedInto(this); - if (ShadowRoot* shadowRoot = node->shadowRoot()) - notifyNodeInsertedInternal(*shadowRoot); } } @@ -617,8 +605,6 @@ void ContainerNode::notifyNodeRemoved(Node& root) if (!node->inDocument() && !node->isContainerNode()) continue; node->removedFrom(this); - if (ShadowRoot* shadowRoot = node->shadowRoot()) - notifyNodeRemoved(*shadowRoot); } } @@ -986,20 +972,4 @@ Element* ContainerNode::getElementById(const AtomicString& id) const return 0; } -#if ENABLE(ASSERT) -bool childAttachedAllowedWhenAttachingChildren(ContainerNode* node) -{ - if (node->isShadowRoot()) - return true; - - if (node->isInsertionPoint()) - return true; - - if (node->isElementNode() && toElement(node)->shadow()) - return true; - - return false; -} -#endif - } // namespace blink diff --git a/sky/engine/core/dom/ContainerNode.h b/sky/engine/core/dom/ContainerNode.h index c37643cdd210a..141c07b3e838e 100644 --- a/sky/engine/core/dom/ContainerNode.h +++ b/sky/engine/core/dom/ContainerNode.h @@ -158,7 +158,6 @@ class ContainerNode : public Node { inline void checkAcceptChildType(const Node* newChild, ExceptionState&) const; inline void checkAcceptChildHierarchy(const Node& newChild, const Node* oldChild, ExceptionState&) const; - inline bool containsConsideringHostElements(const Node&) const; void attachChildren(const AttachContext& = AttachContext()); void detachChildren(const AttachContext& = AttachContext()); @@ -189,9 +188,8 @@ inline void ContainerNode::attachChildren(const AttachContext& context) childrenContext.resolvedStyle = 0; for (Node* child = firstChild(); child; child = child->nextSibling()) { - ASSERT(child->needsAttach() || childAttachedAllowedWhenAttachingChildren(this)); - if (child->needsAttach()) - child->attach(childrenContext); + ASSERT(child->needsAttach()); + child->attach(childrenContext); } } diff --git a/sky/engine/core/dom/DOMTokenList.idl b/sky/engine/core/dom/DOMTokenList.idl index a7281bfd01ed2..c06c7ef117d2c 100644 --- a/sky/engine/core/dom/DOMTokenList.idl +++ b/sky/engine/core/dom/DOMTokenList.idl @@ -28,9 +28,9 @@ readonly attribute unsigned long length; [TreatReturnedNullStringAs=Null] getter DOMString item(unsigned long index); [RaisesException] boolean contains(DOMString token); - [RaisesException, CustomElementCallbacks] void add(DOMString tokens); - [RaisesException, CustomElementCallbacks] void remove(DOMString tokens); - [RaisesException, CustomElementCallbacks] boolean toggle(DOMString token); + [RaisesException] void add(DOMString tokens); + [RaisesException] void remove(DOMString tokens); + [RaisesException] boolean toggle(DOMString token); void clear(); diff --git a/sky/engine/core/dom/Document.cpp b/sky/engine/core/dom/Document.cpp index 7b30dcbb4cfc0..35937ac427250 100644 --- a/sky/engine/core/dom/Document.cpp +++ b/sky/engine/core/dom/Document.cpp @@ -27,7 +27,6 @@ #include "sky/engine/core/dom/Document.h" -#include "gen/sky/core/HTMLElementFactory.h" #include "gen/sky/core/EventNames.h" #include "gen/sky/platform/RuntimeEnabledFeatures.h" #include "sky/engine/bindings/exception_messages.h" @@ -53,7 +52,6 @@ #include "sky/engine/core/dom/MutationObserver.h" #include "sky/engine/core/dom/NodeRareData.h" #include "sky/engine/core/dom/NodeRenderStyle.h" -#include "sky/engine/core/dom/NodeRenderingTraversal.h" #include "sky/engine/core/dom/NodeTraversal.h" #include "sky/engine/core/dom/NodeWithIndex.h" #include "sky/engine/core/dom/Range.h" @@ -63,9 +61,6 @@ #include "sky/engine/core/dom/StaticNodeList.h" #include "sky/engine/core/dom/StyleEngine.h" #include "sky/engine/core/dom/Text.h" -#include "sky/engine/core/dom/custom/custom_element_registry.h" -#include "sky/engine/core/dom/shadow/ElementShadow.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/editing/PositionWithAffinity.h" #include "sky/engine/core/events/Event.h" #include "sky/engine/core/events/PageTransitionEvent.h" @@ -213,15 +208,10 @@ Document::Document(const DocumentInit& initializer) #endif , m_didSetReferrerPolicy(false) , m_referrerPolicy(ReferrerPolicyDefault) - , m_elementRegistry(initializer.elementRegistry()) - , m_templateDocumentHost(nullptr) , m_hasViewportUnits(false) , m_styleRecalcElementCounter(0) , m_frameView(nullptr) { - if (!m_elementRegistry) - m_elementRegistry = CustomElementRegistry::Create(); - // We depend on the url getting immediately set in subframes, but we // also depend on the url NOT getting immediately set in opened windows. // See fast/dom/early-frame-url.html @@ -244,9 +234,6 @@ Document::~Document() ASSERT(m_ranges.isEmpty()); ASSERT(!hasGuardRefCount()); - if (m_templateDocument) - m_templateDocument->m_templateDocumentHost = nullptr; // balanced in ensureTemplateDocument(). - if (m_elemSheet) m_elemSheet->clearOwnerNode(); @@ -276,8 +263,6 @@ void Document::dispose() detachParser(); - m_elementRegistry.clear(); - // removeDetachedChildren() doesn't always unregister IDs, // so tear down scope information upfront to avoid having stale references in the map. destroyTreeScopeData(); @@ -327,7 +312,7 @@ PassRefPtr Document::createElement(const AtomicString& name, ExceptionS return nullptr; } - return HTMLElementFactory::createElement(name, *this, false); + return HTMLElement::create(QualifiedName(name), *this); } PassRefPtr Document::createText(const String& text) @@ -335,11 +320,6 @@ PassRefPtr Document::createText(const String& text) return Text::create(*this, text); } -void Document::registerElement(const AtomicString& name, PassRefPtr type, ExceptionState& es) -{ - m_elementRegistry->RegisterElement(name, type); -} - PassRefPtr Document::createDocumentFragment() { return DocumentFragment::create(*this); @@ -383,12 +363,6 @@ PassRefPtr Document::importNode(Node* importedNode, bool deep, ExceptionSt return newElement.release(); } case DOCUMENT_FRAGMENT_NODE: { - if (importedNode->isShadowRoot()) { - // ShadowRoot nodes should not be explicitly importable. - // Either they are imported along with their host node, or created implicitly. - exceptionState.ThrowDOMException(NotSupportedError, "The node provided is a shadow root, which may not be imported."); - return nullptr; - } DocumentFragment* oldFragment = toDocumentFragment(importedNode); RefPtr newFragment = createDocumentFragment(); if (deep && !importContainerNodeChildren(oldFragment, newFragment, exceptionState)) @@ -412,12 +386,6 @@ PassRefPtr Document::adoptNode(PassRefPtr source, ExceptionState& ex exceptionState.ThrowDOMException(NotSupportedError, "The node provided is of type '" + source->nodeName() + "', which may not be adopted."); return nullptr; default: - if (source->isShadowRoot()) { - // ShadowRoot cannot disconnect itself from the host node. - exceptionState.ThrowDOMException(HierarchyRequestError, "The node provided is a shadow root, which may not be adopted."); - return nullptr; - } - if (source->parentNode()) { source->parentNode()->removeChild(source.get(), exceptionState); if (exceptionState.had_exception()) @@ -430,11 +398,9 @@ PassRefPtr Document::adoptNode(PassRefPtr source, ExceptionState& ex return source; } -// FIXME: This should really be in a possible ElementFactory class PassRefPtr Document::createElement(const QualifiedName& qName, bool createdByParser) { - // FIXME(sky): This should only take a local name. - return HTMLElementFactory::createElement(qName.localName(), *this, createdByParser); + return HTMLElement::create(qName, *this); } String Document::readyState() const @@ -513,14 +479,6 @@ PassRefPtr Document::caretRangeFromPoint(int x, int y) if (!renderer) return nullptr; - Node* node = renderer->node(); - Node* shadowAncestorNode = ancestorInThisScope(node); - if (shadowAncestorNode != node) { - unsigned offset = shadowAncestorNode->nodeIndex(); - ContainerNode* container = shadowAncestorNode->parentNode(); - return Range::create(*this, container, offset, container, offset); - } - PositionWithAffinity positionWithAffinity = result.position(); if (positionWithAffinity.position().isNull()) return nullptr; @@ -652,9 +610,6 @@ bool Document::needsFullRenderTreeUpdate() const return false; if (needsStyleRecalc()) return true; - // FIXME: The childNeedsDistributionRecalc bit means either self or children, we should fix that. - if (childNeedsDistributionRecalc()) - return true; return false; } @@ -681,33 +636,6 @@ void Document::scheduleVisualUpdate() { } -void Document::updateDistributionIfNeeded() -{ - ScriptForbiddenScope forbidScript; - - if (!childNeedsDistributionRecalc()) - return; - TRACE_EVENT0("blink", "Document::updateDistributionIfNeeded"); - recalcDistribution(); -} - -void Document::updateDistributionForNodeIfNeeded(Node* node) -{ - ScriptForbiddenScope forbidScript; - - if (node->inDocument()) { - updateDistributionIfNeeded(); - return; - } - Node* root = node; - while (Node* host = root->shadowHost()) - root = host; - while (Node* ancestor = root->parentOrShadowHostNode()) - root = ancestor; - if (root->childNeedsDistributionRecalc()) - root->recalcDistribution(); -} - void Document::setupFontBuilder(RenderStyle* documentStyle) { FontBuilder fontBuilder; @@ -747,7 +675,6 @@ void Document::updateRenderTree(StyleRecalcChange change) m_styleRecalcElementCounter = 0; evaluateMediaQueryListIfNeeded(); - updateDistributionIfNeeded(); // FIXME: We should update style on our ancestor chain before proceeding // however doing so currently causes several tests to crash, as LocalFrame::setDocument calls Document::attach @@ -815,7 +742,7 @@ void Document::updateRenderTreeForNodeIfNeeded(Node* node) { bool needsRecalc = needsFullRenderTreeUpdate(); - for (const Node* ancestor = node; ancestor && !needsRecalc; ancestor = NodeRenderingTraversal::parent(ancestor)) + for (const Node* ancestor = node; ancestor && !needsRecalc; ancestor = ancestor->parentNode()) needsRecalc = ancestor->needsStyleRecalc(); if (needsRecalc) @@ -1072,7 +999,7 @@ PassRefPtr Document::cloneNode(bool deep) PassRefPtr Document::cloneDocumentWithoutChildren() { - return create(DocumentInit(url()).withElementRegistry(elementRegistry())); + return create(DocumentInit(url())); } void Document::evaluateMediaQueryListIfNeeded() @@ -1127,7 +1054,7 @@ void Document::removeFocusedElementOfSubtree(Node* node, bool amongChildrenOnly) // We can't be focused if we're not in the document. if (!node->inDocument()) return; - bool contains = node->containsIncludingShadowDOM(m_focusedElement.get()); + bool contains = node->contains(m_focusedElement.get()); if (contains && (m_focusedElement != node || !amongChildrenOnly)) setFocusedElement(nullptr); } @@ -1137,12 +1064,12 @@ void Document::hoveredNodeDetached(Node* node) if (!m_hoverNode) return; - if (node != m_hoverNode && (!m_hoverNode->isTextNode() || node != NodeRenderingTraversal::parent(m_hoverNode.get()))) + if (node != m_hoverNode && (!m_hoverNode->isTextNode() || node != m_hoverNode.get()->parentNode())) return; - m_hoverNode = NodeRenderingTraversal::parent(node); + m_hoverNode = node->parentNode(); while (m_hoverNode && !m_hoverNode->renderer()) - m_hoverNode = NodeRenderingTraversal::parent(m_hoverNode.get()); + m_hoverNode = m_hoverNode.get()->parentNode(); } void Document::activeChainNodeDetached(Node* node) @@ -1153,9 +1080,9 @@ void Document::activeChainNodeDetached(Node* node) if (node != m_activeHoverElement) return; - Node* activeNode = NodeRenderingTraversal::parent(node); + Node* activeNode = node->parentNode(); while (activeNode && activeNode->isElementNode() && !activeNode->renderer()) - activeNode = NodeRenderingTraversal::parent(activeNode); + activeNode = activeNode->parentNode(); m_activeHoverElement = activeNode && activeNode->isElementNode() ? toElement(activeNode) : 0; } @@ -1522,22 +1449,6 @@ void Document::decrementActiveParserCount() --m_activeParserCount; } -Document& Document::ensureTemplateDocument() -{ - if (isTemplateDocument()) - return *this; - - if (m_templateDocument) - return *m_templateDocument; - - DocumentInit init = DocumentInit::fromContext(contextDocument(), blankURL()); - m_templateDocument = Document::create(init); - - m_templateDocument->m_templateDocumentHost = this; // balanced in dtor. - - return *m_templateDocument.get(); -} - float Document::devicePixelRatio() const { return m_frame ? m_frame->devicePixelRatio() : 1.0; diff --git a/sky/engine/core/dom/Document.h b/sky/engine/core/dom/Document.h index 0608533a9863d..f24ce2de56732 100644 --- a/sky/engine/core/dom/Document.h +++ b/sky/engine/core/dom/Document.h @@ -60,7 +60,6 @@ class Comment; class ConsoleMessage; class CSSStyleDeclaration; class CSSStyleSheet; -class CustomElementRegistry; class DocumentFragment; class DocumentLoadTiming; class DocumentMarkerController; @@ -385,9 +384,6 @@ class Document : public ContainerNode, public TreeScope, public DocumentSuppleme IntSize initialViewportSize() const; - void registerElement(const AtomicString& name, PassRefPtr type, ExceptionState&); - CustomElementRegistry& elementRegistry() const { return *m_elementRegistry; } - unsigned activeParserCount() { return m_activeParserCount; } void incrementActiveParserCount() { ++m_activeParserCount; } void decrementActiveParserCount(); @@ -398,11 +394,6 @@ class Document : public ContainerNode, public TreeScope, public DocumentSuppleme bool inStyleRecalc() const { return m_inStyleRecalc; } - // A non-null m_templateDocumentHost implies that |this| was created by ensureTemplateDocument(). - bool isTemplateDocument() const { return !!m_templateDocumentHost; } - Document& ensureTemplateDocument(); - Document* templateDocumentHost() { return m_templateDocumentHost; } - LocalFrame* executingFrame(); bool isActive() const { return m_active; } @@ -546,16 +537,8 @@ class Document : public ContainerNode, public TreeScope, public DocumentSuppleme RefPtr m_scriptedAnimationController; - RefPtr m_elementRegistry; - OwnPtr m_elementDataCache; - RefPtr m_templateDocument; - // With Oilpan the templateDocument and the templateDocumentHost - // live and die together. Without Oilpan, the templateDocumentHost - // is a manually managed backpointer from m_templateDocument. - RawPtr m_templateDocumentHost; - bool m_hasViewportUnits; int m_styleRecalcElementCounter; diff --git a/sky/engine/core/dom/Document.idl b/sky/engine/core/dom/Document.idl index 4093a86084f54..14e1b21e1d404 100644 --- a/sky/engine/core/dom/Document.idl +++ b/sky/engine/core/dom/Document.idl @@ -18,21 +18,19 @@ * Boston, MA 02110-1301, USA. */ -callback CustomElementConstructor = Element (); - [ Constructor(), ] interface Document : ParentNode { - [CustomElementCallbacks, RaisesException] Element createElement(DOMString tagName); + [RaisesException] Element createElement(DOMString tagName); Text createText(DOMString? text); DocumentFragment createDocumentFragment(); - [CustomElementCallbacks, RaisesException, TypeChecking=Interface] Node importNode(Node node, [Named] optional boolean deep = false); + [RaisesException, TypeChecking=Interface] Node importNode(Node node, [Named] optional boolean deep = false); Element getElementById(DOMString elementId); - [RaisesException, CustomElementCallbacks, TypeChecking=Interface] Node adoptNode(Node node); + [RaisesException, TypeChecking=Interface] Node adoptNode(Node node); readonly attribute DOMString? baseURI; @@ -40,7 +38,7 @@ callback CustomElementConstructor = Element (); readonly attribute DOMString contentType; - [TreatNullAs=NullString, CustomElementCallbacks] attribute DOMString dir; + [TreatNullAs=NullString] attribute DOMString dir; readonly attribute DOMString referrer; readonly attribute DOMString URL; @@ -56,6 +54,4 @@ callback CustomElementConstructor = Element (); // HTML 5 readonly attribute Element activeElement; boolean hasFocus(); - - [RaisesException] void registerElement(DOMString name, any type); }; diff --git a/sky/engine/core/dom/DocumentInit.cpp b/sky/engine/core/dom/DocumentInit.cpp index 01b894bd23d82..39ada1233b953 100644 --- a/sky/engine/core/dom/DocumentInit.cpp +++ b/sky/engine/core/dom/DocumentInit.cpp @@ -29,7 +29,6 @@ #include "gen/sky/platform/RuntimeEnabledFeatures.h" #include "sky/engine/core/dom/Document.h" -#include "sky/engine/core/dom/custom/custom_element_registry.h" #include "sky/engine/core/frame/LocalFrame.h" namespace blink { @@ -45,7 +44,6 @@ DocumentInit::DocumentInit(const DocumentInit& other) : m_url(other.m_url) , m_frame(other.m_frame) , m_contextDocument(other.m_contextDocument) - , m_elementRegistry(other.m_elementRegistry) { } @@ -69,13 +67,6 @@ Settings* DocumentInit::settings() const return frameForSecurityContext()->settings(); } -DocumentInit& DocumentInit::withElementRegistry(CustomElementRegistry& elementregistry) -{ - ASSERT(!m_elementRegistry); - m_elementRegistry = &elementregistry; - return *this; -} - WeakPtr DocumentInit::contextDocument() const { return m_contextDocument; diff --git a/sky/engine/core/dom/DocumentInit.h b/sky/engine/core/dom/DocumentInit.h index 8f269a466ace5..c1ca97dca7282 100644 --- a/sky/engine/core/dom/DocumentInit.h +++ b/sky/engine/core/dom/DocumentInit.h @@ -38,7 +38,6 @@ namespace blink { class Document; class LocalFrame; -class CustomElementRegistry; class Settings; class DocumentInit final { @@ -59,13 +58,8 @@ class DocumentInit final { LocalFrame* ownerFrame() const; Settings* settings() const; - DocumentInit& withElementRegistry(CustomElementRegistry&); WeakPtr contextDocument() const; - CustomElementRegistry* elementRegistry() const { - return m_elementRegistry.get(); - } - static DocumentInit fromContext(WeakPtr contextDocument, const KURL& = KURL()); private: @@ -76,7 +70,6 @@ class DocumentInit final { RefPtr m_parent; RefPtr m_owner; WeakPtr m_contextDocument; - RefPtr m_elementRegistry; }; } // namespace blink diff --git a/sky/engine/core/dom/DocumentOrderedList.cpp b/sky/engine/core/dom/DocumentOrderedList.cpp index 7581b7d22e3e7..a74d2a9c3aea7 100644 --- a/sky/engine/core/dom/DocumentOrderedList.cpp +++ b/sky/engine/core/dom/DocumentOrderedList.cpp @@ -46,7 +46,7 @@ void DocumentOrderedList::add(Node* node) do { --it; Node* n = *it; - unsigned short position = n->compareDocumentPosition(node, Node::TreatShadowTreesAsComposed); + unsigned short position = n->compareDocumentPosition(node); if (position & Node::DOCUMENT_POSITION_FOLLOWING) { m_nodes.insertBefore(followingNode, node); return; @@ -59,7 +59,7 @@ void DocumentOrderedList::add(Node* node) void DocumentOrderedList::parserAdd(Node* node) { - ASSERT(m_nodes.isEmpty() || m_nodes.last()->compareDocumentPosition(node, Node::TreatShadowTreesAsComposed) & Node::DOCUMENT_POSITION_FOLLOWING); + ASSERT(m_nodes.isEmpty() || m_nodes.last()->compareDocumentPosition(node) & Node::DOCUMENT_POSITION_FOLLOWING); m_nodes.add(node); } diff --git a/sky/engine/core/dom/Element.cpp b/sky/engine/core/dom/Element.cpp index 7660adad8f076..8f4ac5135782e 100644 --- a/sky/engine/core/dom/Element.cpp +++ b/sky/engine/core/dom/Element.cpp @@ -53,9 +53,6 @@ #include "sky/engine/core/dom/SelectorQuery.h" #include "sky/engine/core/dom/StyleEngine.h" #include "sky/engine/core/dom/Text.h" -#include "sky/engine/core/dom/custom/custom_element.h" -#include "sky/engine/core/dom/shadow/InsertionPoint.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/editing/TextIterator.h" #include "sky/engine/core/editing/htmlediting.h" #include "sky/engine/core/frame/FrameView.h" @@ -98,11 +95,6 @@ Element::Element(const QualifiedName& tagName, Document* document, ConstructionT Element::~Element() { ASSERT(needsAttach()); - -#if !ENABLE(OILPAN) - if (hasRareData()) - elementRareData()->clearShadow(); -#endif } inline ElementRareData* Element::elementRareData() const @@ -451,11 +443,6 @@ ALWAYS_INLINE void Element::setAttributeInternal(size_t index, const QualifiedNa void Element::attributeChanged(const QualifiedName& name, const AtomicString& newValue, AttributeModificationReason reason) { - if (ElementShadow* parentElementShadow = shadowWhereNodeCanBeDistributed(*this)) { - if (shouldInvalidateDistributionWhenAttributeChanged(parentElementShadow, name, newValue)) - parentElementShadow->setNeedsDistributionRecalc(); - } - parseAttribute(name, newValue); bool testShouldInvalidateStyle = inActiveDocument() && styleChangeType() < SubtreeStyleChange; @@ -528,32 +515,6 @@ bool Element::classChangeNeedsStyleRecalc(const SpaceSplitString& oldClasses, co return false; } -bool Element::shouldInvalidateDistributionWhenAttributeChanged(ElementShadow* elementShadow, const QualifiedName& name, const AtomicString& newValue) -{ - ASSERT(elementShadow); - const SelectRuleFeatureSet& featureSet = elementShadow->ensureSelectFeatureSet(); - - if (name == HTMLNames::idAttr) { - AtomicString oldId = elementData()->idForStyleResolution(); - AtomicString newId = newValue; - if (newId != oldId) { - if (!oldId.isEmpty() && featureSet.hasSelectorForId(oldId)) - return true; - if (!newId.isEmpty() && featureSet.hasSelectorForId(newId)) - return true; - } - } - - if (name == HTMLNames::classAttr) { - const SpaceSplitString& oldClasses = elementData()->classNames(); - const SpaceSplitString newClasses(newValue, false); - if (featureSet.checkSelectorsForClassChange(oldClasses, newClasses)) - return true; - } - - return featureSet.hasSelectorForAttribute(name.localName()); -} - void Element::parserSetAttributes(const Vector& attributeVector) { ASSERT(!inDocument()); @@ -612,9 +573,6 @@ void Element::insertedInto(ContainerNode* insertionPoint) if (!insertionPoint->isInTreeScope()) return; - if (isUpgradedCustomElement() && inDocument()) - CustomElement::DidAttach(this, document()); - TreeScope& scope = insertionPoint->treeScope(); if (scope != treeScope()) return; @@ -626,8 +584,6 @@ void Element::insertedInto(ContainerNode* insertionPoint) void Element::removedFrom(ContainerNode* insertionPoint) { - bool wasInDocument = insertionPoint->inDocument(); - if (insertionPoint->isInTreeScope() && treeScope() == document()) { const AtomicString& idValue = getIdAttribute(); if (!idValue.isNull()) @@ -635,19 +591,12 @@ void Element::removedFrom(ContainerNode* insertionPoint) } ContainerNode::removedFrom(insertionPoint); - if (wasInDocument) { - if (isUpgradedCustomElement()) - CustomElement::DidDetach(this, insertionPoint->document()); - } } void Element::attach(const AttachContext& context) { ASSERT(document().inStyleRecalc()); - if (isInsertionPoint()) - toInsertionPoint(this)->attachDistribution(context); - // We've already been through detach when doing an attach, but we might // need to clear any state that's been added since then. if (hasRareData() && styleChangeType() == NeedsReattachStyleChange) { @@ -657,18 +606,11 @@ void Element::attach(const AttachContext& context) RenderTreeBuilder(this, context.resolvedStyle).createRendererForElementIfNeeded(); - // When a shadow root exists, it does the work of attaching the children. - if (ElementShadow* shadow = this->shadow()) - shadow->attach(context); - ContainerNode::attach(context); } void Element::detach(const AttachContext& context) { - if (isInsertionPoint()) - toInsertionPoint(this)->detachDistribution(context); - if (hasRareData()) { ElementRareData* data = elementRareData(); @@ -677,8 +619,6 @@ void Element::detach(const AttachContext& context) data->clearComputedStyle(); } - if (ElementShadow* shadow = data->shadow()) - shadow->detach(context); } ContainerNode::detach(context); } @@ -700,10 +640,7 @@ PassRefPtr Element::styleForRenderer() void Element::recalcStyle(StyleRecalcChange change) { ASSERT(document().inStyleRecalc()); - ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); - - if (isInsertionPoint()) - toInsertionPoint(this)->willRecalcStyle(change); + ASSERT(!parentNode()->needsStyleRecalc()); if (change >= Inherit || needsStyleRecalc()) { if (hasRareData()) { @@ -725,7 +662,7 @@ void Element::recalcStyle(StyleRecalcChange change) StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) { ASSERT(document().inStyleRecalc()); - ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); + ASSERT(!parentNode()->needsStyleRecalc()); ASSERT(change >= Inherit || needsStyleRecalc()); ASSERT(parentRenderStyle()); @@ -765,10 +702,6 @@ void Element::recalcChildStyle(StyleRecalcChange change) ASSERT(!needsStyleRecalc()); if (change > Inherit || childNeedsStyleRecalc()) { - if (ShadowRoot* root = shadowRoot()) { - if (root->shouldCallRecalcStyle(change)) - root->recalcStyle(change); - } // This loop is deliberately backwards because we use insertBefore in the rendering tree, and want to avoid // a potentially n^2 loop to find the insertion point while resolving style. Having us start from the last @@ -789,33 +722,6 @@ void Element::recalcChildStyle(StyleRecalcChange change) } } -ElementShadow* Element::shadow() const -{ - return hasRareData() ? elementRareData()->shadow() : 0; -} - -ElementShadow& Element::ensureShadow() -{ - return ensureElementRareData().ensureShadow(); -} - -// TODO(esprehn): Implement the sky spec where shadow roots are a custom -// element registration feature. -PassRefPtr Element::ensureShadowRoot(ExceptionState& exceptionState) -{ - if (ShadowRoot* root = shadowRoot()) - return root; - return PassRefPtr(ensureShadow().addShadowRoot(*this)); -} - -ShadowRoot* Element::shadowRoot() const -{ - ElementShadow* elementShadow = shadow(); - if (!elementShadow) - return 0; - return elementShadow->shadowRoot(); -} - double Element::x() const { if (RenderBox* box = renderBox()) @@ -953,9 +859,6 @@ void Element::setLayoutManager(PassOwnPtr layoutManager, void Element::childrenChanged(const ChildrenChange& change) { ContainerNode::childrenChanged(change); - - if (ElementShadow* shadow = this->shadow()) - shadow->setNeedsDistributionRecalc(); } #ifndef NDEBUG @@ -1269,7 +1172,7 @@ SpellcheckAttributeState Element::spellcheckAttributeState() const bool Element::isSpellCheckingEnabled() const { - for (const Element* element = this; element; element = element->parentOrShadowHostElement()) { + for (const Element* element = this; element; element = element->parentElement()) { switch (element->spellcheckAttributeState()) { case SpellcheckAttributeTrue: return true; @@ -1313,9 +1216,6 @@ void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& if (inActiveDocument() && styleChangeType() < SubtreeStyleChange && affectedByAttributeSelector(name.localName())) setNeedsStyleRecalc(LocalStyleChange); - if (isUpgradedCustomElement()) - CustomElement::AttributeDidChange(this, name.localName(), oldValue, newValue); - if (OwnPtr recipients = MutationObserverInterestGroup::createForAttributesMutation(*this, name)) recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue)); } @@ -1500,7 +1400,7 @@ void Element::removeAllInlineStyleProperties() bool Element::supportsStyleSharing() const { - if (!isStyledElement() || !parentOrShadowHostElement()) + if (!isStyledElement() || !parentElement()) return false; // If the element has inline style it is probably unique. if (inlineStyle()) @@ -1522,9 +1422,6 @@ bool Element::affectedByAttributeSelector(const AtomicString& attributeName) con return false; if (treeScope().scopedStyleResolver().hasSelectorForAttribute(attributeName)) return true; - // Host rules could also have effects. - if (ShadowRoot* shadowRoot = this->shadowRoot()) - return shadowRoot->scopedStyleResolver().hasSelectorForAttribute(attributeName); return false; } @@ -1534,9 +1431,6 @@ bool Element::affectedByClassSelector(const AtomicString& classValue) const return false; if (treeScope().scopedStyleResolver().hasSelectorForClass(classValue)) return true; - // Host rules could also have effects. - if (ShadowRoot* shadowRoot = this->shadowRoot()) - return shadowRoot->scopedStyleResolver().hasSelectorForClass(classValue); return false; } @@ -1546,9 +1440,6 @@ bool Element::affectedByIdSelector(const AtomicString& idValue) const return false; if (treeScope().scopedStyleResolver().hasSelectorForId(idValue)) return true; - // Host rules could also have effects. - if (ShadowRoot* shadowRoot = this->shadowRoot()) - return shadowRoot->scopedStyleResolver().hasSelectorForId(idValue); return false; } diff --git a/sky/engine/core/dom/Element.h b/sky/engine/core/dom/Element.h index 294fbe643ce1e..ec1d7fc8eabec 100644 --- a/sky/engine/core/dom/Element.h +++ b/sky/engine/core/dom/Element.h @@ -46,7 +46,6 @@ class ClientRectList; class DOMTokenList; class Document; class ElementRareData; -class ElementShadow; class ExceptionState; class Image; class IntSize; @@ -55,7 +54,6 @@ class MutableStylePropertySet; class PaintingCallback; class PropertySetCSSStyleDeclaration; class PseudoElement; -class ShadowRoot; class StylePropertySet; enum SpellcheckAttributeState { @@ -195,12 +193,6 @@ class Element : public ContainerNode { bool supportsStyleSharing() const; - ElementShadow* shadow() const; - ElementShadow& ensureShadow(); - PassRefPtr ensureShadowRoot(ExceptionState&); - ShadowRoot* shadowRoot() const; - bool hasAuthorShadowRoot() const { return shadowRoot(); } - double x() const; void setX(double); @@ -232,9 +224,6 @@ class Element : public ContainerNode { RenderStyle* computedStyle(); - bool isUpgradedCustomElement() const { return customElementState() == Upgraded; } - bool isUnresolvedCustomElement() const { return customElementState() == WaitingForUpgrade; } - AtomicString computeInheritedLanguage() const; virtual bool isURLAttribute(const Attribute&) const { return false; } @@ -371,8 +360,6 @@ class Element : public ContainerNode { void createUniqueElementData(); - bool shouldInvalidateDistributionWhenAttributeChanged(ElementShadow*, const QualifiedName&, const AtomicString&); - ElementRareData* elementRareData() const; ElementRareData& ensureElementRareData(); @@ -524,10 +511,6 @@ inline void Node::insertedInto(ContainerNode* insertionPoint) ASSERT(insertionPoint->inDocument() || isContainerNode()); if (insertionPoint->inDocument()) setFlag(InDocumentFlag); - if (parentOrShadowHostNode()->isInShadowTree()) - setFlag(IsInShadowTreeFlag); - if (childNeedsDistributionRecalc() && !insertionPoint->childNeedsDistributionRecalc()) - insertionPoint->markAncestorsWithChildNeedsDistributionRecalc(); } inline void Node::removedFrom(ContainerNode* insertionPoint) @@ -535,15 +518,6 @@ inline void Node::removedFrom(ContainerNode* insertionPoint) ASSERT(insertionPoint->inDocument() || isContainerNode()); if (insertionPoint->inDocument()) clearFlag(InDocumentFlag); - if (isInShadowTree() && !treeScope().rootNode().isShadowRoot()) - clearFlag(IsInShadowTreeFlag); -} - -inline ShadowRoot* Node::shadowRoot() const -{ - if (!isElementNode()) - return 0; - return toElement(this)->shadowRoot(); } inline void Element::invalidateStyleAttribute() @@ -552,24 +526,6 @@ inline void Element::invalidateStyleAttribute() elementData()->m_styleAttributeIsDirty = true; } -inline bool isShadowHost(const Node* node) -{ - return node && node->isElementNode() && toElement(node)->shadow(); -} - -inline bool isShadowHost(const Element* element) -{ - return element && element->shadow(); -} - -inline bool isAtShadowBoundary(const Element* element) -{ - if (!element) - return false; - ContainerNode* parentNode = element->parentNode(); - return parentNode && parentNode->isShadowRoot(); -} - // These macros do the same as their NODE equivalents but additionally provide a template specialization // for isElementOfType<>() so that the Traversal<> API works for these Element types. #define DEFINE_ELEMENT_TYPE_CASTS(thisType, predicate) \ diff --git a/sky/engine/core/dom/Element.idl b/sky/engine/core/dom/Element.idl index ffd15e8ab654b..3aabade5e3072 100644 --- a/sky/engine/core/dom/Element.idl +++ b/sky/engine/core/dom/Element.idl @@ -7,13 +7,11 @@ interface Element : ParentNode { boolean hasAttribute(DOMString name); [TreatReturnedNullStringAs=Null] DOMString getAttribute(DOMString name); - [CustomElementCallbacks, RaisesException] void setAttribute(DOMString name, optional DOMString? value); - [CustomElementCallbacks] void removeAttribute(DOMString name); + [RaisesException] void setAttribute(DOMString name, optional DOMString? value); + void removeAttribute(DOMString name); sequence getAttributes(); - readonly attribute ShadowRoot shadowRoot; - void setNeedsLayout(); void layout(); void setLayoutManager(LayoutCallback layout, LayoutCallback computeIntrinsicWidths); @@ -27,7 +25,6 @@ interface Element : ParentNode { void blur(); attribute long tabIndex; readonly attribute DOMTokenList classList; - [RaisesException] ShadowRoot ensureShadowRoot(); ClientRect getBoundingClientRect(); readonly attribute long offsetLeft; diff --git a/sky/engine/core/dom/ElementRareData.h b/sky/engine/core/dom/ElementRareData.h index f76d458c675e8..e210d6da5873c 100644 --- a/sky/engine/core/dom/ElementRareData.h +++ b/sky/engine/core/dom/ElementRareData.h @@ -25,7 +25,6 @@ #include "sky/engine/core/css/PropertySetCSSStyleDeclaration.h" #include "sky/engine/core/dom/DOMTokenList.h" #include "sky/engine/core/dom/NodeRareData.h" -#include "sky/engine/core/dom/shadow/ElementShadow.h" #include "sky/engine/core/rendering/style/StyleInheritedData.h" #include "sky/engine/wtf/OwnPtr.h" @@ -40,8 +39,6 @@ class ElementRareData : public NodeRareData { return new ElementRareData(renderer); } - ~ElementRareData(); - short tabIndex() const { return m_tabindex; } bool hasTabIndex() const { return m_hasTabIndex; } @@ -59,15 +56,6 @@ class ElementRareData : public NodeRareData { CSSStyleDeclaration& ensureInlineCSSStyleDeclaration(Element* ownerElement); - void clearShadow() { m_shadow = nullptr; } - ElementShadow* shadow() const { return m_shadow.get(); } - ElementShadow& ensureShadow() - { - if (!m_shadow) - m_shadow = ElementShadow::create(); - return *m_shadow; - } - RenderStyle* computedStyle() const { return m_computedStyle.get(); } void setComputedStyle(PassRefPtr computedStyle) { m_computedStyle = computedStyle; } void clearComputedStyle() { m_computedStyle = nullptr; } @@ -80,7 +68,6 @@ class ElementRareData : public NodeRareData { unsigned m_hasTabIndex : 1; OwnPtr m_classList; - OwnPtr m_shadow; OwnPtr m_cssomWrapper; RefPtr m_computedStyle; @@ -96,13 +83,6 @@ inline ElementRareData::ElementRareData(RenderObject* renderer) m_isElementRareData = true; } -inline ElementRareData::~ElementRareData() -{ -#if !ENABLE(OILPAN) - ASSERT(!m_shadow); -#endif -} - } // namespace #endif // SKY_ENGINE_CORE_DOM_ELEMENTRAREDATA_H_ diff --git a/sky/engine/core/dom/Node.cpp b/sky/engine/core/dom/Node.cpp index 44e35d55d15ab..cf6dc5eba2c56 100644 --- a/sky/engine/core/dom/Node.cpp +++ b/sky/engine/core/dom/Node.cpp @@ -39,18 +39,13 @@ #include "sky/engine/core/dom/ElementTraversal.h" #include "sky/engine/core/dom/ExceptionCode.h" #include "sky/engine/core/dom/NodeRareData.h" -#include "sky/engine/core/dom/NodeRenderingTraversal.h" #include "sky/engine/core/dom/NodeTraversal.h" #include "sky/engine/core/dom/Range.h" #include "sky/engine/core/dom/StaticNodeList.h" -#include "sky/engine/core/dom/TemplateContentDocumentFragment.h" #include "sky/engine/core/dom/Text.h" #include "sky/engine/core/dom/TreeScopeAdopter.h" #include "sky/engine/core/dom/UserActionElementSet.h" #include "sky/engine/core/dom/WeakNodeMap.h" -#include "sky/engine/core/dom/shadow/ElementShadow.h" -#include "sky/engine/core/dom/shadow/InsertionPoint.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/editing/htmlediting.h" #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/frame/Settings.h" @@ -101,7 +96,6 @@ void Node::dumpStatistics() size_t documentNodes = 0; size_t docTypeNodes = 0; size_t fragmentNodes = 0; - size_t shadowRootNodes = 0; HashMap perTagCount; @@ -144,10 +138,7 @@ void Node::dumpStatistics() break; } case DOCUMENT_FRAGMENT_NODE: { - if (node->isShadowRoot()) - ++shadowRootNodes; - else - ++fragmentNodes; + ++fragmentNodes; break; } } @@ -162,7 +153,6 @@ void Node::dumpStatistics() printf(" Number of Document nodes: %zu\n", documentNodes); printf(" Number of DocumentType nodes: %zu\n", docTypeNodes); printf(" Number of DocumentFragment nodes: %zu\n", fragmentNodes); - printf(" Number of ShadowRoot nodes: %zu\n", shadowRootNodes); printf("Element tag name distibution:\n"); for (HashMap::iterator it = perTagCount.begin(); it != perTagCount.end(); ++it) @@ -190,12 +180,12 @@ void Node::trackForDebugging() Node::Node(TreeScope* treeScope, ConstructionType type) : m_nodeFlags(type) - , m_parentOrShadowHostNode(nullptr) + , m_parentNode(nullptr) , m_treeScope(treeScope) , m_previous(nullptr) , m_next(nullptr) { - ASSERT(m_treeScope || type == CreateDocument || type == CreateShadowRoot); + ASSERT(m_treeScope || type == CreateDocument); #if !ENABLE(OILPAN) if (m_treeScope) m_treeScope->guardRef(); @@ -298,7 +288,7 @@ static const Node* rootForGC(const Node* node) { if (node->inDocument()) return &node->document(); - while (Node* parent = node->parentOrShadowHostOrTemplateHostNode()) + while (Node* parent = node->parentNode()) node = parent; return node; } @@ -469,38 +459,11 @@ LayoutRect Node::boundingBox() const return LayoutRect(); } -void Node::recalcDistribution() -{ - if (isElementNode()) { - if (ElementShadow* shadow = toElement(this)->shadow()) - shadow->distributeIfNeeded(); - } - - for (Node* child = firstChild(); child; child = child->nextSibling()) { - if (child->childNeedsDistributionRecalc()) - child->recalcDistribution(); - } - - if (ShadowRoot* root = shadowRoot()) { - if (root->childNeedsDistributionRecalc()) - root->recalcDistribution(); - } - - clearChildNeedsDistributionRecalc(); -} - void Node::setIsLink(bool isLink) { setFlag(isLink, IsLinkFlag); } -void Node::markAncestorsWithChildNeedsDistributionRecalc() -{ - for (Node* node = this; node && !node->childNeedsDistributionRecalc(); node = node->parentOrShadowHostNode()) - node->setChildNeedsDistributionRecalc(); - document().scheduleRenderTreeUpdateIfNeeded(); -} - namespace { class JSONTraceValue : public base::trace_event::ConvertableToTraceFormat { @@ -526,8 +489,6 @@ unsigned Node::styledSubtreeSize() const for (const Node* node = this; node; node = NodeTraversal::next(*node, this)) { if (node->isTextNode() || node->isElementNode()) nodeCount++; - if (ShadowRoot* root = node->shadowRoot()) - nodeCount += root->styledSubtreeSize(); } return nodeCount; @@ -561,7 +522,7 @@ inline void Node::setStyleChange(StyleChangeType changeType) void Node::markAncestorsWithChildNeedsStyleRecalc() { - for (ContainerNode* p = parentOrShadowHostNode(); p && !p->childNeedsStyleRecalc(); p = p->parentOrShadowHostNode()) + for (ContainerNode* p = parentNode(); p && !p->childNeedsStyleRecalc(); p = p->parentNode()) p->setChildNeedsStyleRecalc(); document().scheduleRenderTreeUpdateIfNeeded(); } @@ -625,47 +586,6 @@ bool Node::contains(const Node* node) const return this == node || node->isDescendantOf(this); } -bool Node::containsIncludingShadowDOM(const Node* node) const -{ - if (!node) - return false; - - if (this == node) - return true; - - if (document() != node->document()) - return false; - - if (inDocument() != node->inDocument()) - return false; - - bool hasChildren = isContainerNode() && toContainerNode(this)->hasChildren(); - bool hasShadow = isElementNode() && toElement(this)->shadow(); - if (!hasChildren && !hasShadow) - return false; - - for (; node; node = node->shadowHost()) { - if (treeScope() == node->treeScope()) - return contains(node); - } - - return false; -} - -bool Node::containsIncludingHostElements(const Node& node) const -{ - const Node* current = &node; - do { - if (current == this) - return true; - if (current->isDocumentFragment() && toDocumentFragment(current)->isTemplateContent()) - current = static_cast(current)->host(); - else - current = current->parentOrShadowHostNode(); - } while (current); - return false; -} - void Node::reattach(const AttachContext& context) { AttachContext reattachContext(context); @@ -764,7 +684,7 @@ Node *Node::nextLeafNode() const RenderStyle* Node::virtualComputedStyle() { - return parentOrShadowHostNode() ? parentOrShadowHostNode()->computedStyle() : 0; + return parentNode() ? parentNode()->computedStyle() : 0; } int Node::maxCharacterOffset() const @@ -780,63 +700,7 @@ bool Node::canStartSelection() const if (hasEditableStyle()) return true; - return parentOrShadowHostNode() ? parentOrShadowHostNode()->canStartSelection() : true; -} - -Element* Node::shadowHost() const -{ - if (ShadowRoot* root = containingShadowRoot()) - return root->host(); - return 0; -} - -ShadowRoot* Node::containingShadowRoot() const -{ - Node& root = treeScope().rootNode(); - return root.isShadowRoot() ? toShadowRoot(&root) : 0; -} - -Node* Node::nonBoundaryShadowTreeRootNode() -{ - ASSERT(!isShadowRoot()); - Node* root = this; - while (root) { - if (root->isShadowRoot()) - return root; - Node* parent = root->parentOrShadowHostNode(); - if (parent && parent->isShadowRoot()) - return root; - root = parent; - } - return 0; -} - -ContainerNode* Node::nonShadowBoundaryParentNode() const -{ - ContainerNode* parent = parentNode(); - return parent && !parent->isShadowRoot() ? parent : 0; -} - -Element* Node::parentOrShadowHostElement() const -{ - ContainerNode* parent = parentOrShadowHostNode(); - if (!parent) - return 0; - - if (parent->isShadowRoot()) - return toShadowRoot(parent)->host(); - - if (!parent->isElementNode()) - return 0; - - return toElement(parent); -} - -ContainerNode* Node::parentOrShadowHostOrTemplateHostNode() const -{ - if (isDocumentFragment() && toDocumentFragment(this)->isTemplateContent()) - return static_cast(this)->host(); - return parentOrShadowHostNode(); + return parentNode() ? parentNode()->canStartSelection() : true; } bool Node::isRootEditableElement() const @@ -872,8 +736,6 @@ ContainerNode* Node::owner() const { if (inDocument()) return &treeScope().rootNode(); - if (ShadowRoot* root = containingShadowRoot()) - return root; return 0; } @@ -926,7 +788,7 @@ bool Node::offsetInCharacters() const return false; } -unsigned short Node::compareDocumentPosition(const Node* otherNode, ShadowTreesTreatment treatment) const +unsigned short Node::compareDocumentPosition(const Node* otherNode) const { // It is not clear what should be done if |otherNode| is 0. if (!otherNode) @@ -951,16 +813,16 @@ unsigned short Node::compareDocumentPosition(const Node* otherNode, ShadowTreesT // If one node is in the document and the other is not, we must be disconnected. // If the nodes have different owning documents, they must be disconnected. Note that we avoid // comparing Attr nodes here, since they return false from inDocument() all the time (which seems like a bug). - if (start1->inDocument() != start2->inDocument() || (treatment == TreatShadowTreesAsDisconnected && start1->treeScope() != start2->treeScope())) { + if (start1->inDocument() != start2->inDocument() || (start1->treeScope() != start2->treeScope())) { unsigned short direction = (this > otherNode) ? DOCUMENT_POSITION_PRECEDING : DOCUMENT_POSITION_FOLLOWING; return DOCUMENT_POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | direction; } // We need to find a common ancestor container, and then compare the indices of the two immediate children. const Node* current; - for (current = start1; current; current = current->parentOrShadowHostNode()) + for (current = start1; current; current = current->parentNode()) chain1.append(current); - for (current = start2; current; current = current->parentOrShadowHostNode()) + for (current = start2; current; current = current->parentNode()) chain2.append(current); unsigned index1 = chain1.size(); @@ -979,16 +841,6 @@ unsigned short Node::compareDocumentPosition(const Node* otherNode, ShadowTreesT const Node* child1 = chain1[--index1]; const Node* child2 = chain2[--index2]; if (child1 != child2) { - // If one of the children is a shadow root, - if (child1->isShadowRoot() || child2->isShadowRoot()) { - if (!child2->isShadowRoot()) - return Node::DOCUMENT_POSITION_FOLLOWING | connection; - if (!child1->isShadowRoot()) - return Node::DOCUMENT_POSITION_PRECEDING | connection; - - return Node::DOCUMENT_POSITION_PRECEDING | connection; - } - if (!child2->nextSibling()) return DOCUMENT_POSITION_FOLLOWING | connection; if (!child1->nextSibling()) @@ -1081,17 +933,12 @@ void Node::showNodePathForThis() const { Vector chain; const Node* node = this; - while (node->parentOrShadowHostNode()) { + while (node->parentNode()) { chain.append(node); - node = node->parentOrShadowHostNode(); + node = node->parentNode(); } for (unsigned index = chain.size(); index > 0; --index) { const Node* node = chain[index - 1]; - if (node->isShadowRoot()) { - fprintf(stderr, "/#shadow-root"); - continue; - } - switch (node->nodeType()) { case ELEMENT_NODE: { fprintf(stderr, "/%s", node->nodeName().utf8().data()); @@ -1133,13 +980,11 @@ static void traverseTreeAndMark(const String& baseIndent, const Node* rootNode, StringBuilder indent; indent.append(baseIndent); - for (const Node* tmpNode = node; tmpNode && tmpNode != rootNode; tmpNode = tmpNode->parentOrShadowHostNode()) + for (const Node* tmpNode = node; tmpNode && tmpNode != rootNode; tmpNode = tmpNode->parentNode()) indent.append('\t'); fprintf(stderr, "%s", indent.toString().utf8().data()); node->showNode(); indent.append('\t'); - if (ShadowRoot* shadowRoot = node->shadowRoot()) - traverseTreeAndMark(indent.toString(), shadowRoot, markedNode1, markedLabel1, markedNode2, markedLabel2); } } @@ -1147,8 +992,8 @@ void Node::showTreeAndMark(const Node* markedNode1, const char* markedLabel1, co { const Node* rootNode; const Node* node = this; - while (node->parentOrShadowHostNode()) - node = node->parentOrShadowHostNode(); + while (node->parentNode()) + node = node->parentNode(); rootNode = node; String startingIndent; @@ -1175,8 +1020,6 @@ static void showSubTreeAcrossFrame(const Node* node, const Node* markedNode, con fputs("*", stderr); fputs(indent.utf8().data(), stderr); node->showNode(); - if (ShadowRoot* shadowRoot = node->shadowRoot()) - showSubTreeAcrossFrame(shadowRoot, markedNode, indent + "\t"); for (Node* child = node->firstChild(); child; child = child->nextSibling()) showSubTreeAcrossFrame(child, markedNode, indent + "\t"); } @@ -1372,17 +1215,6 @@ void Node::removedLastRef() } #endif -Vector> Node::getDestinationInsertionPoints() -{ - document().updateDistributionForNodeIfNeeded(this); - Vector, 8> insertionPoints; - collectDestinationInsertionPoints(*this, insertionPoints); - // FIXME(sky): Is there an easier way to get this into a Vector? - Vector> result(insertionPoints.size()); - copyToVector(insertionPoints, result); - return result; -} - void Node::setFocus(bool flag) { document().userActionElements().setFocused(this, flag); @@ -1422,27 +1254,6 @@ bool Node::isUserActionElementFocused() const return document().userActionElements().isFocused(this); } -void Node::setCustomElementState(CustomElementState newState) -{ - switch (newState) { - case NotCustomElement: - ASSERT_NOT_REACHED(); // Everything starts in this state - return; - - case WaitingForUpgrade: - ASSERT(NotCustomElement == customElementState()); - break; - - case Upgraded: - ASSERT(WaitingForUpgrade == customElementState()); - break; - } - - ASSERT(isElementNode()); - setFlag(CustomElementFlag); - setFlag(newState == Upgraded, CustomElementUpgradedFlag); -} - unsigned Node::lengthOfContents() const { // This switch statement must be consistent with that of Range::processContentsBetweenOffsets. diff --git a/sky/engine/core/dom/Node.h b/sky/engine/core/dom/Node.h index 83c7e2c41bd10..c4d96e2b4f90b 100644 --- a/sky/engine/core/dom/Node.h +++ b/sky/engine/core/dom/Node.h @@ -63,7 +63,6 @@ class RenderBox; class RenderBoxModelObject; class RenderObject; class RenderStyle; -class ShadowRoot; template class StaticNodeTypeList; typedef StaticNodeTypeList StaticNodeList; class Text; @@ -133,6 +132,7 @@ class Node : public DartWrappable, public TreeShared { virtual String nodeName() const = 0; virtual NodeType nodeType() const = 0; ContainerNode* parentNode() const; + void setParentNode(ContainerNode*); Element* parentElement() const; Node* previousSibling() const { return m_previous; } Node* nextSibling() const { return m_next; } @@ -170,20 +170,6 @@ class Node : public DartWrappable, public TreeShared { bool isTextNode() const { return getFlag(IsTextFlag); } bool isHTMLElement() const { return getFlag(IsHTMLFlag); } - bool isCustomElement() const { return getFlag(CustomElementFlag); } - enum CustomElementState { - NotCustomElement = 0, - WaitingForUpgrade = 1 << 0, - Upgraded = 1 << 1 - }; - CustomElementState customElementState() const - { - return isCustomElement() - ? (getFlag(CustomElementUpgradedFlag) ? Upgraded : WaitingForUpgrade) - : NotCustomElement; - } - void setCustomElementState(CustomElementState newState); - // StyledElements allow inline style (style="border: 1px"), presentational attributes (ex. color), // class names (ex. class="foo bar") and other non-basic styling features. They and also control // if this element can participate in style sharing. @@ -197,27 +183,6 @@ class Node : public DartWrappable, public TreeShared { bool isDocumentNode() const; bool isTreeScope() const; bool isDocumentFragment() const { return getFlag(IsDocumentFragmentFlag); } - bool isShadowRoot() const { return isDocumentFragment() && isTreeScope(); } - bool isInsertionPoint() const { return getFlag(IsInsertionPointFlag); } - - // If this node is in a shadow tree, returns its shadow host. Otherwise, returns 0. - Element* shadowHost() const; - ShadowRoot* containingShadowRoot() const; - ShadowRoot* shadowRoot() const; - - // Returns 0, a child of ShadowRoot, or a legacy shadow root. - Node* nonBoundaryShadowTreeRootNode(); - - // Node's parent, shadow tree host. - ContainerNode* parentOrShadowHostNode() const; - Element* parentOrShadowHostElement() const; - void setParentOrShadowHostNode(ContainerNode*); - - // Knows about all kinds of hosts. - ContainerNode* parentOrShadowHostOrTemplateHostNode() const; - - // Returns the parent node, but 0 if the parent node is a ShadowRoot. - ContainerNode* nonShadowBoundaryParentNode() const; // Returns the enclosing event parent Element (or self) that, when clicked, would trigger a navigation. Element* enclosingLinkEventParentOrSelf(); @@ -269,13 +234,6 @@ class Node : public DartWrappable, public TreeShared { void setNeedsStyleRecalc(StyleChangeType); void clearNeedsStyleRecalc(); - bool childNeedsDistributionRecalc() const { return getFlag(ChildNeedsDistributionRecalcFlag); } - void setChildNeedsDistributionRecalc() { setFlag(ChildNeedsDistributionRecalcFlag); } - void clearChildNeedsDistributionRecalc() { clearFlag(ChildNeedsDistributionRecalcFlag); } - void markAncestorsWithChildNeedsDistributionRecalc(); - - void recalcDistribution(); - void setIsLink(bool f); bool isV8CollectableDuringMinorGC() const { return getFlag(V8CollectableDuringMinorGCFlag); } @@ -350,15 +308,12 @@ class Node : public DartWrappable, public TreeShared { { return getFlag(InDocumentFlag); } - bool isInShadowTree() const { return getFlag(IsInShadowTreeFlag); } - bool isInTreeScope() const { return getFlag(static_cast(InDocumentFlag | IsInShadowTreeFlag)); } + bool isInTreeScope() const { return getFlag(static_cast(InDocumentFlag)); } unsigned countChildren() const; bool isDescendantOf(const Node*) const; bool contains(const Node*) const; - bool containsIncludingShadowDOM(const Node*) const; - bool containsIncludingHostElements(const Node&) const; // Used to determine whether range offsets use characters or node indices. virtual bool offsetInCharacters() const; @@ -433,12 +388,7 @@ class Node : public DartWrappable, public TreeShared { void showTreeAndMark(const Node* markedNode1, const char* markedLabel1, const Node* markedNode2 = 0, const char* markedLabel2 = 0) const; #endif - enum ShadowTreesTreatment { - TreatShadowTreesAsDisconnected, - TreatShadowTreesAsComposed - }; - - unsigned short compareDocumentPosition(const Node*, ShadowTreesTreatment = TreatShadowTreesAsDisconnected) const; + unsigned short compareDocumentPosition(const Node*) const; void AcceptDartGCVisitor(DartGCVisitor& visitor) const override; @@ -479,23 +429,18 @@ class Node : public DartWrappable, public TreeShared { // Tree state flags. These change when the element is added/removed // from a DOM tree. InDocumentFlag = 1 << 10, - IsInShadowTreeFlag = 1 << 11, // Flags related to recalcStyle. - // FIXME(sky): Flags 12-16 are free. + // FIXME(sky): Flags 11-17 are free. - ChildNeedsDistributionRecalcFlag = 1 << 17, ChildNeedsStyleRecalcFlag = 1 << 18, StyleChangeMask = 1 << nodeStyleChangeShift | 1 << (nodeStyleChangeShift + 1), - CustomElementFlag = 1 << 21, - CustomElementUpgradedFlag = 1 << 22, - - IsEditingTextFlag = 1 << 23, - HasWeakReferencesFlag = 1 << 24, - V8CollectableDuringMinorGCFlag = 1 << 25, - AlreadySpellCheckedFlag = 1 << 26, + IsEditingTextFlag = 1 << 21, + HasWeakReferencesFlag = 1 << 22, + V8CollectableDuringMinorGCFlag = 1 << 23, + AlreadySpellCheckedFlag = 1 << 24, DefaultNodeFlags = ChildNeedsStyleRecalcFlag | NeedsReattachStyleChange }; @@ -513,7 +458,6 @@ class Node : public DartWrappable, public TreeShared { CreateText = DefaultNodeFlags | IsTextFlag, CreateContainer = DefaultNodeFlags | IsContainerFlag, CreateElement = CreateContainer | IsElementFlag, - CreateShadowRoot = CreateContainer | IsDocumentFragmentFlag | IsInShadowTreeFlag, CreateDocumentFragment = CreateContainer | IsDocumentFragmentFlag, CreateHTMLElement = CreateElement | IsHTMLFlag, CreateDocument = CreateContainer | InDocumentFlag, @@ -536,7 +480,6 @@ class Node : public DartWrappable, public TreeShared { void setTreeScope(TreeScope* scope) { m_treeScope = scope; } // isTreeScopeInitialized() can be false - // - in the destruction of Document or ShadowRoot where m_treeScope is set to null or // - in the Node constructor called by these two classes where m_treeScope is set by TreeScope ctor. bool isTreeScopeInitialized() const { return m_treeScope; } @@ -551,7 +494,7 @@ class Node : public DartWrappable, public TreeShared { #if !ENABLE(OILPAN) void removedLastRef(); #endif - bool hasTreeSharedParent() const { return !!parentOrShadowHostNode(); } + bool hasTreeSharedParent() const { return !!parentNode(); } enum EditableLevel { Editable, RichlyEditable }; bool hasEditableStyle(EditableLevel, UserSelectAllTreatment = UserSelectAllIsAlwaysNonEditable) const; @@ -574,7 +517,7 @@ class Node : public DartWrappable, public TreeShared { HashSet >* transientMutationObserverRegistry(); uint32_t m_nodeFlags; - ContainerNode* m_parentOrShadowHostNode; + ContainerNode* m_parentNode; TreeScope* m_treeScope; Node* m_previous; Node* m_next; @@ -585,22 +528,17 @@ class Node : public DartWrappable, public TreeShared { NodeRareDataBase* m_rareData; } m_data; }; - -inline void Node::setParentOrShadowHostNode(ContainerNode* parent) + +inline void Node::setParentNode(ContainerNode* parent) { ASSERT(isMainThread()); - m_parentOrShadowHostNode = parent; -} - -inline ContainerNode* Node::parentOrShadowHostNode() const -{ - ASSERT(isMainThread()); - return m_parentOrShadowHostNode; + m_parentNode = parent; } inline ContainerNode* Node::parentNode() const { - return isShadowRoot() ? 0 : parentOrShadowHostNode(); + ASSERT(isMainThread()); + return m_parentNode; } inline void Node::lazyReattachIfAttached() diff --git a/sky/engine/core/dom/Node.idl b/sky/engine/core/dom/Node.idl index 3e67baa70fb18..bfdb734b1b59e 100644 --- a/sky/engine/core/dom/Node.idl +++ b/sky/engine/core/dom/Node.idl @@ -14,11 +14,11 @@ interface Node { readonly attribute Element nextElementSibling; readonly attribute Element previousElementSibling; - [CustomElementCallbacks, RaisesException, ImplementedAs=newInsertBefore] void insertBefore(sequence nodes); - [CustomElementCallbacks, RaisesException, ImplementedAs=newInsertAfter] void insertAfter(sequence nodes); - [CustomElementCallbacks, RaisesException] void replaceWith(sequence nodes); + [RaisesException, ImplementedAs=newInsertBefore] void insertBefore(sequence nodes); + [RaisesException, ImplementedAs=newInsertAfter] void insertAfter(sequence nodes); + [RaisesException] void replaceWith(sequence nodes); - [CustomElementCallbacks, RaisesException] void remove(); + [RaisesException] void remove(); [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] attribute DOMString textContent; }; diff --git a/sky/engine/core/dom/NodeRenderStyle.h b/sky/engine/core/dom/NodeRenderStyle.h index e120ae9e467b0..e2f23b0cf4fe8 100644 --- a/sky/engine/core/dom/NodeRenderStyle.h +++ b/sky/engine/core/dom/NodeRenderStyle.h @@ -26,7 +26,6 @@ #define SKY_ENGINE_CORE_DOM_NODERENDERSTYLE_H_ #include "sky/engine/core/dom/Node.h" -#include "sky/engine/core/dom/NodeRenderingTraversal.h" #include "sky/engine/core/rendering/RenderObject.h" #include "sky/engine/core/rendering/style/RenderStyle.h" @@ -41,7 +40,7 @@ inline RenderStyle* Node::renderStyle() const inline RenderStyle* Node::parentRenderStyle() const { - ContainerNode* parent = NodeRenderingTraversal::parent(this); + ContainerNode* parent = parentNode(); return parent ? parent->renderStyle() : 0; } diff --git a/sky/engine/core/dom/NodeRenderingTraversal.cpp b/sky/engine/core/dom/NodeRenderingTraversal.cpp deleted file mode 100644 index 4057ba7e6eca9..0000000000000 --- a/sky/engine/core/dom/NodeRenderingTraversal.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* - * 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. - * * 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 "sky/engine/core/dom/NodeRenderingTraversal.h" - -#include "sky/engine/core/dom/shadow/ComposedTreeWalker.h" -#include "sky/engine/core/rendering/RenderObject.h" - -namespace blink { - -namespace NodeRenderingTraversal { - -void ParentDetails::didTraverseInsertionPoint(const InsertionPoint* insertionPoint) -{ - if (!m_insertionPoint) { - m_insertionPoint = insertionPoint; - } -} - -ContainerNode* parent(const Node* node, ParentDetails* details) -{ - ASSERT(node); - ASSERT(!node->document().childNeedsDistributionRecalc()); - if (isActiveInsertionPoint(*node)) - return 0; - ComposedTreeWalker walker(node, ComposedTreeWalker::CanStartFromShadowBoundary); - return toContainerNode(walker.traverseParent(walker.get(), details)); -} - -bool contains(const ContainerNode* container, const Node* node) -{ - while (node) { - if (node == container) - return true; - node = NodeRenderingTraversal::parent(node); - } - return false; -} - -Node* nextSibling(const Node* node) -{ - ComposedTreeWalker walker(node); - walker.nextSibling(); - return walker.get(); -} - -Node* previousSibling(const Node* node) -{ - ComposedTreeWalker walker(node); - walker.previousSibling(); - return walker.get(); -} - -static Node* lastChild(const Node* node) -{ - ComposedTreeWalker walker(node); - walker.lastChild(); - return walker.get(); -} - -static Node* firstChild(const Node* node) -{ - ComposedTreeWalker walker(node); - walker.firstChild(); - return walker.get(); -} - -Node* previous(const Node* node, const Node* stayWithin) -{ - if (node == stayWithin) - return 0; - - if (Node* previousNode = previousSibling(node)) { - while (Node* previousLastChild = lastChild(previousNode)) - previousNode = previousLastChild; - return previousNode; - } - return parent(node); -} - -Node* next(const Node* node, const Node* stayWithin) -{ - if (Node* child = firstChild(node)) - return child; - if (node == stayWithin) - return 0; - if (Node* nextNode = nextSibling(node)) - return nextNode; - for (Node* parentNode = parent(node); parentNode; parentNode = parent(parentNode)) { - if (parentNode == stayWithin) - return 0; - if (Node* nextNode = nextSibling(parentNode)) - return nextNode; - } - return 0; -} - -RenderObject* nextSiblingRenderer(const Node* node) -{ - for (Node* sibling = NodeRenderingTraversal::nextSibling(node); sibling; sibling = NodeRenderingTraversal::nextSibling(sibling)) { - if (RenderObject* renderer = sibling->renderer()) - return renderer; - } - return 0; -} - -RenderObject* previousSiblingRenderer(const Node* node) -{ - for (Node* sibling = NodeRenderingTraversal::previousSibling(node); sibling; sibling = NodeRenderingTraversal::previousSibling(sibling)) { - if (RenderObject* renderer = sibling->renderer()) - return renderer; - } - return 0; -} - -Node* commonAncestor(Node& a, Node& b) -{ - if (a == b) - return &a; - if (a.document() != b.document()) - return 0; - int thisDepth = 0; - for (Node* node = &a; node; node = parent(node)) { - if (node == b) - return node; - thisDepth++; - } - int otherDepth = 0; - for (const Node* node = &b; node; node = parent(node)) { - if (node == a) - return &a; - otherDepth++; - } - Node* thisIterator = &a; - const Node* otherIterator = &b; - if (thisDepth > otherDepth) { - for (int i = thisDepth; i > otherDepth; --i) - thisIterator = parent(thisIterator); - } else if (otherDepth > thisDepth) { - for (int i = otherDepth; i > thisDepth; --i) - otherIterator = parent(otherIterator); - } - while (thisIterator) { - if (thisIterator == otherIterator) - return thisIterator; - thisIterator = parent(thisIterator); - otherIterator = parent(otherIterator); - } - ASSERT(!otherIterator); - return 0; -} - -} - -} // namespace diff --git a/sky/engine/core/dom/NodeRenderingTraversal.h b/sky/engine/core/dom/NodeRenderingTraversal.h deleted file mode 100644 index f1e0e9b04621d..0000000000000 --- a/sky/engine/core/dom/NodeRenderingTraversal.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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. - * * 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 SKY_ENGINE_CORE_DOM_NODERENDERINGTRAVERSAL_H_ -#define SKY_ENGINE_CORE_DOM_NODERENDERINGTRAVERSAL_H_ - -#include "sky/engine/core/dom/Element.h" - -namespace blink { - -class InsertionPoint; -class RenderObject; - -namespace NodeRenderingTraversal { - -class ParentDetails { -public: - ParentDetails() - : m_insertionPoint(0) - { } - - const InsertionPoint* insertionPoint() const { return m_insertionPoint; } - - void didTraverseInsertionPoint(const InsertionPoint*); - - bool operator==(const ParentDetails& other) - { - return m_insertionPoint == other.m_insertionPoint; - } - -private: - const InsertionPoint* m_insertionPoint; -}; - -ContainerNode* parent(const Node*, ParentDetails* = 0); -bool contains(const ContainerNode*, const Node*); -Node* nextSibling(const Node*); -Node* previousSibling(const Node*); -Node* previous(const Node*, const Node* stayWithin); -Node* next(const Node*, const Node* stayWithin); -Node* commonAncestor(Node&, Node&); -RenderObject* nextSiblingRenderer(const Node*); -RenderObject* previousSiblingRenderer(const Node*); - -inline Element* parentElement(const Node* node) -{ - ContainerNode* found = parent(node); - return found && found->isElementNode() ? toElement(found) : 0; -} - -} - -} // namespace blink - -#endif // SKY_ENGINE_CORE_DOM_NODERENDERINGTRAVERSAL_H_ diff --git a/sky/engine/core/dom/ParentNode.idl b/sky/engine/core/dom/ParentNode.idl index a1f0c753f627a..7ccd0ea5b998b 100644 --- a/sky/engine/core/dom/ParentNode.idl +++ b/sky/engine/core/dom/ParentNode.idl @@ -13,14 +13,14 @@ sequence getChildNodes(); sequence getChildElements(); - [CustomElementCallbacks, RaisesException] void append(sequence nodes); - [CustomElementCallbacks, RaisesException] Node appendChild(Node node); - [CustomElementCallbacks, RaisesException] void prepend(sequence nodes); - [CustomElementCallbacks, RaisesException] Node prependChild(Node node); + [RaisesException] void append(sequence nodes); + [RaisesException] Node appendChild(Node node); + [RaisesException] void prepend(sequence nodes); + [RaisesException] Node prependChild(Node node); - [CustomElementCallbacks] void removeChildren(); - [CustomElementCallbacks, RaisesException] Node setChild(Node node); - [CustomElementCallbacks, RaisesException] void setChildren(sequence nodes); + void removeChildren(); + [RaisesException] Node setChild(Node node); + [RaisesException] void setChildren(sequence nodes); // TODO(abarth): Remove when we have the selector object. [RaisesException] Element querySelector(DOMString selectors); diff --git a/sky/engine/core/dom/Position.cpp b/sky/engine/core/dom/Position.cpp index 289683c133c2f..10ca436fb4e5a 100644 --- a/sky/engine/core/dom/Position.cpp +++ b/sky/engine/core/dom/Position.cpp @@ -417,12 +417,11 @@ Node* Position::parentEditingBoundary() const if (!m_anchorNode) return 0; - // FIXME: Why does this look at parentNode? Node* boundary = m_anchorNode.get(); - while (boundary->nonShadowBoundaryParentNode() - && boundary->nonShadowBoundaryParentNode()->isElementNode() + while (boundary->parentNode() + && boundary->parentNode()->isElementNode() && m_anchorNode->hasEditableStyle() == boundary->parentNode()->hasEditableStyle()) - boundary = boundary->nonShadowBoundaryParentNode(); + boundary = boundary->parentNode(); return boundary; } diff --git a/sky/engine/core/dom/Range.cpp b/sky/engine/core/dom/Range.cpp index d274ed0986ede..033bbe7341041 100644 --- a/sky/engine/core/dom/Range.cpp +++ b/sky/engine/core/dom/Range.cpp @@ -813,7 +813,7 @@ void Range::insertNode(PassRefPtr prpNewNode, ExceptionState& exceptionSta Node::NodeType newNodeType = newNode->nodeType(); int numNewChildren; - if (newNodeType == Node::DOCUMENT_FRAGMENT_NODE && !newNode->isShadowRoot()) { + if (newNodeType == Node::DOCUMENT_FRAGMENT_NODE) { // check each child node, not the DocumentFragment itself numNewChildren = 0; for (Node* c = toDocumentFragment(newNode)->firstChild(); c; c = c->nextSibling()) { @@ -830,16 +830,12 @@ void Range::insertNode(PassRefPtr prpNewNode, ExceptionState& exceptionSta } } - // InvalidNodeTypeError: Raised if newNode is an Attr, Entity, Notation, ShadowRoot or Document node. + // InvalidNodeTypeError: Raised if newNode is an Attr, Entity, Notation, or Document node. switch (newNodeType) { case Node::DOCUMENT_NODE: exceptionState.ThrowDOMException(InvalidNodeTypeError, "The node to be inserted is a '" + newNode->nodeName() + "' node, which may not be inserted here."); return; default: - if (newNode->isShadowRoot()) { - exceptionState.ThrowDOMException(InvalidNodeTypeError, "The node to be inserted is a shadow root, which may not be inserted here."); - return; - } break; } @@ -947,8 +943,8 @@ void Range::checkNodeBA(Node* n, ExceptionState& exceptionState) const } // InvalidNodeTypeError: Raised if the root container of refNode is not an - // Attr, Document, DocumentFragment or ShadowRoot node, or part of a SVG shadow DOM tree, - // or if refNode is a Document, DocumentFragment, ShadowRoot, Attr, Entity, or Notation node. + // Attr, Document, DocumentFragment node, + // or if refNode is a Document, DocumentFragment, Attr, Entity, or Notation node. if (!n->parentNode()) { exceptionState.ThrowDOMException(InvalidNodeTypeError, "the given Node has no parent."); @@ -1025,7 +1021,7 @@ void Range::selectNode(Node* refNode, ExceptionState& exceptionState) } // InvalidNodeTypeError: Raised if an ancestor of refNode is an Entity, Notation or - // DocumentType node or if refNode is a Document, DocumentFragment, ShadowRoot, Attr, Entity, or Notation + // DocumentType node or if refNode is a Document, DocumentFragment, Attr, Entity, or Notation // node. switch (refNode->nodeType()) { case Node::ELEMENT_NODE: @@ -1154,11 +1150,6 @@ Node* Range::firstNode() const return NodeTraversal::nextSkippingChildren(*m_start.container()); } -ShadowRoot* Range::shadowRoot() const -{ - return startContainer() ? startContainer()->containingShadowRoot() : 0; -} - Node* Range::pastLastNode() const { if (m_end.container()->offsetInCharacters()) diff --git a/sky/engine/core/dom/Range.h b/sky/engine/core/dom/Range.h index 81e3c5dc68814..62c722b02a3f7 100644 --- a/sky/engine/core/dom/Range.h +++ b/sky/engine/core/dom/Range.h @@ -106,8 +106,6 @@ class Range final : public RefCounted, public DartWrappable { Node* firstNode() const; Node* pastLastNode() const; - ShadowRoot* shadowRoot() const; - // Not transform-friendly void textRects(Vector&, bool useSelectionHeight = false) const; IntRect boundingBox() const; diff --git a/sky/engine/core/dom/Range.idl b/sky/engine/core/dom/Range.idl index 042f2959c8028..d5bb6a8e06644 100644 --- a/sky/engine/core/dom/Range.idl +++ b/sky/engine/core/dom/Range.idl @@ -49,11 +49,11 @@ // TODO(eseidel): Generate a dart enum for above. // [RaisesException, TypeChecking=Interface] short compareBoundaryPoints(CompareHow how, Range sourceRange); - [RaisesException, CustomElementCallbacks] void deleteContents(); - [RaisesException, CustomElementCallbacks] DocumentFragment extractContents(); - [RaisesException, CustomElementCallbacks] DocumentFragment cloneContents(); - [RaisesException, CustomElementCallbacks] void insertNode(Node newNode); - [RaisesException, CustomElementCallbacks] void surroundContents(Node newParent); + [RaisesException] void deleteContents(); + [RaisesException] DocumentFragment extractContents(); + [RaisesException] DocumentFragment cloneContents(); + [RaisesException] void insertNode(Node newNode); + [RaisesException] void surroundContents(Node newParent); Range cloneRange(); stringifier; diff --git a/sky/engine/core/dom/RenderTreeBuilder.cpp b/sky/engine/core/dom/RenderTreeBuilder.cpp index a6f5a0d952f5c..df74f7531bb5e 100644 --- a/sky/engine/core/dom/RenderTreeBuilder.cpp +++ b/sky/engine/core/dom/RenderTreeBuilder.cpp @@ -28,7 +28,6 @@ #include "sky/engine/core/css/resolver/StyleResolver.h" #include "sky/engine/core/dom/Node.h" #include "sky/engine/core/dom/Text.h" -#include "sky/engine/core/dom/shadow/InsertionPoint.h" #include "sky/engine/core/rendering/RenderObject.h" #include "sky/engine/core/rendering/RenderText.h" #include "sky/engine/core/rendering/RenderView.h" @@ -38,12 +37,17 @@ namespace blink { RenderObject* RenderTreeBuilder::nextRenderer() const { ASSERT(m_renderingParent); + ASSERT(m_node); // Avoid an O(N^2) walk over the children when reattaching all children of a node. if (m_renderingParent->needsAttach()) return 0; - return NodeRenderingTraversal::nextSiblingRenderer(m_node); + for (Node* sibling = m_node->nextSibling(); sibling; sibling = sibling->nextSibling()) { + if (RenderObject* next = sibling->renderer()) + return next; + } + return nullptr; } RenderObject* RenderTreeBuilder::parentRenderer() const @@ -61,8 +65,6 @@ bool RenderTreeBuilder::shouldCreateRenderer() const return false; if (!parentRenderer->canHaveChildren()) return false; - if (isActiveInsertionPoint(*m_node)) - return false; return true; } diff --git a/sky/engine/core/dom/RenderTreeBuilder.h b/sky/engine/core/dom/RenderTreeBuilder.h index 2d980e4e87e38..38630416bde11 100644 --- a/sky/engine/core/dom/RenderTreeBuilder.h +++ b/sky/engine/core/dom/RenderTreeBuilder.h @@ -28,7 +28,6 @@ #include "sky/engine/core/dom/Document.h" #include "sky/engine/core/dom/Node.h" -#include "sky/engine/core/dom/NodeRenderingTraversal.h" #include "sky/engine/wtf/RefPtr.h" namespace blink { @@ -50,7 +49,7 @@ class RenderTreeBuilder { ASSERT(node->document().inStyleRecalc()); ASSERT(node->inActiveDocument()); - m_renderingParent = NodeRenderingTraversal::parent(node, &m_parentDetails); + m_renderingParent = node->parentNode(); } void createRendererForTextIfNeeded(); @@ -64,7 +63,6 @@ class RenderTreeBuilder { RawPtr m_node; RawPtr m_renderingParent; - NodeRenderingTraversal::ParentDetails m_parentDetails; mutable RefPtr m_style; }; diff --git a/sky/engine/core/dom/StyleEngine.cpp b/sky/engine/core/dom/StyleEngine.cpp index 491e4e9504744..c87e2cea84c8b 100644 --- a/sky/engine/core/dom/StyleEngine.cpp +++ b/sky/engine/core/dom/StyleEngine.cpp @@ -35,7 +35,6 @@ #include "sky/engine/core/dom/Document.h" #include "sky/engine/core/dom/Element.h" #include "sky/engine/core/dom/ElementTraversal.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/frame/Settings.h" #include "sky/engine/core/page/Page.h" #include "sky/engine/core/rendering/RenderView.h" @@ -87,8 +86,6 @@ void StyleEngine::resolverChanged() void StyleEngine::updateDocumentFonts() { - // TODO(esprehn): We should really support @font-face in ShadowRoot too. - const auto& sheets = m_document->scopedStyleResolver().authorStyleSheets(); for (const auto& sheet : sheets) { diff --git a/sky/engine/core/dom/TemplateContentDocumentFragment.h b/sky/engine/core/dom/TemplateContentDocumentFragment.h deleted file mode 100644 index 33c1e176630e9..0000000000000 --- a/sky/engine/core/dom/TemplateContentDocumentFragment.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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. - * * 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 SKY_ENGINE_CORE_DOM_TEMPLATECONTENTDOCUMENTFRAGMENT_H_ -#define SKY_ENGINE_CORE_DOM_TEMPLATECONTENTDOCUMENTFRAGMENT_H_ - -#include "sky/engine/core/dom/DocumentFragment.h" - -namespace blink { - -class TemplateContentDocumentFragment final : public DocumentFragment { -public: - static PassRefPtr create(Document& document, Element* host) - { - return adoptRef(new TemplateContentDocumentFragment(document, host)); - } - - Element* host() const { return m_host; } -#if !ENABLE(OILPAN) - void clearHost() { m_host = nullptr; } -#endif - -private: - TemplateContentDocumentFragment(Document& document, Element* host) - : DocumentFragment(&document, CreateDocumentFragment) - , m_host(host) - { - } - - virtual bool isTemplateContent() const override { return true; } - - RawPtr m_host; -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_DOM_TEMPLATECONTENTDOCUMENTFRAGMENT_H_ diff --git a/sky/engine/core/dom/Text.cpp b/sky/engine/core/dom/Text.cpp index 1e124961f4747..68c4b7a56d70c 100644 --- a/sky/engine/core/dom/Text.cpp +++ b/sky/engine/core/dom/Text.cpp @@ -26,10 +26,8 @@ #include "sky/engine/core/css/resolver/StyleResolver.h" #include "sky/engine/core/dom/ExceptionCode.h" #include "sky/engine/core/dom/NodeRenderStyle.h" -#include "sky/engine/core/dom/NodeRenderingTraversal.h" #include "sky/engine/core/dom/NodeTraversal.h" #include "sky/engine/core/dom/RenderTreeBuilder.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/rendering/RenderText.h" #include "sky/engine/wtf/text/CString.h" #include "sky/engine/wtf/text/StringBuilder.h" @@ -113,7 +111,11 @@ bool Text::textRendererIsNeeded(const RenderStyle& style, const RenderObject& pa if (style.preserveNewline()) // pre/pre-wrap/pre-line always make renderers. return true; - const RenderObject* prev = NodeRenderingTraversal::previousSiblingRenderer(this); + RenderObject* prev; + for (Node* sibling = this->previousSibling(); sibling; sibling = sibling->previousSibling()) { + if ((prev = sibling->renderer())) + break; + } if (parent.isRenderInline()) { //
@@ -130,10 +132,23 @@ bool Text::textRendererIsNeeded(const RenderStyle& style, const RenderObject& pa RenderObject* first = parent.slowFirstChild(); while (first && first->isFloatingOrOutOfFlowPositioned() && maxSiblingsToVisit--) first = first->nextSibling(); - if (!first || NodeRenderingTraversal::nextSiblingRenderer(this) == first) - // Whitespace at the start of a block just goes away. Don't even - // make a render object for this text. + + if (!first) { + // If the block has nothing but white-space we ignore it return false; + } + + for (Node* sibling = this->nextSibling(); sibling; sibling = sibling->nextSibling()) { + if (RenderObject* nextRenderer = sibling->renderer()) { + if (nextRenderer == first) { + // Whitespace at the start of a block just goes away. Don't even + // make a render object for this text. + return false; + } + break; + } + } + } return true; } diff --git a/sky/engine/core/dom/Text.idl b/sky/engine/core/dom/Text.idl index f46eaee86dacc..27770d345f2e0 100644 --- a/sky/engine/core/dom/Text.idl +++ b/sky/engine/core/dom/Text.idl @@ -18,5 +18,4 @@ */ interface Text : CharacterData { [RaisesException] Text splitText(unsigned long offset); - sequence getDestinationInsertionPoints(); }; diff --git a/sky/engine/core/dom/TreeScope.cpp b/sky/engine/core/dom/TreeScope.cpp index b7667850839a6..0d51965b9884d 100644 --- a/sky/engine/core/dom/TreeScope.cpp +++ b/sky/engine/core/dom/TreeScope.cpp @@ -34,8 +34,6 @@ #include "sky/engine/core/dom/ElementTraversal.h" #include "sky/engine/core/dom/NodeRenderStyle.h" #include "sky/engine/core/dom/TreeScopeAdopter.h" -#include "sky/engine/core/dom/shadow/ElementShadow.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/frame/FrameView.h" #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/page/FocusController.h" @@ -77,15 +75,6 @@ TreeScope::~TreeScope() m_parentTreeScope->guardDeref(); } -bool TreeScope::isInclusiveOlderSiblingShadowRootOrAncestorTreeScopeOf(const TreeScope& scope) const -{ - for (const TreeScope* current = &scope; current; current = current->parentTreeScope()) { - if (current == this) - return true; - } - return false; -} - bool TreeScope::rootNodeHasTreeSharedParent() const { return rootNode().hasTreeSharedParent(); @@ -139,15 +128,8 @@ void TreeScope::removeElementById(const AtomicString& elementId, Element* elemen Node* TreeScope::ancestorInThisScope(Node* node) const { - while (node) { - if (node->treeScope() == this) - return node; - if (!node->isInShadowTree()) - return 0; - - node = node->shadowHost(); - } - + if (node->treeScope() == this) + return node; return 0; } @@ -178,8 +160,8 @@ Element* TreeScope::elementFromPoint(int x, int y) const if (!node || node->isDocumentNode()) return 0; if (node->isTextNode()) - node = node->parentOrShadowHostNode(); - ASSERT(!node || node->isElementNode() || node->isShadowRoot()); + node = node->parentNode(); + ASSERT(!node || node->isElementNode()); node = ancestorInThisScope(node); if (!node || !node->isElementNode()) return 0; @@ -225,11 +207,6 @@ unsigned short TreeScope::comparePosition(const TreeScope& otherScope) const const TreeScope* child1 = chain1[--index1]; const TreeScope* child2 = chain2[--index2]; if (child1 != child2) { - Node* shadowHost1 = child1->rootNode().parentOrShadowHostNode(); - Node* shadowHost2 = child2->rootNode().parentOrShadowHostNode(); - if (shadowHost1 != shadowHost2) - return shadowHost1->compareDocumentPosition(shadowHost2, Node::TreatShadowTreesAsDisconnected); - return Node::DOCUMENT_POSITION_PRECEDING; } } @@ -267,17 +244,6 @@ TreeScope* TreeScope::commonAncestorTreeScope(TreeScope& other) return const_cast(static_cast(*this).commonAncestorTreeScope(other)); } -static void listTreeScopes(Node* node, Vector& treeScopes) -{ - while (true) { - treeScopes.append(&node->treeScope()); - Element* ancestor = node->shadowHost(); - if (!ancestor) - break; - node = ancestor; - } -} - TreeScope* commonTreeScope(Node* nodeA, Node* nodeB) { if (!nodeA || !nodeB) @@ -286,18 +252,7 @@ TreeScope* commonTreeScope(Node* nodeA, Node* nodeB) if (nodeA->treeScope() == nodeB->treeScope()) return &nodeA->treeScope(); - Vector treeScopesA; - listTreeScopes(nodeA, treeScopesA); - - Vector treeScopesB; - listTreeScopes(nodeB, treeScopesB); - - size_t indexA = treeScopesA.size(); - size_t indexB = treeScopesB.size(); - - for (; indexA > 0 && indexB > 0 && treeScopesA[indexA - 1] == treeScopesB[indexB - 1]; --indexA, --indexB) { } - - return treeScopesA[indexA] == treeScopesB[indexB] ? treeScopesA[indexA] : 0; + return 0; } #if ENABLE(SECURITY_ASSERT) && !ENABLE(OILPAN) @@ -331,8 +286,6 @@ bool TreeScope::isInclusiveAncestorOf(const TreeScope& scope) const void TreeScope::setNeedsStyleRecalcForViewportUnits() { for (Element* element = ElementTraversal::firstWithin(rootNode()); element; element = ElementTraversal::next(*element)) { - if (ShadowRoot* root = element->shadowRoot()) - root->setNeedsStyleRecalcForViewportUnits(); RenderStyle* style = element->renderStyle(); if (style && style->hasViewportUnits()) element->setNeedsStyleRecalc(LocalStyleChange); diff --git a/sky/engine/core/dom/TreeScope.h b/sky/engine/core/dom/TreeScope.h index 672dba9240cd7..32b8fcd33e215 100644 --- a/sky/engine/core/dom/TreeScope.h +++ b/sky/engine/core/dom/TreeScope.h @@ -47,8 +47,6 @@ class TreeScope { public: TreeScope* parentTreeScope() const { return m_parentTreeScope; } - bool isInclusiveOlderSiblingShadowRootOrAncestorTreeScopeOf(const TreeScope&) const; - Element* adjustedFocusedElement() const; Element* getElementById(const AtomicString&) const; void addElementById(const AtomicString& elementId, Element*); diff --git a/sky/engine/core/dom/TreeScopeAdopter.cpp b/sky/engine/core/dom/TreeScopeAdopter.cpp index fc27cd07d9068..83cbfc4a0c994 100644 --- a/sky/engine/core/dom/TreeScopeAdopter.cpp +++ b/sky/engine/core/dom/TreeScopeAdopter.cpp @@ -27,8 +27,6 @@ #include "sky/engine/core/dom/Attr.h" #include "sky/engine/core/dom/Document.h" #include "sky/engine/core/dom/NodeTraversal.h" -#include "sky/engine/core/dom/shadow/ElementShadow.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" namespace blink { @@ -50,12 +48,6 @@ void TreeScopeAdopter::moveTreeToNewScope(Node& root) const if (!node->isElementNode()) continue; - - if (ShadowRoot* shadow = node->shadowRoot()) { - shadow->setParentTreeScope(newScope()); - if (willMoveToNewDocument) - moveTreeToNewDocument(*shadow, oldDocument, newDocument); - } } oldScope().guardDeref(); @@ -66,9 +58,6 @@ void TreeScopeAdopter::moveTreeToNewDocument(Node& root, Document& oldDocument, ASSERT(oldDocument != newDocument); for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) { moveNodeToNewDocument(*node, oldDocument, newDocument); - - if (ShadowRoot* shadow = node->shadowRoot()) - moveTreeToNewDocument(*shadow, oldDocument, newDocument); } } @@ -99,9 +88,6 @@ inline void TreeScopeAdopter::moveNodeToNewDocument(Node& node, Document& oldDoc { ASSERT(oldDocument != newDocument); - if (node.isShadowRoot()) - toShadowRoot(node).setDocument(newDocument); - #if ENABLE(ASSERT) didMoveToNewDocumentWasCalled = false; oldDocumentDidMoveToNewDocumentWasCalledWith = &oldDocument; diff --git a/sky/engine/core/dom/TreeScopeTest.cpp b/sky/engine/core/dom/TreeScopeTest.cpp index 7d5ea553b9134..85c95bfbcb5a8 100644 --- a/sky/engine/core/dom/TreeScopeTest.cpp +++ b/sky/engine/core/dom/TreeScopeTest.cpp @@ -7,7 +7,6 @@ #include #include "sky/engine/core/dom/Document.h" #include "sky/engine/core/dom/Element.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" using namespace blink; @@ -20,71 +19,6 @@ TEST(TreeScopeTest, CommonAncestorOfSameTrees) RefPtr html = document->createElement("html", nullAtom, ASSERT_NO_EXCEPTION); document->appendChild(html, ASSERT_NO_EXCEPTION); - RefPtr shadowRoot = html->ensureShadowRoot(ASSERT_NO_EXCEPTION); - EXPECT_EQ(shadowRoot.get(), shadowRoot->commonAncestorTreeScope(*shadowRoot)); -} - -TEST(TreeScopeTest, CommonAncestorOfInclusiveTrees) -{ - // document - // | : Common ancestor is document. - // shadowRoot - - RefPtr document = Document::create(); - RefPtr html = document->createElement("html", nullAtom, ASSERT_NO_EXCEPTION); - document->appendChild(html, ASSERT_NO_EXCEPTION); - RefPtr shadowRoot = html->ensureShadowRoot(ASSERT_NO_EXCEPTION); - - EXPECT_EQ(document.get(), document->commonAncestorTreeScope(*shadowRoot)); - EXPECT_EQ(document.get(), shadowRoot->commonAncestorTreeScope(*document)); -} - -TEST(TreeScopeTest, CommonAncestorOfSiblingTrees) -{ - // document - // / \ : Common ancestor is document. - // A B - - RefPtr document = Document::create(); - RefPtr html = document->createElement("html", nullAtom, ASSERT_NO_EXCEPTION); - document->appendChild(html, ASSERT_NO_EXCEPTION); - RefPtr head = document->createElement("head", nullAtom, ASSERT_NO_EXCEPTION); - html->appendChild(head); - RefPtr body = document->createElement("body", nullAtom, ASSERT_NO_EXCEPTION); - html->appendChild(body); - - RefPtr shadowRootA = head->ensureShadowRoot(ASSERT_NO_EXCEPTION); - RefPtr shadowRootB = body->ensureShadowRoot(ASSERT_NO_EXCEPTION); - - EXPECT_EQ(document.get(), shadowRootA->commonAncestorTreeScope(*shadowRootB)); - EXPECT_EQ(document.get(), shadowRootB->commonAncestorTreeScope(*shadowRootA)); -} - -TEST(TreeScopeTest, CommonAncestorOfTreesAtDifferentDepths) -{ - // document - // / \ : Common ancestor is document. - // Y B - // / - // A - - RefPtr document = Document::create(); - RefPtr html = document->createElement("html", nullAtom, ASSERT_NO_EXCEPTION); - document->appendChild(html, ASSERT_NO_EXCEPTION); - RefPtr head = document->createElement("head", nullAtom, ASSERT_NO_EXCEPTION); - html->appendChild(head); - RefPtr body = document->createElement("body", nullAtom, ASSERT_NO_EXCEPTION); - html->appendChild(body); - - RefPtr shadowRootY = head->ensureShadowRoot(ASSERT_NO_EXCEPTION); - RefPtr shadowRootB = body->ensureShadowRoot(ASSERT_NO_EXCEPTION); - - RefPtr divInY = document->createElement("div", nullAtom, ASSERT_NO_EXCEPTION); - shadowRootY->appendChild(divInY); - RefPtr shadowRootA = divInY->ensureShadowRoot(ASSERT_NO_EXCEPTION); - - EXPECT_EQ(document.get(), shadowRootA->commonAncestorTreeScope(*shadowRootB)); - EXPECT_EQ(document.get(), shadowRootB->commonAncestorTreeScope(*shadowRootA)); } TEST(TreeScopeTest, CommonAncestorOfTreesInDifferentDocuments) diff --git a/sky/engine/core/dom/custom/custom_element.cc b/sky/engine/core/dom/custom/custom_element.cc deleted file mode 100644 index cad167e7b3988..0000000000000 --- a/sky/engine/core/dom/custom/custom_element.cc +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2015 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. - -#include "sky/engine/core/dom/custom/custom_element.h" - -#include "base/bind.h" -#include "dart/runtime/include/dart_api.h" -#include "sky/engine/core/dom/Document.h" -#include "sky/engine/core/dom/Element.h" -#include "sky/engine/core/dom/Microtask.h" -#include "sky/engine/core/dom/custom/custom_element_callback_scope.h" -#include "sky/engine/core/dom/custom/custom_element_registry.h" -#include "sky/engine/tonic/dart_converter.h" -#include "sky/engine/tonic/dart_invoke.h" -#include "sky/engine/tonic/dart_state.h" -#include "sky/engine/wtf/text/AtomicString.h" - -namespace blink { -namespace { - -void ScheduleCallback(const base::Closure& callback) { - if (auto* scope = CustomElementCallbackScope::Current()) { - scope->Enqueue(callback); - } else { - Microtask::enqueueMicrotask(callback); - } -} - -void CallAttributeDidChangedCallback(RefPtr element, - AtomicString name, - AtomicString oldValue, - AtomicString newValue) { - auto* dart_state = element->document().elementRegistry().dart_state().get(); - if (!dart_state) - return; - DartState::Scope scope(dart_state); - Dart_Handle wrapper = ToDart(element); - Dart_Handle callback = Dart_NewStringFromCString("attributeChangedCallback"); - Dart_Handle args[] = { - StringToDart(dart_state, name), - StringToDart(dart_state, oldValue), - StringToDart(dart_state, newValue), - }; - DartInvokeAppField(wrapper, callback, arraysize(args), args); -} - -void CallDidAttachedCallback(RefPtr element, RefPtr document) { - auto* dart_state = document->elementRegistry().dart_state().get(); - if (!dart_state) - return; - DartState::Scope scope(dart_state); - Dart_Handle wrapper = ToDart(element); - Dart_Handle callback = Dart_NewStringFromCString("attachedCallback"); - LogIfError(Dart_Invoke(wrapper, callback, 0, nullptr)); -} - -void CallDidDetachedCallback(RefPtr element, RefPtr document) { - auto* dart_state = document->elementRegistry().dart_state().get(); - if (!dart_state) - return; - DartState::Scope scope(dart_state); - Dart_Handle wrapper = ToDart(element); - Dart_Handle callback = Dart_NewStringFromCString("detachedCallback"); - LogIfError(Dart_Invoke(wrapper, callback, 0, nullptr)); -} - -} // namespace - -void CustomElement::AttributeDidChange(Element* element, - const AtomicString& name, - const AtomicString& oldValue, - const AtomicString& newValue) { - ScheduleCallback(base::Bind(CallAttributeDidChangedCallback, - element, name, oldValue, newValue)); -} - -void CustomElement::DidAttach(Element* element, Document& document) { - ScheduleCallback(base::Bind(CallDidAttachedCallback, element, &document)); -} - -void CustomElement::DidDetach(Element* element, Document& document) { - ScheduleCallback(base::Bind(CallDidDetachedCallback, element, &document)); -} - -} // namespace blink diff --git a/sky/engine/core/dom/custom/custom_element.h b/sky/engine/core/dom/custom/custom_element.h deleted file mode 100644 index b50fd33072b4d..0000000000000 --- a/sky/engine/core/dom/custom/custom_element.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 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. - -#ifndef SKY_ENGINE_CORE_DOM_CUSTOM_NEW_CUSTOM_ELEMENT_H_ -#define SKY_ENGINE_CORE_DOM_CUSTOM_NEW_CUSTOM_ELEMENT_H_ - -#include "sky/engine/wtf/text/AtomicString.h" - -namespace blink { -class Document; -class Element; - -class CustomElement { - public: - static void AttributeDidChange(Element*, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue); - static void DidAttach(Element*, Document&); - static void DidDetach(Element*, Document&); - - private: - CustomElement(); -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_DOM_CUSTOM_NEW_CUSTOM_ELEMENT_H_ diff --git a/sky/engine/core/dom/custom/custom_element_callback_scope.cc b/sky/engine/core/dom/custom/custom_element_callback_scope.cc deleted file mode 100644 index 660c3cbe0c543..0000000000000 --- a/sky/engine/core/dom/custom/custom_element_callback_scope.cc +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2015 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. - -#include "sky/engine/core/dom/custom/custom_element_callback_scope.h" - -#include "base/callback.h" - -namespace blink { -namespace { -static CustomElementCallbackScope* g_current = nullptr; -} - -CustomElementCallbackScope::CustomElementCallbackScope() - : previous_scope_(g_current) { - g_current = this; -} - -CustomElementCallbackScope::~CustomElementCallbackScope() { - while(!callbacks_.isEmpty()) { - Vector local; - callbacks_.swap(local); - for (const auto& callback : local) - callback.Run(); - } - - g_current = previous_scope_; -} - -CustomElementCallbackScope* CustomElementCallbackScope::Current() { - return g_current; -} - -void CustomElementCallbackScope::Enqueue(const base::Closure& callback) { - callbacks_.append(callback); -} - -} // namespace blink diff --git a/sky/engine/core/dom/custom/custom_element_callback_scope.h b/sky/engine/core/dom/custom/custom_element_callback_scope.h deleted file mode 100644 index 617d628c24aad..0000000000000 --- a/sky/engine/core/dom/custom/custom_element_callback_scope.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 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. - -#ifndef SKY_ENGINE_CORE_DOM_CUSTOM_NEW_CUSTOM_ELEMENT_CALLBACK_SCOPE_H_ -#define SKY_ENGINE_CORE_DOM_CUSTOM_NEW_CUSTOM_ELEMENT_CALLBACK_SCOPE_H_ - -#include "base/callback_forward.h" -#include "sky/engine/wtf/Vector.h" - -namespace blink { - -class CustomElementCallbackScope { - public: - CustomElementCallbackScope(); - ~CustomElementCallbackScope(); - - void Enqueue(const base::Closure&); - - static CustomElementCallbackScope* Current(); - - private: - CustomElementCallbackScope* previous_scope_; - Vector callbacks_; -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_DOM_CUSTOM_NEW_CUSTOM_ELEMENT_CALLBACK_SCOPE_H_ diff --git a/sky/engine/core/dom/custom/custom_element_registry.cc b/sky/engine/core/dom/custom/custom_element_registry.cc deleted file mode 100644 index f215e5421c9d2..0000000000000 --- a/sky/engine/core/dom/custom/custom_element_registry.cc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2015 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. - -#include "sky/engine/core/dom/custom/custom_element_registry.h" - -#include "sky/engine/core/dom/Element.h" -#include "sky/engine/core/html/HTMLElement.h" - -namespace blink { - -CustomElementRegistry::CustomElementRegistry() { -} - -CustomElementRegistry::~CustomElementRegistry() { -} - -void CustomElementRegistry::RegisterElement(const AtomicString& name, - PassRefPtr type) { - if (!dart_state_) - dart_state_ = type->dart_state(); - DCHECK(dart_state_.get() == type->dart_state().get()); - - auto result = registrations_.add(name, type); - if (!result.isNewEntry) { - // TODO(abarth): Handle the case of multiple registrations. - } -} - -PassRefPtr CustomElementRegistry::CreateElement( - Document& document, const AtomicString& name) { - const auto& it = registrations_.find(name); - if (it != registrations_.end()) { - DartState::Scope scope(dart_state_.get()); - Dart_Handle type = it->value->dart_value(); - Dart_Handle wrapper = Dart_New(type, Dart_EmptyString(), 0, nullptr); - if (!LogIfError(wrapper)) { - RefPtr element = DartConverter::FromDart(wrapper); - DCHECK(element); - DCHECK(element->isUpgradedCustomElement()); - return element.release(); - } - } - return HTMLElement::create(QualifiedName(name), document); -} - -} // namespace blink diff --git a/sky/engine/core/dom/custom/custom_element_registry.h b/sky/engine/core/dom/custom/custom_element_registry.h deleted file mode 100644 index c77c4c74c0565..0000000000000 --- a/sky/engine/core/dom/custom/custom_element_registry.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2015 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. - -#ifndef SKY_ENGINE_CORE_DOM_CUSTOM_NEW_CUSTOM_ELEMENT_REGISTRY_H_ -#define SKY_ENGINE_CORE_DOM_CUSTOM_NEW_CUSTOM_ELEMENT_REGISTRY_H_ - -#include "base/macros.h" -#include "base/memory/weak_ptr.h" -#include "sky/engine/core/dom/Element.h" -#include "sky/engine/tonic/dart_state.h" -#include "sky/engine/tonic/dart_value.h" -#include "sky/engine/wtf/HashMap.h" -#include "sky/engine/wtf/PassRefPtr.h" -#include "sky/engine/wtf/RefCounted.h" -#include "sky/engine/wtf/RefPtr.h" -#include "sky/engine/wtf/text/AtomicString.h" - -namespace blink { -class Document; - -class CustomElementRegistry : public RefCounted { - public: - static PassRefPtr Create() { - return adoptRef(new CustomElementRegistry()); - } - - ~CustomElementRegistry(); - - void RegisterElement(const AtomicString& name, PassRefPtr type); - PassRefPtr CreateElement(Document& document, const AtomicString& name); - - const base::WeakPtr& dart_state() const { return dart_state_; } - - private: - CustomElementRegistry(); - - base::WeakPtr dart_state_; - HashMap> registrations_; - - DISALLOW_COPY_AND_ASSIGN(CustomElementRegistry); -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_DOM_CUSTOM_NEW_CUSTOM_ELEMENT_REGISTRY_H_ diff --git a/sky/engine/core/dom/shadow/ComposedTreeWalker.cpp b/sky/engine/core/dom/shadow/ComposedTreeWalker.cpp deleted file mode 100644 index 042b4002c56a9..0000000000000 --- a/sky/engine/core/dom/shadow/ComposedTreeWalker.cpp +++ /dev/null @@ -1,139 +0,0 @@ - -/* - * 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. - * * 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 "sky/engine/core/dom/shadow/ComposedTreeWalker.h" - -#include "sky/engine/core/dom/Element.h" -#include "sky/engine/core/dom/shadow/ElementShadow.h" - -namespace blink { - -static inline ElementShadow* shadowFor(const Node* node) -{ - if (node && node->isElementNode()) - return toElement(node)->shadow(); - return 0; -} - -Node* ComposedTreeWalker::traverseChild(const Node* node, TraversalDirection direction) const -{ - ASSERT(node); - ElementShadow* shadow = shadowFor(node); - return shadow ? traverseLightChildren(shadow->shadowRoot(), direction) - : traverseLightChildren(node, direction); -} - -Node* ComposedTreeWalker::traverseLightChildren(const Node* node, TraversalDirection direction) -{ - ASSERT(node); - return traverseSiblings(direction == TraversalDirectionForward ? node->firstChild() : node->lastChild(), direction); -} - -Node* ComposedTreeWalker::traverseSiblings(const Node* node, TraversalDirection direction) -{ - for (const Node* sibling = node; sibling; sibling = (direction == TraversalDirectionForward ? sibling->nextSibling() : sibling->previousSibling())) { - if (Node* found = traverseNode(sibling, direction)) - return found; - } - return 0; -} - -Node* ComposedTreeWalker::traverseNode(const Node* node, TraversalDirection direction) -{ - ASSERT(node); - if (!isActiveInsertionPoint(*node)) - return const_cast(node); - const InsertionPoint* insertionPoint = toInsertionPoint(node); - if (Node* found = traverseDistributedNodes(direction == TraversalDirectionForward ? insertionPoint->first() : insertionPoint->last(), insertionPoint, direction)) - return found; - ASSERT_NOT_REACHED(); - return 0; -} - -Node* ComposedTreeWalker::traverseDistributedNodes(const Node* node, const InsertionPoint* insertionPoint, TraversalDirection direction) -{ - for (const Node* next = node; next; next = (direction == TraversalDirectionForward ? insertionPoint->nextTo(next) : insertionPoint->previousTo(next))) { - if (Node* found = traverseNode(next, direction)) - return found; - } - return 0; -} - -Node* ComposedTreeWalker::traverseSiblingOrBackToInsertionPoint(const Node* node, TraversalDirection direction) -{ - ASSERT(node); - - if (!shadowWhereNodeCanBeDistributed(*node)) - return traverseSiblingInCurrentTree(node, direction); - - const InsertionPoint* insertionPoint = resolveReprojection(node); - if (!insertionPoint) - return traverseSiblingInCurrentTree(node, direction); - - if (Node* found = traverseDistributedNodes(direction == TraversalDirectionForward ? insertionPoint->nextTo(node) : insertionPoint->previousTo(node), insertionPoint, direction)) - return found; - return traverseSiblingOrBackToInsertionPoint(insertionPoint, direction); -} - -Node* ComposedTreeWalker::traverseSiblingInCurrentTree(const Node* node, TraversalDirection direction) -{ - ASSERT(node); - if (Node* found = traverseSiblings(direction == TraversalDirectionForward ? node->nextSibling() : node->previousSibling(), direction)) - return found; - return 0; -} - -// FIXME: Use an iterative algorithm so that it can be inlined. -// https://bugs.webkit.org/show_bug.cgi?id=90415 -Node* ComposedTreeWalker::traverseParent(const Node* node, ParentTraversalDetails* details) const -{ - if (shadowWhereNodeCanBeDistributed(*node)) { - if (const InsertionPoint* insertionPoint = resolveReprojection(node)) { - if (details) - details->didTraverseInsertionPoint(insertionPoint); - // The node is distributed. But the distribution was stopped at this insertion point. - if (shadowWhereNodeCanBeDistributed(*insertionPoint)) - return 0; - return traverseParentOrHost(insertionPoint); - } - return 0; - } - return traverseParentOrHost(node); -} - -inline Node* ComposedTreeWalker::traverseParentOrHost(const Node* node) const -{ - Node* parent = node->parentNode(); - if (!parent) - return 0; - if (!parent->isShadowRoot()) - return parent; - ShadowRoot* shadowRoot = toShadowRoot(parent); - return shadowRoot->host(); -} - -} // namespace diff --git a/sky/engine/core/dom/shadow/ComposedTreeWalker.h b/sky/engine/core/dom/shadow/ComposedTreeWalker.h deleted file mode 100644 index b5c68a3939762..0000000000000 --- a/sky/engine/core/dom/shadow/ComposedTreeWalker.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - * 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. - * * 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 SKY_ENGINE_CORE_DOM_SHADOW_COMPOSEDTREEWALKER_H_ -#define SKY_ENGINE_CORE_DOM_SHADOW_COMPOSEDTREEWALKER_H_ - -#include "sky/engine/core/dom/NodeRenderingTraversal.h" -#include "sky/engine/core/dom/shadow/InsertionPoint.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" - -namespace blink { - -class Node; - -// FIXME: Make some functions inline to optimise the performance. -// https://bugs.webkit.org/show_bug.cgi?id=82702 -class ComposedTreeWalker { - STACK_ALLOCATED(); -public: - typedef NodeRenderingTraversal::ParentDetails ParentTraversalDetails; - - enum StartPolicy { - CanStartFromShadowBoundary, - CannotStartFromShadowBoundary - }; - - ComposedTreeWalker(const Node*, StartPolicy = CannotStartFromShadowBoundary); - - Node* get() const { return const_cast(m_node.get()); } - - void firstChild(); - void lastChild(); - - void nextSibling(); - void previousSibling(); - - void parent(); - - void next(); - void previous(); - - Node* traverseParent(const Node*, ParentTraversalDetails* = 0) const; - -private: - ComposedTreeWalker(const Node*, ParentTraversalDetails*); - - enum TraversalDirection { - TraversalDirectionForward, - TraversalDirectionBackward - }; - - void assertPrecondition() const - { -#if ENABLE(ASSERT) - ASSERT(m_node); - ASSERT(!m_node->isShadowRoot()); - ASSERT(!isActiveInsertionPoint(*m_node)); -#endif - } - - void assertPostcondition() const - { -#if ENABLE(ASSERT) - if (m_node) - assertPrecondition(); -#endif - } - - static Node* traverseNode(const Node*, TraversalDirection); - static Node* traverseLightChildren(const Node*, TraversalDirection); - - Node* traverseFirstChild(const Node*) const; - Node* traverseLastChild(const Node*) const; - Node* traverseChild(const Node*, TraversalDirection) const; - - static Node* traverseNextSibling(const Node*); - static Node* traversePreviousSibling(const Node*); - - static Node* traverseSiblingOrBackToInsertionPoint(const Node*, TraversalDirection); - static Node* traverseSiblingInCurrentTree(const Node*, TraversalDirection); - - static Node* traverseSiblings(const Node*, TraversalDirection); - static Node* traverseDistributedNodes(const Node*, const InsertionPoint*, TraversalDirection); - - Node* traverseParentOrHost(const Node*) const; - - RawPtr m_node; -}; - -inline ComposedTreeWalker::ComposedTreeWalker(const Node* node, StartPolicy startPolicy) - : m_node(node) -{ -#if ENABLE(ASSERT) - if (m_node && startPolicy == CannotStartFromShadowBoundary) - assertPrecondition(); -#endif -} - -inline void ComposedTreeWalker::parent() -{ - assertPrecondition(); - m_node = traverseParent(m_node); - assertPostcondition(); -} - -inline void ComposedTreeWalker::nextSibling() -{ - assertPrecondition(); - m_node = traverseSiblingOrBackToInsertionPoint(m_node, TraversalDirectionForward); - assertPostcondition(); -} - -inline void ComposedTreeWalker::previousSibling() -{ - assertPrecondition(); - m_node = traverseSiblingOrBackToInsertionPoint(m_node, TraversalDirectionBackward); - assertPostcondition(); -} - -inline void ComposedTreeWalker::next() -{ - assertPrecondition(); - if (Node* next = traverseFirstChild(m_node)) { - m_node = next; - } else { - while (m_node) { - if (Node* sibling = traverseNextSibling(m_node)) { - m_node = sibling; - break; - } - m_node = traverseParent(m_node); - } - } - assertPostcondition(); -} - -inline void ComposedTreeWalker::previous() -{ - assertPrecondition(); - if (Node* previous = traversePreviousSibling(m_node)) { - while (Node* child = traverseLastChild(previous)) - previous = child; - m_node = previous; - } else { - parent(); - } - assertPostcondition(); -} - -inline void ComposedTreeWalker::firstChild() -{ - assertPrecondition(); - m_node = traverseChild(m_node, TraversalDirectionForward); - assertPostcondition(); -} - -inline void ComposedTreeWalker::lastChild() -{ - assertPrecondition(); - m_node = traverseLastChild(m_node); - assertPostcondition(); -} - -inline Node* ComposedTreeWalker::traverseNextSibling(const Node* node) -{ - ASSERT(node); - return traverseSiblingOrBackToInsertionPoint(node, TraversalDirectionForward); -} - -inline Node* ComposedTreeWalker::traversePreviousSibling(const Node* node) -{ - ASSERT(node); - return traverseSiblingOrBackToInsertionPoint(node, TraversalDirectionBackward); -} - -inline Node* ComposedTreeWalker::traverseFirstChild(const Node* node) const -{ - ASSERT(node); - return traverseChild(node, TraversalDirectionForward); -} - -inline Node* ComposedTreeWalker::traverseLastChild(const Node* node) const -{ - ASSERT(node); - return traverseChild(node, TraversalDirectionBackward); -} - -} // namespace - -#endif // SKY_ENGINE_CORE_DOM_SHADOW_COMPOSEDTREEWALKER_H_ diff --git a/sky/engine/core/dom/shadow/ContentDistribution.cpp b/sky/engine/core/dom/shadow/ContentDistribution.cpp deleted file mode 100644 index bb67dd63958cb..0000000000000 --- a/sky/engine/core/dom/shadow/ContentDistribution.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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. - * * 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 "sky/engine/core/dom/shadow/ContentDistribution.h" - -#include "sky/engine/core/dom/shadow/InsertionPoint.h" - -namespace blink { - -void ContentDistribution::swap(ContentDistribution& other) -{ - m_nodes.swap(other.m_nodes); - m_indices.swap(other.m_indices); -} - -void ContentDistribution::append(PassRefPtr node) -{ - ASSERT(node); - ASSERT(!isActiveInsertionPoint(*node)); - size_t size = m_nodes.size(); - m_indices.set(node.get(), size); - m_nodes.append(node); -} - -size_t ContentDistribution::find(const Node* node) const -{ - HashMap, size_t>::const_iterator it = m_indices.find(node); - if (it == m_indices.end()) - return kNotFound; - - return it.get()->value; -} - -Node* ContentDistribution::nextTo(const Node* node) const -{ - size_t index = find(node); - if (index == kNotFound || index + 1 == size()) - return 0; - return at(index + 1).get(); -} - -Node* ContentDistribution::previousTo(const Node* node) const -{ - size_t index = find(node); - if (index == kNotFound || !index) - return 0; - return at(index - 1).get(); -} - -} // namespace blink diff --git a/sky/engine/core/dom/shadow/ContentDistribution.h b/sky/engine/core/dom/shadow/ContentDistribution.h deleted file mode 100644 index 4f86bb11e190c..0000000000000 --- a/sky/engine/core/dom/shadow/ContentDistribution.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 SKY_ENGINE_CORE_DOM_SHADOW_CONTENTDISTRIBUTION_H_ -#define SKY_ENGINE_CORE_DOM_SHADOW_CONTENTDISTRIBUTION_H_ - -#include "sky/engine/core/dom/Node.h" -#include "sky/engine/wtf/HashMap.h" -#include "sky/engine/wtf/Vector.h" - -namespace blink { - -class ContentDistribution final { - DISALLOW_ALLOCATION(); -public: - ContentDistribution() { m_nodes.reserveInitialCapacity(32); } - - PassRefPtr first() const { return m_nodes.first(); } - PassRefPtr last() const { return m_nodes.last(); } - PassRefPtr at(size_t index) const { return m_nodes.at(index); } - - size_t size() const { return m_nodes.size(); } - bool isEmpty() const { return m_nodes.isEmpty(); } - - void append(PassRefPtr); - void clear() { m_nodes.clear(); m_indices.clear(); } - void shrinkToFit() { m_nodes.shrinkToFit(); } - - bool contains(const Node* node) const { return m_indices.contains(node); } - size_t find(const Node*) const; - Node* nextTo(const Node*) const; - Node* previousTo(const Node*) const; - - void swap(ContentDistribution& other); - - const Vector >& nodes() const { return m_nodes; } - -private: - Vector > m_nodes; - HashMap, size_t> m_indices; -}; - -} - -#endif // SKY_ENGINE_CORE_DOM_SHADOW_CONTENTDISTRIBUTION_H_ diff --git a/sky/engine/core/dom/shadow/ElementShadow.cpp b/sky/engine/core/dom/shadow/ElementShadow.cpp deleted file mode 100644 index ba20801fa53e8..0000000000000 --- a/sky/engine/core/dom/shadow/ElementShadow.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/* - * 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. - * * 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 "sky/engine/core/dom/shadow/ElementShadow.h" - -#include "sky/engine/core/dom/Document.h" -#include "sky/engine/core/dom/ElementTraversal.h" -#include "sky/engine/core/dom/NodeTraversal.h" -#include "sky/engine/core/dom/shadow/ContentDistribution.h" -#include "sky/engine/platform/EventDispatchForbiddenScope.h" -#include "sky/engine/platform/ScriptForbiddenScope.h" - -namespace blink { - -class DistributionPool final { - STACK_ALLOCATED(); -public: - explicit DistributionPool(const ContainerNode&); - void clear(); - ~DistributionPool(); - void distributeTo(InsertionPoint*, ElementShadow*); - void populateChildren(const ContainerNode&); - -private: - void detachNonDistributedNodes(); - Vector, 32> m_nodes; - Vector m_distributed; -}; - -inline DistributionPool::DistributionPool(const ContainerNode& parent) -{ - populateChildren(parent); -} - -inline void DistributionPool::clear() -{ - detachNonDistributedNodes(); - m_nodes.clear(); - m_distributed.clear(); -} - -inline void DistributionPool::populateChildren(const ContainerNode& parent) -{ - clear(); - for (Node* child = parent.firstChild(); child; child = child->nextSibling()) { - if (isActiveInsertionPoint(*child)) { - InsertionPoint* insertionPoint = toInsertionPoint(child); - for (size_t i = 0; i < insertionPoint->size(); ++i) - m_nodes.append(insertionPoint->at(i)); - } else { - m_nodes.append(child); - } - } - m_distributed.resize(m_nodes.size()); - m_distributed.fill(false); -} - -void DistributionPool::distributeTo(InsertionPoint* insertionPoint, ElementShadow* elementShadow) -{ - ContentDistribution distribution; - - for (size_t i = 0; i < m_nodes.size(); ++i) { - if (m_distributed[i]) - continue; - - Node* node = m_nodes[i]; - distribution.append(node); - elementShadow->didDistributeNode(node, insertionPoint); - m_distributed[i] = true; - } - - // Distributes fallback elements - if (insertionPoint->isContentInsertionPoint() && distribution.isEmpty()) { - for (Node* fallbackNode = insertionPoint->firstChild(); fallbackNode; fallbackNode = fallbackNode->nextSibling()) { - distribution.append(fallbackNode); - elementShadow->didDistributeNode(fallbackNode, insertionPoint); - } - } - insertionPoint->setDistribution(distribution); -} - -inline DistributionPool::~DistributionPool() -{ - detachNonDistributedNodes(); -} - -inline void DistributionPool::detachNonDistributedNodes() -{ - for (size_t i = 0; i < m_nodes.size(); ++i) { - if (m_distributed[i]) - continue; - if (m_nodes[i]->renderer()) - m_nodes[i]->lazyReattachIfAttached(); - } -} - -PassOwnPtr ElementShadow::create() -{ - return adoptPtr(new ElementShadow()); -} - -ElementShadow::ElementShadow() - : m_shadowRoot(0) - , m_needsDistributionRecalc(false) - , m_needsSelectFeatureSet(false) -{ -} - -ElementShadow::~ElementShadow() -{ - removeDetachedShadowRoot(); -} - -ShadowRoot& ElementShadow::addShadowRoot(Element& shadowHost) -{ - EventDispatchForbiddenScope assertNoEventDispatch; - ScriptForbiddenScope forbidScript; - - ASSERT(!m_shadowRoot); - - RefPtr shadowRoot = ShadowRoot::create(shadowHost.document()); - shadowRoot->setParentOrShadowHostNode(&shadowHost); - shadowRoot->setParentTreeScope(shadowHost.treeScope()); - m_shadowRoot = shadowRoot.get(); - - setNeedsDistributionRecalc(); - - shadowRoot->insertedInto(&shadowHost); - - return *shadowRoot; -} - -void ElementShadow::removeDetachedShadowRoot() -{ - // Dont protect this ref count. - Element* shadowHost = host(); - ASSERT(shadowHost); - - if (RefPtr oldRoot = m_shadowRoot) { - shadowHost->document().removeFocusedElementOfSubtree(oldRoot.get()); - m_shadowRoot = 0; - oldRoot->setParentOrShadowHostNode(0); - oldRoot->setParentTreeScope(shadowHost->document()); - } -} - -void ElementShadow::attach(const Node::AttachContext& context) -{ - if (!m_shadowRoot) - return; - - ASSERT(m_shadowRoot->needsAttach()); - - Node::AttachContext childrenContext(context); - childrenContext.resolvedStyle = 0; - m_shadowRoot->attach(childrenContext); -} - -void ElementShadow::detach(const Node::AttachContext& context) -{ - if (!m_shadowRoot) - return; - - Node::AttachContext childrenContext(context); - childrenContext.resolvedStyle = 0; - m_shadowRoot->detach(childrenContext); -} - -void ElementShadow::setNeedsDistributionRecalc() -{ - if (m_needsDistributionRecalc) - return; - m_needsDistributionRecalc = true; - host()->markAncestorsWithChildNeedsDistributionRecalc(); - clearDistribution(); -} - -bool ElementShadow::hasSameStyles(const ElementShadow* other) const -{ - ShadowRoot* root = m_shadowRoot; - ShadowRoot* otherRoot = other->shadowRoot(); - if (!root && !otherRoot) - return true; - if (root && otherRoot) - return root->hasSameStyles(*otherRoot); - return false; -} - -const InsertionPoint* ElementShadow::finalDestinationInsertionPointFor(const Node* key) const -{ - ASSERT(key && !key->document().childNeedsDistributionRecalc()); - NodeToDestinationInsertionPoints::const_iterator it = m_nodeToInsertionPoints.find(key); - return it == m_nodeToInsertionPoints.end() ? 0: it->value.last().get(); -} - -const DestinationInsertionPoints* ElementShadow::destinationInsertionPointsFor(const Node* key) const -{ - ASSERT(key && !key->document().childNeedsDistributionRecalc()); - NodeToDestinationInsertionPoints::const_iterator it = m_nodeToInsertionPoints.find(key); - return it == m_nodeToInsertionPoints.end() ? 0: &it->value; -} - -void ElementShadow::distribute() -{ - host()->setNeedsStyleRecalc(SubtreeStyleChange); - DistributionPool pool(*host()); - - if (ShadowRoot* root = shadowRoot()) { - const Vector >& insertionPoints = root->descendantInsertionPoints(); - for (size_t i = 0; i < insertionPoints.size(); ++i) { - InsertionPoint* point = insertionPoints[i].get(); - if (!point->isActive()) - continue; - pool.distributeTo(point, this); - if (ElementShadow* shadow = shadowWhereNodeCanBeDistributed(*point)) - shadow->setNeedsDistributionRecalc(); - } - } -} - -void ElementShadow::didDistributeNode(const Node* node, InsertionPoint* insertionPoint) -{ - NodeToDestinationInsertionPoints::AddResult result = m_nodeToInsertionPoints.add(node, DestinationInsertionPoints()); - result.storedValue->value.append(insertionPoint); -} - -const SelectRuleFeatureSet& ElementShadow::ensureSelectFeatureSet() -{ - if (!m_needsSelectFeatureSet) - return m_selectFeatures; - - m_selectFeatures.clear(); - if (ShadowRoot* root = shadowRoot()) - collectSelectFeatureSetFrom(*root); - m_needsSelectFeatureSet = false; - return m_selectFeatures; -} - -void ElementShadow::collectSelectFeatureSetFrom(ShadowRoot& root) -{ - if (!root.containsShadowRoots() && !root.containsContentElements()) - return; - - for (Element* element = ElementTraversal::firstWithin(root); element; element = ElementTraversal::next(*element, &root)) { - if (ElementShadow* shadow = element->shadow()) - m_selectFeatures.add(shadow->ensureSelectFeatureSet()); - } -} - -void ElementShadow::willAffectSelector() -{ - for (ElementShadow* shadow = this; shadow; shadow = shadow->containingShadow()) { - if (shadow->needsSelectFeatureSet()) - break; - shadow->setNeedsSelectFeatureSet(); - } - setNeedsDistributionRecalc(); -} - -void ElementShadow::clearDistribution() -{ - m_nodeToInsertionPoints.clear(); -} - -} // namespace diff --git a/sky/engine/core/dom/shadow/ElementShadow.h b/sky/engine/core/dom/shadow/ElementShadow.h deleted file mode 100644 index 0f8f846f5f05f..0000000000000 --- a/sky/engine/core/dom/shadow/ElementShadow.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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. - * * 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 SKY_ENGINE_CORE_DOM_SHADOW_ELEMENTSHADOW_H_ -#define SKY_ENGINE_CORE_DOM_SHADOW_ELEMENTSHADOW_H_ - -#include "sky/engine/core/dom/shadow/InsertionPoint.h" -#include "sky/engine/core/dom/shadow/SelectRuleFeatureSet.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" -#include "sky/engine/platform/heap/Handle.h" -#include "sky/engine/wtf/HashMap.h" -#include "sky/engine/wtf/Noncopyable.h" -#include "sky/engine/wtf/PassOwnPtr.h" - -namespace blink { - -class ElementShadow final { - WTF_MAKE_NONCOPYABLE(ElementShadow); - WTF_MAKE_FAST_ALLOCATED; -public: - static PassOwnPtr create(); - ~ElementShadow(); - - Element* host() const; - ShadowRoot* shadowRoot() const { return m_shadowRoot; } - ElementShadow* containingShadow() const; - - ShadowRoot& addShadowRoot(Element& shadowHost); - - bool hasSameStyles(const ElementShadow*) const; - - void attach(const Node::AttachContext&); - void detach(const Node::AttachContext&); - - void willAffectSelector(); - const SelectRuleFeatureSet& ensureSelectFeatureSet(); - - void distributeIfNeeded(); - void setNeedsDistributionRecalc(); - - const InsertionPoint* finalDestinationInsertionPointFor(const Node*) const; - const DestinationInsertionPoints* destinationInsertionPointsFor(const Node*) const; - - void didDistributeNode(const Node*, InsertionPoint*); - -private: - ElementShadow(); - - void removeDetachedShadowRoot(); - - void distribute(); - void clearDistribution(); - - void collectSelectFeatureSetFrom(ShadowRoot&); - void distributeNodeChildrenTo(InsertionPoint*, ContainerNode*); - - bool needsSelectFeatureSet() const { return m_needsSelectFeatureSet; } - void setNeedsSelectFeatureSet() { m_needsSelectFeatureSet = true; } - - typedef HashMap, DestinationInsertionPoints> NodeToDestinationInsertionPoints; - NodeToDestinationInsertionPoints m_nodeToInsertionPoints; - - SelectRuleFeatureSet m_selectFeatures; - ShadowRoot* m_shadowRoot; - bool m_needsDistributionRecalc; - bool m_needsSelectFeatureSet; -}; - -inline Element* ElementShadow::host() const -{ - ASSERT(m_shadowRoot); - return m_shadowRoot->host(); -} - -inline ElementShadow* ElementShadow::containingShadow() const -{ - if (ShadowRoot* parentRoot = host()->containingShadowRoot()) - return parentRoot->owner(); - return 0; -} - -inline void ElementShadow::distributeIfNeeded() -{ - if (m_needsDistributionRecalc) - distribute(); - m_needsDistributionRecalc = false; -} - -} // namespace - -#endif // SKY_ENGINE_CORE_DOM_SHADOW_ELEMENTSHADOW_H_ diff --git a/sky/engine/core/dom/shadow/InsertionPoint.cpp b/sky/engine/core/dom/shadow/InsertionPoint.cpp deleted file mode 100644 index b8301fb808b14..0000000000000 --- a/sky/engine/core/dom/shadow/InsertionPoint.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/* - * 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 "sky/engine/core/dom/shadow/InsertionPoint.h" - -#include "sky/engine/core/dom/Document.h" -#include "sky/engine/core/dom/ElementTraversal.h" -#include "sky/engine/core/dom/QualifiedName.h" -#include "sky/engine/core/dom/StaticNodeList.h" -#include "sky/engine/core/dom/shadow/ElementShadow.h" - -namespace blink { - -InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document& document) - : HTMLElement(tagName, document, CreateInsertionPoint) - , m_registeredWithShadowRoot(false) -{ -} - -InsertionPoint::~InsertionPoint() -{ -} - -void InsertionPoint::setDistribution(ContentDistribution& distribution) -{ - if (shouldUseFallbackElements()) { - for (Node* child = firstChild(); child; child = child->nextSibling()) - child->lazyReattachIfAttached(); - } - - // Attempt not to reattach nodes that would be distributed to the exact same - // location by comparing the old and new distributions. - - size_t i = 0; - size_t j = 0; - - for ( ; i < m_distribution.size() && j < distribution.size(); ++i, ++j) { - if (m_distribution.size() < distribution.size()) { - // If the new distribution is larger than the old one, reattach all nodes in - // the new distribution that were inserted. - for ( ; j < distribution.size() && m_distribution.at(i) != distribution.at(j); ++j) - distribution.at(j)->lazyReattachIfAttached(); - } else if (m_distribution.size() > distribution.size()) { - // If the old distribution is larger than the new one, reattach all nodes in - // the old distribution that were removed. - for ( ; i < m_distribution.size() && m_distribution.at(i) != distribution.at(j); ++i) - m_distribution.at(i)->lazyReattachIfAttached(); - } else if (m_distribution.at(i) != distribution.at(j)) { - // If both distributions are the same length reattach both old and new. - m_distribution.at(i)->lazyReattachIfAttached(); - distribution.at(j)->lazyReattachIfAttached(); - } - } - - // If we hit the end of either list above we need to reattach all remaining nodes. - - for ( ; i < m_distribution.size(); ++i) - m_distribution.at(i)->lazyReattachIfAttached(); - - for ( ; j < distribution.size(); ++j) - distribution.at(j)->lazyReattachIfAttached(); - - m_distribution.swap(distribution); - m_distribution.shrinkToFit(); -} - -void InsertionPoint::attachDistribution(const AttachContext& context) -{ - // We need to attach the distribution here so that they're inserted in the right order - // otherwise the n^2 protection inside RenderTreeBuilder will cause them to be - // inserted in the wrong place later. This also lets distributed nodes benefit from - // the n^2 protection. - for (size_t i = 0; i < m_distribution.size(); ++i) { - if (m_distribution.at(i)->needsAttach()) - m_distribution.at(i)->attach(context); - } -} - -void InsertionPoint::detachDistribution(const AttachContext& context) -{ - for (size_t i = 0; i < m_distribution.size(); ++i) - m_distribution.at(i)->lazyReattachIfAttached(); -} - -void InsertionPoint::willRecalcStyle(StyleRecalcChange change) -{ - if (change < Inherit) - return; - for (size_t i = 0; i < m_distribution.size(); ++i) - m_distribution.at(i)->setNeedsStyleRecalc(SubtreeStyleChange); -} - -bool InsertionPoint::shouldUseFallbackElements() const -{ - return isActive() && !hasDistribution(); -} - -bool InsertionPoint::canBeActive() const -{ - if (!isInShadowTree()) - return false; - return !Traversal::firstAncestor(*this); -} - -bool InsertionPoint::isActive() const -{ - // FIXME(sky): Remove this. - return canBeActive(); -} - -bool InsertionPoint::isContentInsertionPoint() const -{ - return false; -} - -Vector> InsertionPoint::getDistributedNodes() -{ - document().updateDistributionForNodeIfNeeded(this); - - Vector > result; - result.reserveInitialCapacity(m_distribution.size()); - for (size_t i = 0; i < m_distribution.size(); ++i) - result.uncheckedAppend(m_distribution.at(i)); - return result; -} - -void InsertionPoint::childrenChanged(const ChildrenChange& change) -{ - HTMLElement::childrenChanged(change); - if (ShadowRoot* root = containingShadowRoot()) { - if (ElementShadow* rootOwner = root->owner()) - rootOwner->setNeedsDistributionRecalc(); - } -} - -void InsertionPoint::insertedInto(ContainerNode* insertionPoint) -{ - HTMLElement::insertedInto(insertionPoint); - if (ShadowRoot* root = containingShadowRoot()) { - if (ElementShadow* rootOwner = root->owner()) { - rootOwner->setNeedsDistributionRecalc(); - if (canBeActive() && !m_registeredWithShadowRoot && insertionPoint->treeScope().rootNode() == root) { - m_registeredWithShadowRoot = true; - root->didAddInsertionPoint(); - if (canAffectSelector()) - rootOwner->willAffectSelector(); - } - } - } -} - -void InsertionPoint::removedFrom(ContainerNode* insertionPoint) -{ - ShadowRoot* root = containingShadowRoot(); - if (!root) - root = insertionPoint->containingShadowRoot(); - - if (root) { - if (ElementShadow* rootOwner = root->owner()) - rootOwner->setNeedsDistributionRecalc(); - } - - // host can be null when removedFrom() is called from ElementShadow destructor. - ElementShadow* rootOwner = root ? root->owner() : 0; - - // Since this insertion point is no longer visible from the shadow subtree, it need to clean itself up. - clearDistribution(); - - if (m_registeredWithShadowRoot && insertionPoint->treeScope().rootNode() == root) { - ASSERT(root); - m_registeredWithShadowRoot = false; - root->didRemoveInsertionPoint(); - if (rootOwner) { - if (canAffectSelector()) - rootOwner->willAffectSelector(); - } - } - - HTMLElement::removedFrom(insertionPoint); -} - -const InsertionPoint* resolveReprojection(const Node* projectedNode) -{ - ASSERT(projectedNode); - const InsertionPoint* insertionPoint = 0; - const Node* current = projectedNode; - ElementShadow* lastElementShadow = 0; - while (true) { - ElementShadow* shadow = shadowWhereNodeCanBeDistributed(*current); - if (!shadow || shadow == lastElementShadow) - break; - lastElementShadow = shadow; - const InsertionPoint* insertedTo = shadow->finalDestinationInsertionPointFor(projectedNode); - if (!insertedTo) - break; - ASSERT(current != insertedTo); - current = insertedTo; - insertionPoint = insertedTo; - } - return insertionPoint; -} - -void collectDestinationInsertionPoints(const Node& node, Vector, 8>& results) -{ - const Node* current = &node; - ElementShadow* lastElementShadow = 0; - while (true) { - ElementShadow* shadow = shadowWhereNodeCanBeDistributed(*current); - if (!shadow || shadow == lastElementShadow) - return; - lastElementShadow = shadow; - const DestinationInsertionPoints* insertionPoints = shadow->destinationInsertionPointsFor(&node); - if (!insertionPoints) - return; - for (size_t i = 0; i < insertionPoints->size(); ++i) - results.append(insertionPoints->at(i).get()); - ASSERT(current != insertionPoints->last().get()); - current = insertionPoints->last().get(); - } -} - -} // namespace blink diff --git a/sky/engine/core/dom/shadow/InsertionPoint.h b/sky/engine/core/dom/shadow/InsertionPoint.h deleted file mode 100644 index ec1c4140d551d..0000000000000 --- a/sky/engine/core/dom/shadow/InsertionPoint.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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. - */ - -#ifndef SKY_ENGINE_CORE_DOM_SHADOW_INSERTIONPOINT_H_ -#define SKY_ENGINE_CORE_DOM_SHADOW_INSERTIONPOINT_H_ - -#include "sky/engine/core/css/CSSSelectorList.h" -#include "sky/engine/core/dom/shadow/ContentDistribution.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" -#include "sky/engine/core/html/HTMLElement.h" - -namespace blink { - -class InsertionPoint : public HTMLElement { -public: - virtual ~InsertionPoint(); - - bool hasDistribution() const { return !m_distribution.isEmpty(); } - void setDistribution(ContentDistribution&); - void clearDistribution() { m_distribution.clear(); } - bool isActive() const; - bool canBeActive() const; - - bool isContentInsertionPoint() const; - - Vector> getDistributedNodes(); - - virtual bool canAffectSelector() const { return false; } - - void attachDistribution(const AttachContext&); - void detachDistribution(const AttachContext&); - - bool shouldUseFallbackElements() const; - - size_t size() const { return m_distribution.size(); } - Node* at(size_t index) const { return m_distribution.at(index).get(); } - Node* first() const { return m_distribution.isEmpty() ? 0 : m_distribution.first().get(); } - Node* last() const { return m_distribution.isEmpty() ? 0 : m_distribution.last().get(); } - Node* nextTo(const Node* node) const { return m_distribution.nextTo(node); } - Node* previousTo(const Node* node) const { return m_distribution.previousTo(node); } - - void willRecalcStyle(StyleRecalcChange); - -protected: - InsertionPoint(const QualifiedName&, Document&); - virtual void childrenChanged(const ChildrenChange&) override; - virtual void insertedInto(ContainerNode*) override; - virtual void removedFrom(ContainerNode*) override; - -private: - bool isInsertionPoint() const = delete; // This will catch anyone doing an unnecessary check. - - ContentDistribution m_distribution; - bool m_registeredWithShadowRoot; -}; - -typedef Vector > DestinationInsertionPoints; - -DEFINE_ELEMENT_TYPE_CASTS(InsertionPoint, isInsertionPoint()); - -inline bool isActiveInsertionPoint(const Node& node) -{ - return node.isInsertionPoint() && toInsertionPoint(node).isActive(); -} - -inline ElementShadow* shadowWhereNodeCanBeDistributed(const Node& node) -{ - Node* parent = node.parentNode(); - if (!parent) - return 0; - if (isActiveInsertionPoint(*parent)) - return node.shadowHost()->shadow(); - if (parent->isElementNode()) - return toElement(parent)->shadow(); - return 0; -} - -const InsertionPoint* resolveReprojection(const Node*); - -void collectDestinationInsertionPoints(const Node&, Vector, 8>& results); - -} // namespace blink - -#endif // SKY_ENGINE_CORE_DOM_SHADOW_INSERTIONPOINT_H_ diff --git a/sky/engine/core/dom/shadow/SelectRuleFeatureSet.cpp b/sky/engine/core/dom/shadow/SelectRuleFeatureSet.cpp deleted file mode 100644 index 021b00ae88f25..0000000000000 --- a/sky/engine/core/dom/shadow/SelectRuleFeatureSet.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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 "sky/engine/core/dom/shadow/SelectRuleFeatureSet.h" - -#include "sky/engine/core/css/CSSSelector.h" - -#include "sky/engine/wtf/BitVector.h" - -namespace blink { - -SelectRuleFeatureSet::SelectRuleFeatureSet() -{ -} - -void SelectRuleFeatureSet::add(const SelectRuleFeatureSet& featureSet) -{ - m_cssRuleFeatureSet.add(featureSet.m_cssRuleFeatureSet); -} - -void SelectRuleFeatureSet::clear() -{ - m_cssRuleFeatureSet.clear(); -} - -void SelectRuleFeatureSet::collectFeaturesFromSelector(const CSSSelector& selector) -{ - m_cssRuleFeatureSet.collectFeaturesFromSelector(selector); -} - -bool SelectRuleFeatureSet::checkSelectorsForClassChange(const SpaceSplitString& changedClasses) const -{ - unsigned changedSize = changedClasses.size(); - for (unsigned i = 0; i < changedSize; ++i) { - if (hasSelectorForClass(changedClasses[i])) - return true; - } - return false; -} - -bool SelectRuleFeatureSet::checkSelectorsForClassChange(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses) const -{ - if (!oldClasses.size()) - return checkSelectorsForClassChange(newClasses); - - // Class vectors tend to be very short. This is faster than using a hash table. - BitVector remainingClassBits; - remainingClassBits.ensureSize(oldClasses.size()); - - for (unsigned i = 0; i < newClasses.size(); ++i) { - bool found = false; - for (unsigned j = 0; j < oldClasses.size(); ++j) { - if (newClasses[i] == oldClasses[j]) { - // Mark each class that is still in the newClasses so we can skip doing - // an n^2 search below when looking for removals. We can't break from - // this loop early since a class can appear more than once. - remainingClassBits.quickSet(j); - found = true; - } - } - // Class was added. - if (!found) { - if (hasSelectorForClass(newClasses[i])) - return true; - } - } - - for (unsigned i = 0; i < oldClasses.size(); ++i) { - if (remainingClassBits.quickGet(i)) - continue; - - // Class was removed. - if (hasSelectorForClass(oldClasses[i])) - return true; - } - return false; -} - -} - diff --git a/sky/engine/core/dom/shadow/SelectRuleFeatureSet.h b/sky/engine/core/dom/shadow/SelectRuleFeatureSet.h deleted file mode 100644 index ff432e1ec6cf6..0000000000000 --- a/sky/engine/core/dom/shadow/SelectRuleFeatureSet.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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. - */ - -#ifndef SKY_ENGINE_CORE_DOM_SHADOW_SELECTRULEFEATURESET_H_ -#define SKY_ENGINE_CORE_DOM_SHADOW_SELECTRULEFEATURESET_H_ - -#include "sky/engine/core/css/RuleFeature.h" -#include "sky/engine/core/dom/Element.h" - -namespace blink { - -class SpaceSplitString; - -class SelectRuleFeatureSet { - DISALLOW_ALLOCATION(); -public: - SelectRuleFeatureSet(); - - void add(const SelectRuleFeatureSet&); - void clear(); - void collectFeaturesFromSelector(const CSSSelector&); - - bool hasSelectorForId(const AtomicString&) const; - bool hasSelectorForClass(const AtomicString&) const; - bool hasSelectorForAttribute(const AtomicString&) const; - - bool checkSelectorsForClassChange(const SpaceSplitString& changedClasses) const; - bool checkSelectorsForClassChange(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses) const; - -private: - RuleFeatureSet m_cssRuleFeatureSet; -}; - -inline bool SelectRuleFeatureSet::hasSelectorForId(const AtomicString& idValue) const -{ - ASSERT(!idValue.isEmpty()); - return m_cssRuleFeatureSet.hasSelectorForId(idValue); -} - -inline bool SelectRuleFeatureSet::hasSelectorForClass(const AtomicString& classValue) const -{ - ASSERT(!classValue.isEmpty()); - return m_cssRuleFeatureSet.hasSelectorForClass(classValue); -} - -inline bool SelectRuleFeatureSet::hasSelectorForAttribute(const AtomicString& attributeName) const -{ - ASSERT(!attributeName.isEmpty()); - return m_cssRuleFeatureSet.hasSelectorForAttribute(attributeName); -} - -} - -#endif // SKY_ENGINE_CORE_DOM_SHADOW_SELECTRULEFEATURESET_H_ diff --git a/sky/engine/core/dom/shadow/ShadowRoot.cpp b/sky/engine/core/dom/shadow/ShadowRoot.cpp deleted file mode 100644 index 20019075556e0..0000000000000 --- a/sky/engine/core/dom/shadow/ShadowRoot.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* - * 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. - * * 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 "sky/engine/core/dom/shadow/ShadowRoot.h" - -#include "sky/engine/bindings/exception_state.h" -#include "sky/engine/core/css/resolver/StyleResolver.h" -#include "sky/engine/core/dom/Document.h" -#include "sky/engine/core/dom/ElementTraversal.h" -#include "sky/engine/core/dom/StyleEngine.h" -#include "sky/engine/core/dom/Text.h" -#include "sky/engine/core/dom/shadow/ElementShadow.h" -#include "sky/engine/core/dom/shadow/InsertionPoint.h" -#include "sky/engine/public/platform/Platform.h" - -namespace blink { - -struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope { - Vector> vector; - unsigned countersAndFlags[3]; -}; - -COMPILE_ASSERT(sizeof(ShadowRoot) == sizeof(SameSizeAsShadowRoot), shadowroot_should_stay_small); - -ShadowRoot::ShadowRoot(Document& document) - : DocumentFragment(0, CreateShadowRoot) - , TreeScope(*this, document) - , m_descendantContentElementCount(0) - , m_childShadowRootCount(0) - , m_descendantInsertionPointsIsValid(false) -{ -} - -ShadowRoot::~ShadowRoot() -{ - // We cannot let ContainerNode destructor call willBeDeletedFromDocument() - // for this ShadowRoot instance because TreeScope destructor - // clears Node::m_treeScope thus ContainerNode is no longer able - // to access it Document reference after that. - willBeDeletedFromDocument(); - - // We must remove all of our children first before the TreeScope destructor - // runs so we don't go through TreeScopeAdopter for each child with a - // destructed tree scope in each descendant. - removeDetachedChildren(); - - // We must call clearRareData() here since a ShadowRoot class inherits TreeScope - // as well as Node. See a comment on TreeScope.h for the reason. - if (hasRareData()) - clearRareData(); -} - -void ShadowRoot::dispose() -{ - invalidateDescendantInsertionPoints(); - removeDetachedChildren(); -} - -PassRefPtr ShadowRoot::cloneNode(bool, ExceptionState& exceptionState) -{ - exceptionState.ThrowDOMException(DataCloneError, "ShadowRoot nodes are not clonable."); - return nullptr; -} - -PassRefPtr ShadowRoot::cloneNode(ExceptionState& exceptionState) -{ - return nullptr; -} - -PassRefPtr ShadowRoot::cloneNode(bool deep) -{ - return nullptr; -} - -void ShadowRoot::recalcStyle(StyleRecalcChange change) -{ - if (styleChangeType() >= SubtreeStyleChange) - change = Force; - - // There's no style to update so just calling recalcStyle means we're updated. - clearNeedsStyleRecalc(); - - for (Node* child = lastChild(); child; child = child->previousSibling()) { - if (child->isTextNode()) { - toText(child)->recalcTextStyle(change); - } else if (child->isElementNode()) { - if (child->shouldCallRecalcStyle(change)) - toElement(child)->recalcStyle(change); - } - } - - clearChildNeedsStyleRecalc(); -} - -void ShadowRoot::insertedInto(ContainerNode* insertionPoint) -{ - DocumentFragment::insertedInto(insertionPoint); - - if (inActiveDocument()) - document().styleEngine()->addTreeScope(*this); - - if (ShadowRoot* root = host()->containingShadowRoot()) - root->addChildShadowRoot(); -} - -void ShadowRoot::removedFrom(ContainerNode* insertionPoint) -{ - ShadowRoot* root = host()->containingShadowRoot(); - if (!root) - root = insertionPoint->containingShadowRoot(); - if (root) - root->removeChildShadowRoot(); - - if (inActiveDocument()) - document().styleEngine()->removeTreeScope(*this); - - DocumentFragment::removedFrom(insertionPoint); -} - -void ShadowRoot::didAddInsertionPoint() -{ - ++m_descendantContentElementCount; - invalidateDescendantInsertionPoints(); -} - -void ShadowRoot::didRemoveInsertionPoint() -{ - ASSERT(m_descendantContentElementCount); - --m_descendantContentElementCount; - invalidateDescendantInsertionPoints(); -} - -void ShadowRoot::addChildShadowRoot() -{ - ++m_childShadowRootCount; -} - -void ShadowRoot::removeChildShadowRoot() -{ - ASSERT(m_childShadowRootCount); - --m_childShadowRootCount; -} - -void ShadowRoot::invalidateDescendantInsertionPoints() -{ - m_descendantInsertionPointsIsValid = false; - m_descendantInsertionPoints.clear(); -} - -bool ShadowRoot::containsContentElements() const -{ - return m_descendantContentElementCount; -} - -bool ShadowRoot::containsShadowRoots() const -{ - return m_childShadowRootCount; -} - -const Vector >& ShadowRoot::descendantInsertionPoints() -{ - DEFINE_STATIC_LOCAL(Vector >, emptyList, ()); - if (m_descendantInsertionPointsIsValid) - return m_descendantInsertionPoints; - - m_descendantInsertionPointsIsValid = true; - - if (!containsContentElements()) - return emptyList; - - Vector > insertionPoints; - for (InsertionPoint* insertionPoint = Traversal::firstWithin(*this); insertionPoint; insertionPoint = Traversal::next(*insertionPoint, this)) - insertionPoints.append(insertionPoint); - - m_descendantInsertionPoints.swap(insertionPoints); - - return m_descendantInsertionPoints; -} - -} diff --git a/sky/engine/core/dom/shadow/ShadowRoot.h b/sky/engine/core/dom/shadow/ShadowRoot.h deleted file mode 100644 index d8981034e721a..0000000000000 --- a/sky/engine/core/dom/shadow/ShadowRoot.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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. - * * 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 SKY_ENGINE_CORE_DOM_SHADOW_SHADOWROOT_H_ -#define SKY_ENGINE_CORE_DOM_SHADOW_SHADOWROOT_H_ - -#include "sky/engine/core/dom/ContainerNode.h" -#include "sky/engine/core/dom/DocumentFragment.h" -#include "sky/engine/core/dom/Element.h" -#include "sky/engine/core/dom/TreeScope.h" - -namespace blink { - -class Document; -class ElementShadow; -class ExceptionState; -class InsertionPoint; - -class ShadowRoot final : public DocumentFragment, public TreeScope { - DEFINE_WRAPPERTYPEINFO(); -public: - - static PassRefPtr create(Document& document) - { - return adoptRef(new ShadowRoot(document)); - } - - void recalcStyle(StyleRecalcChange); - - // Disambiguate between Node and TreeScope hierarchies; TreeScope's implementation is simpler. - using TreeScope::document; - using TreeScope::getElementById; - - Element* host() const { return toElement(parentOrShadowHostNode()); } - ElementShadow* owner() const { return host() ? host()->shadow() : 0; } - - virtual void insertedInto(ContainerNode*) override; - virtual void removedFrom(ContainerNode*) override; - - bool containsContentElements() const; - bool containsShadowRoots() const; - - void didAddInsertionPoint(); - void didRemoveInsertionPoint(); - const Vector >& descendantInsertionPoints(); - - // Make protected methods from base class public here. - using TreeScope::setDocument; - using TreeScope::setParentTreeScope; - - Element* activeElement() const; - - PassRefPtr cloneNode(bool, ExceptionState&); - PassRefPtr cloneNode(ExceptionState& exceptionState); - -private: - explicit ShadowRoot(Document&); - virtual ~ShadowRoot(); - - virtual void dispose() override; - - void addChildShadowRoot(); - void removeChildShadowRoot(); - void invalidateDescendantInsertionPoints(); - - virtual PassRefPtr cloneNode(bool) override; - - Vector > m_descendantInsertionPoints; - unsigned m_descendantContentElementCount; - unsigned m_childShadowRootCount; - unsigned m_descendantInsertionPointsIsValid : 1; -}; - -inline Element* ShadowRoot::activeElement() const -{ - return adjustedFocusedElement(); -} - -DEFINE_NODE_TYPE_CASTS(ShadowRoot, isShadowRoot()); -DEFINE_TYPE_CASTS(ShadowRoot, TreeScope, treeScope, treeScope->rootNode().isShadowRoot(), treeScope.rootNode().isShadowRoot()); - -} // namespace blink - -#endif // SKY_ENGINE_CORE_DOM_SHADOW_SHADOWROOT_H_ diff --git a/sky/engine/core/dom/shadow/ShadowRoot.idl b/sky/engine/core/dom/shadow/ShadowRoot.idl deleted file mode 100644 index ee040f4f52b2b..0000000000000 --- a/sky/engine/core/dom/shadow/ShadowRoot.idl +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - * * 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. - */ - -interface ShadowRoot : DocumentFragment { - readonly attribute Element activeElement; - - [RaisesException] Node cloneNode([Named] optional boolean deep = true); - Element getElementById([Default=Undefined] optional DOMString elementId); - - Element elementFromPoint([Default=Undefined] optional long x, - [Default=Undefined] optional long y); - - readonly attribute Element host; -}; diff --git a/sky/engine/core/editing/TextIterator.cpp b/sky/engine/core/editing/TextIterator.cpp index 16069c05ed7ce..a46120e501142 100644 --- a/sky/engine/core/editing/TextIterator.cpp +++ b/sky/engine/core/editing/TextIterator.cpp @@ -31,7 +31,6 @@ #include "sky/engine/bindings/exception_state_placeholder.h" #include "sky/engine/core/dom/Document.h" #include "sky/engine/core/dom/NodeTraversal.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/editing/VisiblePosition.h" #include "sky/engine/core/editing/VisibleUnits.h" #include "sky/engine/core/editing/htmlediting.h" @@ -147,22 +146,23 @@ unsigned BitStack::size() const return m_size; } -// -------- #if ENABLE(ASSERT) -static unsigned depthCrossingShadowBoundaries(Node* node) +static unsigned depth(Node* node) { unsigned depth = 0; - for (ContainerNode* parent = node->parentOrShadowHostNode(); parent; parent = parent->parentOrShadowHostNode()) + for (ContainerNode* parent = node->parentNode(); parent; parent = parent->parentNode()) ++depth; return depth; } #endif -// This function is like Range::pastLastNode, except for the fact that it can climb up out of shadow trees. -static Node* nextInPreOrderCrossingShadowBoundaries(Node* rangeEndContainer, int rangeEndOffset) +// -------- + +// This function is like Range::pastLastNode +static Node* nextInPreOrder(Node* rangeEndContainer, int rangeEndOffset) { if (!rangeEndContainer) return 0; @@ -170,7 +170,7 @@ static Node* nextInPreOrderCrossingShadowBoundaries(Node* rangeEndContainer, int if (Node* next = NodeTraversal::childAt(*rangeEndContainer, rangeEndOffset)) return next; } - for (Node* node = rangeEndContainer; node; node = node->parentOrShadowHostNode()) { + for (Node* node = rangeEndContainer; node; node = node->parentNode()) { if (Node* next = node->nextSibling()) return next; } @@ -197,16 +197,7 @@ static inline bool ignoresContainerClip(Node* node) static void pushFullyClippedState(BitStack& stack, Node* node) { - ASSERT(stack.size() == depthCrossingShadowBoundaries(node)); - - // FIXME: m_fullyClippedStack was added in response to - // ("Search can find text that's hidden by overflow:hidden"), but the logic here will not work correctly if - // a shadow tree redistributes nodes. m_fullyClippedStack relies on the assumption that DOM node hierarchy matches - // the render tree, which is not necessarily true if there happens to be shadow DOM distribution or other mechanics - // that shuffle around the render objects regardless of node tree hierarchy (like CSS flexbox). - // - // A more appropriate way to handle this situation is to detect overflow:hidden blocks by using only rendering - // primitives, not with DOM primitives. + ASSERT(stack.size() == depth(node)); // Push true if this node full clips its contents, or if a parent already has fully // clipped and this is not a node that ignores its container's clip. @@ -217,7 +208,7 @@ static void setUpFullyClippedStack(BitStack& stack, Node* node) { // Put the nodes in a vector so we can iterate in reverse order. Vector, 100> ancestry; - for (ContainerNode* parent = node->parentOrShadowHostNode(); parent; parent = parent->parentOrShadowHostNode()) + for (ContainerNode* parent = node->parentNode(); parent; parent = parent->parentNode()) ancestry.append(parent); // Call pushFullyClippedState on each node starting with the earliest ancestor. @@ -226,7 +217,7 @@ static void setUpFullyClippedStack(BitStack& stack, Node* node) pushFullyClippedState(stack, ancestry[size - i - 1]); pushFullyClippedState(stack, node); - ASSERT(stack.size() == 1 + depthCrossingShadowBoundaries(node)); + ASSERT(stack.size() == 1 + depth(node)); } // -------- @@ -248,7 +239,6 @@ TextIterator::TextIterator(const Range* range, TextIteratorBehaviorFlags behavio , m_emitsCharactersBetweenAllVisiblePositions(behavior & TextIteratorEmitsCharactersBetweenAllVisiblePositions) , m_emitsOriginalText(behavior & TextIteratorEmitsOriginalText) , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility) - , m_entersAuthorShadowRoots(behavior & TextIteratorEntersAuthorShadowRoots) , m_emitsObjectReplacementCharacter(behavior & TextIteratorEmitsObjectReplacementCharacter) { if (range) @@ -272,7 +262,6 @@ TextIterator::TextIterator(const Position& start, const Position& end, TextItera , m_emitsCharactersBetweenAllVisiblePositions(behavior & TextIteratorEmitsCharactersBetweenAllVisiblePositions) , m_emitsOriginalText(behavior & TextIteratorEmitsOriginalText) , m_ignoresStyleVisibility(behavior & TextIteratorIgnoresStyleVisibility) - , m_entersAuthorShadowRoots(behavior & TextIteratorEntersAuthorShadowRoots) , m_emitsObjectReplacementCharacter(behavior & TextIteratorEmitsObjectReplacementCharacter) { initialize(start, end); @@ -298,14 +287,6 @@ void TextIterator::initialize(const Position& start, const Position& end) m_endContainer = endContainer; m_endOffset = endOffset; - // Figure out the initial value of m_shadowDepth: the depth of startContainer's tree scope from - // the common ancestor tree scope. - const TreeScope* commonAncestorTreeScope = startContainer->treeScope().commonAncestorTreeScope(endContainer->treeScope()); - ASSERT(commonAncestorTreeScope); - m_shadowDepth = 0; - for (const TreeScope* treeScope = &startContainer->treeScope(); treeScope != commonAncestorTreeScope; treeScope = treeScope->parentTreeScope()) - ++m_shadowDepth; - // Set up the current node for processing. if (startContainer->offsetInCharacters()) m_node = startContainer; @@ -326,7 +307,7 @@ void TextIterator::initialize(const Position& start, const Position& end) m_iterationProgress = HandledNone; // Calculate first out of bounds node. - m_pastEndNode = nextInPreOrderCrossingShadowBoundaries(endContainer, endOffset); + m_pastEndNode = nextInPreOrder(endContainer, endOffset); // Identify the first run. advance(); @@ -374,7 +355,7 @@ void TextIterator::advance() return; } - while (m_node && (m_node != m_pastEndNode || m_shadowDepth > 0)) { + while (m_node && (m_node != m_pastEndNode)) { // if the range ends at offset 0 of an element, represent the // position, but not the content, of that element e.g. if the // node is a blockflow element, emit a newline that @@ -387,31 +368,8 @@ void TextIterator::advance() RenderObject* renderer = m_node->renderer(); if (!renderer) { - if (m_node->isShadowRoot()) { - // A shadow root doesn't have a renderer, but we want to visit children anyway. - m_iterationProgress = m_iterationProgress < HandledNode ? HandledNode : m_iterationProgress; - } else { - m_iterationProgress = HandledChildren; - } + m_iterationProgress = HandledChildren; } else { - // Enter author shadow roots, from youngest, if any and if necessary. - if (m_iterationProgress < HandledAuthorShadowRoots) { - if (m_entersAuthorShadowRoots && m_node->isElementNode() && toElement(m_node)->hasAuthorShadowRoot()) { - ShadowRoot* youngestShadowRoot = toElement(m_node)->shadowRoot(); - m_node = youngestShadowRoot; - m_iterationProgress = HandledNone; - ++m_shadowDepth; - pushFullyClippedState(m_fullyClippedStack, m_node); - continue; - } - - m_iterationProgress = HandledAuthorShadowRoots; - } - - // Enter user-agent shadow root, if necessary. - if (m_iterationProgress < HandledUserAgentShadowRoot) - m_iterationProgress = HandledUserAgentShadowRoot; - // Handle the current node according to its type. if (m_iterationProgress < HandledNode) { bool handledNode = false; @@ -457,16 +415,6 @@ void TextIterator::advance() } next = m_node->nextSibling(); } - - if (!next && !parentNode && m_shadowDepth > 0) { - // 4. Reached the top of a shadow root. - ShadowRoot* shadowRoot = toShadowRoot(m_node); - m_node = shadowRoot->host(); - m_iterationProgress = HandledAuthorShadowRoots; - --m_shadowDepth; - m_fullyClippedStack.pop(); - continue; - } } m_fullyClippedStack.pop(); } @@ -1055,7 +1003,7 @@ void SimplifiedBackwardsTextIterator::advance() // Exit all other containers. while (!m_node->previousSibling()) { - if (!advanceRespectingRange(m_node->parentOrShadowHostNode())) + if (!advanceRespectingRange(m_node->parentNode())) break; m_fullyClippedStack.pop(); exitNode(); @@ -1837,7 +1785,7 @@ static size_t findPlainTextInternal(CharacterIterator& it, const String& target, return matchLength; } -static const TextIteratorBehaviorFlags iteratorFlagsForFindPlainText = TextIteratorEntersAuthorShadowRoots; +static const TextIteratorBehaviorFlags iteratorFlagsForFindPlainText = 0; PassRefPtr findPlainText(const Range* range, const String& target, FindOptions options) { diff --git a/sky/engine/core/editing/TextIterator.h b/sky/engine/core/editing/TextIterator.h index 8cff26519b571..057b6f07157d7 100644 --- a/sky/engine/core/editing/TextIterator.h +++ b/sky/engine/core/editing/TextIterator.h @@ -41,8 +41,7 @@ enum TextIteratorBehavior { TextIteratorEmitsCharactersBetweenAllVisiblePositions = 1 << 0, TextIteratorIgnoresStyleVisibility = 1 << 2, TextIteratorEmitsOriginalText = 1 << 3, - TextIteratorEntersAuthorShadowRoots = 1 << 5, - TextIteratorEmitsObjectReplacementCharacter = 1 << 6 + TextIteratorEmitsObjectReplacementCharacter = 1 << 5 }; typedef unsigned TextIteratorBehaviorFlags; @@ -117,8 +116,6 @@ class TextIterator { private: enum IterationProgress { HandledNone, - HandledAuthorShadowRoots, - HandledUserAgentShadowRoot, HandledNode, HandledChildren }; @@ -145,7 +142,6 @@ class TextIterator { int m_offset; IterationProgress m_iterationProgress; BitStack m_fullyClippedStack; - int m_shadowDepth; // The range. RawPtr m_startContainer; @@ -195,8 +191,6 @@ class TextIterator { // Used when the visibility of the style should not affect text gathering. bool m_ignoresStyleVisibility; - bool m_entersAuthorShadowRoots; - bool m_emitsObjectReplacementCharacter; }; diff --git a/sky/engine/core/editing/VisibleUnits.cpp b/sky/engine/core/editing/VisibleUnits.cpp index a825021f942f9..4c5769bb71d45 100644 --- a/sky/engine/core/editing/VisibleUnits.cpp +++ b/sky/engine/core/editing/VisibleUnits.cpp @@ -83,7 +83,7 @@ static Position previousRootInlineBoxCandidatePosition(Node* node, const Visible while (previousNode && (!previousNode->renderer() || inSameLine(VisiblePosition(firstPositionInOrBeforeNode(previousNode)), visiblePosition))) previousNode = previousLeafWithSameEditability(previousNode, editableType); - while (previousNode && !previousNode->isShadowRoot()) { + while (previousNode) { if (highestEditableRoot(firstPositionInOrBeforeNode(previousNode), editableType) != highestRoot) break; @@ -104,7 +104,7 @@ static Position nextRootInlineBoxCandidatePosition(Node* node, const VisiblePosi while (nextNode && (!nextNode->renderer() || inSameLine(VisiblePosition(firstPositionInOrBeforeNode(nextNode)), visiblePosition))) nextNode = nextLeafWithSameEditability(nextNode, ContentIsEditable); - while (nextNode && !nextNode->isShadowRoot()) { + while (nextNode) { if (highestEditableRoot(firstPositionInOrBeforeNode(nextNode), editableType) != highestRoot) break; @@ -510,7 +510,6 @@ static VisiblePosition previousBoundary(const VisiblePosition& c, BoundarySearch // Use the character iterator to translate the next value into a DOM position. BackwardsCharacterIterator charIt(searchRange.get()); charIt.advance(string.size() - suffixLength - next); - // FIXME: charIt can get out of shadow host. return VisiblePosition(charIt.range()->endPosition(), DOWNSTREAM); } diff --git a/sky/engine/core/editing/htmlediting.cpp b/sky/engine/core/editing/htmlediting.cpp index 65e9639a86535..eac82d5aadb67 100644 --- a/sky/engine/core/editing/htmlediting.cpp +++ b/sky/engine/core/editing/htmlediting.cpp @@ -25,7 +25,6 @@ #include "sky/engine/core/editing/htmlediting.h" -#include "gen/sky/core/HTMLElementFactory.h" #include "sky/engine/bindings/exception_state.h" #include "sky/engine/bindings/exception_state_placeholder.h" #include "sky/engine/core/dom/Document.h" @@ -34,7 +33,6 @@ #include "sky/engine/core/dom/PositionIterator.h" #include "sky/engine/core/dom/Range.h" #include "sky/engine/core/dom/Text.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/editing/PlainTextRange.h" #include "sky/engine/core/editing/TextIterator.h" #include "sky/engine/core/editing/VisiblePosition.h" @@ -54,8 +52,7 @@ bool isAtomicNode(const Node *node) return node && (!node->hasChildren() || editingIgnoresContent(node)); } -// Compare two positions, taking into account the possibility that one or both -// could be inside a shadow tree. Only works for non-null values. +// Compare two positions. Only works for non-null values. int comparePositions(const Position& a, const Position& b) { ASSERT(a.isNotNull()); @@ -228,13 +225,9 @@ VisiblePosition firstEditableVisiblePositionAfterPositionInRoot(const Position& Position editablePosition = position; - if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) { - Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(editablePosition.deprecatedNode()); - if (!shadowAncestor) - return VisiblePosition(); - - editablePosition = positionAfterNode(shadowAncestor); - } + // TODO(ianh): not really sure what's going on here + if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) + editablePosition = positionAfterNode(editablePosition.deprecatedNode()); while (editablePosition.deprecatedNode() && !isEditablePosition(editablePosition) && editablePosition.deprecatedNode()->isDescendantOf(highestRoot)) editablePosition = isAtomicNode(editablePosition.deprecatedNode()) ? positionInParentAfterNode(*editablePosition.deprecatedNode()) : nextVisuallyDistinctCandidate(editablePosition); @@ -258,13 +251,9 @@ Position lastEditablePositionBeforePositionInRoot(const Position& position, Node Position editablePosition = position; - if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) { - Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(editablePosition.deprecatedNode()); - if (!shadowAncestor) - return Position(); - - editablePosition = firstPositionInOrBeforeNode(shadowAncestor); - } + // TODO(ianh): not really sure what's going on here + if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) + editablePosition = firstPositionInOrBeforeNode(editablePosition.deprecatedNode()); while (editablePosition.deprecatedNode() && !isEditablePosition(editablePosition) && editablePosition.deprecatedNode()->isDescendantOf(highestRoot)) editablePosition = isAtomicNode(editablePosition.deprecatedNode()) ? positionInParentBeforeNode(*editablePosition.deprecatedNode()) : previousVisuallyDistinctCandidate(editablePosition); @@ -479,7 +468,6 @@ VisiblePosition visiblePositionBeforeNode(Node& node) if (node.hasChildren()) return VisiblePosition(firstPositionInOrBeforeNode(&node), DOWNSTREAM); ASSERT(node.parentNode()); - ASSERT(!node.parentNode()->isShadowRoot()); return VisiblePosition(positionInParentBeforeNode(node)); } @@ -489,7 +477,6 @@ VisiblePosition visiblePositionAfterNode(Node& node) if (node.hasChildren()) return VisiblePosition(lastPositionInOrAfterNode(&node), DOWNSTREAM); ASSERT(node.parentNode()); - ASSERT(!node.parentNode()->isShadowRoot()); return VisiblePosition(positionInParentAfterNode(node)); } @@ -719,15 +706,15 @@ void updatePositionForNodeRemoval(Position& position, Node& node) case Position::PositionIsOffsetInAnchor: if (position.containerNode() == node.parentNode() && static_cast(position.offsetInContainerNode()) > node.nodeIndex()) position.moveToOffset(position.offsetInContainerNode() - 1); - else if (node.containsIncludingShadowDOM(position.containerNode())) + else if (node.contains(position.containerNode())) position = positionInParentBeforeNode(node); break; case Position::PositionIsAfterAnchor: - if (node.containsIncludingShadowDOM(position.anchorNode())) + if (node.contains(position.anchorNode())) position = positionInParentAfterNode(node); break; case Position::PositionIsBeforeAnchor: - if (node.containsIncludingShadowDOM(position.anchorNode())) + if (node.contains(position.anchorNode())) position = positionInParentBeforeNode(node); break; } @@ -790,12 +777,7 @@ int indexForVisiblePosition(const VisiblePosition& visiblePosition, RefPtrcontainingShadowRoot(); - - if (shadowRoot) - scope = shadowRoot; - else - scope = &document; + scope = &document; RefPtr range = Range::create(document, firstPositionInNode(scope.get()), p.parentAnchoredEquivalent()); diff --git a/sky/engine/core/html/HTMLElement.h b/sky/engine/core/html/HTMLElement.h index 3b07bc6f23fa6..82ce98730b2b6 100644 --- a/sky/engine/core/html/HTMLElement.h +++ b/sky/engine/core/html/HTMLElement.h @@ -66,6 +66,4 @@ inline HTMLElement::HTMLElement(const QualifiedName& tagName, Document& document } // namespace blink -#include "gen/sky/core/HTMLElementTypeHelpers.h" - #endif // SKY_ENGINE_CORE_HTML_HTMLELEMENT_H_ diff --git a/sky/engine/core/html/HTMLTagNames.in b/sky/engine/core/html/HTMLTagNames.in deleted file mode 100644 index 75920e53fa99d..0000000000000 --- a/sky/engine/core/html/HTMLTagNames.in +++ /dev/null @@ -1,2 +0,0 @@ -namespace="HTML" -fallbackInterfaceName="HTMLElement" diff --git a/sky/engine/core/page/FocusController.cpp b/sky/engine/core/page/FocusController.cpp index b9d20a4b3693f..889ef112c6ca0 100644 --- a/sky/engine/core/page/FocusController.cpp +++ b/sky/engine/core/page/FocusController.cpp @@ -33,8 +33,6 @@ #include "sky/engine/core/dom/ElementTraversal.h" #include "sky/engine/core/dom/NodeTraversal.h" #include "sky/engine/core/dom/Range.h" -#include "sky/engine/core/dom/shadow/ElementShadow.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/editing/htmlediting.h" #include "sky/engine/core/events/Event.h" #include "sky/engine/core/frame/FrameView.h" @@ -47,7 +45,8 @@ #include "sky/engine/core/rendering/RenderLayer.h" // This file is no longer needed now that nothing can be focused and -// events can't be targetted at nodes. +// events can't be targetted at nodes. Parts of it have been gutted, +// in fact, such that it no longer makes sense. // TODO(ianh): We should remove it. namespace blink { @@ -67,11 +66,6 @@ Node* FocusNavigationScope::rootNode() const Element* FocusNavigationScope::owner() const { - Node* root = rootNode(); - if (root->isShadowRoot()) { - ShadowRoot* shadowRoot = toShadowRoot(root); - return shadowRoot->host(); - } return 0; } @@ -81,56 +75,15 @@ FocusNavigationScope FocusNavigationScope::focusNavigationScopeOf(Node* node) Node* root = node; for (Node* n = node; n; n = n->parentNode()) root = n; - // The result is not always a ShadowRoot nor a DocumentNode since + // The result is not always a DocumentNode since // a starting node is in an orphaned tree in composed shadow tree. return FocusNavigationScope(&root->treeScope()); } -FocusNavigationScope FocusNavigationScope::ownedByNonFocusableFocusScopeOwner(Node* node) -{ - ASSERT(node); - return FocusNavigationScope::ownedByShadowHost(node); -} - -FocusNavigationScope FocusNavigationScope::ownedByShadowHost(Node* node) -{ - ASSERT(isShadowHost(node)); - return FocusNavigationScope(toElement(node)->shadow()->shadowRoot()); -} - -#if ENABLE(ASSERT) -static inline bool isNonFocusableShadowHost(Node* node) -{ - ASSERT(node); - if (!node->isElementNode()) - return false; - Element* element = toElement(node); - return !element->isFocusable() && isShadowHost(element); -} -#endif - -static inline bool isNonKeyboardFocusableShadowHost(Node* node) -{ - ASSERT(node); - if (!node->isElementNode()) - return false; - Element* element = toElement(node); - return !element->isKeyboardFocusable() && isShadowHost(element); -} - -static inline bool isKeyboardFocusableShadowHost(Node* node) -{ - ASSERT(node); - if (!node->isElementNode()) - return false; - Element* element = toElement(node); - return element->isKeyboardFocusable() && isShadowHost(element); -} - static inline bool isNonFocusableFocusScopeOwner(Node* node) { ASSERT(node); - return isNonKeyboardFocusableShadowHost(node); + return false; } static inline int adjustedTabIndex(Node* node) @@ -290,11 +243,10 @@ bool FocusController::advanceFocusInDocumentOrder(FocusType type, bool initialFo Node* FocusController::findFocusableNodeAcrossFocusScope(FocusType type, FocusNavigationScope scope, Node* currentNode) { - ASSERT(!currentNode || !isNonFocusableShadowHost(currentNode)); + ASSERT(!currentNode); Node* found; - if (currentNode && type == FocusTypeForward && isKeyboardFocusableShadowHost(currentNode)) { - Node* foundInInnerFocusScope = findFocusableNodeRecursively(type, FocusNavigationScope::ownedByShadowHost(currentNode), 0); - found = foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableNodeRecursively(type, scope, currentNode); + if (currentNode && type == FocusTypeForward) { + found = nullptr; } else { found = findFocusableNodeRecursively(type, scope, currentNode); } @@ -305,7 +257,7 @@ Node* FocusController::findFocusableNodeAcrossFocusScope(FocusType type, FocusNa if (!owner) break; scope = FocusNavigationScope::focusNavigationScopeOf(owner); - if (type == FocusTypeBackward && isKeyboardFocusableShadowHost(owner)) { + if (type == FocusTypeBackward) { found = owner; break; } @@ -317,26 +269,7 @@ Node* FocusController::findFocusableNodeAcrossFocusScope(FocusType type, FocusNa Node* FocusController::findFocusableNodeRecursively(FocusType type, FocusNavigationScope scope, Node* start) { - // Starting node is exclusive. - Node* found = findFocusableNode(type, scope, start); - if (!found) - return 0; - if (type == FocusTypeForward) { - if (!isNonFocusableFocusScopeOwner(found)) - return found; - Node* foundInInnerFocusScope = findFocusableNodeRecursively(type, FocusNavigationScope::ownedByNonFocusableFocusScopeOwner(found), 0); - return foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableNodeRecursively(type, scope, found); - } - ASSERT(type == FocusTypeBackward); - if (isKeyboardFocusableShadowHost(found)) { - Node* foundInInnerFocusScope = findFocusableNodeRecursively(type, FocusNavigationScope::ownedByShadowHost(found), 0); - return foundInInnerFocusScope ? foundInInnerFocusScope : found; - } - if (isNonFocusableFocusScopeOwner(found)) { - Node* foundInInnerFocusScope = findFocusableNodeRecursively(type, FocusNavigationScope::ownedByNonFocusableFocusScopeOwner(found), 0); - return foundInInnerFocusScope ? foundInInnerFocusScope :findFocusableNodeRecursively(type, scope, found); - } - return found; + return nullptr; } Node* FocusController::findFocusableNode(FocusType type, FocusNavigationScope scope, Node* node) @@ -376,7 +309,7 @@ static Node* previousNodeWithLowerTabIndex(Node* start, int tabIndex) Node* winner = 0; for (Node* node = start; node; node = NodeTraversal::previous(*node)) { int currentTabIndex = adjustedTabIndex(node); - if ((shouldVisit(node) || isNonKeyboardFocusableShadowHost(node)) && currentTabIndex < tabIndex && currentTabIndex > winningTabIndex) { + if ((shouldVisit(node)) && currentTabIndex < tabIndex && currentTabIndex > winningTabIndex) { winner = node; winningTabIndex = currentTabIndex; } diff --git a/sky/engine/core/page/FocusController.h b/sky/engine/core/page/FocusController.h index 930710e80bde9..28d0e26dc1734 100644 --- a/sky/engine/core/page/FocusController.h +++ b/sky/engine/core/page/FocusController.h @@ -51,8 +51,6 @@ class FocusNavigationScope { Node* rootNode() const; Element* owner() const; static FocusNavigationScope focusNavigationScopeOf(Node*); - static FocusNavigationScope ownedByNonFocusableFocusScopeOwner(Node*); - static FocusNavigationScope ownedByShadowHost(Node*); private: explicit FocusNavigationScope(TreeScope*); diff --git a/sky/engine/core/rendering/HitTestResult.cpp b/sky/engine/core/rendering/HitTestResult.cpp index f3d751fd0deaf..dec5fb709dfa2 100644 --- a/sky/engine/core/rendering/HitTestResult.cpp +++ b/sky/engine/core/rendering/HitTestResult.cpp @@ -23,8 +23,6 @@ #include "gen/sky/core/HTMLNames.h" #include "sky/engine/core/dom/DocumentMarkerController.h" -#include "sky/engine/core/dom/NodeRenderingTraversal.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/editing/PositionWithAffinity.h" #include "sky/engine/core/editing/VisiblePosition.h" #include "sky/engine/core/frame/LocalFrame.h" @@ -245,7 +243,7 @@ void HitTestResult::resolveRectBasedTest(Node* resolvedInnerNode, const LayoutPo Element* HitTestResult::innerElement() const { - for (Node* node = m_innerNode.get(); node; node = NodeRenderingTraversal::parent(node)) { + for (Node* node = m_innerNode.get(); node; node = node->parentNode()) { if (node->isElementNode()) return toElement(node); } diff --git a/sky/engine/core/rendering/RenderBlock.cpp b/sky/engine/core/rendering/RenderBlock.cpp index 779dffbbf5e47..49bc6f627fa74 100644 --- a/sky/engine/core/rendering/RenderBlock.cpp +++ b/sky/engine/core/rendering/RenderBlock.cpp @@ -26,7 +26,6 @@ #include "sky/engine/core/dom/Document.h" #include "sky/engine/core/dom/Element.h" #include "sky/engine/core/dom/StyleEngine.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/frame/FrameView.h" #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/frame/Settings.h" diff --git a/sky/engine/core/rendering/RenderLayer.cpp b/sky/engine/core/rendering/RenderLayer.cpp index 0a62dea9801fc..9eaf5bc86717f 100644 --- a/sky/engine/core/rendering/RenderLayer.cpp +++ b/sky/engine/core/rendering/RenderLayer.cpp @@ -46,7 +46,6 @@ #include "gen/sky/core/CSSPropertyNames.h" #include "gen/sky/platform/RuntimeEnabledFeatures.h" #include "sky/engine/core/dom/Document.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/frame/FrameView.h" #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/frame/Settings.h" diff --git a/sky/engine/core/rendering/RenderObject.cpp b/sky/engine/core/rendering/RenderObject.cpp index 89da96076c419..7bb92f105f45e 100644 --- a/sky/engine/core/rendering/RenderObject.cpp +++ b/sky/engine/core/rendering/RenderObject.cpp @@ -32,7 +32,6 @@ #include "sky/engine/core/dom/ElementTraversal.h" #include "sky/engine/core/dom/Range.h" #include "sky/engine/core/dom/StyleEngine.h" -#include "sky/engine/core/dom/shadow/ShadowRoot.h" #include "sky/engine/core/editing/EditingBoundary.h" #include "sky/engine/core/editing/htmlediting.h" #include "sky/engine/core/frame/FrameView.h" diff --git a/sky/engine/core/rendering/RenderTheme.cpp b/sky/engine/core/rendering/RenderTheme.cpp index 8af6251147b59..f1b1ed5399136 100644 --- a/sky/engine/core/rendering/RenderTheme.cpp +++ b/sky/engine/core/rendering/RenderTheme.cpp @@ -24,7 +24,6 @@ #include "gen/sky/core/CSSValueKeywords.h" #include "gen/sky/platform/RuntimeEnabledFeatures.h" #include "sky/engine/core/dom/Document.h" -#include "sky/engine/core/dom/shadow/ElementShadow.h" #include "sky/engine/core/frame/LocalFrame.h" #include "sky/engine/core/frame/Settings.h" #include "sky/engine/core/html/parser/HTMLParserIdioms.h" diff --git a/sky/engine/core/rendering/RenderTreeAsText.cpp b/sky/engine/core/rendering/RenderTreeAsText.cpp index 8e31d55bdf30f..41f1793680afa 100644 --- a/sky/engine/core/rendering/RenderTreeAsText.cpp +++ b/sky/engine/core/rendering/RenderTreeAsText.cpp @@ -412,21 +412,15 @@ String nodePositionAsStringForTesting(Node* node) Node* parent; for (Node* n = node; n; n = parent) { - parent = n->parentOrShadowHostNode(); + parent = n->parentNode(); if (n != node) result.appendLiteral(" of "); if (parent) { - if (n->isShadowRoot()) { - result.append('{'); - result.append(n->nodeName()); - result.append('}'); - } else { - result.appendLiteral("child "); - result.appendNumber(n->nodeIndex()); - result.appendLiteral(" {"); - result.append(n->nodeName()); - result.append('}'); - } + result.appendLiteral("child "); + result.appendNumber(n->nodeIndex()); + result.appendLiteral(" {"); + result.append(n->nodeName()); + result.append('}'); } else result.appendLiteral("document"); } diff --git a/sky/engine/core/rendering/style/RenderStyle.cpp b/sky/engine/core/rendering/style/RenderStyle.cpp index 6e061204a3f94..80aa10841e37b 100644 --- a/sky/engine/core/rendering/style/RenderStyle.cpp +++ b/sky/engine/core/rendering/style/RenderStyle.cpp @@ -149,15 +149,9 @@ StyleRecalcChange RenderStyle::stylePropagationDiff(const RenderStyle* oldStyle, return NoInherit; } -void RenderStyle::inheritFrom(const RenderStyle* inheritParent, IsAtShadowBoundary isAtShadowBoundary) -{ - if (isAtShadowBoundary == AtShadowBoundary) { - // Even if surrounding content is user-editable, shadow DOM should act as a single unit, and not necessarily be editable - EUserModify currentUserModify = userModify(); - rareInheritedData = inheritParent->rareInheritedData; - setUserModify(currentUserModify); - } else - rareInheritedData = inheritParent->rareInheritedData; +void RenderStyle::inheritFrom(const RenderStyle* inheritParent) +{ + rareInheritedData = inheritParent->rareInheritedData; inherited = inheritParent->inherited; inherited_flags = inheritParent->inherited_flags; } diff --git a/sky/engine/core/rendering/style/RenderStyle.h b/sky/engine/core/rendering/style/RenderStyle.h index 3d972f7a9a443..46fa3891807a2 100644 --- a/sky/engine/core/rendering/style/RenderStyle.h +++ b/sky/engine/core/rendering/style/RenderStyle.h @@ -257,12 +257,7 @@ class RenderStyle: public RefCounted { StyleDifference visualInvalidationDiff(const RenderStyle&) const; - enum IsAtShadowBoundary { - AtShadowBoundary, - NotAtShadowBoundary, - }; - - void inheritFrom(const RenderStyle* inheritParent, IsAtShadowBoundary = NotAtShadowBoundary); + void inheritFrom(const RenderStyle* inheritParent); void copyNonInheritedFrom(const RenderStyle*); void setHasViewportUnits(bool hasViewportUnits = true) const { noninherited_flags.hasViewportUnits = hasViewportUnits; } diff --git a/sky/tests/dom/appendChild.dart b/sky/tests/dom/appendChild.dart index 5f9a2333f507f..1a8b1e6bd06ca 100644 --- a/sky/tests/dom/appendChild.dart +++ b/sky/tests/dom/appendChild.dart @@ -52,22 +52,6 @@ void main() { expect(childElementCount(parent), equals(2)); }); - // TODO(dart): These might be real bugs too. - // test("should throw when inserting a tree scope", () { - // var parent = document.createElement("div"); - // var doc = new Document(); - // var shadowRoot = document.createElement("span").ensureShadowRoot(); - // expect(() { - // parent.appendChild(doc); - // }, throws); - // expect(() { - // parent.appendChild(shadowRoot); - // }, throws); - // expect(() { - // doc.appendChild(fragment); - // }, throws); - // }); - // TODO(dart): These might be real bugs too. // test("should throw when appending to a text", () { // var parent = new Text(); diff --git a/sky/tests/dom/ownerScope-expected.txt b/sky/tests/dom/ownerScope-expected.txt index e17fc2abd3c10..d2ec79f23e0c5 100644 --- a/sky/tests/dom/ownerScope-expected.txt +++ b/sky/tests/dom/ownerScope-expected.txt @@ -1,10 +1,7 @@ unittest-suite-wait-for-done PASS: should return null for elements not a child of a scope PASS: should return the document for elements in the document scope -PASS: should return the shadow root for elements in the shadow root scope -PASS: should return self for a shadow root or document -PASS: should dynamically update -All 5 tests passed. +All 2 tests passed. unittest-suite-success DONE diff --git a/sky/tests/dom/ownerScope.dart b/sky/tests/dom/ownerScope.dart index 7f7b2c273cf6e..4d2ad0a41cfe6 100644 --- a/sky/tests/dom/ownerScope.dart +++ b/sky/tests/dom/ownerScope.dart @@ -17,31 +17,4 @@ void main() { doc.appendChild(element); expect(element.owner, equals(doc)); }); - test("should return the shadow root for elements in the shadow root scope", () { - var doc = new Document(); - var host = doc.createElement("div"); - var child = doc.createElement("div"); - var shadowRoot = host.ensureShadowRoot(); - shadowRoot.appendChild(child); - expect(child.owner, equals(shadowRoot)); - }); - test("should return self for a shadow root or document", () { - var doc = new Document(); - var host = doc.createElement("div"); - doc.appendChild(host); - var shadowRoot = host.ensureShadowRoot(); - expect(shadowRoot.owner, equals(shadowRoot)); - expect(doc.owner, equals(doc)); - }); - test("should dynamically update", () { - var doc = new Document(); - var host = doc.createElement("div"); - var child = doc.createElement("div"); - var shadowRoot = host.ensureShadowRoot(); - expect(child.owner, isNull); - shadowRoot.appendChild(child); - expect(child.owner, equals(shadowRoot)); - child.remove(); - expect(child.owner, isNull); - }); } diff --git a/sky/tests/dom/replaceChild.dart b/sky/tests/dom/replaceChild.dart index bef11f1f2147e..2ec376636a439 100644 --- a/sky/tests/dom/replaceChild.dart +++ b/sky/tests/dom/replaceChild.dart @@ -47,21 +47,6 @@ void main() { expect(parent.lastChild, equals(lastChild)); }); - // test("should throw when inserting a tree scope", () { - // var parent = document.createElement("div"); - // var doc = new Document(); - // var shadowRoot = document.createElement("span").ensureShadowRoot(); - // expect(() { - // parent.replaceChild(doc); - // }, throws); - // expect(() { - // parent.replaceChild(shadowRoot); - // }, throws); - // expect(() { - // doc.replaceChild(fragment); - // }, throws); - // }); - // test("should throw when appending to a text", () { // var parent = new Text(); // expect(() {