Changeset 112166 in webkit


Ignore:
Timestamp:
Mar 26, 2012 4:01:23 PM (12 years ago)
Author:
leviw@chromium.org
Message:

Update localSelectionRect to return a LayoutRect
https://bugs.webkit.org/show_bug.cgi?id=82183

Reviewed by Eric Seidel.

localSelectionRect returns a rectangle in the coordinate space of its renderer,
and therefor should remain LayoutUnits until being promoted to absolute
coordinates or painted. Also fixing an incorrect conversion of startPos and
endPos in selectionRectForRepaint.

No new tests. No change in behavior.

  • rendering/InlineTextBox.cpp:

(WebCore::InlineTextBox::localSelectionRect): Continuing to use enclosingIntRect
for the value being returned from the font engine since these floating point
values should not be pixel snapped.

  • rendering/InlineTextBox.h:

(InlineTextBox):

  • rendering/RenderReplaced.cpp:

(WebCore::RenderReplaced::localSelectionRect):

  • rendering/RenderReplaced.h:

(RenderReplaced):

  • rendering/RenderText.cpp:

(WebCore::localQuadForTextBox):
(WebCore::RenderText::absoluteRectsForRange):
(WebCore::RenderText::absoluteQuadsForRange):
(WebCore::RenderText::selectionRectForRepaint): Fixing an incorrect conversion of
start/endPos to LayoutUnits. These values represent a range of selected characters,
not layout values!

  • rendering/svg/RenderSVGInlineText.cpp:

(WebCore::RenderSVGInlineText::localCaretRect):

  • rendering/svg/SVGInlineTextBox.cpp:

(WebCore::SVGInlineTextBox::localSelectionRect):

  • rendering/svg/SVGInlineTextBox.h:

