Changeset 96803 in webkit


Ignore:
Timestamp:
Oct 6, 2011 5:53:39 AM (13 years ago)
Author:
dominicc@chromium.org
Message:

Don't make virtual calls in Node::parentNode.
https://bugs.webkit.org/show_bug.cgi?id=69266

Reviewed by Antti Koivisto.

ShadowRoot and SVGShadowRoot remain semantically separate (eg
isShadowRoot/isSVGShadowRoot) but share a flag
(IsShadowRootOrSVGShadowRootFlag, hitherto IsShadowRootFlag just
for ShadowRoot). In combination with IsSVGFlag ShadowRoot (false)
can be distinguished from SVGShadowRoot (true). This lets us make
isSVGShadowRoot non-virtual.

No change in behavior => No new tests.

  • dom/Node.cpp:

(WebCore::Node::shadowHost):

  • dom/Node.h:

(WebCore::Node::isSVGShadowRoot):
(WebCore::Node::isShadowRoot):
(WebCore::Node::parentNode):
(WebCore::Node::parentNodeGuaranteedHostFree):

  • rendering/svg/SVGShadowTreeElements.cpp:

(WebCore::SVGShadowTreeContainerElement::SVGShadowTreeContainerElement):
(WebCore::SVGShadowTreeRootElement::SVGShadowTreeRootElement):

  • rendering/svg/SVGShadowTreeElements.h:
  • svg/SVGElement.cpp:

(WebCore::SVGElement::SVGElement):

  • svg/SVGElement.h:
  • svg/SVGGElement.cpp:

(WebCore::SVGGElement::SVGGElement):

  • svg/SVGGElement.h:
  • svg/SVGStyledElement.cpp:

(WebCore::SVGStyledElement::SVGStyledElement):

  • svg/SVGStyledElement.h:
  • svg/SVGStyledLocatableElement.cpp:

(WebCore::SVGStyledLocatableElement::SVGStyledLocatableElement):

  • svg/SVGStyledLocatableElement.h:
  • svg/SVGStyledTransformableElement.cpp:

(WebCore::SVGStyledTransformableElement::SVGStyledTransformableElement):

  • svg/SVGStyledTransformableElement.h:
