Title: [210239] trunk
Revision
210239
Author
[email protected]
Date
2017-01-03 07:02:26 -0800 (Tue, 03 Jan 2017)

Log Message

A floating element within <li> overlaps with the marker
https://bugs.webkit.org/show_bug.cgi?id=166528

Reviewed by Zalan Bujtas.

Source/WebCore:

Merged from Blink (patch by [email protected]):
https://crrev.com/c896e79e5ba348d7ed87438cd3a19d0176f3036d
https://crbug.com/548616

Establish a list marker's offset before floats have been added to its line.

Computing the offset for a list marker after the rest of the objects on the line
it is on have been laid out, means it will avoid floats it ought not to.

Instead, compute the offset when laying out the marker and cache it for use later.

Tests: fast/lists/list-marker-before-float-nested-rtl.html
       fast/lists/list-marker-before-float-nested.html
       fast/lists/list-marker-before-float-rtl.html
       fast/lists/list-marker-before-float.html

* rendering/RenderListItem.cpp:
(WebCore::RenderListItem::positionListMarker):
* rendering/RenderListMarker.cpp:
(WebCore::RenderListMarker::RenderListMarker):
(WebCore::RenderListMarker::layout):
* rendering/RenderListMarker.h:

LayoutTests:

* fast/lists/list-marker-before-float-expected.html: Added.
* fast/lists/list-marker-before-float-nested-expected.html: Added.
* fast/lists/list-marker-before-float-nested-rtl-expected.html: Added.
* fast/lists/list-marker-before-float-nested-rtl.html: Added.
* fast/lists/list-marker-before-float-nested.html: Added.
* fast/lists/list-marker-before-float-rtl-expected.html: Added.
* fast/lists/list-marker-before-float-rtl.html: Added.
* fast/lists/list-marker-before-float.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (210238 => 210239)


--- trunk/LayoutTests/ChangeLog	2017-01-03 11:59:28 UTC (rev 210238)
+++ trunk/LayoutTests/ChangeLog	2017-01-03 15:02:26 UTC (rev 210239)
@@ -1,3 +1,19 @@
+2017-01-03  Carlos Alberto Lopez Perez  <[email protected]>
+
+        A floating element within <li> overlaps with the marker
+        https://bugs.webkit.org/show_bug.cgi?id=166528
+
+        Reviewed by Zalan Bujtas.
+
+        * fast/lists/list-marker-before-float-expected.html: Added.
+        * fast/lists/list-marker-before-float-nested-expected.html: Added.
+        * fast/lists/list-marker-before-float-nested-rtl-expected.html: Added.
+        * fast/lists/list-marker-before-float-nested-rtl.html: Added.
+        * fast/lists/list-marker-before-float-nested.html: Added.
+        * fast/lists/list-marker-before-float-rtl-expected.html: Added.
+        * fast/lists/list-marker-before-float-rtl.html: Added.
+        * fast/lists/list-marker-before-float.html: Added.
+
 2017-01-03  Carlos Garcia Campos  <[email protected]>
 
         [GTK] HTTP auth layout tests are flaky

Added: trunk/LayoutTests/fast/lists/list-marker-before-float-expected.html (0 => 210239)


--- trunk/LayoutTests/fast/lists/list-marker-before-float-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/lists/list-marker-before-float-expected.html	2017-01-03 15:02:26 UTC (rev 210239)
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<p>webkit.org/b/166528: List markers shouldn't shift to avoid floats that come after them on a line.</p>
+<ol>
+  <li>
+    <img width=20 height=20 style="background-color:black;"><img width=20 height=20 style="background-color:black;">
+  </li>
+</ol>
+

Added: trunk/LayoutTests/fast/lists/list-marker-before-float-nested-expected.html (0 => 210239)


--- trunk/LayoutTests/fast/lists/list-marker-before-float-nested-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/lists/list-marker-before-float-nested-expected.html	2017-01-03 15:02:26 UTC (rev 210239)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<p>webkit.org/b/166528: List markers shouldn't shift to avoid floats that come after them on a line.</p>
+<ol>
+  <li>
+    <img width=20 height=20 style="background-color:black;"><img width=20 height=20 style="background-color:black;">
+    <li>
+      <img width=20 height=20 style="background-color:black;"><img width=20 height=20 style="background-color:black;">
+    </li>
+  </li>
+  <li>
+    <img width=20 height=20 style="background-color:black;"><img width=20 height=20 style="background-color:black;">
+  </li>
+</ol>
+

Added: trunk/LayoutTests/fast/lists/list-marker-before-float-nested-rtl-expected.html (0 => 210239)


--- trunk/LayoutTests/fast/lists/list-marker-before-float-nested-rtl-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/lists/list-marker-before-float-nested-rtl-expected.html	2017-01-03 15:02:26 UTC (rev 210239)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<p>webkit.org/b/166528: List markers shouldn't shift to avoid floats that come after them on a line.</p>
+<ol dir=rtl>
+  <li>
+    <img width=20 height=20 style="background-color:black;"><img width=20 height=20 style="background-color:black;">
+    <li>
+      <img width=20 height=20 style="background-color:black;"><img width=20 height=20 style="background-color:black;">
+    </li>
+  </li>
+  <li>
+    <img width=20 height=20 style="background-color:black;"><img width=20 height=20 style="background-color:black;">
+  </li>
+</ol>
+

