Changeset 122298 in webkit


Ignore:
Timestamp:
Jul 10, 2012 10:43:06 PM (12 years ago)
Author:
shinyak@chromium.org
Message:

ShadowRoot should know its type in debug build.
https://bugs.webkit.org/show_bug.cgi?id=90933

Reviewed by Hajime Morita.

For assertion, ShadowRoot should know its type is UserAgentShadowRoot or AuthorShadowRoot.

This patch also renames ShadowRootCreationPurpose to ShadowRootType, since it is suitable
name for ShadowRoot to have.

No new tests, since it is used only for assertion.

  • dom/Element.cpp:

(WebCore::Element::ensureShadowRoot):

  • dom/ShadowRoot.cpp:

(WebCore::ShadowRoot::create):

  • dom/ShadowRoot.h:

(ShadowRoot):
(WebCore::ShadowRoot::type):

  • html/HTMLDetailsElement.cpp:

(WebCore::HTMLDetailsElement::createShadowSubtree):

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::createShadowSubtree):

  • html/HTMLKeygenElement.cpp:

(WebCore::HTMLKeygenElement::HTMLKeygenElement):

  • html/HTMLMeterElement.cpp:

(WebCore::HTMLMeterElement::createShadowSubtree):

  • html/HTMLProgressElement.cpp:

(WebCore::HTMLProgressElement::createShadowSubtree):

  • html/HTMLSummaryElement.cpp:

(WebCore::HTMLSummaryElement::createShadowSubtree):

  • html/HTMLTextAreaElement.cpp:

(WebCore::HTMLTextAreaElement::createShadowSubtree):

  • html/InputType.cpp:

(WebCore::InputType::destroyShadowSubtree): Asserts that ShadowRoot type is UserAgentShadowRoot.

  • html/shadow/TextFieldDecorationElement.cpp:

(WebCore::getDecorationRootAndDecoratedRoot):

  • svg/SVGTRefElement.cpp:

(WebCore::SVGTRefElement::createShadowSubtree):

