Changeset 209211 in webkit


Ignore:
Timestamp:
Dec 1, 2016 2:24:07 PM (7 years ago)
Author:
matthew_hanson@apple.com
Message:

Merge r209145. rdar://problem/29404231

Location:
branches/safari-602-branch
Files:
12 added
11 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-602-branch/LayoutTests/ChangeLog

    r209210 r209211  
     12016-12-01  Matthew Hanson  <matthew_hanson@apple.com>
     2
     3        Merge r209145. rdar://problem/29404231
     4
     5    2016-11-30  Brent Fulgham  <bfulgham@apple.com>
     6
     7            Use 'childOfType' template when retrieving Shadow DOM elements
     8            https://bugs.webkit.org/show_bug.cgi?id=165145
     9            <rdar://problem/29331830>
     10
     11            Reviewed by Antti Koivisto.
     12
     13            * fast/shadow-dom/color-input-element-shadow-manipulation-expected.txt: Added.
     14            * fast/shadow-dom/color-input-element-shadow-manipulation.html: Added.
     15            * fast/shadow-dom/file-input-element-shadow-manipulation-expected.txt: Added.
     16            * fast/shadow-dom/file-input-element-shadow-manipulation.html: Added.
     17            * fast/shadow-dom/keygen-shadow-manipulation-expected.txt: Added.
     18            * fast/shadow-dom/keygen-shadow-manipulation.html: Added.
     19            * fast/shadow-dom/media-shadow-manipulation-expected.txt: Added.
     20            * fast/shadow-dom/media-shadow-manipulation.html: Added.
     21            * fast/shadow-dom/range-input-element-shadow-manipulation-expected.txt: Added.
     22            * fast/shadow-dom/range-input-element-shadow-manipulation.html: Added.
     23            * fast/shadow-dom/textarea-shadow-manipulation-expected.txt: Added.
     24            * fast/shadow-dom/textarea-shadow-manipulation.html: Added.
     25
    1262016-12-01  Matthew Hanson  <matthew_hanson@apple.com>
    227
  • branches/safari-602-branch/Source/WebCore/ChangeLog

    r209210 r209211  
     12016-12-01  Matthew Hanson  <matthew_hanson@apple.com>
     2
     3        Merge r209145. rdar://problem/29404231
     4
     5    2016-11-30  Brent Fulgham  <bfulgham@apple.com>
     6
     7            Use 'childOfType' template when retrieving Shadow DOM elements
     8            https://bugs.webkit.org/show_bug.cgi?id=165145
     9            <rdar://problem/29331830>
     10
     11            Reviewed by Antti Koivisto.
     12
     13            Tests: fast/shadow-dom/color-input-element-shadow-manipulation.html
     14                   fast/shadow-dom/file-input-element-shadow-manipulation.html
     15                   fast/shadow-dom/keygen-shadow-manipulation.html
     16                   fast/shadow-dom/media-shadow-manipulation.html
     17                   fast/shadow-dom/range-input-element-shadow-manipulation.html
     18                   fast/shadow-dom/textarea-shadow-manipulation.html
     19
     20            Switch to using 'childOfType' when retrieving Shadow DOM elements, rather
     21            than relying on expected element positions, as these can be changed by
     22            JavaScript.
     23
     24            Drive by fix: Make more use of is<> and downcast<> templates rather than blindly casting.
     25
     26            * dom/Element.h:
     27            (WebCore::Element::isUploadButton): Added.
     28            (WebCore::Element::isSliderContainerElement): Added.
     29            * html/ColorInputType.cpp:
     30            (WebCore::ColorInputType::shadowColorSwatch): Use 'childOfType' rather than assuming
     31            the first child is the one we want.
     32            * html/FileInputType.cpp:
     33            (isType): Added.
     34            (WebCore::FileInputType::disabledAttributeChanged): Use 'childOfType' rather than assuming
     35            the first child is the one we want.
     36            (WebCore::FileInputType::multipleAttributeChanged): Ditto.
     37            * html/HTMLKeygenElement.cpp:
     38            (WebCore::HTMLKeygenElement::shadowSelect): Ditto.
     39            * html/HTMLMediaElement.cpp:
     40            (WebCore::HTMLMediaElement::mediaControls): Ditto.
     41            (WebCore::HTMLMediaElement::hasMediaControls): Ditto.
     42            * html/HTMLTextAreaElement.cpp:
     43            (WebCore::HTMLTextAreaElement::innerTextElement): Ditto.
     44            * html/RangeInputType.cpp:
     45            (WebCore::RangeInputType::sliderTrackElement): Ditto.
     46            * html/shadow/SliderThumbElement.h:
     47            (isType): Added.
     48            * svg/SVGUseElement.cpp:
     49            (WebCore::SVGUseElement::targetClone): Use 'childOfType' rather than assuming
     50            the first child is the one we want.
     51
    1522016-12-01  Matthew Hanson  <matthew_hanson@apple.com>
    253
  • branches/safari-602-branch/Source/WebCore/dom/Element.h

    r207194 r209211  
    423423    virtual bool isOutOfRange() const { return false; }
    424424    virtual bool isFrameElementBase() const { return false; }
     425    virtual bool isUploadButton() const { return false; }
     426    virtual bool isSliderContainerElement() const { return false; }
    425427
    426428    bool canContainRangeEndPoint() const override;
  • branches/safari-602-branch/Source/WebCore/html/ColorInputType.cpp

    r203337 r209211  
    3939#include "Chrome.h"
    4040#include "Color.h"
     41#include "ElementChildIterator.h"
    4142#include "HTMLDataListElement.h"
    4243#include "HTMLDivElement.h"
     
    205206{
    206207    ShadowRoot* shadow = element().userAgentShadowRoot();
    207     return shadow ? downcast<HTMLElement>(shadow->firstChild()->firstChild()) : nullptr;
     208    if (!shadow)
     209        return nullptr;
     210
     211    auto wrapper = childrenOfType<HTMLDivElement>(*shadow).first();
     212    if (!wrapper)
     213        return nullptr;
     214
     215    return childrenOfType<HTMLDivElement>(*wrapper).first();
    208216}
    209217
  • branches/safari-602-branch/Source/WebCore/html/FileInputType.cpp

    r203337 r209211  
    2525#include "Chrome.h"
    2626#include "DragData.h"
     27#include "ElementChildIterator.h"
    2728#include "Event.h"
    2829#include "File.h"
     
    4041#include "ScriptController.h"
    4142#include "ShadowRoot.h"
     43#include <wtf/TypeCasts.h>
    4244#include <wtf/text/StringBuilder.h>
     45
     46
     47namespace WebCore {
     48class UploadButtonElement;
     49}
     50
     51SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::UploadButtonElement)
     52    static bool isType(const WebCore::Element& element) { return element.isUploadButton(); }
     53    static bool isType(const WebCore::Node& node) { return is<WebCore::Element>(node) && isType(downcast<WebCore::Element>(node)); }
     54SPECIALIZE_TYPE_TRAITS_END()
    4355
    4456namespace WebCore {
     
    5264
    5365private:
     66    bool isUploadButton() const override { return true; }
     67   
    5468    UploadButtonElement(Document&);
    5569};
     
    278292{
    279293    ASSERT(element().shadowRoot());
    280     UploadButtonElement* button = static_cast<UploadButtonElement*>(element().userAgentShadowRoot()->firstChild());
    281     if (button)
     294
     295    ShadowRoot* root = element().userAgentShadowRoot();
     296    if (!root)
     297        return;
     298   
     299    if (auto* button = childrenOfType<UploadButtonElement>(*root).first())
    282300        button->setBooleanAttribute(disabledAttr, element().isDisabledFormControl());
    283301}
     
    286304{
    287305    ASSERT(element().shadowRoot());
    288     UploadButtonElement* button = static_cast<UploadButtonElement*>(element().userAgentShadowRoot()->firstChild());
    289     if (button)
     306
     307    ShadowRoot* root = element().userAgentShadowRoot();
     308    if (!root)
     309        return;
     310
     311    if (auto* button = childrenOfType<UploadButtonElement>(*root).first())
    290312        button->setValue(element().multiple() ? fileButtonChooseMultipleFilesLabel() : fileButtonChooseFileLabel());
    291313}
  • branches/safari-602-branch/Source/WebCore/html/HTMLKeygenElement.cpp

    r203324 r209211  
    33 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    44 *           (C) 2001 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
     5 * Copyright (C) 2004-2006, 2010, 2012-2016 Apple Inc. All rights reserved.
    66 *           (C) 2006 Alexey Proskuryakov (ap@nypop.com)
    77 *
     
    2828#include "Attribute.h"
    2929#include "Document.h"
     30#include "ElementChildIterator.h"
    3031#include "FormDataList.h"
    3132#include "HTMLNames.h"
     
    146147{
    147148    ShadowRoot* root = userAgentShadowRoot();
    148     return root ? downcast<HTMLSelectElement>(root->firstChild()) : nullptr;
     149    if (!root)
     150        return nullptr;
     151
     152    return childrenOfType<HTMLSelectElement>(*root).first();
    149153}
    150154
  • branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.cpp

    r209209 r209211  
    59665966{
    59675967#if ENABLE(MEDIA_CONTROLS_SCRIPT)
    5968     return 0;
     5968    return nullptr;
    59695969#else
    5970     return toMediaControls(userAgentShadowRoot()->firstChild());
     5970    ShadowRoot* root = userAgentShadowRoot();
     5971    if (!root)
     5972        return nullptr;
     5973   
     5974    return childrenOfType<MediaControls>(*root).first();
    59715975#endif
    59725976}
     
    59795983
    59805984    if (ShadowRoot* userAgent = userAgentShadowRoot()) {
    5981         Node* node = userAgent->firstChild();
     5985        Node* node = childrenOfType<MediaControls>(*root).first();
    59825986        ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isMediaControls());
    59835987        return node;
  • branches/safari-602-branch/Source/WebCore/html/HTMLTextAreaElement.cpp

    r203324 r209211  
    33 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    44 *           (C) 2001 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2014 Apple Inc. All rights reserved.
     5 * Copyright (C) 2004-2008, 2010, 2014, 2016 Apple Inc. All rights reserved.
    66 *           (C) 2006 Alexey Proskuryakov (ap@nypop.com)
    77 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
     
    3131#include "Document.h"
    3232#include "Editor.h"
     33#include "ElementChildIterator.h"
    3334#include "Event.h"
    3435#include "EventHandler.h"
     
    325326TextControlInnerTextElement* HTMLTextAreaElement::innerTextElement() const
    326327{
    327     return downcast<TextControlInnerTextElement>(userAgentShadowRoot()->firstChild());
     328    ShadowRoot* root = userAgentShadowRoot();
     329    if (!root)
     330        return nullptr;
     331   
     332    return childrenOfType<TextControlInnerTextElement>(*root).first();
    328333}
    329334
  • branches/safari-602-branch/Source/WebCore/html/RangeInputType.cpp

    r203324 r209211  
    3434
    3535#include "AXObjectCache.h"
     36#include "ElementChildIterator.h"
    3637#include "EventNames.h"
    3738#include "ExceptionCodePlaceholder.h"
     
    271272    ASSERT(element().userAgentShadowRoot()->firstChild()->firstChild()); // track
    272273
    273     return downcast<HTMLElement>(element().userAgentShadowRoot()->firstChild()->firstChild());
     274    ShadowRoot* root = element().userAgentShadowRoot();
     275    if (!root)
     276        return nullptr;
     277   
     278    auto* container = childrenOfType<SliderContainerElement>(*root).first();
     279    if (!container)
     280        return nullptr;
     281
     282    return childrenOfType<HTMLElement>(*container).first();
    274283}
    275284
  • branches/safari-602-branch/Source/WebCore/html/shadow/SliderThumbElement.h

    r200098 r209211  
    138138    Optional<ElementStyle> resolveCustomStyle(const RenderStyle&, const RenderStyle*) override;
    139139    const AtomicString& shadowPseudoId() const override;
     140    bool isSliderContainerElement() const override { return true; }
    140141
    141142    AtomicString m_shadowPseudoId;
    142143};
    143144
    144 }
     145} // namespace WebCore
     146
     147SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SliderContainerElement)
     148    static bool isType(const WebCore::Element& element) { return element.isSliderContainerElement(); }
     149    static bool isType(const WebCore::Node& node) { return is<WebCore::Element>(node) && isType(downcast<WebCore::Element>(node)); }
     150SPECIALIZE_TYPE_TRAITS_END()
    145151
    146152#endif
  • branches/safari-602-branch/Source/WebCore/svg/SVGUseElement.cpp

    r202105 r209211  
    262262    if (!root)
    263263        return nullptr;
    264     return downcast<SVGElement>(root->firstChild());
     264    return childrenOfType<SVGElement>(*root).first();
    265265}
    266266
Note: See TracChangeset for help on using the changeset viewer.