Added: trunk/LayoutTests/fast/lists/list-marker-before-float-nested-rtl.html (0 => 210239)


--- trunk/LayoutTests/fast/lists/list-marker-before-float-nested-rtl.html	                        (rev 0)
+++ trunk/LayoutTests/fast/lists/list-marker-before-float-nested-rtl.html	2017-01-03 15:02:26 UTC (rev 210239)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<p>webkit.org/b/166528: List markers shouldn't shift to avoid floats that come after them on a line.</p>
+<ol dir=rtl>
+  <li>
+    <img width=20 height=20 style="float: right; background-color:black;"><img width=20 height=20 style="background-color:black;">
+    <li>
+      <img width=20 height=20 style="float: right; background-color:black;"><img width=20 height=20 style="background-color:black;">
+    </li>
+  </li>
+  <li>
+    <img width=20 height=20 style="float: right; background-color:black;"><img width=20 height=20 style="background-color:black;">
+  </li>
+</ol>
+

Added: trunk/LayoutTests/fast/lists/list-marker-before-float-nested.html (0 => 210239)


--- trunk/LayoutTests/fast/lists/list-marker-before-float-nested.html	                        (rev 0)
+++ trunk/LayoutTests/fast/lists/list-marker-before-float-nested.html	2017-01-03 15:02:26 UTC (rev 210239)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<p>webkit.org/b/166528: List markers shouldn't shift to avoid floats that come after them on a line.</p>
+<ol>
+  <li>
+    <img width=20 height=20 style="float: left; background-color:black;"><img width=20 height=20 style="background-color:black;">
+    <li>
+      <img width=20 height=20 style="float: left; background-color:black;"><img width=20 height=20 style="background-color:black;">
+    </li>
+  </li>
+  <li>
+    <img width=20 height=20 style="float: left; background-color:black;"><img width=20 height=20 style="background-color:black;">
+  </li>
+</ol>
+

Added: trunk/LayoutTests/fast/lists/list-marker-before-float-rtl-expected.html (0 => 210239)


--- trunk/LayoutTests/fast/lists/list-marker-before-float-rtl-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/lists/list-marker-before-float-rtl-expected.html	2017-01-03 15:02:26 UTC (rev 210239)
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<p>webkit.org/b/166528: List markers shouldn't shift to avoid floats that come after them on a line.</p>
+<ol dir=rtl>
+  <li>
+    <img width=20 height=20 style="background-color:black;"><img width=20 height=20 style="background-color:black;">
+  </li>
+</ol>
+

Added: trunk/LayoutTests/fast/lists/list-marker-before-float-rtl.html (0 => 210239)


--- trunk/LayoutTests/fast/lists/list-marker-before-float-rtl.html	                        (rev 0)
+++ trunk/LayoutTests/fast/lists/list-marker-before-float-rtl.html	2017-01-03 15:02:26 UTC (rev 210239)
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<p>webkit.org/b/166528: List markers shouldn't shift to avoid floats that come after them on a line.</p>
+<ol dir=rtl>
+  <li>
+    <img width=20 height=20 style="float: right; background-color:black;"><img width=20 height=20 style="background-color:black;">
+  </li>
+</ol>
+

Added: trunk/LayoutTests/fast/lists/list-marker-before-float.html (0 => 210239)


--- trunk/LayoutTests/fast/lists/list-marker-before-float.html	                        (rev 0)
+++ trunk/LayoutTests/fast/lists/list-marker-before-float.html	2017-01-03 15:02:26 UTC (rev 210239)
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<p>webkit.org/b/166528: List markers shouldn't shift to avoid floats that come after them on a line.</p>
+<ol>
+  <li>
+    <img width=20 height=20 style="float: left; background-color:black;"><img width=20 height=20 style="background-color:black;">
+  </li>
+</ol>
+

Modified: trunk/Source/WebCore/ChangeLog (210238 => 210239)


--- trunk/Source/WebCore/ChangeLog	2017-01-03 11:59:28 UTC (rev 210238)
+++ trunk/Source/WebCore/ChangeLog	2017-01-03 15:02:26 UTC (rev 210239)
@@ -1,3 +1,33 @@
+2017-01-03  Carlos Alberto Lopez Perez  <[email protected]>
+
+        A floating element within <li> overlaps with the marker
+        https://bugs.webkit.org/show_bug.cgi?id=166528
+
+        Reviewed by Zalan Bujtas.
+
+        Merged from Blink (patch by [email protected]):
+        https://crrev.com/c896e79e5ba348d7ed87438cd3a19d0176f3036d
+        https://crbug.com/548616
+
+        Establish a list marker's offset before floats have been added to its line.
+
+        Computing the offset for a list marker after the rest of the objects on the line
+        it is on have been laid out, means it will avoid floats it ought not to.
+
+        Instead, compute the offset when laying out the marker and cache it for use later.
+
+        Tests: fast/lists/list-marker-before-float-nested-rtl.html
+               fast/lists/list-marker-before-float-nested.html
+               fast/lists/list-marker-before-float-rtl.html
+               fast/lists/list-marker-before-float.html
+
+        * rendering/RenderListItem.cpp:
+        (WebCore::RenderListItem::positionListMarker):
+        * rendering/RenderListMarker.cpp:
+        (WebCore::RenderListMarker::RenderListMarker):
+        (WebCore::RenderListMarker::layout):
+        * rendering/RenderListMarker.h:
+
 2017-01-03  Per Arne Vollan  <[email protected]>
 
         [Win] Some xmlhttprequest tests are failing.

Modified: trunk/Source/WebCore/rendering/RenderListItem.cpp (210238 => 210239)


--- trunk/Source/WebCore/rendering/RenderListItem.cpp	2017-01-03 11:59:28 UTC (rev 210238)
+++ trunk/Source/WebCore/rendering/RenderListItem.cpp	2017-01-03 15:02:26 UTC (rev 210239)
@@ -371,8 +371,7 @@
 
     // FIXME: Need to account for relative positioning in the layout overflow.
     if (style().isLeftToRightDirection()) {
-        LayoutUnit leftLineOffset = logicalLeftOffsetForLine(blockOffset, logicalLeftOffsetForLine(blockOffset, DoNotIndentText), false);
-        markerLogicalLeft = leftLineOffset - lineOffset - paddingStart() - borderStart() + m_marker->marginStart();
+        markerLogicalLeft = m_marker->lineOffsetForListItem() - lineOffset - paddingStart() - borderStart() + m_marker->marginStart();
         m_marker->inlineBoxWrapper()->adjustLineDirectionPosition(markerLogicalLeft - markerOldLogicalLeft);
         for (InlineFlowBox* box = m_marker->inlineBoxWrapper()->parent(); box; box = box->parent()) {
             LayoutRect newLogicalVisualOverflowRect = box->logicalVisualOverflowRect(lineTop, lineBottom);
@@ -394,8 +393,7 @@
                 hitSelfPaintingLayer = true;
         }
     } else {
-        LayoutUnit rightLineOffset = logicalRightOffsetForLine(blockOffset, logicalRightOffsetForLine(blockOffset, DoNotIndentText), false);
-        markerLogicalLeft = rightLineOffset - lineOffset + paddingStart() + borderStart() + m_marker->marginEnd();
+        markerLogicalLeft = m_marker->lineOffsetForListItem() - lineOffset + paddingStart() + borderStart() + m_marker->marginEnd();
         m_marker->inlineBoxWrapper()->adjustLineDirectionPosition(markerLogicalLeft - markerOldLogicalLeft);
         for (InlineFlowBox* box = m_marker->inlineBoxWrapper()->parent(); box; box = box->parent()) {
             LayoutRect newLogicalVisualOverflowRect = box->logicalVisualOverflowRect(lineTop, lineBottom);

Modified: trunk/Source/WebCore/rendering/RenderListMarker.cpp (210238 => 210239)


--- trunk/Source/WebCore/rendering/RenderListMarker.cpp	2017-01-03 11:59:28 UTC (rev 210238)
+++ trunk/Source/WebCore/rendering/RenderListMarker.cpp	2017-01-03 15:02:26 UTC (rev 210239)
@@ -1372,6 +1372,14 @@
 {
     StackStats::LayoutCheckPoint layoutCheckPoint;
     ASSERT(needsLayout());
+
+    LayoutUnit blockOffset;
+    for (auto* box = parentBox(); box && box != &m_listItem; box = box->parentBox())
+        blockOffset += box->logicalTop();
+    if (style().isLeftToRightDirection())
+        m_lineOffsetForListItem = m_listItem.logicalLeftOffsetForLine(blockOffset, DoNotIndentText, LayoutUnit());
+    else
+        m_lineOffsetForListItem = m_listItem.logicalRightOffsetForLine(blockOffset, DoNotIndentText, LayoutUnit());
  
     if (isImage()) {
         updateMarginsAndContent();

Modified: trunk/Source/WebCore/rendering/RenderListMarker.h (210238 => 210239)


--- trunk/Source/WebCore/rendering/RenderListMarker.h	2017-01-03 11:59:28 UTC (rev 210238)
+++ trunk/Source/WebCore/rendering/RenderListMarker.h	2017-01-03 15:02:26 UTC (rev 210239)
@@ -42,6 +42,8 @@
 
     bool isInside() const;
 
+    LayoutUnit lineOffsetForListItem() const { return m_lineOffsetForListItem; }
+
     void updateMarginsAndContent();
 
 #if !ASSERT_DISABLED
@@ -86,6 +88,7 @@
     String m_text;
     RefPtr<StyleImage> m_image;
     RenderListItem& m_listItem;
+    LayoutUnit m_lineOffsetForListItem;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to