[Regression] Fix Draggable is float:left and container is overflow:hidden
The change from https://chromiumcodereview.appspot.com/23537039 is
reverted (the cause for the regression). This patch also fixes the original
issue 23537039 tried to address. If the target element was a descendant of an
inline-block the PaintInfo::shouldPaintWithinRoot did an early return from the
paint call on inlineFlowBox. We let the paint call go through by clearing the
paintRoot, on the basis that the inlineFlowBoxes will be intersecting the paint
rect.
BUG=341089, 101204
Review URL: https://codereview.chromium.org/278293002
git-svn-id: svn://svn.chromium.org/blink/trunk@176613 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/third_party/WebKit/ManualTests/drag-inline-block.html b/third_party/WebKit/ManualTests/drag-inline-block.html
deleted file mode 100644
index 300dba2..0000000
--- a/third_party/WebKit/ManualTests/drag-inline-block.html
+++ /dev/null
@@ -1,35 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <style>
- .container {
- margin: 10px;
- width: 300px;
- height: 200px;
- background-color: grey;
- }
-
- .static {
- display: static;
- }
-
- .inline-block {
- display: inline-block;
- }
-
- *[draggable=true] {
- width: 100px;
- height: 100px;
- margin: 10px;
- background-color: green;
- }
- </style>
- </head>
- <body>
- <div class="container inline-block static">
- display: inline-block; position: static;
- <div draggable="true">Drag Me</div>
- If the drag-icon follow the mouse pointer while dragging the above green div, the test passes.
- </div>
- </body>
-</html>
diff --git a/third_party/WebKit/ManualTests/drag-should-draw-target.html b/third_party/WebKit/ManualTests/drag-should-draw-target.html
new file mode 100644
index 0000000..6498d633
--- /dev/null
+++ b/third_party/WebKit/ManualTests/drag-should-draw-target.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <style>
+ .container {
+ margin: 10px;
+ width: 300px;
+ height: 200px;
+ background-color: grey;
+ }
+
+ .static {
+ display: static;
+ }
+
+ .inline-block {
+ display: inline-block;
+ }
+
+ .floatleft {
+ float: left;
+ }
+
+ *[draggable=true] {
+ width: 100px;
+ height: 100px;
+ margin: 10px;
+ background-color: green;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="container inline-block static">
+ display: inline-block; position: static;
+ <div draggable="true">Drag Me</div>
+ If the drag-icon follows the mouse pointer while dragging the above green block, the test passes.
+ </div>
+
+ <div class="container" style="overflow:hidden">
+ greybox overflow:hidden; greenbox float:left;<br>
+ <div class="floatleft" draggable="true">Drag Me</div>
+ If the drag-icon follows the mouse pointer while dragging the green block to the left, the test passes.
+ </div>
+
+ </body>
+</html>
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp
index f03a184..7f2fd85 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -2753,8 +2753,7 @@
RenderObject::SetLayoutNeededForbiddenScope forbidSetNeedsLayout(*rootLayer->renderer());
#endif
- RenderObject* enclosingLayerRenderer = renderer ? renderer->enclosingLayer()->renderer() : 0;
- rootLayer->paint(p, rect, m_paintBehavior, enclosingLayerRenderer);
+ rootLayer->paint(p, rect, m_paintBehavior, renderer);
if (rootLayer->containsDirtyOverlayScrollbars())
rootLayer->paintOverlayScrollbars(p, rect, m_paintBehavior, renderer);
diff --git a/third_party/WebKit/Source/core/rendering/InlineFlowBox.cpp b/third_party/WebKit/Source/core/rendering/InlineFlowBox.cpp
index 5346e4b..dd149d9 100644
--- a/third_party/WebKit/Source/core/rendering/InlineFlowBox.cpp
+++ b/third_party/WebKit/Source/core/rendering/InlineFlowBox.cpp
@@ -1143,12 +1143,17 @@
return;
PaintPhase paintPhase = paintInfo.phase == PaintPhaseChildOutlines ? PaintPhaseOutline : paintInfo.phase;
- PaintInfo childInfo(paintInfo);
- childInfo.phase = paintPhase;
- childInfo.updatePaintingRootForChildren(&renderer());
// Paint our children.
if (paintPhase != PaintPhaseSelfOutline) {
+ PaintInfo childInfo(paintInfo);
+ childInfo.phase = paintPhase;
+
+ if (childInfo.paintingRoot && childInfo.paintingRoot->isDescendantOf(&renderer()))
+ childInfo.paintingRoot = 0;
+ else
+ childInfo.updatePaintingRootForChildren(&renderer());
+
for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
if (curr->renderer().isText() || !curr->boxModelObject()->hasSelfPaintingLayer())
curr->paint(childInfo, paintOffset, lineTop, lineBottom);
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
index 19911983..f6260f92 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -5508,22 +5508,28 @@
EXPECT_EQ(WebURLRequest::ReloadBypassingCache, frame->dataSource()->request().cachePolicy());
}
+static void nodeImageTestValidation(const WebCore::IntSize& referenceBitmapSize, WebCore::DragImage* dragImage)
+{
+ // Prepare the reference bitmap.
+ SkBitmap bitmap;
+ ASSERT_TRUE(bitmap.allocN32Pixels(referenceBitmapSize.width(), referenceBitmapSize.height()));
+ SkCanvas canvas(bitmap);
+ canvas.drawColor(SK_ColorGREEN);
+
+ EXPECT_EQ(referenceBitmapSize.width(), dragImage->size().width());
+ EXPECT_EQ(referenceBitmapSize.height(), dragImage->size().height());
+ const SkBitmap& dragBitmap = dragImage->bitmap();
+ SkAutoLockPixels lockPixel(dragBitmap);
+ EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.getSize()));
+}
+
TEST_F(WebFrameTest, NodeImageTestCSSTransform)
{
FrameTestHelpers::WebViewHelper webViewHelper;
OwnPtr<WebCore::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string("case-css-transform"));
EXPECT_TRUE(dragImage);
- SkBitmap bitmap;
- ASSERT_TRUE(bitmap.allocN32Pixels(40, 40));
- SkCanvas canvas(bitmap);
- canvas.drawColor(SK_ColorGREEN);
-
- EXPECT_EQ(40, dragImage->size().width());
- EXPECT_EQ(40, dragImage->size().height());
- const SkBitmap& dragBitmap = dragImage->bitmap();
- SkAutoLockPixels lockPixel(dragBitmap);
- EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.getSize()));
+ nodeImageTestValidation(WebCore::IntSize(40, 40), dragImage.get());
}
TEST_F(WebFrameTest, NodeImageTestCSS3DTransform)
@@ -5532,16 +5538,25 @@
OwnPtr<WebCore::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string("case-css-3dtransform"));
EXPECT_TRUE(dragImage);
- SkBitmap bitmap;
- ASSERT_TRUE(bitmap.allocN32Pixels(20, 40));
- SkCanvas canvas(bitmap);
- canvas.drawColor(SK_ColorGREEN);
+ nodeImageTestValidation(WebCore::IntSize(20, 40), dragImage.get());
+}
- EXPECT_EQ(20, dragImage->size().width());
- EXPECT_EQ(40, dragImage->size().height());
- const SkBitmap& dragBitmap = dragImage->bitmap();
- SkAutoLockPixels lockPixel(dragBitmap);
- EXPECT_EQ(0, memcmp(bitmap.getPixels(), dragBitmap.getPixels(), bitmap.getSize()));
+TEST_F(WebFrameTest, NodeImageTestInlineBlock)
+{
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ OwnPtr<WebCore::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string("case-inlineblock"));
+ EXPECT_TRUE(dragImage);
+
+ nodeImageTestValidation(WebCore::IntSize(40, 40), dragImage.get());
+}
+
+TEST_F(WebFrameTest, NodeImageTestFloatLeft)
+{
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ OwnPtr<WebCore::DragImage> dragImage = nodeImageTestSetup(&webViewHelper, std::string("case-float-left-overflow-hidden"));
+ EXPECT_TRUE(dragImage);
+
+ nodeImageTestValidation(WebCore::IntSize(40, 40), dragImage.get());
}
class BrandColorTestWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
diff --git a/third_party/WebKit/Source/web/tests/data/nodeimage.html b/third_party/WebKit/Source/web/tests/data/nodeimage.html
index e24e87a..846a2db4 100644
--- a/third_party/WebKit/Source/web/tests/data/nodeimage.html
+++ b/third_party/WebKit/Source/web/tests/data/nodeimage.html
@@ -10,3 +10,15 @@
<div draggable="true" id="case-css-3dtransform" style="background-color: #00ff00;width: 40px;height: 40px;"></div>
</div>
</div>
+
+<div style="width: 40px">
+ <div style="display: inline-block">
+ <div draggable="true" id="case-inlineblock" style="background-color: #00ff00;width: 40px;height: 40px;"></div>
+ </div>
+</div>
+
+<div style="width: 40px">
+ <div style="overflow: hidden">
+ <div draggable="true" id="case-float-left-overflow-hidden" style="float: left;background-color: #00ff00;width: 40px;height: 40px;"></div>
+ </div>
+</div>