Backgrounds in HTML inside foreignObject don't draw
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Feb 2012 23:59:59 +0000 (23:59 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Feb 2012 23:59:59 +0000 (23:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=23111

Patch by Florin Malita <fmalita@google.com> on 2012-02-01
Reviewed by Eric Seidel.

Source/WebCore:

Test: svg/foreignObject/body-background.svg

* rendering/RenderBox.cpp:
(WebCore::RenderBox::paintBackground):
Tweak the <body> background inhibiting logic to allow drawing when the element is embedded in FOs.

LayoutTests:

* svg/foreignObject/body-background-expected.png: Added.
* svg/foreignObject/body-background-expected.txt: Added.
* svg/foreignObject/body-background.svg: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106510 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/svg/foreignObject/body-background-expected.png [new file with mode: 0644]
LayoutTests/svg/foreignObject/body-background-expected.txt [new file with mode: 0644]
LayoutTests/svg/foreignObject/body-background.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBox.cpp

index 06c4d1f..3348b07 100644 (file)
@@ -1,3 +1,14 @@
+2012-02-01  Florin Malita  <fmalita@google.com>
+
+        Backgrounds in HTML inside foreignObject don't draw
+        https://bugs.webkit.org/show_bug.cgi?id=23111
+
+        Reviewed by Eric Seidel.
+
+        * svg/foreignObject/body-background-expected.png: Added.
+        * svg/foreignObject/body-background-expected.txt: Added.
+        * svg/foreignObject/body-background.svg: Added.
+
 2012-02-01  Oliver Hunt  <oliver@apple.com>
 
         Add support for inferred function names
diff --git a/LayoutTests/svg/foreignObject/body-background-expected.png b/LayoutTests/svg/foreignObject/body-background-expected.png
new file mode 100644 (file)
index 0000000..807e006
Binary files /dev/null and b/LayoutTests/svg/foreignObject/body-background-expected.png differ
diff --git a/LayoutTests/svg/foreignObject/body-background-expected.txt b/LayoutTests/svg/foreignObject/body-background-expected.txt
new file mode 100644 (file)
index 0000000..a42d2ff
--- /dev/null
@@ -0,0 +1,9 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (20,20) size 200x100
+    RenderSVGRect {rect} at (20,20) size 200x100 [fill={[type=SOLID] [color=#FF0000]}] [x=20.00] [y=20.00] [width=200.00] [height=100.00]
+    RenderSVGForeignObject {foreignObject} at (20,20) size 200x100
+      RenderBlock {html} at (0,0) size 200x100
+        RenderBody {body} at (0,0) size 200x100 [bgcolor=#008000]
+          RenderBlock {div} at (0,0) size 200x100
diff --git a/LayoutTests/svg/foreignObject/body-background.svg b/LayoutTests/svg/foreignObject/body-background.svg
new file mode 100644 (file)
index 0000000..7f26dec
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" standalone="yes"?>
+<svg xmlns="http://www.w3.org/2000/svg">
+    <!-- The FO <body> background should cover this red rect -->
+    <rect x="20" y="20" width="200" height="100" fill="red"/>
+    <foreignObject  x="20" y="20" width="200" height="100">
+      <html xmlns="http://www.w3.org/1999/xhtml">
+        <body style="background-color: green; margin: 0px;">
+          <div style="height: 100px;"></div>
+        </body>
+      </html>
+    </foreignObject>
+</svg>
index 5c00a7c..2534d3e 100644 (file)
@@ -1,3 +1,17 @@
+2012-02-01  Florin Malita  <fmalita@google.com>
+
+        Backgrounds in HTML inside foreignObject don't draw
+        https://bugs.webkit.org/show_bug.cgi?id=23111
+
+        Reviewed by Eric Seidel.
+
+        Test: svg/foreignObject/body-background.svg
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::paintBackground):
+        Tweak the <body> background inhibiting logic to allow drawing when the element is embedded in FOs.
+
+
 2012-02-01  Gustavo Lima Chaves  <glima@profusion.mobi>
 
         Make one able to set the local storage (tracker) database dir's path
index 836b312..63fd6f8 100644 (file)
@@ -947,9 +947,11 @@ void RenderBox::paintBackground(const PaintInfo& paintInfo, const LayoutRect& pa
 {
     if (isRoot())
         paintRootBoxFillLayers(paintInfo);
-    else if (!isBody() || (document()->documentElement()->renderer() && document()->documentElement()->renderer()->hasBackground())) {
-        // The <body> only paints its background if the root element has defined a background
-        // independent of the body.
+    else if (!isBody()
+            || (document()->documentElement()->renderer() && document()->documentElement()->renderer()->hasBackground())
+            || (document()->documentElement()->renderer() != parent())) {
+        // The <body> only paints its background if the root element has defined a background independent of the body,
+        // or if the <body>'s parent is not the document element's renderer (e.g. inside SVG foreignObject).
         if (!backgroundIsObscured())
             paintFillLayers(paintInfo, style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->backgroundLayers(), paintRect, bleedAvoidance);
     }