Changeset 74715 in webkit


Ignore:
Timestamp:
Dec 28, 2010 10:55:42 AM (13 years ago)
Author:
Dimitri Glazkov
Message:

2010-12-28 Dimitri Glazkov <Dimitri Glazkov>

Reviewed by Eric Seidel.

Combine setShadowRoot and clearShadowRoot into a simpler API
https://bugs.webkit.org/show_bug.cgi?id=50971

No change in behavior, and API is not used yet.

  • dom/Element.cpp: (WebCore::Element::setShadowRoot): Combined clearing and setting of

the shadowRoot, also hooked up with setting and clearing of the
corresponding shadowHost values.

  • dom/Element.h: renamed clearShadowRoot to removeShadowRoot and made it

private.

  • dom/Node.h: Made shadow host-related functions public so that

Element::setShadowRoot can access setShadowHost. It seems logical
to make shadowHost public as well to keep the defs together.

Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r74714 r74715  
     12010-12-28  Dimitri Glazkov  <dglazkov@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Combine setShadowRoot and clearShadowRoot into a simpler API
     6        https://bugs.webkit.org/show_bug.cgi?id=50971
     7
     8        No change in behavior, and API is not used yet.
     9
     10        * dom/Element.cpp:
     11        (WebCore::Element::setShadowRoot): Combined clearing and setting of
     12            the shadowRoot, also hooked up with setting and clearing of the
     13            corresponding shadowHost values.
     14        * dom/Element.h: renamed clearShadowRoot to removeShadowRoot and made it
     15            private.
     16        * dom/Node.h: Made shadow host-related functions public so that
     17            Element::setShadowRoot can access setShadowHost. It seems logical
     18            to make shadowHost public as well to keep the defs together.
     19
    1202010-12-28  Andrey Kosyakov  <caseq@chromium.org>
    221
  • trunk/WebCore/dom/Element.cpp

    r73983 r74715  
    10831083void Element::setShadowRoot(PassRefPtr<Node> node)
    10841084{
    1085     ASSERT(node);
    1086 
    1087     // FIXME: Once all instances of shadow DOM are converted to use this code, add setting of shadow host (shadowParent) on node.
    1088     ensureRareData()->m_shadowRoot = node;
    1089 }
    1090 
    1091 void Element::clearShadowRoot()
     1085    // FIXME: Because today this is never called from script directly, we don't have to worry
     1086    // about compromising DOM tree integrity (eg. node being a parent of this). However,
     1087    // once we implement XBL2, we will have to add integrity checks here.
     1088    removeShadowRoot();
     1089    RefPtr<Node> newRoot = node;
     1090    if (!newRoot)
     1091        return;
     1092
     1093    ensureRareData()->m_shadowRoot = newRoot;
     1094    newRoot->setShadowHost(this);
     1095}
     1096
     1097void Element::removeShadowRoot()
    10921098{
    10931099    if (!hasRareData())
    10941100        return;
    10951101
    1096     RefPtr<Node> shadowRoot = rareData()->m_shadowRoot.release();
    1097     document()->removeFocusedNodeOfSubtree(shadowRoot.get());
    1098     // FIXME: Once all instances of shadow DOM are converted to use this code, add clearing of shadow host (shadowParent).
    1099     if (shadowRoot->inDocument())
    1100         shadowRoot->removedFromDocument();
    1101     else
    1102         shadowRoot->removedFromTree(true);
     1102    if (RefPtr<Node> oldRoot = rareData()->m_shadowRoot.release()) {
     1103        document()->removeFocusedNodeOfSubtree(oldRoot.get());
     1104        oldRoot->setShadowHost(0);
     1105        if (oldRoot->inDocument())
     1106            oldRoot->removedFromDocument();
     1107        else
     1108            oldRoot->removedFromTree(true);
     1109    }
    11031110}
    11041111
  • trunk/WebCore/dom/Element.h

    r73114 r74715  
    228228    Node* shadowRoot();
    229229    void setShadowRoot(PassRefPtr<Node>);
    230     void clearShadowRoot();
    231230
    232231    RenderStyle* computedStyle(PseudoId = NOPSEUDO);
     
    393392
    394393    SpellcheckAttributeState spellcheckAttributeState() const;
     394    void removeShadowRoot();
    395395
    396396private:
  • trunk/WebCore/dom/Node.h

    r74406 r74715  
    217217    ContainerNode* parentNodeGuaranteedHostFree() const;
    218218
     219    Element* shadowHost() const;
     220    void setShadowHost(Element*);
     221
    219222    // Returns the enclosing event parent node (or self) that, when clicked, would trigger a navigation.
    220223    Node* enclosingLinkEventParentOrSelf();
     
    639642    NodeRareData* ensureRareData();
    640643
    641     Element* shadowHost() const;
    642     void setShadowHost(Element*);
    643 
    644644private:
    645645#if USE(JSC)
Note: See TracChangeset for help on using the changeset viewer.