Title: [152938] trunk/Source/WebCore
- Revision
- 152938
- Author
- [email protected]
- Date
- 2013-07-19 19:59:41 -0700 (Fri, 19 Jul 2013)
Log Message
Extract computeRenderStyleForProperty and nodeOrItsAncestorNeedsStyleRecalc from ComputedStyleExtractor::propertyValue
https://bugs.webkit.org/show_bug.cgi?id=118930
Reviewed by Andreas Kling.
Extracted two functions as a preparation to fix bugs 118032 and 118618.
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::nodeOrItsAncestorNeedsStyleRecalc):
(WebCore::computeRenderStyleForProperty):
(WebCore::ComputedStyleExtractor::propertyValue):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (152937 => 152938)
--- trunk/Source/WebCore/ChangeLog 2013-07-20 02:53:32 UTC (rev 152937)
+++ trunk/Source/WebCore/ChangeLog 2013-07-20 02:59:41 UTC (rev 152938)
@@ -1,3 +1,17 @@
+2013-07-19 Ryosuke Niwa <[email protected]>
+
+ Extract computeRenderStyleForProperty and nodeOrItsAncestorNeedsStyleRecalc from ComputedStyleExtractor::propertyValue
+ https://bugs.webkit.org/show_bug.cgi?id=118930
+
+ Reviewed by Andreas Kling.
+
+ Extracted two functions as a preparation to fix bugs 118032 and 118618.
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::nodeOrItsAncestorNeedsStyleRecalc):
+ (WebCore::computeRenderStyleForProperty):
+ (WebCore::ComputedStyleExtractor::propertyValue):
+
2013-07-19 Andreas Kling <[email protected]>
Cache style declaration CSSOM wrappers directly on MutableStylePropertySet.
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (152937 => 152938)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2013-07-20 02:53:32 UTC (rev 152937)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2013-07-20 02:59:41 UTC (rev 152938)
@@ -1568,6 +1568,34 @@
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 (renderer && renderer->isComposited() && AnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
+ AnimationUpdateBlock animationUpdateBlock(renderer->animation());
+ RefPtr<RenderStyle> style = renderer->animation()->getAnimatedStyleForRenderer(renderer);
+ if (pseudoElementSpecifier && !styledNode->isPseudoElement()) {
+ // FIXME: This cached pseudo style will only exist if the animation has been run at least once.
+ return style->getCachedPseudoStyle(pseudoElementSpecifier);
+ }
+ return style.release();
+ }
+
+ return styledNode->computedStyle(styledNode->isPseudoElement() ? NOPSEUDO : pseudoElementSpecifier);
+}
+
PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
{
Node* styledNode = this->styledNode();
@@ -1584,35 +1612,19 @@
if (forceFullLayout)
document->updateLayoutIgnorePendingStylesheets();
- else {
- bool needsStyleRecalc = document->hasPendingForcedStyleRecalc();
- for (Node* n = styledNode; n && !needsStyleRecalc; n = n->parentNode())
- needsStyleRecalc = n->needsStyleRecalc();
- if (needsStyleRecalc)
- document->updateStyleIfNeeded();
- }
+ else if (nodeOrItsAncestorNeedsStyleRecalc(styledNode))
+ document->updateStyleIfNeeded();
// 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();
}
- RenderObject* renderer = styledNode->renderer();
-
- RefPtr<RenderStyle> style;
- if (renderer && renderer->isComposited() && AnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
- AnimationUpdateBlock animationUpdateBlock(renderer->animation());
- style = renderer->animation()->getAnimatedStyleForRenderer(renderer);
- if (m_pseudoElementSpecifier && !styledNode->isPseudoElement()) {
- // FIXME: This cached pseudo style will only exist if the animation has been run at least once.
- style = style->getCachedPseudoStyle(m_pseudoElementSpecifier);
- }
- } else
- style = styledNode->computedStyle(styledNode->isPseudoElement() ? NOPSEUDO : m_pseudoElementSpecifier);
-
+ RefPtr<RenderStyle> style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, propertyID);
if (!style)
return 0;
+ RenderObject* renderer = styledNode->renderer();
propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style->direction(), style->writingMode());
switch (propertyID) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes