Use 'childOfType' template when retrieving Shadow DOM elements
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Nov 2016 17:03:48 +0000 (17:03 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Nov 2016 17:03:48 +0000 (17:03 +0000)
commit9443c3d10557e170c0e93b26ee02a410ce644ea9
treee98e194036b8b3f83c1061a929837af4626f7405
parent63810e44b958d3c8084cc6237a7135765a1b02a3
Use 'childOfType' template when retrieving Shadow DOM elements
https://bugs.webkit.org/show_bug.cgi?id=165145
<rdar://problem/29331830>

Reviewed by Antti Koivisto.

Source/WebCore:

Tests: fast/shadow-dom/color-input-element-shadow-manipulation.html
       fast/shadow-dom/file-input-element-shadow-manipulation.html
       fast/shadow-dom/keygen-shadow-manipulation.html
       fast/shadow-dom/media-shadow-manipulation.html
       fast/shadow-dom/range-input-element-shadow-manipulation.html
       fast/shadow-dom/textarea-shadow-manipulation.html

Switch to using 'childOfType' when retrieving Shadow DOM elements, rather
than relying on expected element positions, as these can be changed by
JavaScript.

Drive by fix: Make more use of is<> and downcast<> templates rather than blindly casting.

* dom/Element.h:
(WebCore::Element::isUploadButton): Added.
(WebCore::Element::isSliderContainerElement): Added.
* html/ColorInputType.cpp:
(WebCore::ColorInputType::shadowColorSwatch): Use 'childOfType' rather than assuming
the first child is the one we want.
* html/FileInputType.cpp:
(isType): Added.
(WebCore::FileInputType::disabledAttributeChanged): Use 'childOfType' rather than assuming
the first child is the one we want.
(WebCore::FileInputType::multipleAttributeChanged): Ditto.
* html/HTMLKeygenElement.cpp:
(WebCore::HTMLKeygenElement::shadowSelect): Ditto.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaControls): Ditto.
(WebCore::HTMLMediaElement::hasMediaControls): Ditto.
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::innerTextElement): Ditto.
* html/RangeInputType.cpp:
(WebCore::RangeInputType::sliderTrackElement): Ditto.
* html/shadow/SliderThumbElement.h:
(isType): Added.
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::targetClone): Use 'childOfType' rather than assuming
the first child is the one we want.

LayoutTests:

* fast/shadow-dom/color-input-element-shadow-manipulation-expected.txt: Added.
* fast/shadow-dom/color-input-element-shadow-manipulation.html: Added.
* fast/shadow-dom/file-input-element-shadow-manipulation-expected.txt: Added.
* fast/shadow-dom/file-input-element-shadow-manipulation.html: Added.
* fast/shadow-dom/keygen-shadow-manipulation-expected.txt: Added.
* fast/shadow-dom/keygen-shadow-manipulation.html: Added.
* fast/shadow-dom/media-shadow-manipulation-expected.txt: Added.
* fast/shadow-dom/media-shadow-manipulation.html: Added.
* fast/shadow-dom/range-input-element-shadow-manipulation-expected.txt: Added.
* fast/shadow-dom/range-input-element-shadow-manipulation.html: Added.
* fast/shadow-dom/textarea-shadow-manipulation-expected.txt: Added.
* fast/shadow-dom/textarea-shadow-manipulation.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209130 268f45cc-cd09-0410-ab3c-d52691b4dbfc
23 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/shadow-dom/color-input-element-shadow-manipulation-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/color-input-element-shadow-manipulation.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/file-input-element-shadow-manipulation-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/file-input-element-shadow-manipulation.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/keygen-shadow-manipulation-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/keygen-shadow-manipulation.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/media-shadow-manipulation-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/media-shadow-manipulation.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/range-input-element-shadow-manipulation-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/range-input-element-shadow-manipulation.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/textarea-shadow-manipulation-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/textarea-shadow-manipulation.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.h
Source/WebCore/html/ColorInputType.cpp
Source/WebCore/html/FileInputType.cpp
Source/WebCore/html/HTMLKeygenElement.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLTextAreaElement.cpp
Source/WebCore/html/RangeInputType.cpp
Source/WebCore/html/shadow/SliderThumbElement.h
Source/WebCore/svg/SVGUseElement.cpp