Title: [148970] trunk/Source/WebCore
- Revision
- 148970
- Author
- [email protected]
- Date
- 2013-04-23 09:13:17 -0700 (Tue, 23 Apr 2013)
Log Message
Avoid computing style twice when element has no existing style
https://bugs.webkit.org/show_bug.cgi?id=115042
Reviewed by Andreas Kling.
We currently compute element style twice if we end up having to reattach, first in recalcStyle and then
again during attach(). We can easily avoid this in common case where the element has no existing style
(usually because it is display:none).
* dom/Element.cpp:
(WebCore::Element::recalcStyle):
Don't compute the style and diff if there is no existing style. There is nothing to diff against.
Instead just call reattach() directly, we ended up doing that anyway with the existing code.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (148969 => 148970)
--- trunk/Source/WebCore/ChangeLog 2013-04-23 16:03:46 UTC (rev 148969)
+++ trunk/Source/WebCore/ChangeLog 2013-04-23 16:13:17 UTC (rev 148970)
@@ -1,3 +1,20 @@
+2013-04-23 Antti Koivisto <[email protected]>
+
+ Avoid computing style twice when element has no existing style
+ https://bugs.webkit.org/show_bug.cgi?id=115042
+
+ Reviewed by Andreas Kling.
+
+ We currently compute element style twice if we end up having to reattach, first in recalcStyle and then
+ again during attach(). We can easily avoid this in common case where the element has no existing style
+ (usually because it is display:none).
+
+ * dom/Element.cpp:
+ (WebCore::Element::recalcStyle):
+
+ Don't compute the style and diff if there is no existing style. There is nothing to diff against.
+ Instead just call reattach() directly, we ended up doing that anyway with the existing code.
+
2013-04-23 Lamarque V. Souza <[email protected]>
WebSocket: Return type of send() should be void if hybi-10 protocol is chosen
Modified: trunk/Source/WebCore/dom/Element.cpp (148969 => 148970)
--- trunk/Source/WebCore/dom/Element.cpp 2013-04-23 16:03:46 UTC (rev 148969)
+++ trunk/Source/WebCore/dom/Element.cpp 2013-04-23 16:13:17 UTC (rev 148970)
@@ -1409,9 +1409,13 @@
elementRareData()->resetComputedStyle();
}
if (hasParentStyle && (change >= Inherit || needsStyleRecalc())) {
- RefPtr<RenderStyle> newStyle = styleForRenderer();
- StyleChange ch = Node::diff(currentStyle.get(), newStyle.get(), document());
- if (ch == Detach || !currentStyle) {
+ StyleChange localChange = Detach;
+ RefPtr<RenderStyle> newStyle;
+ if (currentStyle) {
+ newStyle = styleForRenderer();
+ localChange = Node::diff(currentStyle.get(), newStyle.get(), document());
+ }
+ if (localChange == Detach) {
// FIXME: The style gets computed twice by calling attach. We could do better if we passed the style along.
reattach();
// attach recalculates the style for all children. No need to do it twice.
@@ -1424,7 +1428,7 @@
}
if (RenderObject* renderer = this->renderer()) {
- if (ch != NoChange || pseudoStyleCacheIsInvalid(currentStyle.get(), newStyle.get()) || (change == Force && renderer->requiresForcedStyleRecalcPropagation()) || styleChangeType() == SyntheticStyleChange)
+ if (localChange != NoChange || pseudoStyleCacheIsInvalid(currentStyle.get(), newStyle.get()) || (change == Force && renderer->requiresForcedStyleRecalcPropagation()) || styleChangeType() == SyntheticStyleChange)
renderer->setAnimatableStyle(newStyle.get());
else if (needsStyleRecalc()) {
// Although no change occurred, we use the new style so that the cousin style sharing code won't get
@@ -1435,7 +1439,7 @@
// If "rem" units are used anywhere in the document, and if the document element's font size changes, then go ahead and force font updating
// all the way down the tree. This is simpler than having to maintain a cache of objects (and such font size changes should be rare anyway).
- if (document()->styleSheetCollection()->usesRemUnits() && document()->documentElement() == this && ch != NoChange && currentStyle && newStyle && currentStyle->fontSize() != newStyle->fontSize()) {
+ if (document()->styleSheetCollection()->usesRemUnits() && document()->documentElement() == this && localChange != NoChange && currentStyle && newStyle && currentStyle->fontSize() != newStyle->fontSize()) {
// Cached RenderStyles may depend on the re units.
document()->styleResolver()->invalidateMatchedPropertiesCache();
change = Force;
@@ -1445,7 +1449,7 @@
if (styleChangeType() >= FullStyleChange)
change = Force;
else
- change = ch;
+ change = localChange;
}
}
StyleResolverParentPusher parentPusher(this);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes