Commit c79077ea authored by darin@apple.com's avatar darin@apple.com

WebCore:

2009-04-13  Darin Adler  <darin@apple.com>

        Reviewed by Dan Bernstein.

        Bug 25158: hit testing doesn't work right in some cases involving anonymous blocks
        https://bugs.webkit.org/show_bug.cgi?id=25158
        rdar://problem/6769693

        Test: editing/selection/click-after-nested-block.html

        * rendering/RenderBlock.cpp:
        (WebCore::isChildHitTestCandidate): Added. Helper so the two loops in positionForPoint
        can share code.
        (WebCore::RenderBlock::positionForPoint): Removed unneeded special case for first
        child box. Changed special case for last child box to propertly handle the various
        types of child box that are not hit test candidates (the same ones already handled
        by the hit test loop below), adding in a loop so we find the last candidate.

LayoutTests:

2009-04-13  Darin Adler  <darin@apple.com>

        Reviewed by Dan Bernstein.

        Bug 25158: hit testing doesn't work right in some cases involving anonymous blocks
        https://bugs.webkit.org/show_bug.cgi?id=25158
        rdar://problem/6769693

        * editing/selection/click-after-nested-block-expected.txt: Added.
        * editing/selection/click-after-nested-block.html: Added.

        * fast/events/pointer-events-expected.txt: Updated since this is now a plain-text test.
        * fast/events/pointer-events.html: Changed this to a plain-text test, because the old
        results reflected a difference in hit testing behavior that this test was not intended
        to exercise and it's better to have the test be more cross-platform. Also removed
        unneeded use of waitUntilDone.

        * fast/js/finally-codegen-failure.html: Replaced with standard wrapper created by
        running the make-js-test-wrappers script. If we want to include type and charset
        attributes in the script elements, we can change make-js-test-wrappers to do that
        for all tests at some point.
        * fast/js/function-apply-aliased.html: Ditto.
        * fast/js/function-call-aliased.html: Ditto.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@42467 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 640be50f
