⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 243635 in webkit


Ignore:
Timestamp:
Mar 28, 2019, 6:56:51 PM (7 years ago)
Author:
rniwa@webkit.org
Message:

getBoundingClientRect always returns empty rect on a collapsed range
https://bugs.webkit.org/show_bug.cgi?id=196380

Reviewed by Wenson Hsieh.

Source/WebCore:

The bug was caused by Range::boundingRect merging rects via FloatRect::unite which ignores empty rects.
Use uniteIfNonZero instead to fix the bug. Note that we can't use uniteEvenIfEmpty because that would
set x, y to always 0, 0 as we would end up merging any rect with the initial empty rect.

Test: fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range.html

  • dom/Range.cpp:

(WebCore::Range::boundingRect const):

LayoutTests:

Added a regression test.

  • fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range-expected.txt: Added.
  • fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r243634 r243635  
     12019-03-28  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        getBoundingClientRect always returns empty rect on a collapsed range
     4        https://bugs.webkit.org/show_bug.cgi?id=196380
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        Added a regression test.
     9
     10        * fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range-expected.txt: Added.
     11        * fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range.html: Added.
     12
    1132019-03-28  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r243627 r243635  
     12019-03-28  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        getBoundingClientRect always returns empty rect on a collapsed range
     4        https://bugs.webkit.org/show_bug.cgi?id=196380
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        The bug was caused by Range::boundingRect merging rects via FloatRect::unite which ignores empty rects.
     9        Use uniteIfNonZero instead to fix the bug. Note that we can't use uniteEvenIfEmpty because that would
     10        set x, y to always 0, 0 as we would end up merging any rect with the initial empty rect.
     11
     12        Test: fast/dom/Range/getBoundingClientRect-on-collapsed-selection-range.html
     13
     14        * dom/Range.cpp:
     15        (WebCore::Range::boundingRect const):
     16
    1172019-03-28  Justin Fan  <justin_fan@apple.com>
    218
  • trunk/Source/WebCore/dom/Range.cpp

    r243163 r243635  
    18431843    FloatRect result;
    18441844    for (auto& rect : borderAndTextRects(space, respectClippingForTextRects))
    1845         result.unite(rect);
     1845        result.uniteIfNonZero(rect);
    18461846    return result;
    18471847}
Note: See TracChangeset for help on using the changeset viewer.