Changeset 245779 in webkit


Ignore:
Timestamp:
May 26, 2019 7:04:13 AM (5 years ago)
Author:
Alan Bujtas
Message:

[LFC][Verification] Add areEssentiallyEqual for LayoutRect
https://bugs.webkit.org/show_bug.cgi?id=198250
<rdar://problem/51140119>

Reviewed by Antti Koivisto.

WebKit's inline layout is a mix of int/float/LayoutUnit types, while LFC mostly uses LayoutUnit.
When we compute the used size of a block container (based on the inline tree), the final value might go through a few conversions.

  • layout/Verification.cpp:

(WebCore::Layout::areEssentiallyEqual):
(WebCore::Layout::outputMismatchingBlockBoxInformationIfNeeded):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r245778 r245779  
     12019-05-26  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][Verification] Add areEssentiallyEqual for LayoutRect
     4        https://bugs.webkit.org/show_bug.cgi?id=198250
     5        <rdar://problem/51140119>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        WebKit's inline layout is a mix of int/float/LayoutUnit types, while LFC mostly uses LayoutUnit.
     10        When we compute the used size of a block container (based on the inline tree), the final value might go through a few conversions.
     11
     12        * layout/Verification.cpp:
     13        (WebCore::Layout::areEssentiallyEqual):
     14        (WebCore::Layout::outputMismatchingBlockBoxInformationIfNeeded):
     15
    1162019-05-26  Wenson Hsieh  <wenson_hsieh@apple.com>
    217
  • trunk/Source/WebCore/layout/Verification.cpp

    r245776 r245779  
    4343namespace Layout {
    4444
     45static bool areEssentiallyEqual(LayoutUnit a, LayoutUnit b)
     46{
     47    if (a == b)
     48        return true;
     49    // 1/4th CSS pixel.
     50    constexpr float epsilon = kFixedPointDenominator / 4;
     51    return abs(a.rawValue() - b.rawValue()) <= epsilon;
     52}
     53
    4554static bool areEssentiallyEqual(float a, LayoutUnit b)
    4655{
    47     if (a == b.toFloat())
    48         return true;
    49 
    50     return fabs(a - b.toFloat()) <= 10 * LayoutUnit::epsilon();
     56    return areEssentiallyEqual(LayoutUnit { a }, b);
     57}
     58
     59static bool areEssentiallyEqual(LayoutRect a, LayoutRect b)
     60{
     61    return areEssentiallyEqual(a.x(), b.x())
     62        && areEssentiallyEqual(a.y(), b.y())
     63        && areEssentiallyEqual(a.width(), b.width())
     64        && areEssentiallyEqual(a.height(), b.height());
    5165}
    5266
     
    217231        frameRect.move(renderer.offsetForInFlowPosition());
    218232
    219     if (frameRect != displayBox.rect()) {
     233    if (!areEssentiallyEqual(frameRect, displayBox.rect())) {
    220234        outputRect("frameBox", renderer.frameRect(), displayBox.rect());
    221235        return true;
    222236    }
    223237
    224     if (renderer.borderBoxRect() != displayBox.borderBox()) {
     238    if (!areEssentiallyEqual(renderer.borderBoxRect(), displayBox.borderBox())) {
    225239        outputRect("borderBox", renderer.borderBoxRect(), displayBox.borderBox());
    226240        return true;
    227241    }
    228242
    229     if (renderer.paddingBoxRect() != displayBox.paddingBox()) {
     243    if (!areEssentiallyEqual(renderer.paddingBoxRect(), displayBox.paddingBox())) {
    230244        outputRect("paddingBox", renderer.paddingBoxRect(), displayBox.paddingBox());
    231245        return true;
    232246    }
    233247
    234     if (renderer.contentBoxRect() != displayBox.contentBox()) {
     248    if (!areEssentiallyEqual(renderer.contentBoxRect(), displayBox.contentBox())) {
    235249        outputRect("contentBox", renderer.contentBoxRect(), displayBox.contentBox());
    236250        return true;
    237251    }
    238252
    239     if (renderer.marginBoxRect() != renderBoxLikeMarginBox(displayBox)) {
     253    if (!areEssentiallyEqual(renderer.marginBoxRect(), renderBoxLikeMarginBox(displayBox))) {
    240254        // In certain cases, like out-of-flow boxes with margin auto, marginBoxRect() returns 0. It's clearly incorrect,
    241255        // so let's check the individual margin values instead (and at this point we know that all other boxes match).
Note: See TracChangeset for help on using the changeset viewer.