(SVGInlineTextBox):

Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r112165 r112166  
     12012-03-26  Levi Weintraub  <leviw@chromium.org>
     2
     3        Update localSelectionRect to return a LayoutRect
     4        https://bugs.webkit.org/show_bug.cgi?id=82183
     5
     6        Reviewed by Eric Seidel.
     7
     8        localSelectionRect returns a rectangle in the coordinate space of its renderer,
     9        and therefor should remain LayoutUnits until being promoted to absolute
     10        coordinates or painted. Also fixing an incorrect conversion of startPos and
     11        endPos in selectionRectForRepaint.
     12
     13        No new tests. No change in behavior.
     14
     15        * rendering/InlineTextBox.cpp:
     16        (WebCore::InlineTextBox::localSelectionRect): Continuing to use enclosingIntRect
     17        for the value being returned from the font engine since these floating point
     18        values should not be pixel snapped.
     19        * rendering/InlineTextBox.h:
     20        (InlineTextBox):
     21        * rendering/RenderReplaced.cpp:
     22        (WebCore::RenderReplaced::localSelectionRect):
     23        * rendering/RenderReplaced.h:
     24        (RenderReplaced):
     25        * rendering/RenderText.cpp:
     26        (WebCore::localQuadForTextBox):
     27        (WebCore::RenderText::absoluteRectsForRange):
     28        (WebCore::RenderText::absoluteQuadsForRange):
     29        (WebCore::RenderText::selectionRectForRepaint): Fixing an incorrect conversion of
     30        start/endPos to LayoutUnits. These values represent a range of selected characters,
     31        not layout values!
     32        * rendering/svg/RenderSVGInlineText.cpp:
     33        (WebCore::RenderSVGInlineText::localCaretRect):
     34        * rendering/svg/SVGInlineTextBox.cpp:
     35        (WebCore::SVGInlineTextBox::localSelectionRect):
     36        * rendering/svg/SVGInlineTextBox.h:
     37        (SVGInlineTextBox):
     38
    1392012-03-26  Justin Novosad  <junov@chromium.org>
    240
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r110983 r112166  
    175175}
    176176
    177 IntRect InlineTextBox::localSelectionRect(int startPos, int endPos)
     177LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos)
    178178{
    179179    int sPos = max(startPos - m_start, 0);
     
    181181   
    182182    if (sPos > ePos)
    183         return IntRect();
     183        return LayoutRect();
    184184
    185185    FontCachePurgePreventer fontCachePurgePreventer;
    186186
    187187    RenderText* textObj = textRenderer();
    188     int selTop = selectionTop();
    189     int selHeight = selectionHeight();
     188    LayoutUnit selTop = selectionTop();
     189    LayoutUnit selHeight = selectionHeight();
    190190    RenderStyle* styleToUse = textObj->style(m_firstLine);
    191191    const Font& font = styleToUse->font();
     
    197197        endPos = textRun.length();
    198198
    199     IntRect r = enclosingIntRect(font.selectionRectForText(textRun, FloatPoint(logicalLeft(), selTop), selHeight, sPos, ePos));
    200 
    201     int logicalWidth = r.width();
     199    LayoutRect r = enclosingIntRect(font.selectionRectForText(textRun, FloatPoint(logicalLeft(), selTop), selHeight, sPos, ePos));
     200
     201    LayoutUnit logicalWidth = r.width();
    202202    if (r.x() > logicalRight())
    203203        logicalWidth  = 0;
     
    205205        logicalWidth = logicalRight() - r.x();
    206206
    207     IntPoint topPoint = isHorizontal() ? IntPoint(r.x(), selTop) : IntPoint(selTop, r.x());
    208     int width = isHorizontal() ? logicalWidth : selHeight;
    209     int height = isHorizontal() ? selHeight : logicalWidth;
    210 
    211     return IntRect(topPoint, IntSize(width, height));
     207    LayoutPoint topPoint = isHorizontal() ? LayoutPoint(r.x(), selTop) : LayoutPoint(selTop, r.x());
     208    LayoutUnit width = isHorizontal() ? logicalWidth : selHeight;
     209    LayoutUnit height = isHorizontal() ? selHeight : logicalWidth;
     210
     211    return LayoutRect(topPoint, LayoutSize(width, height));
    212212}
    213213
  • trunk/Source/WebCore/rendering/InlineTextBox.h

    r101342 r112166  
    111111    virtual FloatRect calculateBoundaries() const { return FloatRect(x(), y(), width(), height()); }
    112112
    113     virtual IntRect localSelectionRect(int startPos, int endPos);
     113    virtual LayoutRect localSelectionRect(int startPos, int endPos);
    114114    bool isSelected(int startPos, int endPos) const;
    115115    void selectionStartEnd(int& sPos, int& ePos);
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r111126 r112166  
    489489}
    490490
    491 IntRect RenderReplaced::localSelectionRect(bool checkWhetherSelected) const
     491LayoutRect RenderReplaced::localSelectionRect(bool checkWhetherSelected) const
    492492{
    493493    if (checkWhetherSelected && !isSelected())
    494         return IntRect();
     494        return LayoutRect();
    495495
    496496    if (!m_inlineBoxWrapper)
    497497        // We're a block-level replaced element.  Just return our own dimensions.
    498         return IntRect(IntPoint(), size());
     498        return LayoutRect(LayoutPoint(), size());
    499499   
    500500    RootInlineBox* root = m_inlineBoxWrapper->root();
    501     int newLogicalTop = root->block()->style()->isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - root->selectionBottom() : root->selectionTop() - m_inlineBoxWrapper->logicalTop();
     501    LayoutUnit newLogicalTop = root->block()->style()->isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - root->selectionBottom() : root->selectionTop() - m_inlineBoxWrapper->logicalTop();
    502502    if (root->block()->style()->isHorizontalWritingMode())
    503         return IntRect(0, newLogicalTop, width(), root->selectionHeight());
    504     return IntRect(newLogicalTop, 0, root->selectionHeight(), height());
     503        return LayoutRect(0, newLogicalTop, width(), root->selectionHeight());
     504    return LayoutRect(newLogicalTop, 0, root->selectionHeight(), height());
    505505}
    506506
  • trunk/Source/WebCore/rendering/RenderReplaced.h

    r105513 r112166  
    6060    virtual void paint(PaintInfo&, const LayoutPoint&);
    6161    bool shouldPaint(PaintInfo&, const LayoutPoint&);
    62     IntRect localSelectionRect(bool checkWhetherSelected = true) const; // This is in local coordinates, but it's a physical rect (so the top left corner is physical top left).
     62    LayoutRect localSelectionRect(bool checkWhetherSelected = true) const; // This is in local coordinates, but it's a physical rect (so the top left corner is physical top left).
    6363
    6464private:
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r110323 r112166  
    313313{
    314314    unsigned realEnd = min(box->end() + 1, end);
    315     IntRect r = box->localSelectionRect(start, realEnd);
     315    LayoutRect r = box->localSelectionRect(start, realEnd);
    316316    if (r.height()) {
    317317        if (!useSelectionHeight) {
     
    348348            FloatRect r = box->calculateBoundaries();
    349349            if (useSelectionHeight) {
    350                 IntRect selectionRect = box->localSelectionRect(start, end);
     350                LayoutRect selectionRect = box->localSelectionRect(start, end);
    351351                if (box->isHorizontal()) {
    352352                    r.setHeight(selectionRect.height());
     
    431431            FloatRect r = box->calculateBoundaries();
    432432            if (useSelectionHeight) {
    433                 // FIXME: localSelectionRect should switch to return FloatRect soon with the subpixellayout branch.
    434                 IntRect selectionRect = box->localSelectionRect(start, end);
     433                LayoutRect selectionRect = box->localSelectionRect(start, end);
    435434                if (box->isHorizontal()) {
    436435                    r.setHeight(selectionRect.height());
     
    15491548    // Now calculate startPos and endPos for painting selection.
    15501549    // We include a selection while endPos > 0
    1551     LayoutUnit startPos, endPos;
     1550    int startPos, endPos;
    15521551    if (selectionState() == SelectionInside) {
    15531552        // We are fully selected.
  • trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp

    r112119 r112166  
    148148    // Use the edge of the selection rect to determine the caret rect.
    149149    if (static_cast<unsigned>(caretOffset) < textBox->start() + textBox->len()) {
    150         IntRect rect = textBox->localSelectionRect(caretOffset, caretOffset + 1);
    151         int x = box->isLeftToRightDirection() ? rect.x() : rect.maxX();
     150        LayoutRect rect = textBox->localSelectionRect(caretOffset, caretOffset + 1);
     151        LayoutUnit x = box->isLeftToRightDirection() ? rect.x() : rect.maxX();
    152152        return LayoutRect(x, rect.y(), caretWidth, rect.height());
    153153    }
    154154
    155     IntRect rect = textBox->localSelectionRect(caretOffset - 1, caretOffset);
    156     int x = box->isLeftToRightDirection() ? rect.maxX() : rect.x();
     155    LayoutRect rect = textBox->localSelectionRect(caretOffset - 1, caretOffset);
     156    LayoutUnit x = box->isLeftToRightDirection() ? rect.maxX() : rect.x();
    157157    return LayoutRect(x, rect.y(), caretWidth, rect.height());
    158158}
  • trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp

    r111674 r112166  
    129129}
    130130
    131 IntRect SVGInlineTextBox::localSelectionRect(int startPosition, int endPosition)
     131LayoutRect SVGInlineTextBox::localSelectionRect(int startPosition, int endPosition)
    132132{
    133133    int boxStart = start();
     
    135135    endPosition = min(endPosition - boxStart, static_cast<int>(len()));
    136136    if (startPosition >= endPosition)
    137         return IntRect();
     137        return LayoutRect();
    138138
    139139    RenderText* text = textRenderer();
  • trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h

    r110593 r112166  
    4848    void paintSelectionBackground(PaintInfo&);
    4949    virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom);
    50     virtual IntRect localSelectionRect(int startPosition, int endPosition);
     50    virtual LayoutRect localSelectionRect(int startPosition, int endPosition);
    5151
    5252    bool mapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment&, int& startPosition, int& endPosition) const;
Note: See TracChangeset for help on using the changeset viewer.