Location:
trunk/Source/WebCore
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r122295 r122298  
     12012-07-10  Shinya Kawanaka  <shinyak@chromium.org>
     2
     3        ShadowRoot should know its type in debug build.
     4        https://bugs.webkit.org/show_bug.cgi?id=90933
     5
     6        Reviewed by Hajime Morita.
     7
     8        For assertion, ShadowRoot should know its type is UserAgentShadowRoot or AuthorShadowRoot.
     9
     10        This patch also renames ShadowRootCreationPurpose to ShadowRootType, since it is suitable
     11        name for ShadowRoot to have.
     12
     13        No new tests, since it is used only for assertion.
     14
     15        * dom/Element.cpp:
     16        (WebCore::Element::ensureShadowRoot):
     17        * dom/ShadowRoot.cpp:
     18        (WebCore::ShadowRoot::create):
     19        * dom/ShadowRoot.h:
     20        (ShadowRoot):
     21        (WebCore::ShadowRoot::type):
     22        * html/HTMLDetailsElement.cpp:
     23        (WebCore::HTMLDetailsElement::createShadowSubtree):
     24        * html/HTMLInputElement.cpp:
     25        (WebCore::HTMLInputElement::createShadowSubtree):
     26        * html/HTMLKeygenElement.cpp:
     27        (WebCore::HTMLKeygenElement::HTMLKeygenElement):
     28        * html/HTMLMeterElement.cpp:
     29        (WebCore::HTMLMeterElement::createShadowSubtree):
     30        * html/HTMLProgressElement.cpp:
     31        (WebCore::HTMLProgressElement::createShadowSubtree):
     32        * html/HTMLSummaryElement.cpp:
     33        (WebCore::HTMLSummaryElement::createShadowSubtree):
     34        * html/HTMLTextAreaElement.cpp:
     35        (WebCore::HTMLTextAreaElement::createShadowSubtree):
     36        * html/InputType.cpp:
     37        (WebCore::InputType::destroyShadowSubtree): Asserts that ShadowRoot type is UserAgentShadowRoot.
     38        * html/shadow/TextFieldDecorationElement.cpp:
     39        (WebCore::getDecorationRootAndDecoratedRoot):
     40        * svg/SVGTRefElement.cpp:
     41        (WebCore::SVGTRefElement::createShadowSubtree):
     42
    1432012-07-10  George Staikos  <staikos@webkit.org>
    244
  • trunk/Source/WebCore/dom/Element.cpp

    r122188 r122298  
    11821182        return shadow->oldestShadowRoot();
    11831183
    1184     return ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot).get();
     1184    return ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot).get();
    11851185}
    11861186
  • trunk/Source/WebCore/dom/ShadowRoot.cpp

    r119799 r122298  
    100100PassRefPtr<ShadowRoot> ShadowRoot::create(Element* element, ExceptionCode& ec)
    101101{
    102     return create(element, CreatingAuthorShadowRoot, ec);
    103 }
    104 
    105 PassRefPtr<ShadowRoot> ShadowRoot::create(Element* element, ShadowRootCreationPurpose purpose, ExceptionCode& ec)
     102    return create(element, AuthorShadowRoot, ec);
     103}
     104
     105PassRefPtr<ShadowRoot> ShadowRoot::create(Element* element, ShadowRootType type, ExceptionCode& ec)
    106106{
    107107    if (!element) {
     
    112112    // Since some elements recreates shadow root dynamically, multiple shadow subtrees won't work well in that element.
    113113    // Until they are fixed, we disable adding author shadow root for them.
    114     if (purpose == CreatingAuthorShadowRoot && !allowsAuthorShadowRoot(element)) {
     114    if (type == AuthorShadowRoot && !allowsAuthorShadowRoot(element)) {
    115115        ec = HIERARCHY_REQUEST_ERR;
    116116        return 0;
     
    118118
    119119    RefPtr<ShadowRoot> shadowRoot = adoptRef(new ShadowRoot(element->document()));
     120#ifndef NDEBUG
     121    shadowRoot->m_type = type;
     122#endif
    120123
    121124    ec = 0;
  • trunk/Source/WebCore/dom/ShadowRoot.h

    r119799 r122298  
    5252    // in several elements for a while.
    5353    // See https://bugs.webkit.org/show_bug.cgi?id=77503 and related bugs.
    54     enum ShadowRootCreationPurpose {
    55         CreatingUserAgentShadowRoot,
    56         CreatingAuthorShadowRoot,
     54    enum ShadowRootType {
     55        UserAgentShadowRoot,
     56        AuthorShadowRoot
    5757    };
    58     static PassRefPtr<ShadowRoot> create(Element*, ShadowRootCreationPurpose, ExceptionCode& = ASSERT_NO_EXCEPTION);
     58    static PassRefPtr<ShadowRoot> create(Element*, ShadowRootType, ExceptionCode& = ASSERT_NO_EXCEPTION);
    5959
    6060    void recalcShadowTreeStyle(StyleChange);
     
    9090    void setAssignedTo(InsertionPoint*);
    9191
     92#ifndef NDEBUG
     93    ShadowRootType type() const { return m_type; }
     94#endif
     95
    9296private:
    9397    ShadowRoot(Document*);
     
    103107    bool m_resetStyleInheritance : 1;
    104108    InsertionPoint* m_insertionPointAssignedTo;
     109
     110#ifndef NDEBUG
     111    ShadowRootType m_type;
     112#endif
    105113};
    106114
  • trunk/Source/WebCore/html/HTMLDetailsElement.cpp

    r117195 r122298  
    113113    ASSERT(!shadow());
    114114
    115     RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot);
     115    RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot);
    116116    root->appendChild(DetailsSummaryElement::create(document()), ASSERT_NO_EXCEPTION, true);
    117117    root->appendChild(DetailsContentElement::create(document()), ASSERT_NO_EXCEPTION, true);
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r122286 r122298  
    119119{
    120120    ASSERT(!shadow());
    121     ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot, ASSERT_NO_EXCEPTION);
     121    ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot, ASSERT_NO_EXCEPTION);
    122122
    123123    m_inputType->createShadowSubtree();
  • trunk/Source/WebCore/html/HTMLKeygenElement.cpp

    r117195 r122298  
    8888
    8989    ASSERT(!shadow());
    90     RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot);
     90    RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot);
    9191    root->appendChild(select, ec);
    9292}
  • trunk/Source/WebCore/html/HTMLMeterElement.cpp

    r117929 r122298  
    229229    bar->appendChild(m_value, ec);
    230230
    231     RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot);
     231    RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot);
    232232    root->appendChild(bar, ec);
    233233}
  • trunk/Source/WebCore/html/HTMLProgressElement.cpp

    r118236 r122298  
    152152    bar->appendChild(m_value, ASSERT_NO_EXCEPTION);
    153153
    154     RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot, ASSERT_NO_EXCEPTION);
     154    RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot, ASSERT_NO_EXCEPTION);
    155155    root->appendChild(bar, ASSERT_NO_EXCEPTION);
    156156}
  • trunk/Source/WebCore/html/HTMLSummaryElement.cpp

    r116730 r122298  
    8282{
    8383    ASSERT(!shadow());
    84     RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot);
     84    RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot);
    8585    root->appendChild(DetailsMarkerControl::create(document()), ASSERT_NO_EXCEPTION, true);
    8686    root->appendChild(SummaryContentElement::create(document()), ASSERT_NO_EXCEPTION, true);
  • trunk/Source/WebCore/html/HTMLTextAreaElement.cpp

    r121552 r122298  
    9090{
    9191    ASSERT(!shadow());
    92     RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot);
     92    RefPtr<ShadowRoot> root = ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot);
    9393    root->appendChild(TextControlInnerTextElement::create(document()), ASSERT_NO_EXCEPTION);
    9494}
  • trunk/Source/WebCore/html/InputType.cpp

    r122286 r122298  
    454454
    455455    ShadowRoot* root = shadow->oldestShadowRoot();
     456    ASSERT(root->type() == ShadowRoot::UserAgentShadowRoot);
    456457    root->removeAllChildren();
    457458
  • trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.cpp

    r119020 r122298  
    9090        newRoot->removeChild(newRoot->firstChild());
    9191    else
    92         newRoot = ShadowRoot::create(input, ShadowRoot::CreatingUserAgentShadowRoot, ASSERT_NO_EXCEPTION).get();
     92        newRoot = ShadowRoot::create(input, ShadowRoot::UserAgentShadowRoot, ASSERT_NO_EXCEPTION).get();
    9393    decorationRoot = newRoot;
    9494    decoratedRoot = existingRoot;
  • trunk/Source/WebCore/svg/SVGTRefElement.cpp

    r121508 r122298  
    156156void SVGTRefElement::createShadowSubtree()
    157157{
    158     ShadowRoot::create(this, ShadowRoot::CreatingUserAgentShadowRoot, ASSERT_NO_EXCEPTION);
     158    ShadowRoot::create(this, ShadowRoot::UserAgentShadowRoot, ASSERT_NO_EXCEPTION);
    159159}
    160160
Note: See TracChangeset for help on using the changeset viewer.