Changeset 71668 in webkit


Ignore:
Timestamp:
Nov 9, 2010 12:46:15 PM (13 years ago)
Author:
mitz@apple.com
Message:

WebCore: Made tables hit-test correctly in all writing modes.

Reviewed by Dave Hyatt.

Part of: Make tables work with vertical text
https://bugs.webkit.org/show_bug.cgi?id=46417

Test: fast/blockflow/table-hit-test.html

  • rendering/RenderTable.cpp:

(WebCore::RenderTable::nodeAtPoint):

  • rendering/RenderTableRow.cpp:

(WebCore::RenderTableRow::nodeAtPoint):

  • rendering/RenderTableSection.cpp:

(WebCore::RenderTableSection::nodeAtPoint):

LayoutTests: Make tables work with vertical text
https://bugs.webkit.org/show_bug.cgi?id=46417

Reviewed by Dave Hyatt.

  • fast/blockflow/table-hit-test-expected.txt: Added.
  • fast/blockflow/table-hit-test.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r71660 r71668  
     12010-11-09  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        Make tables work with vertical text
     6        https://bugs.webkit.org/show_bug.cgi?id=46417
     7
     8        * fast/blockflow/table-hit-test-expected.txt: Added.
     9        * fast/blockflow/table-hit-test.html: Added.
     10
    1112010-11-09  Ryosuke Niwa  <rniwa@webkit.org>
    212
  • trunk/WebCore/ChangeLog

    r71666 r71668  
     12010-11-09  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        Made tables hit-test correctly in all writing modes.
     6
     7        Part of: Make tables work with vertical text
     8        https://bugs.webkit.org/show_bug.cgi?id=46417
     9
     10        Test: fast/blockflow/table-hit-test.html
     11
     12        * rendering/RenderTable.cpp:
     13        (WebCore::RenderTable::nodeAtPoint):
     14        * rendering/RenderTableRow.cpp:
     15        (WebCore::RenderTableRow::nodeAtPoint):
     16        * rendering/RenderTableSection.cpp:
     17        (WebCore::RenderTableSection::nodeAtPoint):
     18
    1192010-11-09  Simon Fraser  <simon.fraser@apple.com>
    220
     
    23862404        table’s are not supported yet.
    23872405
    2388         Make tables work with vertical text
     2406        Part of: Make tables work with vertical text
    23892407        https://bugs.webkit.org/show_bug.cgi?id=46417
    23902408
  • trunk/WebCore/rendering/RenderTable.cpp

    r71382 r71668  
    11531153    if (!hasOverflowClip() || overflowClipRect(tx, ty).intersects(result.rectForPoint(xPos, yPos))) {
    11541154        for (RenderObject* child = lastChild(); child; child = child->previousSibling()) {
    1155             if (child->isBox() && !toRenderBox(child)->hasSelfPaintingLayer() && (child->isTableSection() || child == m_caption) &&
    1156                 child->nodeAtPoint(request, result, xPos, yPos, tx, ty, action)) {
    1157                 updateHitTestResult(result, IntPoint(xPos - tx, yPos - ty));
    1158                 return true;
     1155            if (child->isBox() && !toRenderBox(child)->hasSelfPaintingLayer() && (child->isTableSection() || child == m_caption)) {
     1156                IntPoint childPoint = flipForWritingMode(toRenderBox(child), IntPoint(tx, ty), ParentToChildFlippingAdjustment);
     1157                if (child->nodeAtPoint(request, result, xPos, yPos, childPoint.x(), childPoint.y(), action)) {
     1158                    updateHitTestResult(result, IntPoint(xPos - childPoint.x(), yPos - childPoint.y()));
     1159                    return true;
     1160                }
    11591161            }
    11601162        }
     
    11641166    IntRect boundsRect = IntRect(tx, ty, width(), height());
    11651167    if (visibleToHitTesting() && (action == HitTestBlockBackground || action == HitTestChildBlockBackground) && boundsRect.intersects(result.rectForPoint(xPos, yPos))) {
    1166         updateHitTestResult(result, IntPoint(xPos - tx, yPos - ty));
     1168        updateHitTestResult(result, flipForWritingMode(IntPoint(xPos - tx, yPos - ty)));
    11671169        if (!result.addNodeToRectBasedTestResult(node(), xPos, yPos, boundsRect))
    11681170            return true;
  • trunk/WebCore/rendering/RenderTableRow.cpp

    r71382 r71668  
    176176        // table-specific hit-test method (which we should do for performance reasons anyway),
    177177        // then we can remove this check.
    178         if (child->isTableCell() && !toRenderBox(child)->hasSelfPaintingLayer() && child->nodeAtPoint(request, result, x, y, tx, ty, action)) {
    179             updateHitTestResult(result, IntPoint(x - tx, y - ty));
    180             return true;
     178        if (child->isTableCell() && !toRenderBox(child)->hasSelfPaintingLayer()) {
     179            IntPoint cellPoint = flipForWritingMode(toRenderTableCell(child), IntPoint(tx, ty), ParentToChildFlippingAdjustment);
     180            if (child->nodeAtPoint(request, result, x, y, cellPoint.x(), cellPoint.y(), action)) {
     181                updateHitTestResult(result, IntPoint(x - cellPoint.x(), y - cellPoint.y()));
     182                return true;
     183            }
    181184        }
    182185    }
  • trunk/WebCore/rendering/RenderTableSection.cpp

    r71382 r71668  
    12191219            // table-specific hit-test method (which we should do for performance reasons anyway),
    12201220            // then we can remove this check.
    1221             if (child->isBox() && !toRenderBox(child)->hasSelfPaintingLayer() && child->nodeAtPoint(request, result, xPos, yPos, tx, ty, action)) {
    1222                 updateHitTestResult(result, IntPoint(xPos - tx, yPos - ty));
    1223                 return true;
     1221            if (child->isBox() && !toRenderBox(child)->hasSelfPaintingLayer()) {
     1222                IntPoint childPoint = flipForWritingMode(toRenderBox(child), IntPoint(tx, ty), ParentToChildFlippingAdjustment);
     1223                if (child->nodeAtPoint(request, result, xPos, yPos, childPoint.x(), childPoint.y(), action)) {
     1224                    updateHitTestResult(result, IntPoint(xPos - childPoint.x(), yPos - childPoint.y()));
     1225                    return true;
     1226                }
    12241227            }
    12251228        }
     
    12271230    }
    12281231
    1229     int relativeY = yPos - ty;
    1230     // leftrow corresponds to the first row that starts after the y mouse position
    1231     unsigned leftrow = std::upper_bound(m_rowPos.begin(), m_rowPos.end(), relativeY) - m_rowPos.begin();
    1232     if (leftrow == m_rowPos.size())
     1232    IntPoint location = IntPoint(xPos - tx, yPos - ty);
     1233    if (style()->isFlippedBlocksWritingMode()) {
     1234        if (style()->isHorizontalWritingMode())
     1235            location.setY(height() - location.y());
     1236        else
     1237            location.setX(width() - location.x());
     1238    }
     1239
     1240    int offsetInColumnDirection = style()->isHorizontalWritingMode() ? location.y() : location.x();
     1241    // Find the first row that starts after offsetInColumnDirection.
     1242    unsigned nextRow = std::upper_bound(m_rowPos.begin(), m_rowPos.end(), offsetInColumnDirection) - m_rowPos.begin();
     1243    if (nextRow == m_rowPos.size())
    12331244        return false;
    1234     // Grab the last row that starts before the y mouse position.
    1235     if (leftrow > 0)
    1236         --leftrow;
     1245    // Now set hitRow to the index of the hit row, or 0.
     1246    unsigned hitRow = nextRow > 0 ? nextRow - 1 : 0;
    12371247
    12381248    Vector<int>& columnPos = table()->columnPositions();
    1239     bool rtl = !style()->isLeftToRightDirection();
    1240     int relativeX = xPos - tx;
    1241     if (rtl)
    1242         relativeX = columnPos[columnPos.size() - 1] - relativeX;
    1243 
    1244     unsigned leftcol = std::lower_bound(columnPos.begin(), columnPos.end(), relativeX) - columnPos.begin();
    1245     if (leftcol == columnPos.size())
     1249    int offsetInRowDirection = style()->isHorizontalWritingMode() ? location.x() : location.y();
     1250    if (!style()->isLeftToRightDirection())
     1251        offsetInRowDirection = columnPos[columnPos.size() - 1] - offsetInRowDirection;
     1252
     1253    unsigned nextColumn = std::lower_bound(columnPos.begin(), columnPos.end(), offsetInRowDirection) - columnPos.begin();
     1254    if (nextColumn == columnPos.size())
    12461255        return false;
    1247     if (leftcol > 0)
    1248         --leftcol;
    1249 
    1250     CellStruct& current = cellAt(leftrow, leftcol);
     1256    unsigned hitColumn = nextColumn > 0 ? nextColumn - 1 : 0;
     1257
     1258    CellStruct& current = cellAt(hitRow, hitColumn);
    12511259
    12521260    // If the cell is empty, there's nothing to do
     
    12561264    for (int i = current.cells.size() - 1; i >= 0; --i) {
    12571265        RenderTableCell* cell = current.cells[i];
    1258         if (static_cast<RenderObject*>(cell)->nodeAtPoint(request, result, xPos, yPos, tx, ty, action)) {
    1259             updateHitTestResult(result, IntPoint(xPos - tx, yPos - ty));
     1266        IntPoint cellPoint = flipForWritingMode(cell, IntPoint(tx, ty), ParentToChildFlippingAdjustment);
     1267        if (static_cast<RenderObject*>(cell)->nodeAtPoint(request, result, xPos, yPos, cellPoint.x(), cellPoint.y(), action)) {
     1268            updateHitTestResult(result, IntPoint(xPos - cellPoint.x(), yPos - cellPoint.y()));
    12601269            return true;
    12611270        }
Note: See TracChangeset for help on using the changeset viewer.