Title: [91481] trunk
- Revision
- 91481
- Author
- [email protected]
- Date
- 2011-07-21 11:45:44 -0700 (Thu, 21 Jul 2011)
Log Message
Cannot click to position the caret to the right of an image with display:block style.
https://bugs.webkit.org/show_bug.cgi?id=64962
<rdar://problem/9446343>
Reviewed by David Hyatt.
Source/WebCore:
Test: editing/selection/click-on-block-image.html
The current implementation of positionForPoint always returns the visible
position to the left of the image, if the image has a block style.
This patch changes the behavior for block styled images to match the behavior
for inline images.
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::positionForPoint): Modified to avoid relying entirely
on InlineBox to calculate the position.
LayoutTests:
* editing/selection/click-on-block-image-expected.txt: Added.
* editing/selection/click-on-block-image.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (91480 => 91481)
--- trunk/LayoutTests/ChangeLog 2011-07-21 18:37:15 UTC (rev 91480)
+++ trunk/LayoutTests/ChangeLog 2011-07-21 18:45:44 UTC (rev 91481)
@@ -1,3 +1,14 @@
+2011-07-21 Enrica Casucci <[email protected]>
+
+ Cannot click to position the caret to the right of an image with display:block style.
+ https://bugs.webkit.org/show_bug.cgi?id=64962
+ <rdar://problem/9446343>
+
+ Reviewed by David Hyatt.
+
+ * editing/selection/click-on-block-image-expected.txt: Added.
+ * editing/selection/click-on-block-image.html: Added.
+
2011-07-21 Ryosuke Niwa <[email protected]>
Chromium rebaseline for r91474.
Added: trunk/LayoutTests/editing/selection/click-on-block-image-expected.txt (0 => 91481)
--- trunk/LayoutTests/editing/selection/click-on-block-image-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/selection/click-on-block-image-expected.txt 2011-07-21 18:45:44 UTC (rev 91481)
@@ -0,0 +1,4 @@
+To run this test manually, click to the left and verify that the caret is placed to the left of the image, then click to the right of the image and verify that the caret is on the right.
+helloworld
+Anchor ([object HTMLDivElement], 1) is correct.
+Anchor ([object HTMLDivElement], 2) is correct.
Added: trunk/LayoutTests/editing/selection/click-on-block-image.html (0 => 91481)
--- trunk/LayoutTests/editing/selection/click-on-block-image.html (rev 0)
+++ trunk/LayoutTests/editing/selection/click-on-block-image.html 2011-07-21 18:45:44 UTC (rev 91481)
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>This tests the ability to place the caret to the left and to the right of an image with display block style.</title>
+</head>
+<body>
+ To run this test manually, click to the left and verify that the caret is placed to the left of the image, then click to the right of the image and verify that the caret is on the right.
+ <div contentEditable="true" id="test">hello<img id='myimage' style="margin-left: 100px; display:block; width: 76px; height: 103px" src=""
+ <ul id="console"></ul>
+</body>
+<script>
+function log(str) {
+ var li = document.createElement("li");
+ li.appendChild(document.createTextNode(str));
+ var console = document.getElementById("console");
+ console.appendChild(li);
+}
+
+function runTest(x, y, elem, offset) {
+ eventSender.mouseMoveTo(x, y);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+
+ var selection = window.getSelection();
+
+ var anchorNode = selection.anchorNode;
+ var anchorOffset = selection.anchorOffset;
+
+ var anchorString = "Anchor (" + anchorNode + ", " + anchorOffset + ")";
+ var anchorCorrect = anchorNode == elem && anchorOffset == offset;
+ if (anchorCorrect)
+ log(anchorString + " is correct.");
+ else
+ log(anchorString + " is incorrect.");
+}
+
+function automaticTest() {
+ if (window.layoutTestController) {
+ window.layoutTestController.dumpAsText();
+
+ var elem;
+ elem = document.getElementById("myimage");
+
+ runTest(elem.offsetLeft - 10, elem.offsetTop + 10, document.getElementById("test"), 1);
+ runTest(elem.offsetLeft + elem.offsetWidth + 10, elem.offsetTop + 10, document.getElementById("test"), 2);
+ }
+}
+
+automaticTest();
+</script>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (91480 => 91481)
--- trunk/Source/WebCore/ChangeLog 2011-07-21 18:37:15 UTC (rev 91480)
+++ trunk/Source/WebCore/ChangeLog 2011-07-21 18:45:44 UTC (rev 91481)
@@ -1,3 +1,22 @@
+2011-07-21 Enrica Casucci <[email protected]>
+
+ Cannot click to position the caret to the right of an image with display:block style.
+ https://bugs.webkit.org/show_bug.cgi?id=64962
+ <rdar://problem/9446343>
+
+ Reviewed by David Hyatt.
+
+ Test: editing/selection/click-on-block-image.html
+
+ The current implementation of positionForPoint always returns the visible
+ position to the left of the image, if the image has a block style.
+ This patch changes the behavior for block styled images to match the behavior
+ for inline images.
+
+ * rendering/RenderReplaced.cpp:
+ (WebCore::RenderReplaced::positionForPoint): Modified to avoid relying entirely
+ on InlineBox to calculate the position.
+
2011-07-21 Pavel Feldman <[email protected]>
Not reviewed: one liner typo fix in Inspector.json.
Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (91480 => 91481)
--- trunk/Source/WebCore/rendering/RenderReplaced.cpp 2011-07-21 18:37:15 UTC (rev 91480)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp 2011-07-21 18:45:44 UTC (rev 91481)
@@ -416,20 +416,16 @@
VisiblePosition RenderReplaced::positionForPoint(const LayoutPoint& point)
{
- InlineBox* box = inlineBoxWrapper();
- if (!box)
- return createVisiblePosition(0, DOWNSTREAM);
-
// FIXME: This code is buggy if the replaced element is relative positioned.
-
- RootInlineBox* root = box->root();
-
- LayoutUnit top = root->selectionTop();
- LayoutUnit bottom = root->selectionBottom();
-
- LayoutUnit blockDirectionPosition = box->isHorizontal() ? point.y() + y() : point.x() + x();
- LayoutUnit lineDirectionPosition = box->isHorizontal() ? point.x() + x() : point.y() + y();
-
+ InlineBox* box = inlineBoxWrapper();
+ RootInlineBox* rootBox = box ? box->root() : 0;
+
+ LayoutUnit top = rootBox ? rootBox->selectionTop() : logicalTop();
+ LayoutUnit bottom = rootBox ? rootBox->selectionBottom() : logicalBottom();
+
+ LayoutUnit blockDirectionPosition = isHorizontalWritingMode() ? point.y() + y() : point.x() + x();
+ LayoutUnit lineDirectionPosition = isHorizontalWritingMode() ? point.x() + x() : point.y() + y();
+
if (blockDirectionPosition < top)
return createVisiblePosition(caretMinOffset(), DOWNSTREAM); // coordinates are above
@@ -437,7 +433,7 @@
return createVisiblePosition(caretMaxOffset(), DOWNSTREAM); // coordinates are below
if (node()) {
- if (lineDirectionPosition <= box->logicalLeft() + (box->logicalWidth() / 2))
+ if (lineDirectionPosition <= logicalLeft() + (logicalWidth() / 2))
return createVisiblePosition(0, DOWNSTREAM);
return createVisiblePosition(1, DOWNSTREAM);
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes