<https://webkit.org/b/129689>
Generalize the mechanism that computed style uses to avoid doing full
style updates when the node we're interested in isn't actually dirty.
Reviewed by Antti Koivisto.
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::propertyValue):
* dom/Document.cpp:
(WebCore::nodeOrItsAncestorNeedsStyleRecalc):
(WebCore::Document::updateStyleIfNeededForNode):
* dom/Document.h:
* editing/htmlediting.cpp:
(WebCore::isEditablePosition):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::defaultEventHandler):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@165076
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-03-04 Andreas Kling <akling@apple.com>
+
+ Add a Document::updateStyleIfNeededForNode(Node&).
+ <https://webkit.org/b/129689>
+
+ Generalize the mechanism that computed style uses to avoid doing full
+ style updates when the node we're interested in isn't actually dirty.
+
+ Reviewed by Antti Koivisto.
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::ComputedStyleExtractor::propertyValue):
+ * dom/Document.cpp:
+ (WebCore::nodeOrItsAncestorNeedsStyleRecalc):
+ (WebCore::Document::updateStyleIfNeededForNode):
+ * dom/Document.h:
+ * editing/htmlediting.cpp:
+ (WebCore::isEditablePosition):
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::defaultEventHandler):
+
2014-03-04 Mark Hahnenberg <mhahnenberg@apple.com>
Merge API shims and JSLock
return ComputedStyleExtractor(m_node, m_allowVisitedStyle, m_pseudoElementSpecifier).copyProperties();
}
-static inline bool nodeOrItsAncestorNeedsStyleRecalc(Node* styledNode)
-{
- if (styledNode->document().hasPendingForcedStyleRecalc())
- return true;
- for (Node* n = styledNode; n; n = n->parentNode()) {// FIXME: Call parentOrShadowHostNode() instead
- if (n->needsStyleRecalc())
- return true;
- }
- return false;
-}
-
static inline PassRefPtr<RenderStyle> computeRenderStyleForProperty(Node* styledNode, PseudoId pseudoElementSpecifier, CSSPropertyID propertyID)
{
RenderObject* renderer = styledNode->renderer();
if (updateLayout) {
Document& document = styledNode->document();
- if (nodeOrItsAncestorNeedsStyleRecalc(styledNode)) {
- document.updateStyleIfNeeded();
+ if (document.updateStyleIfNeededForNode(*styledNode)) {
// The style recalc could have caused the styled node to be discarded or replaced
// if it was a PseudoElement so we need to update it.
styledNode = this->styledNode();
}
#endif // ENABLE(SUBTLE_CRYPTO)
+static inline bool nodeOrItsAncestorNeedsStyleRecalc(const Node& node)
+{
+ for (const Node* n = &node; n; n = n->parentOrShadowHostElement()) {
+ if (n->needsStyleRecalc())
+ return true;
+ }
+ return false;
+}
+
+bool Document::updateStyleIfNeededForNode(const Node& node)
+{
+ if (!hasPendingForcedStyleRecalc() && !nodeOrItsAncestorNeedsStyleRecalc(node))
+ return false;
+ updateStyleIfNeeded();
+ return true;
+}
+
} // namespace WebCore
void recalcStyle(Style::Change = Style::NoChange);
void updateStyleIfNeeded();
+ bool updateStyleIfNeededForNode(const Node&);
void updateLayout();
void updateLayoutIgnorePendingStylesheets();
PassRef<RenderStyle> styleForElementIgnoringPendingStylesheets(Element*);
if (!node)
return false;
if (updateStyle == UpdateStyle)
- node->document().updateStyleIfNeeded();
+ node->document().updateStyleIfNeededForNode(*node);
else
ASSERT(updateStyle == DoNotUpdateStyle);
return;
}
- document().updateStyleIfNeeded();
+ document().updateStyleIfNeededForNode(*this);
m_inputType->forwardEvent(evt);
if (!callBaseClassEarly && !evt->defaultHandled())