Changeset 123980 in webkit


Ignore:
Timestamp:
Jul 29, 2012 10:27:35 AM (12 years ago)
Author:
mitz@apple.com
Message:

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

Reviewed by Simon Fraser.

Source/WebCore:

With respect to hit testing, boxes should always behave as half-open intervals which include
the physical top and left edges and not the bottom and right edges.
RenderBlock::positionForPoint was not adhering to this, since it was comparing flipped
coordinates.

Tests: fast/writing-mode/flipped-blocks-hit-test-box-edges.html

fast/writing-mode/flipped-blocks-hit-test-line-edges.html

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::positionForPointWithInlineChildren): When blocks are flipped, changed
strict inequalities of y coordinates into non-strict ones and non-strict inequalities into
strict ones.
(WebCore::RenderBlock::positionForPoint): Ditto, except for the test for being under the top
of the last candidate box, which was made non-strict in the unflipped case and remained
strict.

LayoutTests:

  • fast/writing-mode/flipped-blocks-hit-test-box-edges-expected.txt: Added.
  • fast/writing-mode/flipped-blocks-hit-test-box-edges.html: Added.
  • fast/writing-mode/flipped-blocks-hit-test-line-edges-expected.txt: Added.
  • fast/writing-mode/flipped-blocks-hit-test-line-edges.html: Added.
