Changeset 84225 in webkit


Ignore:
Timestamp:
Apr 18, 2011 10:44:15 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-04-18 Dominic Cooney <dominicc@chromium.org>

Reviewed by Dimitri Glazkov.

Makes SVG shadow roots and DOM shadow roots distinct.
https://bugs.webkit.org/show_bug.cgi?id=52788

Not a functional change. Covered by existing SVG tests.

  • dom/EventDispatcher.cpp: (WebCore::findElementInstance): (WebCore::EventDispatcher::adjustToShadowBoundaries): (WebCore::EventDispatcher::adjustRelatedTarget): (WebCore::EventDispatcher::ensureEventAncestors):
  • dom/Node.cpp: (WebCore::Node::setShadowHost): (WebCore::Node::svgShadowHost): (WebCore::Node::shadowTreeRootNode):
  • dom/Node.h: (WebCore::Node::isSVGShadowRoot): (WebCore::Node::parentNode): (WebCore::Node::parentNodeGuaranteedHostFree):
  • rendering/svg/RenderSVGShadowTreeRootContainer.cpp: (WebCore::RenderSVGShadowTreeRootContainer::~RenderSVGShadowTreeRootContainer): (WebCore::RenderSVGShadowTreeRootContainer::updateFromElement):
  • rendering/svg/SVGShadowTreeElements.cpp: (WebCore::SVGShadowTreeRootElement::SVGShadowTreeRootElement): (WebCore::SVGShadowTreeRootElement::create): (WebCore::SVGShadowTreeRootElement::attachElement): (WebCore::SVGShadowTreeRootElement::clearSVGShadowHost):
  • rendering/svg/SVGShadowTreeElements.h: (WebCore::SVGShadowTreeRootElement::isSVGShadowRoot):
  • svg/SVGStyledElement.cpp: (WebCore::SVGStyledElement::title):
Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r84224 r84225  
     12011-04-18  Dominic Cooney  <dominicc@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Makes SVG shadow roots and DOM shadow roots distinct.
     6        https://bugs.webkit.org/show_bug.cgi?id=52788
     7
     8        Not a functional change. Covered by existing SVG tests.
     9
     10        * dom/EventDispatcher.cpp:
     11        (WebCore::findElementInstance):
     12        (WebCore::EventDispatcher::adjustToShadowBoundaries):
     13        (WebCore::EventDispatcher::adjustRelatedTarget):
     14        (WebCore::EventDispatcher::ensureEventAncestors):
     15        * dom/Node.cpp:
     16        (WebCore::Node::setShadowHost):
     17        (WebCore::Node::svgShadowHost):
     18        (WebCore::Node::shadowTreeRootNode):
     19        * dom/Node.h:
     20        (WebCore::Node::isSVGShadowRoot):
     21        (WebCore::Node::parentNode):
     22        (WebCore::Node::parentNodeGuaranteedHostFree):
     23        * rendering/svg/RenderSVGShadowTreeRootContainer.cpp:
     24        (WebCore::RenderSVGShadowTreeRootContainer::~RenderSVGShadowTreeRootContainer):
     25        (WebCore::RenderSVGShadowTreeRootContainer::updateFromElement):
     26        * rendering/svg/SVGShadowTreeElements.cpp:
     27        (WebCore::SVGShadowTreeRootElement::SVGShadowTreeRootElement):
     28        (WebCore::SVGShadowTreeRootElement::create):
     29        (WebCore::SVGShadowTreeRootElement::attachElement):
     30        (WebCore::SVGShadowTreeRootElement::clearSVGShadowHost):
     31        * rendering/svg/SVGShadowTreeElements.h:
     32        (WebCore::SVGShadowTreeRootElement::isSVGShadowRoot):
     33        * svg/SVGStyledElement.cpp:
     34        (WebCore::SVGStyledElement::title):
     35
    1362011-04-18  Taiju TSUIKI  <develop@tzik.jp>
    237
  • trunk/Source/WebCore/dom/EventDispatcher.cpp

    r83386 r84225  
    6666    // as a deeply cloned child of the 'use' element, except that events are dispatched to the SVGElementInstance objects
    6767    for (Node* n = referenceNode; n; n = n->parentNode()) {
    68         if (!n->isShadowRoot() || !n->isSVGElement())
     68        if (!n->isSVGShadowRoot() || !n->isSVGElement())
    6969            continue;
    7070
    71         Element* shadowTreeParentElement = n->shadowHost();
     71        Element* shadowTreeParentElement = n->svgShadowHost();
    7272        ASSERT(shadowTreeParentElement->hasTagName(SVGNames::useTag));
    7373
     
    123123}
    124124
     125static inline bool isShadowRootOrSVGShadowRoot(const Node* node)
     126{
     127    return node->isShadowRoot() || node->isSVGShadowRoot();
     128}
     129
    125130PassRefPtr<EventTarget> EventDispatcher::adjustToShadowBoundaries(PassRefPtr<Node> relatedTarget, const Vector<Node*> relatedTargetAncestors)
    126131{
     
    134139    for (Vector<Node*>::const_iterator i = relatedTargetAncestors.end() - 1; i >= relatedTargetAncestors.begin(); --i) {
    135140        if (diverged) {
    136             if ((*i)->isShadowRoot()) {
     141            if (isShadowRootOrSVGShadowRoot(*i)) {
    137142                firstDivergentBoundary = i + 1;
    138143                break;
     
    148153        targetAncestor--;
    149154
    150         if ((*i)->isShadowRoot())
     155        if (isShadowRootOrSVGShadowRoot(*i))
    151156            lowestCommonBoundary = targetAncestor;
    152157
     
    157162    if (!diverged) {
    158163        // The relatedTarget is a parent or shadowHost of the target.
    159         if (m_node->isShadowRoot())
     164        if (isShadowRootOrSVGShadowRoot(m_node.get()))
    160165            lowestCommonBoundary = m_ancestors.begin();
    161166    } else if ((*firstDivergentBoundary) == m_node.get()) {
     
    204209    Node* outermostShadowBoundary = relatedTarget.get();
    205210    for (Node* n = outermostShadowBoundary; n; n = n->parentOrHostNode()) {
    206         if (n->isShadowRoot())
     211        if (isShadowRootOrSVGShadowRoot(n))
    207212            outermostShadowBoundary = n->parentOrHostNode();
    208213        if (!noCommonBoundary)
     
    241246    bool shouldSkipNextAncestor = false;
    242247    while (true) {
    243         if (ancestor->isShadowRoot()) {
     248        bool isSVGShadowRoot = ancestor->isSVGShadowRoot();
     249        if (isSVGShadowRoot || ancestor->isShadowRoot()) {
    244250            if (behavior == StayInsideShadowDOM)
    245251                return;
    246             ancestor = ancestor->shadowHost();
     252            ancestor = isSVGShadowRoot ? ancestor->svgShadowHost() : ancestor->shadowHost();
    247253            if (!shouldSkipNextAncestor)
    248254                target = ancestor;
     
    255261#if ENABLE(SVG)
    256262        // Skip SVGShadowTreeRootElement.
    257         shouldSkipNextAncestor = ancestor->isSVGElement() && ancestor->isShadowRoot();
     263        shouldSkipNextAncestor = ancestor->isSVGShadowRoot();
    258264        if (shouldSkipNextAncestor)
    259265            continue;
  • trunk/Source/WebCore/dom/Node.cpp

    r84050 r84225  
    549549void Node::setShadowHost(Element* host)
    550550{
    551     ASSERT(!parentNode());
     551    ASSERT(!parentNode() && !isSVGShadowRoot());
    552552    if (host)
    553553        setFlag(IsShadowRootFlag);
     
    16031603}
    16041604
     1605#if ENABLE(SVG)
     1606SVGUseElement* Node::svgShadowHost() const
     1607{
     1608    return isSVGShadowRoot() ? static_cast<SVGUseElement*>(parent()) : 0;
     1609}
     1610#endif
     1611
    16051612Node* Node::shadowAncestorNode()
    16061613{
     
    16241631    Node* root = this;
    16251632    while (root) {
    1626         if (root->isShadowRoot())
     1633        if (root->isShadowRoot() || root->isSVGShadowRoot())
    16271634            return root;
    16281635        root = root->parentNodeGuaranteedHostFree();
  • trunk/Source/WebCore/dom/Node.h

    r84050 r84225  
    7272class RenderObject;
    7373class RenderStyle;
     74#if ENABLE(SVG)
     75class SVGUseElement;
     76#endif
    7477class TagNodeList;
    7578class TreeScope;
     
    192195
    193196    bool isSVGElement() const { return getFlag(IsSVGFlag); }
     197    virtual bool isSVGShadowRoot() const { return false; }
     198#if ENABLE(SVG)
     199    SVGUseElement* svgShadowHost() const;
     200#endif
    194201
    195202#if ENABLE(WML)
     
    214221    Node* shadowTreeRootNode();
    215222    bool isInShadowTree();
    216     // Node's parent or shadow tree host.
     223    // Node's parent, shadow tree host, or SVG use.
    217224    ContainerNode* parentOrHostNode() const;
    218     // Use when it's guaranteed to that shadowHost is 0.
     225    // Use when it's guaranteed to that shadowHost is 0 and svgShadowHost is 0.
    219226    ContainerNode* parentNodeGuaranteedHostFree() const;
    220227
     
    734741inline ContainerNode* Node::parentNode() const
    735742{
    736     return getFlag(IsShadowRootFlag) ? 0 : parent();
     743    return getFlag(IsShadowRootFlag) || isSVGShadowRoot() ? 0 : parent();
    737744}
    738745
     
    744751inline ContainerNode* Node::parentNodeGuaranteedHostFree() const
    745752{
    746     ASSERT(!getFlag(IsShadowRootFlag));
     753    ASSERT(!getFlag(IsShadowRootFlag) && !isSVGShadowRoot());
    747754    return parentOrHostNode();
    748755}
  • trunk/Source/WebCore/rendering/svg/RenderSVGShadowTreeRootContainer.cpp

    r75350 r84225  
    3939    if (m_shadowRoot && m_shadowRoot->attached()) {
    4040        m_shadowRoot->detach();
    41         m_shadowRoot->clearShadowHost();
     41        m_shadowRoot->clearSVGShadowHost();
    4242    }
    4343}
     
    6060    }
    6161
    62     ASSERT(m_shadowRoot->shadowHost() == useElement);
     62    ASSERT(m_shadowRoot->svgShadowHost() == useElement);
    6363
    6464    bool shouldRecreateTree = m_recreateTree;
  • trunk/Source/WebCore/rendering/svg/SVGShadowTreeElements.cpp

    r82242 r84225  
    5454// SVGShadowTreeRootElement
    5555
    56 inline SVGShadowTreeRootElement::SVGShadowTreeRootElement(Document* document, SVGUseElement* shadowParent)
     56inline SVGShadowTreeRootElement::SVGShadowTreeRootElement(Document* document, SVGUseElement* host)
    5757    : SVGShadowTreeContainerElement(document)
    5858{
    59     setShadowHost(shadowParent);
     59    setParent(host);
    6060    setInDocument();
    6161}
    6262
    63 PassRefPtr<SVGShadowTreeRootElement> SVGShadowTreeRootElement::create(Document* document, SVGUseElement* shadowParent)
     63PassRefPtr<SVGShadowTreeRootElement> SVGShadowTreeRootElement::create(Document* document, SVGUseElement* host)
    6464{
    65     return adoptRef(new SVGShadowTreeRootElement(document, shadowParent));
     65    return adoptRef(new SVGShadowTreeRootElement(document, host));
    6666}
    6767
    6868void SVGShadowTreeRootElement::attachElement(PassRefPtr<RenderStyle> style, RenderArena* arena)
    6969{
    70     ASSERT(shadowHost());
     70    ASSERT(svgShadowHost());
    7171
    7272    // Create the renderer with the specified style
     
    8282    // Add the renderer to the render tree
    8383    if (renderer)
    84         shadowHost()->renderer()->addChild(renderer);
     84        svgShadowHost()->renderer()->addChild(renderer);
    8585}
    8686
    87 void SVGShadowTreeRootElement::clearShadowHost()
     87void SVGShadowTreeRootElement::clearSVGShadowHost()
    8888{
    89     setShadowHost(0);
     89    setParent(0);
    9090}
    9191
  • trunk/Source/WebCore/rendering/svg/SVGShadowTreeElements.h

    r82242 r84225  
    5454class SVGShadowTreeRootElement : public SVGShadowTreeContainerElement {
    5555public:
    56     static PassRefPtr<SVGShadowTreeRootElement> create(Document*, SVGUseElement* shadowParent);
     56    static PassRefPtr<SVGShadowTreeRootElement> create(Document*, SVGUseElement* host);
    5757
    5858    void attachElement(PassRefPtr<RenderStyle>, RenderArena*);
    59     void clearShadowHost();
     59    void clearSVGShadowHost();
     60
     61    virtual bool isSVGShadowRoot() const { return true; }
    6062
    6163private:
    62     SVGShadowTreeRootElement(Document*, SVGUseElement* shadowParent);
     64    SVGShadowTreeRootElement(Document*, SVGUseElement* host);
    6365};
    6466
  • trunk/Source/WebCore/svg/SVGStyledElement.cpp

    r78543 r84225  
    8282    Node* parent = const_cast<SVGStyledElement*>(this);
    8383    while (parent) {
    84         if (!parent->isShadowRoot()) {
     84        if (!parent->isSVGShadowRoot()) {
    8585            parent = parent->parentNodeGuaranteedHostFree();
    8686            continue;
     
    8888       
    8989        // Get the <use> element.
    90         Element* shadowParent = parent->shadowHost();
     90        Element* shadowParent = parent->svgShadowHost();
    9191        if (shadowParent && shadowParent->isSVGElement() && shadowParent->hasTagName(SVGNames::useTag)) {
    9292            SVGUseElement* useElement = static_cast<SVGUseElement*>(shadowParent);
Note: See TracChangeset for help on using the changeset viewer.