2009-04-13 Darin Adler <darin@apple.com>
Reviewed by Dan Bernstein.
Bug 25158: hit testing doesn't work right in some cases involving anonymous blocks
https://bugs.webkit.org/show_bug.cgi?id=25158
rdar://problem/6769693
* editing/selection/click-after-nested-block-expected.txt: Added.
* editing/selection/click-after-nested-block.html: Added.
* fast/events/pointer-events-expected.txt: Updated since this is now a plain-text test.
* fast/events/pointer-events.html: Changed this to a plain-text test, because the old
results reflected a difference in hit testing behavior that this test was not intended
to exercise and it's better to have the test be more cross-platform. Also removed
unneeded use of waitUntilDone.
* fast/js/finally-codegen-failure.html: Replaced with standard wrapper created by
running the make-js-test-wrappers script. If we want to include type and charset
attributes in the script elements, we can change make-js-test-wrappers to do that
for all tests at some point.
* fast/js/function-apply-aliased.html: Ditto.
* fast/js/function-call-aliased.html: Ditto.
2009-04-13 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
Rubber-stamped by Holger Freyther.
......
This is a test for a bug where clicking below a block didn't work right if the block was nested inside an inline.
To test interactively, click below and to the right of the 2 in line 2. The caret should appear after the 2.
SUCCESS
line 1
line 2
<html>
<head>
<script>
function runTest()
{
if (!window.layoutTestController)
return;
layoutTestController.dumpAsText();
var target = document.getElementById("test");
x = target.offsetLeft + target.offsetWidth - 10;
y = target.offsetTop + target.offsetHeight - 10;
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.mouseUp();
}
function setTestResultMessage()
{
var line2Text = document.getElementById("line2").firstChild;
var result = "FAILED";
if (getSelection().rangeCount !== 1)
result = "FAILED: Selection had range count of " + getSelection().rangeCount;
else if (getSelection().getRangeAt(0).startContainer !== line2Text)
result = "FAILED: Selection was not within second line of text.";
else if (getSelection().getRangeAt(0).endContainer !== line2Text)
result = "FAILED: Selection end was not within second line of text.";
else if (getSelection().getRangeAt(0).startOffset !== getSelection().getRangeAt(0).endOffset)
result = "FAILED: Selection was not a caret.";
else if (getSelection().getRangeAt(0).startOffset !== 6)
result = "FAILED: Selection was not at the end of the line.";
else
result = "SUCCESS";
document.getElementById("message").firstChild.data = result;
}
</script>
</head>
<body onload="runTest()" onclick="setTestResultMessage()">
<p>
This is a test for a bug where clicking below a block didn't work right if
the block was nested inside an inline.
</p>
<p>
To test interactively, click below and to the right of the 2 in line 2.
The caret should appear after the 2.
</p>
<p id="message">TEST HAS NOT RUN YET</p>
<hr>
<div contenteditable id="test" style="font-size: 48px; width: 250px; height: 250px"><div>line 1</div><div><span><div id="line2">line 2</div></span></div></div>
</body>
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x105
RenderBlock {HTML} at (0,0) size 800x105
RenderBody {BODY} at (8,21) size 784x76
RenderBlock {H1} at (0,0) size 784x37
RenderText {#text} at (0,0) size 759x37
text run at (0,0) width 759: "Testing the values of 'pointer-events' on HTML content"
RenderBlock {DIV} at (0,58) size 784x18
RenderText {#text} at (0,0) size 448x18
text run at (0,0) width 448: "The labels on the left will be clicked and the result is shown to the right"
RenderBlock {DIV} at (0,76) size 784x0
layer at (10,120) size 100x30
RenderBlock (positioned) {P} at (10,120) size 100x30
RenderText {#text} at (0,0) size 35x23
text run at (0,0) width 35: "auto"
layer at (140,120) size 100x30
RenderBlock (positioned) {P} at (140,120) size 100x30
RenderText {#text} at (0,0) size 33x23
text run at (0,0) width 33: "HIT"
layer at (10,160) size 100x30
RenderBlock (positioned) {P} at (10,160) size 100x30
RenderText {#text} at (0,0) size 39x23
text run at (0,0) width 39: "none"
layer at (140,160) size 100x30
RenderBlock (positioned) {P} at (140,160) size 100x30
RenderText {#text} at (0,0) size 38x23
text run at (0,0) width 38: "miss"
caret: position 0 of child 0 {#text} of child 1 {P} of child 5 {DIV} of child 1 {BODY} of child 1 {HTML} of document
Testing the values of 'pointer-events' on HTML content
The labels on the left will be clicked and the result is shown to the right
auto-HIT-none-miss-
......@@ -15,19 +15,19 @@
}
</style>
<script>
if (window.layoutTestController)
layoutTestController.waitUntilDone();
var pointerEventsValues = ['auto', 'none'];
var topEdge = 120;
function clickHit(identifierString) {
var text = document.getElementById('text' + identifierString);
text.textContent = 'HIT';
text.textContent = '-HIT-';
}
function testContent() {
if (window.layoutTestController)
layoutTestController.dumpAsText();
var yOffset = topEdge;
var testContent = document.getElementById("test-content");
......@@ -45,7 +45,7 @@
hit.style.left = "140px";
hit.style.top = yOffset + "px";
hit.id = "text" + pointerEventsValues[pi];
hit.appendChild(document.createTextNode("miss"));
hit.appendChild(document.createTextNode("-miss-"));
testContent.appendChild(hit);
......@@ -58,9 +58,6 @@
yOffset += 40;
}
if (window.layoutTestController)
layoutTestController.notifyDone();
}
</script>
......
<!DOCTYPE html>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="resources/js-test-style.css">
......@@ -7,7 +7,7 @@
<body>
<p id="description"></p>
<div id="console"></div>
<script src="resources/finally-codegen-failure.js" type="text/javascript" charset="utf-8"></script>
<script src="resources/finally-codegen-failure.js"></script>
<script src="resources/js-test-post.js"></script>
</body>
</html>
......@@ -7,7 +7,7 @@
<body>
<p id="description"></p>
<div id="console"></div>
<script src="resources/function-apply-aliased.js" type="text/javascript" charset="utf-8"></script>
<script src="resources/function-apply-aliased.js"></script>
<script src="resources/js-test-post.js"></script>
</body>
</html>
......@@ -7,7 +7,7 @@
<body>
<p id="description"></p>
<div id="console"></div>
<script src="resources/function-call-aliased.js" type="text/javascript" charset="utf-8"></script>
<script src="resources/function-call-aliased.js"></script>
<script src="resources/js-test-post.js"></script>
</body>
</html>
2009-04-13 Darin Adler <darin@apple.com>
Reviewed by Dan Bernstein.
Bug 25158: hit testing doesn't work right in some cases involving anonymous blocks
https://bugs.webkit.org/show_bug.cgi?id=25158
rdar://problem/6769693
Test: editing/selection/click-after-nested-block.html
* rendering/RenderBlock.cpp:
(WebCore::isChildHitTestCandidate): Added. Helper so the two loops in positionForPoint
can share code.
(WebCore::RenderBlock::positionForPoint): Removed unneeded special case for first
child box. Changed special case for last child box to propertly handle the various
types of child box that are not hit test candidates (the same ones already handled
by the hit test loop below), adding in a loop so we find the last candidate.
2009-04-13 David Hyatt <hyatt@apple.com>
Reviewed by Sam Weinig.
......@@ -3492,6 +3492,11 @@ static VisiblePosition positionForPointWithInlineChildren(RenderBlock* block, co
return block->createVisiblePosition(0, DOWNSTREAM);
}
static inline bool isChildHitTestCandidate(RenderBox* box)
{
return box->height() && box->style()->visibility() == VISIBLE && !box->isFloatingOrPositioned();
}
VisiblePosition RenderBlock::positionForPoint(const IntPoint& point)
{
if (isTable())
......@@ -3513,19 +3518,17 @@ VisiblePosition RenderBlock::positionForPoint(const IntPoint& point)
return positionForPointWithInlineChildren(this, pointInContents);
}
// Check top/bottom child-margin/parent-padding for clicks and place them in the first/last child
// FIXME: This will not correctly handle first or last children being positioned or non-visible
if (firstChildBox() && contentsY < firstChildBox()->y())
return positionForPointRespectingEditingBoundaries(this, firstChildBox(), pointInContents);
if (lastChildBox() && contentsY > lastChildBox()->y())
return positionForPointRespectingEditingBoundaries(this, lastChildBox(), pointInContents);
for (RenderBox* childBox = firstChildBox(); childBox; childBox = childBox->nextSiblingBox()) {
if (childBox->height() == 0 || childBox->style()->visibility() != VISIBLE || childBox->isFloatingOrPositioned())
continue;
// We hit this child if our click was above the bottom of its padding box (like IE6/7 and FF3)
if (contentsY < childBox->y() + childBox->height())
return positionForPointRespectingEditingBoundaries(this, childBox, pointInContents);
if (lastChildBox() && contentsY > lastChildBox()->y()) {
for (RenderBox* childBox = lastChildBox(); childBox; childBox = childBox->previousSiblingBox()) {
if (isChildHitTestCandidate(childBox))
return positionForPointRespectingEditingBoundaries(this, childBox, pointInContents);
}
} else {
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) && contentsY < childBox->frameRect().bottom())
return positionForPointRespectingEditingBoundaries(this, childBox, pointInContents);
}
}
// We only get here if there are no, or only floated/positioned, or only
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment