Title: [179145] trunk/Source/WebCore
- Revision
- 179145
- Author
- [email protected]
- Date
- 2015-01-26 14:44:19 -0800 (Mon, 26 Jan 2015)
Log Message
Simplify RenderElement's shouldRepaintForImageAnimation()
https://bugs.webkit.org/show_bug.cgi?id=140890
Reviewed by Darin Adler.
Simplify RenderElement's shouldRepaintForImageAnimation() by
not calling rendererForRootBackground(). The previous code was
doing a null-check on Document::documentElement() but failing
to do a null-check on the renderer just after, which lead me
to refactor this code.
Instead of calling document().documentElement.renderer(), we
now call renderer.parent(). This is equivalent because we already
know that renderer.isBody() returns true. The parent of the <body>
has to be the <html> element, which has to be the documentElement.
There is also no need to do a null-check on renderer.parent(). We
already know that the <body> has a renderer (because |renderer| is
its renderer), thus its parent <html> element has to have a renderer
as well.
Finally, simply call !rootElement.hasBackground() instead of
rootElement.rendererForRootBackground() == &bodyRenderer to determine
if the background painted by the root. This is equivalent but more
efficient because:
- We already know that the root renderer's is an <html> element. We
can thus avoid the check in rendererForRootBackground().
- We already have the <body>'s renderer so we don't need to do the
DOM tree traversal in rendererForRootBackground() to get it.
No new tests, already covered by:
fast/images/animated-gif-body-delegated-background-image.html
fast/images/animated-gif-html-background-image.html
* rendering/RenderElement.cpp:
(WebCore::shouldRepaintForImageAnimation):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (179144 => 179145)
--- trunk/Source/WebCore/ChangeLog 2015-01-26 22:40:35 UTC (rev 179144)
+++ trunk/Source/WebCore/ChangeLog 2015-01-26 22:44:19 UTC (rev 179145)
@@ -1,5 +1,43 @@
2015-01-26 Chris Dumez <[email protected]>
+ Simplify RenderElement's shouldRepaintForImageAnimation()
+ https://bugs.webkit.org/show_bug.cgi?id=140890
+
+ Reviewed by Darin Adler.
+
+ Simplify RenderElement's shouldRepaintForImageAnimation() by
+ not calling rendererForRootBackground(). The previous code was
+ doing a null-check on Document::documentElement() but failing
+ to do a null-check on the renderer just after, which lead me
+ to refactor this code.
+
+ Instead of calling document().documentElement.renderer(), we
+ now call renderer.parent(). This is equivalent because we already
+ know that renderer.isBody() returns true. The parent of the <body>
+ has to be the <html> element, which has to be the documentElement.
+ There is also no need to do a null-check on renderer.parent(). We
+ already know that the <body> has a renderer (because |renderer| is
+ its renderer), thus its parent <html> element has to have a renderer
+ as well.
+
+ Finally, simply call !rootElement.hasBackground() instead of
+ rootElement.rendererForRootBackground() == &bodyRenderer to determine
+ if the background painted by the root. This is equivalent but more
+ efficient because:
+ - We already know that the root renderer's is an <html> element. We
+ can thus avoid the check in rendererForRootBackground().
+ - We already have the <body>'s renderer so we don't need to do the
+ DOM tree traversal in rendererForRootBackground() to get it.
+
+ No new tests, already covered by:
+ fast/images/animated-gif-body-delegated-background-image.html
+ fast/images/animated-gif-html-background-image.html
+
+ * rendering/RenderElement.cpp:
+ (WebCore::shouldRepaintForImageAnimation):
+
+2015-01-26 Chris Dumez <[email protected]>
+
First argument to DOM traversal functions should be a reference
https://bugs.webkit.org/show_bug.cgi?id=140895
Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (179144 => 179145)
--- trunk/Source/WebCore/rendering/RenderElement.cpp 2015-01-26 22:40:35 UTC (rev 179144)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp 2015-01-26 22:44:19 UTC (rev 179145)
@@ -1377,9 +1377,11 @@
// can no longer check if it is a background image.
bool backgroundIsPaintedByRoot = renderer.isRoot();
if (renderer.isBody()) {
+ auto& rootRenderer = *renderer.parent(); // If <body> has a renderer then <html> does too.
+ ASSERT(rootRenderer.isRoot());
+ ASSERT(is<HTMLHtmlElement>(rootRenderer.element()));
// FIXME: Should share body background propagation code.
- RenderElement* rootObject = renderer.document().documentElement() ? renderer.document().documentElement()->renderer() : nullptr;
- backgroundIsPaintedByRoot = &rootObject->rendererForRootBackground() == &renderer;
+ backgroundIsPaintedByRoot = !rootRenderer.hasBackground();
}
LayoutRect backgroundPaintingRect = backgroundIsPaintedByRoot ? renderer.view().backgroundRect(&renderer.view()) : renderer.absoluteClippedOverflowRect();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes