Diff
Modified: trunk/LayoutTests/ChangeLog (104627 => 104628)
--- trunk/LayoutTests/ChangeLog 2012-01-10 21:30:30 UTC (rev 104627)
+++ trunk/LayoutTests/ChangeLog 2012-01-10 21:38:41 UTC (rev 104628)
@@ -1,3 +1,19 @@
+2012-01-10 Simon Fraser <[email protected]>
+
+ Clean up RenderLayerBacking code that looks for the body
+ https://bugs.webkit.org/show_bug.cgi?id=39502
+
+ Reviewed by Dave Hyatt.
+
+ Tests for propagation of the <body> background to the root.
+
+ * fast/backgrounds/root-background-propagation-expected.png: Added.
+ * fast/backgrounds/root-background-propagation-expected.txt: Added.
+ * fast/backgrounds/root-background-propagation.html: Added.
+ * fast/backgrounds/root-background-propagation2-expected.png: Added.
+ * fast/backgrounds/root-background-propagation2-expected.txt: Added.
+ * fast/backgrounds/root-background-propagation2.html: Added.
+
2012-01-10 Ojan Vafai <[email protected]>
Layout test rebaselines after r104606.
Added: trunk/LayoutTests/fast/backgrounds/root-background-propagation-expected.png
(Binary files differ)
Property changes on: trunk/LayoutTests/fast/backgrounds/root-background-propagation-expected.png
___________________________________________________________________
Added: svn:mime-type
Added: trunk/LayoutTests/fast/backgrounds/root-background-propagation-expected.txt (0 => 104628)
--- trunk/LayoutTests/fast/backgrounds/root-background-propagation-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/root-background-propagation-expected.txt 2012-01-10 21:38:41 UTC (rev 104628)
@@ -0,0 +1 @@
+The entire viewport should be filled with green
Property changes on: trunk/LayoutTests/fast/backgrounds/root-background-propagation-expected.txt
___________________________________________________________________
Added: svn:mime-type
Added: svn:keywords
Added: svn:eol-style
Added: trunk/LayoutTests/fast/backgrounds/root-background-propagation.html (0 => 104628)
--- trunk/LayoutTests/fast/backgrounds/root-background-propagation.html (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/root-background-propagation.html 2012-01-10 21:38:41 UTC (rev 104628)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ body {
+ background-color: green;
+ height: 100px;
+ }
+ p {
+ color: green; /* Hide from pixel result */
+ }
+ </style>
+ <script>
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText(true);
+ </script>
+</head>
+<body>
+ <p>The entire viewport should be filled with green</p>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/backgrounds/root-background-propagation.html
___________________________________________________________________
Added: svn:mime-type
Added: svn:keywords
Added: svn:eol-style
Added: trunk/LayoutTests/fast/backgrounds/root-background-propagation2-expected.png
(Binary files differ)
Property changes on: trunk/LayoutTests/fast/backgrounds/root-background-propagation2-expected.png
___________________________________________________________________
Added: svn:mime-type
Added: trunk/LayoutTests/fast/backgrounds/root-background-propagation2-expected.txt (0 => 104628)
--- trunk/LayoutTests/fast/backgrounds/root-background-propagation2-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/root-background-propagation2-expected.txt 2012-01-10 21:38:41 UTC (rev 104628)
@@ -0,0 +1 @@
+Should see a 100px tall light green rect on a field of green.
Property changes on: trunk/LayoutTests/fast/backgrounds/root-background-propagation2-expected.txt
___________________________________________________________________
Added: svn:mime-type
Added: svn:keywords
Added: svn:eol-style
Added: trunk/LayoutTests/fast/backgrounds/root-background-propagation2.html (0 => 104628)
--- trunk/LayoutTests/fast/backgrounds/root-background-propagation2.html (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/root-background-propagation2.html 2012-01-10 21:38:41 UTC (rev 104628)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ html {
+ background-color: green;
+ }
+ body {
+ background-color: #0F0;
+ height: 100px;
+ }
+ p {
+ color: #0F0; /* Hide from pixel result */
+ }
+ </style>
+ <script>
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText(true);
+ </script>
+</head>
+<body>
+ <p>Should see a 100px tall light green rect on a field of green.</p>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/backgrounds/root-background-propagation2.html
___________________________________________________________________
Added: svn:mime-type
Added: svn:keywords
Added: svn:eol-style
Modified: trunk/Source/WebCore/ChangeLog (104627 => 104628)
--- trunk/Source/WebCore/ChangeLog 2012-01-10 21:30:30 UTC (rev 104627)
+++ trunk/Source/WebCore/ChangeLog 2012-01-10 21:38:41 UTC (rev 104628)
@@ -1,3 +1,31 @@
+2012-01-10 Simon Fraser <[email protected]>
+
+ Clean up RenderLayerBacking code that looks for the body
+ https://bugs.webkit.org/show_bug.cgi?id=39502
+
+ Reviewed by Dave Hyatt.
+
+ Consolidate code that propagates the <body> background to the
+ root, adding a utility method on RenderObject that is called
+ by RenderBox and RenderLayerBacking.
+
+ Removed an unused method in RenderLayerBacking.
+
+ The compositiong changes are not testable, since rendererBackgroundColor()
+ is only used by fullscreen at present.
+
+ Tests: fast/backgrounds/root-background-propagation.html
+ fast/backgrounds/root-background-propagation2.html
+
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::paintRootBoxFillLayers):
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::RenderLayerBacking::rendererBackgroundColor):
+ * rendering/RenderLayerBacking.h:
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::rendererForRootBackground):
+ * rendering/RenderObject.h:
+
2012-01-10 Dana Jansens <[email protected]>
[chromium] Create iterators for the RenderSurface-Layer tree
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (104627 => 104628)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2012-01-10 21:30:30 UTC (rev 104627)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2012-01-10 21:38:41 UTC (rev 104628)
@@ -858,23 +858,12 @@
void RenderBox::paintRootBoxFillLayers(const PaintInfo& paintInfo)
{
- const FillLayer* bgLayer = style()->backgroundLayers();
- Color bgColor = style()->visitedDependentColor(CSSPropertyBackgroundColor);
- RenderObject* bodyObject = 0;
- if (!hasBackground() && node() && node()->hasTagName(HTMLNames::htmlTag)) {
- // Locate the <body> element using the DOM. This is easier than trying
- // to crawl around a render tree with potential :before/:after content and
- // anonymous blocks created by inline <body> tags etc. We can locate the <body>
- // render object very easily via the DOM.
- HTMLElement* body = document()->body();
- bodyObject = (body && body->hasLocalName(bodyTag)) ? body->renderer() : 0;
- if (bodyObject) {
- bgLayer = bodyObject->style()->backgroundLayers();
- bgColor = bodyObject->style()->visitedDependentColor(CSSPropertyBackgroundColor);
- }
- }
+ RenderObject* rootBackgroundRenderer = rendererForRootBackground();
+
+ const FillLayer* bgLayer = rootBackgroundRenderer->style()->backgroundLayers();
+ Color bgColor = rootBackgroundRenderer->style()->visitedDependentColor(CSSPropertyBackgroundColor);
- paintFillLayers(paintInfo, bgColor, bgLayer, view()->backgroundRect(this), BackgroundBleedNone, CompositeSourceOver, bodyObject);
+ paintFillLayers(paintInfo, bgColor, bgLayer, view()->backgroundRect(this), BackgroundBleedNone, CompositeSourceOver, rootBackgroundRenderer);
}
BackgroundBleedAvoidance RenderBox::determineBackgroundBleedAvoidance(GraphicsContext* context) const
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (104627 => 104628)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2012-01-10 21:30:30 UTC (rev 104627)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2012-01-10 21:38:41 UTC (rev 104628)
@@ -777,40 +777,13 @@
return hasBoxDecorations(style) || style->hasBackgroundImage();
}
-bool RenderLayerBacking::rendererHasBackground() const
-{
- // FIXME: share more code here
- if (renderer()->node() && renderer()->node()->isDocumentNode()) {
- RenderObject* htmlObject = renderer()->firstChild();
- if (!htmlObject)
- return false;
-
- if (htmlObject->hasBackground())
- return true;
-
- RenderObject* bodyObject = htmlObject->firstChild();
- if (!bodyObject)
- return false;
-
- return bodyObject->hasBackground();
- }
-
- return renderer()->hasBackground();
-}
-
Color RenderLayerBacking::rendererBackgroundColor() const
{
- // FIXME: share more code here
- if (renderer()->node() && renderer()->node()->isDocumentNode()) {
- RenderObject* htmlObject = renderer()->firstChild();
- if (htmlObject->hasBackground())
- return htmlObject->style()->visitedDependentColor(CSSPropertyBackgroundColor);
+ RenderObject* backgroundRenderer = renderer();
+ if (backgroundRenderer->isRoot())
+ backgroundRenderer = backgroundRenderer->rendererForRootBackground();
- RenderObject* bodyObject = htmlObject->firstChild();
- return bodyObject->style()->visitedDependentColor(CSSPropertyBackgroundColor);
- }
-
- return renderer()->style()->visitedDependentColor(CSSPropertyBackgroundColor);
+ return backgroundRenderer->style()->visitedDependentColor(CSSPropertyBackgroundColor);
}
void RenderLayerBacking::updateBackgroundColor()
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.h (104627 => 104628)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.h 2012-01-10 21:30:30 UTC (rev 104627)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.h 2012-01-10 21:38:41 UTC (rev 104628)
@@ -194,7 +194,6 @@
bool isDirectlyCompositedImage() const;
void updateImageContents();
- bool rendererHasBackground() const;
Color rendererBackgroundColor() const;
void updateBackgroundColor();
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (104627 => 104628)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2012-01-10 21:30:30 UTC (rev 104627)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2012-01-10 21:38:41 UTC (rev 104628)
@@ -38,6 +38,7 @@
#include "Frame.h"
#include "FrameView.h"
#include "GraphicsContext.h"
+#include "HTMLElement.h"
#include "HTMLNames.h"
#include "HitTestResult.h"
#include "Page.h"
@@ -2126,6 +2127,23 @@
return true;
}
+RenderObject* RenderObject::rendererForRootBackground()
+{
+ ASSERT(isRoot());
+ if (!hasBackground() && node() && node()->hasTagName(HTMLNames::htmlTag)) {
+ // Locate the <body> element using the DOM. This is easier than trying
+ // to crawl around a render tree with potential :before/:after content and
+ // anonymous blocks created by inline <body> tags etc. We can locate the <body>
+ // render object very easily via the DOM.
+ HTMLElement* body = document()->body();
+ RenderObject* bodyObject = (body && body->hasLocalName(bodyTag)) ? body->renderer() : 0;
+ if (bodyObject)
+ return bodyObject;
+ }
+
+ return this;
+}
+
bool RenderObject::hasOutlineAnnotation() const
{
return node() && node()->isLink() && document()->printing();
Modified: trunk/Source/WebCore/rendering/RenderObject.h (104627 => 104628)
--- trunk/Source/WebCore/rendering/RenderObject.h 2012-01-10 21:30:30 UTC (rev 104627)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2012-01-10 21:38:41 UTC (rev 104628)
@@ -851,6 +851,9 @@
return outlineBoundsForRepaint(0);
}
+ // Return the renderer whose background style is used to paint the root background. Should only be called on the renderer for which isRoot() is true.
+ RenderObject* rendererForRootBackground();
+
protected:
// Overrides should call the superclass at the end
virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);