Location:
trunk/Source/WebCore
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r96798 r96803  
     12011-10-06  Dominic Cooney   <dominicc@chromium.org>
     2
     3        Don't make virtual calls in Node::parentNode.
     4        https://bugs.webkit.org/show_bug.cgi?id=69266
     5
     6        Reviewed by Antti Koivisto.
     7
     8        ShadowRoot and SVGShadowRoot remain semantically separate (eg
     9        isShadowRoot/isSVGShadowRoot) but share a flag
     10        (IsShadowRootOrSVGShadowRootFlag, hitherto IsShadowRootFlag just
     11        for ShadowRoot). In combination with IsSVGFlag ShadowRoot (false)
     12        can be distinguished from SVGShadowRoot (true). This lets us make
     13        isSVGShadowRoot non-virtual.
     14
     15        No change in behavior => No new tests.
     16
     17        * dom/Node.cpp:
     18        (WebCore::Node::shadowHost):
     19        * dom/Node.h:
     20        (WebCore::Node::isSVGShadowRoot):
     21        (WebCore::Node::isShadowRoot):
     22        (WebCore::Node::parentNode):
     23        (WebCore::Node::parentNodeGuaranteedHostFree):
     24        * rendering/svg/SVGShadowTreeElements.cpp:
     25        (WebCore::SVGShadowTreeContainerElement::SVGShadowTreeContainerElement):
     26        (WebCore::SVGShadowTreeRootElement::SVGShadowTreeRootElement):
     27        * rendering/svg/SVGShadowTreeElements.h:
     28        * svg/SVGElement.cpp:
     29        (WebCore::SVGElement::SVGElement):
     30        * svg/SVGElement.h:
     31        * svg/SVGGElement.cpp:
     32        (WebCore::SVGGElement::SVGGElement):
     33        * svg/SVGGElement.h:
     34        * svg/SVGStyledElement.cpp:
     35        (WebCore::SVGStyledElement::SVGStyledElement):
     36        * svg/SVGStyledElement.h:
     37        * svg/SVGStyledLocatableElement.cpp:
     38        (WebCore::SVGStyledLocatableElement::SVGStyledLocatableElement):
     39        * svg/SVGStyledLocatableElement.h:
     40        * svg/SVGStyledTransformableElement.cpp:
     41        (WebCore::SVGStyledTransformableElement::SVGStyledTransformableElement):
     42        * svg/SVGStyledTransformableElement.h:
     43
    1442011-10-06  John Knottenbelt  <jknotten@chromium.org>
    245
  • trunk/Source/WebCore/dom/Node.cpp

    r96782 r96803  
    564564Element* Node::shadowHost() const
    565565{
    566     return toElement(getFlag(IsShadowRootFlag) ? parent() : 0);
     566    return toElement(isShadowRoot() ? parent() : 0);
    567567}
    568568
  • trunk/Source/WebCore/dom/Node.h

    r96782 r96803  
    199199
    200200    bool isSVGElement() const { return getFlag(IsSVGFlag); }
    201     virtual bool isSVGShadowRoot() const { return false; }
     201    bool isSVGShadowRoot() const { return getFlag(IsShadowRootOrSVGShadowRootFlag) && isSVGElement(); }
    202202#if ENABLE(SVG)
    203203    SVGUseElement* svgShadowHost() const;
     
    212212    virtual bool isCharacterDataNode() const { return false; }
    213213    bool isDocumentNode() const;
    214     bool isShadowRoot() const { return getFlag(IsShadowRootFlag); }
     214    bool isShadowRoot() const { return getFlag(IsShadowRootOrSVGShadowRootFlag) && !isSVGElement(); }
    215215    virtual bool isContentElement() const { return false; }
    216216    virtual bool canHaveLightChildRendererWithShadow() const { return false; }
     
    601601        InDetachFlag = 1 << 16,
    602602        HasRareDataFlag = 1 << 17,
    603         IsShadowRootFlag = 1 << 18,
     603        IsShadowRootOrSVGShadowRootFlag = 1 << 18,
    604604
    605605        // These bits are used by derived classes, pulled up here so they can
     
    641641        CreateContainer = DefaultNodeFlags | IsContainerFlag,
    642642        CreateElement = CreateContainer | IsElementFlag,
    643         CreateShadowRoot = CreateContainer | IsShadowRootFlag,
     643        CreateShadowRoot = CreateContainer | IsShadowRootOrSVGShadowRootFlag,
    644644        CreateStyledElement = CreateElement | IsStyledElementFlag,
    645645        CreateHTMLElement = CreateStyledElement | IsHTMLFlag,
    646646        CreateSVGElement = CreateStyledElement | IsSVGFlag,
     647        CreateSVGShadowRoot = CreateSVGElement | IsShadowRootOrSVGShadowRootFlag,
    647648    };
    648649    Node(Document*, ConstructionType);
     
    744745inline ContainerNode* Node::parentNode() const
    745746{
    746     return getFlag(IsShadowRootFlag) || isSVGShadowRoot() ? 0 : parent();
     747    return getFlag(IsShadowRootOrSVGShadowRootFlag) ? 0 : parent();
    747748}
    748749
     
    754755inline ContainerNode* Node::parentNodeGuaranteedHostFree() const
    755756{
    756     ASSERT(!getFlag(IsShadowRootFlag) && !isSVGShadowRoot());
     757    ASSERT(!getFlag(IsShadowRootOrSVGShadowRootFlag));
    757758    return parentOrHostNode();
    758759}
  • trunk/Source/WebCore/rendering/svg/SVGShadowTreeElements.cpp

    r95901 r96803  
    3434// SVGShadowTreeContainerElement
    3535
    36 SVGShadowTreeContainerElement::SVGShadowTreeContainerElement(Document* document)
    37     : SVGGElement(SVGNames::gTag, document)
     36SVGShadowTreeContainerElement::SVGShadowTreeContainerElement(Document* document, ConstructionType constructionType)
     37    : SVGGElement(SVGNames::gTag, document, constructionType)
    3838    , m_containerOffsetChanged(false)
    3939{
     
    6464
    6565inline SVGShadowTreeRootElement::SVGShadowTreeRootElement(Document* document, SVGUseElement* host)
    66     : SVGShadowTreeContainerElement(document)
     66    : SVGShadowTreeContainerElement(document, CreateSVGShadowRoot)
    6767{
    6868    setParent(host);
  • trunk/Source/WebCore/rendering/svg/SVGShadowTreeElements.h

    r95901 r96803  
    4343
    4444protected:
    45     SVGShadowTreeContainerElement(Document*);
     45    SVGShadowTreeContainerElement(Document*, ConstructionType = CreateSVGElement);
    4646
    4747private:
     
    6161    void clearSVGShadowHost();
    6262
    63     virtual bool isSVGShadowRoot() const { return true; }
    64 
    6563private:
    6664    SVGShadowTreeRootElement(Document*, SVGUseElement* host);
  • trunk/Source/WebCore/svg/SVGElement.cpp

    r94659 r96803  
    5656using namespace HTMLNames;
    5757
    58 SVGElement::SVGElement(const QualifiedName& tagName, Document* document)
    59     : StyledElement(tagName, document, CreateSVGElement)
     58SVGElement::SVGElement(const QualifiedName& tagName, Document* document, ConstructionType constructionType)
     59    : StyledElement(tagName, document, constructionType)
    6060{
    6161    setHasCustomStyleForRenderer();
  • trunk/Source/WebCore/svg/SVGElement.h

    r96307 r96803  
    103103
    104104protected:
    105     SVGElement(const QualifiedName&, Document*);
     105    SVGElement(const QualifiedName&, Document*, ConstructionType = CreateSVGElement);
    106106
    107107    virtual void parseMappedAttribute(Attribute*);
  • trunk/Source/WebCore/svg/SVGGElement.cpp

    r96307 r96803  
    4141END_REGISTER_ANIMATED_PROPERTIES
    4242
    43 SVGGElement::SVGGElement(const QualifiedName& tagName, Document* document)
    44     : SVGStyledTransformableElement(tagName, document)
     43SVGGElement::SVGGElement(const QualifiedName& tagName, Document* document, ConstructionType constructionType)
     44    : SVGStyledTransformableElement(tagName, document, constructionType)
    4545{
    4646    ASSERT(hasTagName(SVGNames::gTag));
  • trunk/Source/WebCore/svg/SVGGElement.h

    r90680 r96803  
    4141
    4242protected:
    43     SVGGElement(const QualifiedName&, Document*);
     43    SVGGElement(const QualifiedName&, Document*, ConstructionType = CreateSVGElement);
    4444
    4545    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
  • trunk/Source/WebCore/svg/SVGStyledElement.cpp

    r94928 r96803  
    6565}
    6666
    67 SVGStyledElement::SVGStyledElement(const QualifiedName& tagName, Document* document)
    68     : SVGElement(tagName, document)
     67SVGStyledElement::SVGStyledElement(const QualifiedName& tagName, Document* document, ConstructionType constructionType)
     68    : SVGElement(tagName, document, constructionType)
    6969{
    7070    registerAnimatedPropertiesForSVGStyledElement();
  • trunk/Source/WebCore/svg/SVGStyledElement.h

    r95047 r96803  
    6363
    6464protected:
    65     SVGStyledElement(const QualifiedName&, Document*);
     65    SVGStyledElement(const QualifiedName&, Document*, ConstructionType = CreateSVGElement);
    6666    virtual bool rendererIsNeeded(const NodeRenderingContext&);
    6767
  • trunk/Source/WebCore/svg/SVGStyledLocatableElement.cpp

    r91404 r96803  
    3030namespace WebCore {
    3131
    32 SVGStyledLocatableElement::SVGStyledLocatableElement(const QualifiedName& tagName, Document* document)
    33     : SVGStyledElement(tagName, document)
     32SVGStyledLocatableElement::SVGStyledLocatableElement(const QualifiedName& tagName, Document* document, ConstructionType constructionType)
     33    : SVGStyledElement(tagName, document, constructionType)
    3434{
    3535}
  • trunk/Source/WebCore/svg/SVGStyledLocatableElement.h

    r91404 r96803  
    4343
    4444protected:
    45     SVGStyledLocatableElement(const QualifiedName&, Document*);
     45    SVGStyledLocatableElement(const QualifiedName&, Document*, ConstructionType = CreateSVGElement);
    4646
    4747private:
  • trunk/Source/WebCore/svg/SVGStyledTransformableElement.cpp

    r96307 r96803  
    4141END_REGISTER_ANIMATED_PROPERTIES
    4242
    43 SVGStyledTransformableElement::SVGStyledTransformableElement(const QualifiedName& tagName, Document* document)
    44     : SVGStyledLocatableElement(tagName, document)
     43SVGStyledTransformableElement::SVGStyledTransformableElement(const QualifiedName& tagName, Document* document, ConstructionType constructionType)
     44    : SVGStyledLocatableElement(tagName, document, constructionType)
    4545{
    4646    registerAnimatedPropertiesForSVGStyledTransformableElement();
  • trunk/Source/WebCore/svg/SVGStyledTransformableElement.h

    r91404 r96803  
    5454
    5555protected:
    56     SVGStyledTransformableElement(const QualifiedName&, Document*);
     56    SVGStyledTransformableElement(const QualifiedName&, Document*, ConstructionType = CreateSVGElement);
    5757
    5858    bool isSupportedAttribute(const QualifiedName&);
Note: See TracChangeset for help on using the changeset viewer.