Fix default background of a dragged image.
authorshawnsingh@chromium.org <shawnsingh@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Mar 2013 00:11:28 +0000 (00:11 +0000)
committershawnsingh@chromium.org <shawnsingh@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Mar 2013 00:11:28 +0000 (00:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=110512

Reviewed by Tony Chang.

.:

* ManualTests/drag-background-with-padding.html: Added.

Source/WebCore:

Transparent background color (particularly visible in the padding
of an element) was not being respected. The solution is to
initially fill the drag image with transparent instead of white,
so that any color background works correctly. This patch does not
affect Apple Mac or Win platforms, given that this part of the
code is #if guarded from those platforms.

Manual test added:
  ManualTests/drag-background-with-padding.html

Infrastructure for retrieving the drag image for pixel testing
does not yet exist.

* page/Frame.cpp:
(WebCore::Frame::nodeImage):

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

ChangeLog
ManualTests/drag-background-with-padding.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/Frame.cpp

index 7886cb605246824c90cf2d97b8ff3ff7a9006e5c..bc85ccdaaa6bc5978c8b206c55ed33edbbc14d8a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2013-03-05  Shawn Singh  <shawnsingh@chromium.org>
+
+        Fix default background of a dragged image.
+        https://bugs.webkit.org/show_bug.cgi?id=110512
+
+        Reviewed by Tony Chang.
+
+        * ManualTests/drag-background-with-padding.html: Added.
+
 2013-03-05  Gustavo Noronha Silva  <gns@gnome.org>
 
         Unreviewed build fix.
diff --git a/ManualTests/drag-background-with-padding.html b/ManualTests/drag-background-with-padding.html
new file mode 100644 (file)
index 0000000..fd2e1f6
--- /dev/null
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML>
+<html>
+  <body style="background-color: silver;">
+    <p>For a draggable element that has padding, the drag image that is created
+    should respect that background color. Note that none of the drag images
+    use any of the body element's silver background.</p>
+
+    <div style="position: absolute; top: 100px; padding: 50px; border: solid 2px black;" draggable="true">
+      <div style="background-color: grey; width: 100px; height: 100px;">Drag me! Drag image padding should remain transparent.</div>
+    </div>
+
+    <div style="position: absolute; top: 350px; padding: 50px; border: solid 2px black; background-color: rgba(1, 0, 0, 0);" draggable="true">
+      <div style="background-color: grey; width: 100px; height: 100px;">Drag me! Drag image padding should be transparent.</div>
+    </div>
+
+    <div style="position: absolute; top: 350px; left: 250px; padding: 50px; border: solid 2px black; background-color: white;" draggable="true">
+      <div style="background-color: grey; width: 100px; height: 100px;">Drag me! Drag image padding should be white.</div>
+    </div>
+
+    <div style="position: absolute; top: 350px; left: 500px; padding: 50px; border: solid 2px black; background-color: lime;" draggable="true">
+      <div style="background-color: grey; width: 100px; height: 100px;">Drag me! Drag image padding should be lime.</div>
+    </div>
+
+    <div style="position: absolute; top: 100px; left: 250px; width: 200px; height: 200px; background-color: cyan;"> Drag on top of me just for reference.</div>
+
+  </body>
+</html>
index 28172868c0122ac528ea5137239acb0296d985ec..89a7c089bacee4fd1ed885ae67fdd7137d279905 100644 (file)
@@ -1,3 +1,26 @@
+2013-03-05  Shawn Singh  <shawnsingh@chromium.org>
+
+        Fix default background of a dragged image.
+        https://bugs.webkit.org/show_bug.cgi?id=110512
+
+        Reviewed by Tony Chang.
+
+        Transparent background color (particularly visible in the padding
+        of an element) was not being respected. The solution is to
+        initially fill the drag image with transparent instead of white,
+        so that any color background works correctly. This patch does not
+        affect Apple Mac or Win platforms, given that this part of the
+        code is #if guarded from those platforms.
+
+        Manual test added:
+          ManualTests/drag-background-with-padding.html
+
+        Infrastructure for retrieving the drag image for pixel testing
+        does not yet exist.
+
+        * page/Frame.cpp:
+        (WebCore::Frame::nodeImage):
+
 2013-03-05  Emil A Eklund  <eae@chromium.org>
 
         ASSERTION FAILED: i < size(), UNKNOWN in WebCore::RenderTableSection::layout
index a9fba23c3bc1a4f870c37f4be4102972ccc43817..c7ed072eaf5bf2e16c67cf978e2eb4f6b86fdbe9 100644 (file)
@@ -1085,7 +1085,7 @@ DragImageRef Frame::nodeImage(Node* node)
     m_view->setPaintBehavior(state.paintBehavior | PaintBehaviorFlattenCompositingLayers);
 
     // When generating the drag image for an element, ignore the document background.
-    m_view->setBaseBackgroundColor(colorWithOverrideAlpha(Color::white, 1.0));
+    m_view->setBaseBackgroundColor(Color::transparent);
     m_doc->updateLayout();
     m_view->setNodeToDraw(node); // Enable special sub-tree drawing mode.