Changeset 160536 in webkit


Ignore:
Timestamp:
Dec 13, 2013 1:14:30 AM (10 years ago)
Author:
Darin Adler
Message:

Eliminate awkward virtualComputedStyle construction
https://bugs.webkit.org/show_bug.cgi?id=125681

Reviewed by Andreas Kling.

  • dom/Element.cpp:

(WebCore::Element::computedStyle): Tweak coding style a bit.

  • dom/Element.h: Marked computedStyle virtual and got rid of virtualComputedStyle.

This fixes a bug that we would not call SVGElement::computedStyle if we called
it through an Element pointer or reference. Not sure how to get test coverage for this.

  • dom/Node.cpp:

(WebCore::Node::computedStyle): Use a loop instead of recursive virtual calls.

  • dom/Node.h: Made computedStyle virtual and got rid of virtualComputedStyle.
  • svg/SVGElement.cpp:

(WebCore::SVGElement::computedStyle): Tweak coding style a bit.

  • svg/SVGElement.h: Made computedStyle virtual (and FINAL) and got rid fo

virtualComputedStyle.

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r160535 r160536  
     12013-12-13  Darin Adler  <darin@apple.com>
     2
     3        Eliminate awkward virtualComputedStyle construction
     4        https://bugs.webkit.org/show_bug.cgi?id=125681
     5
     6        Reviewed by Andreas Kling.
     7
     8        * dom/Element.cpp:
     9        (WebCore::Element::computedStyle): Tweak coding style a bit.
     10
     11        * dom/Element.h: Marked computedStyle virtual and got rid of virtualComputedStyle.
     12        This fixes a bug that we would not call SVGElement::computedStyle if we called
     13        it through an Element pointer or reference. Not sure how to get test coverage for this.
     14
     15        * dom/Node.cpp:
     16        (WebCore::Node::computedStyle): Use a loop instead of recursive virtual calls.
     17
     18        * dom/Node.h: Made computedStyle virtual and got rid of virtualComputedStyle.
     19
     20        * svg/SVGElement.cpp:
     21        (WebCore::SVGElement::computedStyle): Tweak coding style a bit.
     22
     23        * svg/SVGElement.h: Made computedStyle virtual (and FINAL) and got rid fo
     24        virtualComputedStyle.
     25
    1262013-12-13  Darin Adler  <darin@apple.com>
    227
  • trunk/Source/WebCore/dom/Element.cpp

    r160138 r160536  
    21552155            RenderStyle* cachedPseudoStyle = usedStyle->getCachedPseudoStyle(pseudoElementSpecifier);
    21562156            return cachedPseudoStyle ? cachedPseudoStyle : usedStyle;
    2157          } else
    2158             return usedStyle;
    2159     }
    2160 
    2161     if (!attached())
     2157        }
     2158        return usedStyle;
     2159    }
     2160
     2161    if (!attached()) {
    21622162        // FIXME: Try to do better than this. Ensure that styleForElement() works for elements that are not in the
    21632163        // document tree and figure out when to destroy the computed style for such elements.
    2164         return 0;
     2164        return nullptr;
     2165    }
    21652166
    21662167    ElementRareData& data = ensureElementRareData();
  • trunk/Source/WebCore/dom/Element.h

    r160138 r160536  
    341341    virtual Element* focusDelegate();
    342342
    343     RenderStyle* computedStyle(PseudoId = NOPSEUDO);
     343    virtual RenderStyle* computedStyle(PseudoId = NOPSEUDO) OVERRIDE;
    344344
    345345    // Methods for indicating the style is affected by dynamic updates (e.g., children changing, our position changing in our sibling list, etc.)
     
    637637    void cancelFocusAppearanceUpdate();
    638638
    639     virtual RenderStyle* virtualComputedStyle(PseudoId pseudoElementSpecifier = NOPSEUDO) OVERRIDE { return computedStyle(pseudoElementSpecifier); }
    640    
    641639    // cloneNode is private so that non-virtual cloneElementWithChildren and cloneElementWithoutChildren
    642640    // are used instead.
  • trunk/Source/WebCore/dom/Node.cpp

    r158663 r160536  
    885885}
    886886
    887 RenderStyle* Node::virtualComputedStyle(PseudoId pseudoElementSpecifier)
    888 {
    889     return parentOrShadowHostNode() ? parentOrShadowHostNode()->computedStyle(pseudoElementSpecifier) : 0;
     887RenderStyle* Node::computedStyle(PseudoId pseudoElementSpecifier)
     888{
     889    for (Node* node = this; node; node = node->parentOrShadowHostNode()) {
     890        if (node->isElementNode())
     891            return toElement(node)->computedStyle(pseudoElementSpecifier);
     892    }
     893    return nullptr;
    890894}
    891895
  • trunk/Source/WebCore/dom/Node.h

    r159191 r160536  
    453453    RenderStyle* renderStyle() const;
    454454
    455     RenderStyle* computedStyle(PseudoId pseudoElementSpecifier = NOPSEUDO) { return virtualComputedStyle(pseudoElementSpecifier); }
     455    virtual RenderStyle* computedStyle(PseudoId pseudoElementSpecifier = NOPSEUDO);
    456456
    457457    // -----------------------------------------------------------------------------
     
    665665
    666666    virtual RenderStyle* nonRendererStyle() const { return 0; }
    667     virtual RenderStyle* virtualComputedStyle(PseudoId = NOPSEUDO);
    668667
    669668    Element* ancestorElement() const;
  • trunk/Source/WebCore/svg/SVGElement.cpp

    r159856 r160536  
    783783        return Element::computedStyle(pseudoElementSpecifier);
    784784
    785     RenderStyle* parentStyle = 0;
     785    RenderStyle* parentStyle = nullptr;
    786786    if (Element* parent = parentOrShadowHostElement()) {
    787787        if (auto renderer = parent->renderer())
  • trunk/Source/WebCore/svg/SVGElement.h

    r159856 r160536  
    172172    virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; }
    173173
    174     RenderStyle* computedStyle(PseudoId = NOPSEUDO);
    175     virtual RenderStyle* virtualComputedStyle(PseudoId pseudoElementSpecifier = NOPSEUDO) OVERRIDE { return computedStyle(pseudoElementSpecifier); }
     174    virtual RenderStyle* computedStyle(PseudoId = NOPSEUDO) OVERRIDE FINAL;
    176175    virtual bool willRecalcStyle(Style::Change) OVERRIDE;
    177176
Note: See TracChangeset for help on using the changeset viewer.