Location:
trunk
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r123978 r123980  
     12012-07-29  Dan Bernstein  <mitz@apple.com>
     2
     3        In flipped blocks, a point on the top edge of a box is considered outside the box (and vice versa)
     4        https://bugs.webkit.org/show_bug.cgi?id=92593
     5
     6        Reviewed by Simon Fraser.
     7
     8        * fast/writing-mode/flipped-blocks-hit-test-box-edges-expected.txt: Added.
     9        * fast/writing-mode/flipped-blocks-hit-test-box-edges.html: Added.
     10        * fast/writing-mode/flipped-blocks-hit-test-line-edges-expected.txt: Added.
     11        * fast/writing-mode/flipped-blocks-hit-test-line-edges.html: Added.
     12
    1132012-07-29  Mike West  <mkwst@chromium.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r123977 r123980  
     12012-07-29  Dan Bernstein  <mitz@apple.com>
     2
     3        In flipped blocks, a point on the top edge of a box is considered outside the box (and vice versa)
     4        https://bugs.webkit.org/show_bug.cgi?id=92593
     5
     6        Reviewed by Simon Fraser.
     7
     8        With respect to hit testing, boxes should always behave as half-open intervals which include
     9        the physical top and left edges and not the bottom and right edges.
     10        RenderBlock::positionForPoint was not adhering to this, since it was comparing flipped
     11        coordinates.
     12
     13        Tests: fast/writing-mode/flipped-blocks-hit-test-box-edges.html
     14               fast/writing-mode/flipped-blocks-hit-test-line-edges.html
     15
     16        * rendering/RenderBlock.cpp:
     17        (WebCore::RenderBlock::positionForPointWithInlineChildren): When blocks are flipped, changed
     18        strict inequalities of y coordinates into non-strict ones and non-strict inequalities into
     19        strict ones.
     20        (WebCore::RenderBlock::positionForPoint): Ditto, except for the test for being under the top
     21        of the last candidate box, which was made non-strict in the unflipped case and remained
     22        strict.
     23
    1242012-07-28  Dan Bernstein  <mitz@apple.com>
    225
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r123977 r123980  
    49184918
    49194919    bool linesAreFlipped = style()->isFlippedLinesWritingMode();
     4920    bool blocksAreFlipped = style()->isFlippedBlocksWritingMode();
    49204921
    49214922    // look for the closest line box in the root box which is at the passed-in y coordinate
     
    49294930            firstRootBoxWithChildren = root;
    49304931
    4931         if (!linesAreFlipped && root->isFirstAfterPageBreak() && pointInLogicalContents.y() < root->lineTopWithLeading())
     4932        if (!linesAreFlipped && root->isFirstAfterPageBreak() && (pointInLogicalContents.y() < root->lineTopWithLeading()
     4933            || (blocksAreFlipped && pointInLogicalContents.y() == root->lineTopWithLeading())))
    49324934            break;
    49334935
     
    49354937
    49364938        // check if this root line box is located at this y coordinate
    4937         if (pointInLogicalContents.y() < root->selectionBottom()) {
     4939        if (pointInLogicalContents.y() < root->selectionBottom() || (blocksAreFlipped && pointInLogicalContents.y() == root->selectionBottom())) {
    49384940            if (linesAreFlipped) {
    49394941                RootInlineBox* nextRootBoxWithChildren = root->nextRootBox();
     
    49414943                    nextRootBoxWithChildren = nextRootBoxWithChildren->nextRootBox();
    49424944
    4943                 if (nextRootBoxWithChildren && nextRootBoxWithChildren->isFirstAfterPageBreak() && pointInLogicalContents.y() >= nextRootBoxWithChildren->lineTopWithLeading())
     4945                if (nextRootBoxWithChildren && nextRootBoxWithChildren->isFirstAfterPageBreak() && (pointInLogicalContents.y() > nextRootBoxWithChildren->lineTopWithLeading()
     4946                    || (!blocksAreFlipped && pointInLogicalContents.y() == nextRootBoxWithChildren->lineTopWithLeading())))
    49444947                    continue;
    49454948            }
     
    49584961
    49594962    if (closestBox) {
    4960         if (moveCaretToBoundary && pointInLogicalContents.y() < firstRootBoxWithChildren->selectionTop()
    4961             && pointInLogicalContents.y() < firstRootBoxWithChildren->logicalTop()) {
    4962             InlineBox* box = firstRootBoxWithChildren->firstLeafChild();
    4963             if (box->isLineBreak()) {
    4964                 if (InlineBox* newBox = box->nextLeafChildIgnoringLineBreak())
    4965                     box = newBox;
     4963        if (moveCaretToBoundary) {
     4964            LayoutUnit firstRootBoxWithChildrenTop = min<LayoutUnit>(firstRootBoxWithChildren->selectionTop(), firstRootBoxWithChildren->logicalTop());
     4965            if (pointInLogicalContents.y() < firstRootBoxWithChildrenTop
     4966                || (blocksAreFlipped && pointInLogicalContents.y() == firstRootBoxWithChildrenTop)) {
     4967                InlineBox* box = firstRootBoxWithChildren->firstLeafChild();
     4968                if (box->isLineBreak()) {
     4969                    if (InlineBox* newBox = box->nextLeafChildIgnoringLineBreak())
     4970                        box = newBox;
     4971                }
     4972                // y coordinate is above first root line box, so return the start of the first
     4973                return VisiblePosition(positionForBox(box, true), DOWNSTREAM);
    49664974            }
    4967             // y coordinate is above first root line box, so return the start of the first
    4968             return VisiblePosition(positionForBox(box, true), DOWNSTREAM);
    49694975        }
    49704976
     
    50265032        lastCandidateBox = lastCandidateBox->previousSiblingBox();
    50275033
     5034    bool blocksAreFlipped = style()->isFlippedBlocksWritingMode();
    50285035    if (lastCandidateBox) {
    5029         if (pointInLogicalContents.y() > logicalTopForChild(lastCandidateBox))
     5036        if (pointInLogicalContents.y() > logicalTopForChild(lastCandidateBox)
     5037            || (!blocksAreFlipped && pointInLogicalContents.y() == logicalTopForChild(lastCandidateBox)))
    50305038            return positionForPointRespectingEditingBoundaries(this, lastCandidateBox, pointInContents);
    50315039
    50325040        for (RenderBox* childBox = firstChildBox(); childBox; childBox = childBox->nextSiblingBox()) {
     5041            if (!isChildHitTestCandidate(childBox))
     5042                continue;
     5043            LayoutUnit childLogicalBottom = logicalTopForChild(childBox) + logicalHeightForChild(childBox);
    50335044            // We hit child if our click is above the bottom of its padding box (like IE6/7 and FF3).
    5034             if (isChildHitTestCandidate(childBox) && pointInLogicalContents.y() < logicalTopForChild(childBox) + logicalHeightForChild(childBox))
     5045            if (isChildHitTestCandidate(childBox) && (pointInLogicalContents.y() < childLogicalBottom
     5046                || (blocksAreFlipped && pointInLogicalContents.y() == childLogicalBottom)))
    50355047                return positionForPointRespectingEditingBoundaries(this, childBox, pointInContents);
    50365048        }
Note: See TracChangeset for help on using the changeset viewer.