- Revision
- 123988
- Author
- [email protected]
- Date
- 2012-07-29 15:55:51 -0700 (Sun, 29 Jul 2012)
Log Message
In flipped blocks, a point on the top edge of a text box is considered outside the box (and vice versa)
https://bugs.webkit.org/show_bug.cgi?id=92597
Reviewed by Ryosuke Niwa.
Source/WebCore:
This is similar to <http://webkit.org/b/92593> except for RenderText. Fixing this required
fixing some code that creates a point inside a box by setting its y coordinate to the
logical top of the box. In a flipped block, this would be just outside the box.
Enhanced fast/writing-mode/flipped-blocks-hit-test-line-edges.html to cover this.
* editing/visible_units.cpp:
(WebCore::absoluteLineDirectionPointToLocalPointInBlock): Changed to use
RootInlineBox::blockDirectionPointInLine in the vertical case as well.
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::positionForPointWithInlineChildren): Changed to use
RootInlineBox::blockDirectionPointInLine.
* rendering/RenderText.cpp:
(WebCore::RenderText::positionForPoint): Changed the strictness of y inequalities based on
the flippedness of the block. This fixes the bug.
* rendering/RootInlineBox.cpp:
(WebCore::RootInlineBox::blockDirectionPointInLine): Moved the implementation here from the
header, and made it return the bottom in the flipped block case, so that the returned point
is inside the line in that case as well.
* rendering/RootInlineBox.h:
LayoutTests:
Added hits inside the text to this test.
* fast/writing-mode/flipped-blocks-hit-test-line-edges-expected.txt:
* fast/writing-mode/flipped-blocks-hit-test-line-edges.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (123987 => 123988)
--- trunk/LayoutTests/ChangeLog 2012-07-29 22:36:16 UTC (rev 123987)
+++ trunk/LayoutTests/ChangeLog 2012-07-29 22:55:51 UTC (rev 123988)
@@ -1,5 +1,17 @@
2012-07-29 Dan Bernstein <[email protected]>
+ In flipped blocks, a point on the top edge of a text box is considered outside the box (and vice versa)
+ https://bugs.webkit.org/show_bug.cgi?id=92597
+
+ Reviewed by Ryosuke Niwa.
+
+ Added hits inside the text to this test.
+
+ * fast/writing-mode/flipped-blocks-hit-test-line-edges-expected.txt:
+ * fast/writing-mode/flipped-blocks-hit-test-line-edges.html:
+
+2012-07-29 Dan Bernstein <[email protected]>
+
In flipped blocks, a point on the top edge of a box is considered outside the box (and vice versa)
https://bugs.webkit.org/show_bug.cgi?id=92593
Modified: trunk/LayoutTests/fast/writing-mode/flipped-blocks-hit-test-line-edges-expected.txt (123987 => 123988)
--- trunk/LayoutTests/fast/writing-mode/flipped-blocks-hit-test-line-edges-expected.txt 2012-07-29 22:36:16 UTC (rev 123987)
+++ trunk/LayoutTests/fast/writing-mode/flipped-blocks-hit-test-line-edges-expected.txt 2012-07-29 22:55:51 UTC (rev 123988)
@@ -1,7 +1,12 @@
Lorem ipsum dolor sit amet
+PASS: offset at (100,105) was 4.
PASS: offset at (160,105) was 5.
+PASS: offset at (100,104) was 10.
PASS: offset at (160,104) was 11.
+PASS: offset at (60,26) was 24.
PASS: offset at (160,26) was 26.
+PASS: offset at (60,25) was 24.
PASS: offset at (160,25) was 26.
+PASS: offset at (60,24) was 26.
PASS: offset at (160,24) was 26.
Modified: trunk/LayoutTests/fast/writing-mode/flipped-blocks-hit-test-line-edges.html (123987 => 123988)
--- trunk/LayoutTests/fast/writing-mode/flipped-blocks-hit-test-line-edges.html 2012-07-29 22:36:16 UTC (rev 123987)
+++ trunk/LayoutTests/fast/writing-mode/flipped-blocks-hit-test-line-edges.html 2012-07-29 22:55:51 UTC (rev 123988)
@@ -25,9 +25,14 @@
log("FAIL: offset at (" + x + "," + y + ") was " + actualOffset + ". Expected " + expectedOffset + ".");
}
+ test(100, 105, 4);
test(160, 105, 5);
+ test(100, 104, 10);
test(160, 104, 11);
+ test(60, 26, 24);
test(160, 26, 26);
+ test(60, 25, 24);
test(160, 25, 26);
+ test(60, 24, 26);
test(160, 24, 26);
</script>
Modified: trunk/Source/WebCore/ChangeLog (123987 => 123988)
--- trunk/Source/WebCore/ChangeLog 2012-07-29 22:36:16 UTC (rev 123987)
+++ trunk/Source/WebCore/ChangeLog 2012-07-29 22:55:51 UTC (rev 123988)
@@ -1,3 +1,31 @@
+2012-07-29 Dan Bernstein <[email protected]>
+
+ In flipped blocks, a point on the top edge of a text box is considered outside the box (and vice versa)
+ https://bugs.webkit.org/show_bug.cgi?id=92597
+
+ Reviewed by Ryosuke Niwa.
+
+ This is similar to <http://webkit.org/b/92593> except for RenderText. Fixing this required
+ fixing some code that creates a point inside a box by setting its y coordinate to the
+ logical top of the box. In a flipped block, this would be just outside the box.
+
+ Enhanced fast/writing-mode/flipped-blocks-hit-test-line-edges.html to cover this.
+
+ * editing/visible_units.cpp:
+ (WebCore::absoluteLineDirectionPointToLocalPointInBlock): Changed to use
+ RootInlineBox::blockDirectionPointInLine in the vertical case as well.
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::positionForPointWithInlineChildren): Changed to use
+ RootInlineBox::blockDirectionPointInLine.
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::positionForPoint): Changed the strictness of y inequalities based on
+ the flippedness of the block. This fixes the bug.
+ * rendering/RootInlineBox.cpp:
+ (WebCore::RootInlineBox::blockDirectionPointInLine): Moved the implementation here from the
+ header, and made it return the bottom in the flipped block case, so that the returned point
+ is inside the line in that case as well.
+ * rendering/RootInlineBox.h:
+
2012-07-29 Rik Cabanier <[email protected]>
ENABLE_CSS_COMPOSITING flag
Modified: trunk/Source/WebCore/editing/visible_units.cpp (123987 => 123988)
--- trunk/Source/WebCore/editing/visible_units.cpp 2012-07-29 22:36:16 UTC (rev 123987)
+++ trunk/Source/WebCore/editing/visible_units.cpp 2012-07-29 22:55:51 UTC (rev 123988)
@@ -919,7 +919,7 @@
if (root->block()->isHorizontalWritingMode())
return IntPoint(lineDirectionPoint - absoluteBlockPoint.x(), root->blockDirectionPointInLine());
- return IntPoint(root->selectionTop(), lineDirectionPoint - absoluteBlockPoint.y());
+ return IntPoint(root->blockDirectionPointInLine(), lineDirectionPoint - absoluteBlockPoint.y());
}
VisiblePosition previousLinePosition(const VisiblePosition &visiblePosition, int lineDirectionPoint, EditableType editableType)
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (123987 => 123988)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-07-29 22:36:16 UTC (rev 123987)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-07-29 22:55:51 UTC (rev 123988)
@@ -4975,7 +4975,7 @@
}
// pass the box a top position that is inside it
- LayoutPoint point(pointInLogicalContents.x(), max(closestBox->root()->lineTop(), closestBox->root()->selectionTop()));
+ LayoutPoint point(pointInLogicalContents.x(), closestBox->root()->blockDirectionPointInLine());
if (!isHorizontalWritingMode())
point = point.transposedPoint();
if (closestBox->renderer()->isReplaced())
Modified: trunk/Source/WebCore/rendering/RenderText.cpp (123987 => 123988)
--- trunk/Source/WebCore/rendering/RenderText.cpp 2012-07-29 22:36:16 UTC (rev 123987)
+++ trunk/Source/WebCore/rendering/RenderText.cpp 2012-07-29 22:55:51 UTC (rev 123988)
@@ -613,6 +613,7 @@
LayoutUnit pointLineDirection = firstTextBox()->isHorizontal() ? point.x() : point.y();
LayoutUnit pointBlockDirection = firstTextBox()->isHorizontal() ? point.y() : point.x();
+ bool blocksAreFlipped = style()->isFlippedBlocksWritingMode();
InlineTextBox* lastBox = 0;
for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
@@ -620,12 +621,13 @@
box = box->nextTextBox();
RootInlineBox* rootBox = box->root();
- if (pointBlockDirection >= rootBox->selectionTop() || pointBlockDirection >= rootBox->lineTop()) {
+ LayoutUnit top = min(rootBox->selectionTop(), rootBox->lineTop());
+ if (pointBlockDirection > top || (!blocksAreFlipped && pointBlockDirection == top)) {
LayoutUnit bottom = rootBox->selectionBottom();
if (rootBox->nextRootBox())
bottom = min(bottom, rootBox->nextRootBox()->lineTop());
- if (pointBlockDirection < bottom) {
+ if (pointBlockDirection < bottom || (blocksAreFlipped && pointBlockDirection == bottom)) {
ShouldAffinityBeDownstream shouldAffinityBeDownstream;
if (lineDirectionPointFitsInBox(pointLineDirection, box, shouldAffinityBeDownstream))
return createVisiblePositionAfterAdjustingOffsetForBiDi(box, box->offsetForPosition(pointLineDirection), shouldAffinityBeDownstream);
Modified: trunk/Source/WebCore/rendering/RootInlineBox.cpp (123987 => 123988)
--- trunk/Source/WebCore/rendering/RootInlineBox.cpp 2012-07-29 22:36:16 UTC (rev 123987)
+++ trunk/Source/WebCore/rendering/RootInlineBox.cpp 2012-07-29 22:55:51 UTC (rev 123988)
@@ -601,6 +601,11 @@
return nextTop;
}
+int RootInlineBox::blockDirectionPointInLine() const
+{
+ return !block()->style()->isFlippedBlocksWritingMode() ? max(lineTop(), selectionTop()) : min(lineBottom(), selectionBottom());
+}
+
RenderBlock* RootInlineBox::block() const
{
return toRenderBlock(renderer());
Modified: trunk/Source/WebCore/rendering/RootInlineBox.h (123987 => 123988)
--- trunk/Source/WebCore/rendering/RootInlineBox.h 2012-07-29 22:36:16 UTC (rev 123987)
+++ trunk/Source/WebCore/rendering/RootInlineBox.h 2012-07-29 22:55:51 UTC (rev 123988)
@@ -69,7 +69,7 @@
LayoutUnit selectionTopAdjustedForPrecedingBlock() const;
LayoutUnit selectionHeightAdjustedForPrecedingBlock() const { return max<LayoutUnit>(0, selectionBottom() - selectionTopAdjustedForPrecedingBlock()); }
- int blockDirectionPointInLine() const { return max(lineTop(), selectionTop()); }
+ int blockDirectionPointInLine() const;
LayoutUnit alignBoxesInBlockDirection(LayoutUnit heightOfBlock, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&);
void setLineTopBottomPositions(LayoutUnit top, LayoutUnit bottom, LayoutUnit topWithLeading, LayoutUnit bottomWithLeading)