Changeset 223196 in webkit


Ignore:
Timestamp:
Oct 11, 2017 12:13:07 PM (7 years ago)
Author:
dbates@webkit.org
Message:

InlineTextBox::isSelected() should only return true for a non-empty selection
and remove incorrect FIXME from InlineTextBox::localSelectionRect()
https://bugs.webkit.org/show_bug.cgi?id=160786

Reviewed by Zalan Bujtas.

Partial revert of r204400 in InlineTextBox::{isSelected, localSelectionRect}().

The function InlineTextBox::isSelected() should only return true for a non-empty selection.
Also remove an incorrect FIXME added to InlineTextBox::localSelectionRect() that questioned
whether it was correct for it to return an empty rectangle. It is correct for it to return
such a rectangle because this function is used to implement Element.getClientRects(). And
Element.getClientRects() can return a rectangle with zero width or zero height by step 3
of algorithm getClientRects() of section Extensions to the Element interface of the
CSSOM View Module spec., <https://drafts.csswg.org/cssom-view/> (Editor's Draft, 15 September 2017).

  • rendering/InlineTextBox.cpp:

(WebCore::InlineTextBox::isSelected const): Only return true for a non-empty selection
and remove unnecessary FIXME. Also rename variables to improve readability.
(WebCore::InlineTextBox::localSelectionRect const): Remove inaccurate FIXME comment.

  • rendering/InlineTextBox.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r223195 r223196  
     12017-10-11  Daniel Bates  <dabates@apple.com>
     2
     3        InlineTextBox::isSelected() should only return true for a non-empty selection
     4        and remove incorrect FIXME from InlineTextBox::localSelectionRect()
     5        https://bugs.webkit.org/show_bug.cgi?id=160786
     6
     7        Reviewed by Zalan Bujtas.
     8
     9        Partial revert of r204400 in InlineTextBox::{isSelected, localSelectionRect}().
     10
     11        The function InlineTextBox::isSelected() should only return true for a non-empty selection.
     12        Also remove an incorrect FIXME added to InlineTextBox::localSelectionRect() that questioned
     13        whether it was correct for it to return an empty rectangle. It is correct for it to return
     14        such a rectangle because this function is used to implement Element.getClientRects(). And
     15        Element.getClientRects() can return a rectangle with zero width or zero height by step 3
     16        of algorithm getClientRects() of section Extensions to the Element interface of the
     17        CSSOM View Module spec., <https://drafts.csswg.org/cssom-view/> (Editor's Draft, 15 September 2017).
     18
     19        * rendering/InlineTextBox.cpp:
     20        (WebCore::InlineTextBox::isSelected const): Only return true for a non-empty selection
     21        and remove unnecessary FIXME. Also rename variables to improve readability.
     22        (WebCore::InlineTextBox::localSelectionRect const): Remove inaccurate FIXME comment.
     23        * rendering/InlineTextBox.h:
     24
    1252017-10-11  Ryosuke Niwa  <rniwa@webkit.org>
    226
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r223013 r223196  
    130130}
    131131
    132 bool InlineTextBox::isSelected(unsigned startPos, unsigned endPos) const
    133 {
    134     int sPos = clampedOffset(startPos);
    135     int ePos = clampedOffset(endPos);
    136     // FIXME: https://bugs.webkit.org/show_bug.cgi?id=160786
    137     // We should only be checking if sPos >= ePos here, because those are the
    138     // indices used to actually generate the selection rect. Allowing us past this guard
    139     // on any other condition creates zero-width selection rects.
    140     return sPos < ePos || (startPos == endPos && startPos >= start() && startPos <= (start() + len()));
     132bool InlineTextBox::isSelected(unsigned startPosition, unsigned endPosition) const
     133{
     134    return clampedOffset(startPosition) < clampedOffset(endPosition);
    141135}
    142136
     
    198192    unsigned ePos = clampedOffset(endPos);
    199193
    200     // FIXME: https://bugs.webkit.org/show_bug.cgi?id=160786
    201     // We should only be checking if sPos >= ePos here, because those are the
    202     // indices used to actually generate the selection rect. Allowing us past this guard
    203     // on any other condition creates zero-width selection rects.
    204194    if (sPos >= ePos && !(startPos == endPos && startPos >= start() && startPos <= (start() + len())))
    205         return LayoutRect();
     195        return { };
    206196
    207197    LayoutUnit selectionTop = this->selectionTop();
  • trunk/Source/WebCore/rendering/InlineTextBox.h

    r222758 r223196  
    112112
    113113    virtual LayoutRect localSelectionRect(unsigned startPos, unsigned endPos) const;
    114     bool isSelected(unsigned startPos, unsigned endPos) const;
     114    bool isSelected(unsigned startPosition, unsigned endPosition) const;
    115115    std::pair<unsigned, unsigned> selectionStartEnd() const;
    116116
Note: See TracChangeset for help on using the changeset viewer.