Commit d8ecd202 authored by darin@apple.com's avatar darin@apple.com

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.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160536 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 03347ab4
2013-12-13 Darin Adler <darin@apple.com>
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.
2013-12-13 Darin Adler <darin@apple.com>
Fix a couple stray uses of RefPtr that should release
......@@ -2154,14 +2154,15 @@ RenderStyle* Element::computedStyle(PseudoId pseudoElementSpecifier)
if (pseudoElementSpecifier) {
RenderStyle* cachedPseudoStyle = usedStyle->getCachedPseudoStyle(pseudoElementSpecifier);
return cachedPseudoStyle ? cachedPseudoStyle : usedStyle;
} else
return usedStyle;
}
return usedStyle;
}
if (!attached())
if (!attached()) {
// FIXME: Try to do better than this. Ensure that styleForElement() works for elements that are not in the
// document tree and figure out when to destroy the computed style for such elements.
return 0;
return nullptr;
}
ElementRareData& data = ensureElementRareData();
if (!data.computedStyle())
......
......@@ -340,7 +340,7 @@ public:
virtual short tabIndex() const;
virtual Element* focusDelegate();
RenderStyle* computedStyle(PseudoId = NOPSEUDO);
virtual RenderStyle* computedStyle(PseudoId = NOPSEUDO) OVERRIDE;
// Methods for indicating the style is affected by dynamic updates (e.g., children changing, our position changing in our sibling list, etc.)
bool styleAffectedByEmpty() const { return hasRareData() && rareDataStyleAffectedByEmpty(); }
......@@ -636,8 +636,6 @@ private:
void cancelFocusAppearanceUpdate();
virtual RenderStyle* virtualComputedStyle(PseudoId pseudoElementSpecifier = NOPSEUDO) OVERRIDE { return computedStyle(pseudoElementSpecifier); }
// cloneNode is private so that non-virtual cloneElementWithChildren and cloneElementWithoutChildren
// are used instead.
virtual PassRefPtr<Node> cloneNode(bool deep) OVERRIDE;
......
......@@ -884,9 +884,13 @@ Node* Node::pseudoAwareLastChild() const
return lastChild();
}
RenderStyle* Node::virtualComputedStyle(PseudoId pseudoElementSpecifier)
RenderStyle* Node::computedStyle(PseudoId pseudoElementSpecifier)
{
return parentOrShadowHostNode() ? parentOrShadowHostNode()->computedStyle(pseudoElementSpecifier) : 0;
for (Node* node = this; node; node = node->parentOrShadowHostNode()) {
if (node->isElementNode())
return toElement(node)->computedStyle(pseudoElementSpecifier);
}
return nullptr;
}
int Node::maxCharacterOffset() const
......
......@@ -452,7 +452,7 @@ public:
// Wrapper for nodes that don't have a renderer, but still cache the style (like HTMLOptionElement).
RenderStyle* renderStyle() const;
RenderStyle* computedStyle(PseudoId pseudoElementSpecifier = NOPSEUDO) { return virtualComputedStyle(pseudoElementSpecifier); }
virtual RenderStyle* computedStyle(PseudoId pseudoElementSpecifier = NOPSEUDO);
// -----------------------------------------------------------------------------
// Notification of document structure changes (see ContainerNode.h for more notification methods)
......@@ -664,7 +664,6 @@ private:
virtual void derefEventTarget() OVERRIDE;
virtual RenderStyle* nonRendererStyle() const { return 0; }
virtual RenderStyle* virtualComputedStyle(PseudoId = NOPSEUDO);
Element* ancestorElement() const;
......
......@@ -782,7 +782,7 @@ RenderStyle* SVGElement::computedStyle(PseudoId pseudoElementSpecifier)
if (!m_svgRareData || !m_svgRareData->useOverrideComputedStyle())
return Element::computedStyle(pseudoElementSpecifier);
RenderStyle* parentStyle = 0;
RenderStyle* parentStyle = nullptr;
if (Element* parent = parentOrShadowHostElement()) {
if (auto renderer = parent->renderer())
parentStyle = &renderer->style();
......
......@@ -171,8 +171,7 @@ private:
// https://bugs.webkit.org/show_bug.cgi?id=77938
virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; }
RenderStyle* computedStyle(PseudoId = NOPSEUDO);
virtual RenderStyle* virtualComputedStyle(PseudoId pseudoElementSpecifier = NOPSEUDO) OVERRIDE { return computedStyle(pseudoElementSpecifier); }
virtual RenderStyle* computedStyle(PseudoId = NOPSEUDO) OVERRIDE FINAL;
virtual bool willRecalcStyle(Style::Change) OVERRIDE;
virtual bool isSupported(StringImpl* feature, StringImpl* version) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment