[LFC][Floats] Remove redundant intersecting logic
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Feb 2019 22:33:43 +0000 (22:33 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Feb 2019 22:33:43 +0000 (22:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194804

Reviewed by Antti Koivisto.

Source/WebCore:

floatAvoider.overflowsContainingBlock() check already (and properly) takes care of the far left/right case (see comment).

* layout/floats/FloatingContext.cpp:
(WebCore::Layout::FloatingContext::floatingPosition const):
(WebCore::Layout::FloatingPair::intersects const):

Tools:

* LayoutReloaded/misc/LFC-passing-tests.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241774 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/layout/floats/FloatingContext.cpp
Tools/ChangeLog
Tools/LayoutReloaded/misc/LFC-passing-tests.txt

index a6da53f..787650f 100644 (file)
@@ -1,3 +1,16 @@
+2019-02-19  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][Floats] Remove redundant intersecting logic
+        https://bugs.webkit.org/show_bug.cgi?id=194804
+
+        Reviewed by Antti Koivisto.
+
+        floatAvoider.overflowsContainingBlock() check already (and properly) takes care of the far left/right case (see comment).
+
+        * layout/floats/FloatingContext.cpp:
+        (WebCore::Layout::FloatingContext::floatingPosition const):
+        (WebCore::Layout::FloatingPair::intersects const):
+
 2019-02-19  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r241722.
index 57564d6..97cd83a 100644 (file)
@@ -277,7 +277,8 @@ void FloatingContext::floatingPosition(FloatAvoider& floatAvoider) const
         floatAvoider.setVerticalConstraint(floats.verticalConstraint());
 
         // Ensure that the float avoider
-        // 1. does not overflow its containing block with the current horiztonal constraints
+        // 1. does not "overflow" its containing block with the current horiztonal constraints. It simply means that the float avoider's
+        // containing block could push the candidate position beyond the current float horizontally (too far to the left/right)
         // 2. avoids floats on both sides.
         if (!floatAvoider.overflowsContainingBlock() && !floats.intersects(floatAvoider.rect()))
             return;
@@ -318,33 +319,14 @@ const FloatingState::FloatItem* FloatingPair::right() const
     return &m_floats[*m_rightIndex];
 }
 
-bool FloatingPair::intersects(const Display::Box::Rect& candidateRect) const
+bool FloatingPair::intersects(const Display::Box::Rect& floatAvoiderRect) const
 {
-    auto intersects = [&](const FloatingState::FloatItem* floating, Float floatingType) {
-        if (!floating)
-            return false;
-
-        auto marginRect = floating->rectWithMargin();
-        // Before intersecting, check if the candidate position is too far to the left/right.
-        // The new float's containing block could push the candidate position beyond the current float horizontally.
-        if ((floatingType == Float::Left && candidateRect.left() < marginRect.right())
-            || (floatingType == Float::Right && candidateRect.right() > marginRect.left()))
-            return true;
-        return marginRect.intersects(candidateRect);
+    auto intersects = [&](auto* floating) {
+        return floating ? floating->rectWithMargin().intersects(floatAvoiderRect) : false;
     };
 
-    if (!m_leftIndex && !m_rightIndex) {
-        ASSERT_NOT_REACHED();
-        return false;
-    }
-
-    if (intersects(left(), Float::Left))
-        return true;
-
-    if (intersects(right(), Float::Right))
-        return true;
-
-    return false;
+    ASSERT(m_leftIndex || m_rightIndex);
+    return intersects(left()) || intersects(right());
 }
 
 bool FloatingPair::operator ==(const FloatingPair& other) const
index 226d36d..288e9fa 100644 (file)
@@ -1,3 +1,12 @@
+2019-02-19  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][Floats] Remove redundant intersecting logic
+        https://bugs.webkit.org/show_bug.cgi?id=194804
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LFC-passing-tests.txt:
+
 2019-02-19  Dean Jackson  <dino@apple.com>
 
         Clean-up output from generate-xcfilelists so it can be filtered
index 1fbfb9e..5affc29 100644 (file)
@@ -843,6 +843,7 @@ css2.1/20110323/float-replaced-width-004.htm
 css2.1/20110323/float-replaced-width-005.htm
 css2.1/20110323/float-replaced-width-006.htm
 css2.1/20110323/float-replaced-width-011.htm
+css2.1/20110323/floats-wrap-top-below-bfc-002l.htm
 css2.1/20110323/floats-001.html
 css2.1/20110323/floats-102.html
 css2.1/20110323/inline-block-non-replaced-width-001.htm