Add ShadowRoot interface and Element.prototype.attachShadow
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Sep 2015 02:40:53 +0000 (02:40 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Sep 2015 02:40:53 +0000 (02:40 +0000)
commit24d640361fdfccb816b7fef2127bae3b593ebf09
treeffa45658d4bd314b0870521c01156eb43f338557
parent73ce965d2435e7431036e7008d9cd814c9446393
Add ShadowRoot interface and Element.prototype.attachShadow
https://bugs.webkit.org/show_bug.cgi?id=149187

Reviewed by Antti Koivisto.

.:

* Source/cmake/OptionsGTK.cmake:

Source/JavaScriptCore:

* Configurations/FeatureDefines.xcconfig:

Source/WebCore:

Add back ShadowRoot IDL interface and Element.prototype.attachShadow in accordance with
http://w3c.github.io/webcomponents/spec/shadow/ at db27e6e36eab512d86edcdabb33ed27b5751acd7 excluding getSelection(),
elementFromPoint(), elementsFromPoint(), caretPositionFromPoint(), and styleSheets attribute on ShadowRoot interface.

The feature is enabled by default on Mac and iOS ports for testing and disabled by default elsewhere.

Also added HTMLElement::canHaveUserAgentShadowRoot which returns false by default and overridden elsewhere to return true
to distinguish elements for which attachShadow is supposed to throw NotSupported.
See https://w3c.github.io/webcomponents/spec/shadow/#widl-Element-attachShadow-ShadowRoot-ShadowRootInit-shadowRootInitDict

Tests: fast/shadow-dom/Element-interface-attachShadow.html
       fast/shadow-dom/Element-interface-shadowRoot-attribute.html
       fast/shadow-dom/ShadowRoot-interface.html

* CMakeLists.txt:
* Configurations/FeatureDefines.xcconfig:
* DerivedSources.cpp:
* DerivedSources.make:
* PlatformGTK.cmake:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::matchRecursively):
* dom/Element.cpp:
(WebCore::Element::bindingsOffsetParent):
(WebCore::Element::offsetParent):
(WebCore::Element::addShadowRoot):
(WebCore::Element::createShadowRoot):
(WebCore::Element::attachShadow): Added.
(WebCore::Element::bindingShadowRoot): Added. Returns null unless the attached shadow root is in the "open" mode.
* dom/Element.h:
* dom/Element.idl: Added attachShadow and shadowRoot. We only expose these to JS for now since Dictionary argument isn't
supported by other binding code.
* dom/ShadowRoot.cpp: Removed an unused enum.
* dom/ShadowRoot.h:
(WebCore::ShadowRoot::Type): Replaced old-style enum "ShadowRootType" by an enum class named "Type". Also added two new
values Open and Closed for author shadow roots.
(WebCore::ShadowRoot::type):
* dom/ShadowRoot.idl: Added.
* html/HTMLButtonElement.h:
* html/HTMLDetailsElement.h:
(HTMLButtonElement::canHaveUserAgentShadowRoot): Ditto.
* html/HTMLElement.h:
(WebCore::HTMLElement::canHaveUserAgentShadowRoot): Added. Returns false by default.
* html/HTMLInputElement.h:
* html/HTMLKeygenElement.h:
* html/HTMLMarqueeElement.h:
* html/HTMLMediaElement.h:
* html/HTMLMeterElement.h:
* html/HTMLPlugInElement.h:
* html/HTMLProgressElement.h:
* html/HTMLSelectElement.h:
* html/HTMLSummaryElement.h:
* html/HTMLTextAreaElement.h:
* html/shadow/InsertionPoint.h:
(ShadowRootWithInsertionPoints::ShadowRootWithInsertionPoints):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::selectionPseudoStyle):
* rendering/RenderLayer.cpp:
(WebCore::rendererForScrollbar):
* svg/SVGElement.cpp:
(WebCore::SVGElement::correspondingUseElement):
* testing/Internals.cpp:
(WebCore::Internals::shadowRootType):

Source/WebKit/mac:

* Configurations/FeatureDefines.xcconfig:

Source/WebKit2:

* Configurations/FeatureDefines.xcconfig:

Source/WTF:

* wtf/FeatureDefines.h:

Tools:

* Scripts/webkitperl/FeatureList.pm:

LayoutTests:

Add new tests for Shadow DOM with failing expectations on all platforms but Mac.

* TestExpectations:
* fast/shadow-dom: Added.
* fast/shadow-dom/Element-interface-attachShadow-expected.txt: Added.
* fast/shadow-dom/Element-interface-attachShadow.html: Added.
* fast/shadow-dom/Element-interface-shadowRoot-attribute-expected.txt: Added.
* fast/shadow-dom/Element-interface-shadowRoot-attribute.html: Added.
* fast/shadow-dom/ShadowRoot-interface-expected.txt: Added.
* fast/shadow-dom/ShadowRoot-interface.html: Added.
* js/dom/dom-static-property-for-in-iteration-expected.txt:
* platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt:
* platform/mac/TestExpectations:
* platform/mac/js/dom/constructor-length-expected.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@189841 268f45cc-cd09-0410-ab3c-d52691b4dbfc
59 files changed:
ChangeLog
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/fast/shadow-dom/Element-interface-attachShadow-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/Element-interface-attachShadow.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/Element-interface-shadowRoot-attribute-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/Element-interface-shadowRoot-attribute.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/ShadowRoot-interface-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/ShadowRoot-interface.html [new file with mode: 0644]
LayoutTests/js/dom/dom-static-property-for-in-iteration-expected.txt
LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/mac/js/dom/constructor-length-expected.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/Configurations/FeatureDefines.xcconfig
Source/WTF/ChangeLog
Source/WTF/wtf/FeatureDefines.h
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Configurations/FeatureDefines.xcconfig
Source/WebCore/DerivedSources.cpp
Source/WebCore/DerivedSources.make
Source/WebCore/PlatformGTK.cmake
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/SelectorChecker.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/Element.idl
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/ShadowRoot.cpp
Source/WebCore/dom/ShadowRoot.h
Source/WebCore/dom/ShadowRoot.idl [new file with mode: 0644]
Source/WebCore/html/HTMLButtonElement.h
Source/WebCore/html/HTMLDetailsElement.h
Source/WebCore/html/HTMLElement.h
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/HTMLKeygenElement.h
Source/WebCore/html/HTMLMarqueeElement.h
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLMeterElement.h
Source/WebCore/html/HTMLPlugInElement.h
Source/WebCore/html/HTMLProgressElement.h
Source/WebCore/html/HTMLSelectElement.h
Source/WebCore/html/HTMLSummaryElement.h
Source/WebCore/html/HTMLTextAreaElement.h
Source/WebCore/html/shadow/InsertionPoint.h
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/svg/SVGElement.cpp
Source/WebCore/testing/Internals.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Configurations/FeatureDefines.xcconfig
Source/WebKit2/ChangeLog
Source/WebKit2/Configurations/FeatureDefines.xcconfig
Source/cmake/OptionsGTK.cmake
Tools/ChangeLog
Tools/Scripts/webkitperl/FeatureList.pm