- Revision
- 138317
- Author
- [email protected]
- Date
- 2012-12-20 16:15:22 -0800 (Thu, 20 Dec 2012)
Log Message
RenderBlock hit testing should ignore PseudoElements
https://bugs.webkit.org/show_bug.cgi?id=105545
Reviewed by Eric Seidel.
Source/WebCore:
Use nonPseudoNode() in hit testing code in RenderBlock and RenderBox so
that when clicking on the box generated by a pseudo element we never
generate a Position for the PseudoElement, but instead for the
generating node.
Test: fast/css-generated-content/block-and-box-hit-testing.html
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::positionForBox):
(WebCore::isEditingBoundary):
(WebCore::positionForPointRespectingEditingBoundaries):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::positionForPoint):
LayoutTests:
Add test for hit testing on pseudo element generated blocks and boxes.
* fast/css-generated-content/block-and-box-hit-testing-expected.txt: Added.
* fast/css-generated-content/block-and-box-hit-testing.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (138316 => 138317)
--- trunk/LayoutTests/ChangeLog 2012-12-21 00:13:14 UTC (rev 138316)
+++ trunk/LayoutTests/ChangeLog 2012-12-21 00:15:22 UTC (rev 138317)
@@ -1,3 +1,15 @@
+2012-12-20 Elliott Sprehn <[email protected]>
+
+ RenderBlock hit testing should ignore PseudoElements
+ https://bugs.webkit.org/show_bug.cgi?id=105545
+
+ Reviewed by Eric Seidel.
+
+ Add test for hit testing on pseudo element generated blocks and boxes.
+
+ * fast/css-generated-content/block-and-box-hit-testing-expected.txt: Added.
+ * fast/css-generated-content/block-and-box-hit-testing.html: Added.
+
2012-12-20 Stephen Chenney <[email protected]>
SVG: <altglpyh> for a surrogate pair character in a ligature fails
Added: trunk/LayoutTests/fast/css-generated-content/block-and-box-hit-testing-expected.txt (0 => 138317)
--- trunk/LayoutTests/fast/css-generated-content/block-and-box-hit-testing-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css-generated-content/block-and-box-hit-testing-expected.txt 2012-12-21 00:15:22 UTC (rev 138317)
@@ -0,0 +1 @@
+Bug 105545 - RenderBlock and RenderBox hit testing should ignore PseudoElements
Added: trunk/LayoutTests/fast/css-generated-content/block-and-box-hit-testing.html (0 => 138317)
--- trunk/LayoutTests/fast/css-generated-content/block-and-box-hit-testing.html (rev 0)
+++ trunk/LayoutTests/fast/css-generated-content/block-and-box-hit-testing.html 2012-12-21 00:15:22 UTC (rev 138317)
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+
+<style>
+ html, body {
+ margin: 0;
+ padding: 0;
+ font-size: 14px;
+ }
+
+ div:before {
+ display: block;
+ content: "Clicking the red border should not crash.";
+ border: 5px solid red;
+ }
+
+ div:after {
+ display: table;
+ content: "Clicking the margin should not crash.";
+ margin: 10px;
+ background: yellow;
+ }
+</style>
+
+<div></div>
+
+<p>Bug 105545 - RenderBlock and RenderBox hit testing should ignore PseudoElements</p>
+
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+if (window.eventSender) {
+ eventSender.mouseMoveTo(0, 0);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ eventSender.mouseMoveTo(0, 40);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+}
+</script>
Modified: trunk/Source/WebCore/ChangeLog (138316 => 138317)
--- trunk/Source/WebCore/ChangeLog 2012-12-21 00:13:14 UTC (rev 138316)
+++ trunk/Source/WebCore/ChangeLog 2012-12-21 00:15:22 UTC (rev 138317)
@@ -1,3 +1,24 @@
+2012-12-20 Elliott Sprehn <[email protected]>
+
+ RenderBlock hit testing should ignore PseudoElements
+ https://bugs.webkit.org/show_bug.cgi?id=105545
+
+ Reviewed by Eric Seidel.
+
+ Use nonPseudoNode() in hit testing code in RenderBlock and RenderBox so
+ that when clicking on the box generated by a pseudo element we never
+ generate a Position for the PseudoElement, but instead for the
+ generating node.
+
+ Test: fast/css-generated-content/block-and-box-hit-testing.html
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::positionForBox):
+ (WebCore::isEditingBoundary):
+ (WebCore::positionForPointRespectingEditingBoundaries):
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::positionForPoint):
+
2012-12-20 Stephen Chenney <[email protected]>
SVG: <altglpyh> for a surrogate pair character in a ligature fails
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (138316 => 138317)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-12-21 00:13:14 UTC (rev 138316)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-12-21 00:15:22 UTC (rev 138317)
@@ -4935,22 +4935,22 @@
if (!box)
return Position();
- if (!box->renderer()->node())
- return createLegacyEditingPosition(node(), start ? caretMinOffset() : caretMaxOffset());
+ if (!box->renderer()->nonPseudoNode())
+ return createLegacyEditingPosition(nonPseudoNode(), start ? caretMinOffset() : caretMaxOffset());
if (!box->isInlineTextBox())
- return createLegacyEditingPosition(box->renderer()->node(), start ? box->renderer()->caretMinOffset() : box->renderer()->caretMaxOffset());
+ return createLegacyEditingPosition(box->renderer()->nonPseudoNode(), start ? box->renderer()->caretMinOffset() : box->renderer()->caretMaxOffset());
InlineTextBox* textBox = toInlineTextBox(box);
- return createLegacyEditingPosition(box->renderer()->node(), start ? textBox->start() : textBox->start() + textBox->len());
+ return createLegacyEditingPosition(box->renderer()->nonPseudoNode(), start ? textBox->start() : textBox->start() + textBox->len());
}
static inline bool isEditingBoundary(RenderObject* ancestor, RenderObject* child)
{
- ASSERT(!ancestor || ancestor->node());
- ASSERT(child && child->node());
+ ASSERT(!ancestor || ancestor->nonPseudoNode());
+ ASSERT(child && child->nonPseudoNode());
return !ancestor || !ancestor->parent() || (ancestor->hasLayer() && ancestor->parent()->isRenderView())
- || ancestor->node()->rendererIsEditable() == child->node()->rendererIsEditable();
+ || ancestor->nonPseudoNode()->rendererIsEditable() == child->nonPseudoNode()->rendererIsEditable();
}
// FIXME: This function should go on RenderObject as an instance method. Then
@@ -4966,14 +4966,14 @@
LayoutPoint pointInChildCoordinates(toLayoutPoint(pointInParentCoordinates - childLocation));
// If this is an anonymous renderer, we just recur normally
- Node* childNode = child->node();
+ Node* childNode = child->nonPseudoNode();
if (!childNode)
return child->positionForPoint(pointInChildCoordinates);
// Otherwise, first make sure that the editability of the parent and child agree.
// If they don't agree, then we return a visible position just before or after the child
RenderObject* ancestor = parent;
- while (ancestor && !ancestor->node())
+ while (ancestor && !ancestor->nonPseudoNode())
ancestor = ancestor->parent();
// If we can't find an ancestor to check editability on, or editability is unchanged, we recur like normal
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (138316 => 138317)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2012-12-21 00:13:14 UTC (rev 138316)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2012-12-21 00:15:22 UTC (rev 138317)
@@ -3715,16 +3715,16 @@
{
// no children...return this render object's element, if there is one, and offset 0
if (!firstChild())
- return createVisiblePosition(node() ? firstPositionInOrBeforeNode(node()) : Position());
+ return createVisiblePosition(nonPseudoNode() ? firstPositionInOrBeforeNode(nonPseudoNode()) : Position());
- if (isTable() && node()) {
+ if (isTable() && nonPseudoNode()) {
LayoutUnit right = contentWidth() + borderAndPaddingWidth();
LayoutUnit bottom = contentHeight() + borderAndPaddingHeight();
if (point.x() < 0 || point.x() > right || point.y() < 0 || point.y() > bottom) {
if (point.x() <= right / 2)
- return createVisiblePosition(firstPositionInOrBeforeNode(node()));
- return createVisiblePosition(lastPositionInOrAfterNode(node()));
+ return createVisiblePosition(firstPositionInOrBeforeNode(nonPseudoNode()));
+ return createVisiblePosition(lastPositionInOrAfterNode(nonPseudoNode()));
}
}
@@ -3792,7 +3792,7 @@
if (closestRenderer)
return closestRenderer->positionForPoint(adjustedPoint - closestRenderer->locationOffset());
- return createVisiblePosition(firstPositionInOrBeforeNode(node()));
+ return createVisiblePosition(firstPositionInOrBeforeNode(nonPseudoNode()));
}
bool RenderBox::shrinkToAvoidFloats() const