https://bugs.webkit.org/show_bug.cgi?id=39503
Reviewed by Kenneth Rohde Christiansen.
Source/WebCore:
The bug was caused by a false assumption in RenderBlock::positionForPoint. Because the last child box
can be positioned, floated, invisible, etc..., we can't always trust last child's logicalTop to tell us
whether a given point is inside or below the last child box.
Fixed the bug by using the last hit-test candidate instead.
Test: editing/selection/block-with-positioned-lastchild.html
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::positionForPoint):
LayoutTests:
Added a regression test for placing the caret inside a block with multiple logical lines
with an absolutely positioned last child. WebKit should place the caret on the left of the first line
(instead of after the last line) when the user clicks on the left of the first line.
* editing/selection/block-with-positioned-lastchild-expected.txt: Added.
* editing/selection/block-with-positioned-lastchild.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95478
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-09-19 Ryosuke Niwa <rniwa@webkit.org>
+
+ Incorrect selection with absolutely positioned div
+ https://bugs.webkit.org/show_bug.cgi?id=39503
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Added a regression test for placing the caret inside a block with multiple logical lines
+ with an absolutely positioned last child. WebKit should place the caret on the left of the first line
+ (instead of after the last line) when the user clicks on the left of the first line.
+
+ * editing/selection/block-with-positioned-lastchild-expected.txt: Added.
+ * editing/selection/block-with-positioned-lastchild.html: Added.
+
2011-09-19 Abhishek Arya <inferno@chromium.org>
Unreviewed. Chromium Rebaselines for r95461.
--- /dev/null
+Click on the left of this line.
+Caret should NOT be placed in this line,
+PASS
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<body>
+<div style="padding: 20px;" contenteditable>Click on the left of this line.
+<div>Caret should NOT be placed in this line,</div>
+<div style="position:absolute; top:0px; right:0px;"></div>
+</div>
+<pre><script>
+
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+
+ var container = document.body.children[0];
+ eventSender.mouseMoveTo(container.offsetLeft + 5, container.offsetTop + 5);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+
+ if (!getSelection().isCollapsed)
+ document.writeln('FAIL - selection was not collapsed');
+ else if (getSelection().baseNode != container.firstChild)
+ document.writeln('FAIL - caret was not in the first line');
+ else if (getSelection().baseOffset)
+ document.writeln('FAIL - caret was not on the left edge');
+ else
+ document.writeln('PASS');
+}
+
+</script></pre>
+</body>
+</html>
+2011-09-19 Ryosuke Niwa <rniwa@webkit.org>
+
+ Incorrect selection with absolutely positioned div
+ https://bugs.webkit.org/show_bug.cgi?id=39503
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ The bug was caused by a false assumption in RenderBlock::positionForPoint. Because the last child box
+ can be positioned, floated, invisible, etc..., we can't always trust last child's logicalTop to tell us
+ whether a given point is inside or below the last child box.
+
+ Fixed the bug by using the last hit-test candidate instead.
+
+ Test: editing/selection/block-with-positioned-lastchild.html
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::positionForPoint):
+
2011-09-19 Dmitry Titov <dimich@chromium.org>
[Chromium] Crash after magic iframe transfer for Pepper/NaCl plugins.
if (childrenInline())
return positionForPointWithInlineChildren(pointInLogicalContents);
- if (lastChildBox() && pointInContents.y() > lastChildBox()->logicalTop()) {
- for (RenderBox* childBox = lastChildBox(); childBox; childBox = childBox->previousSiblingBox()) {
- if (isChildHitTestCandidate(childBox))
- return positionForPointRespectingEditingBoundaries(this, childBox, pointInContents);
- }
- } else {
+ RenderBox* lastCandidateBox = lastChildBox();
+ while (lastCandidateBox && !isChildHitTestCandidate(lastCandidateBox))
+ lastCandidateBox = lastCandidateBox->previousSiblingBox();
+
+ if (lastCandidateBox) {
+ if (pointInContents.y() > lastCandidateBox->logicalTop())
+ return positionForPointRespectingEditingBoundaries(this, lastCandidateBox, pointInContents);
+
for (RenderBox* childBox = firstChildBox(); childBox; childBox = childBox->nextSiblingBox()) {
// We hit child if our click is above the bottom of its padding box (like IE6/7 and FF3).
if (isChildHitTestCandidate(childBox) && pointInContents.y() < childBox->logicalBottom())