Title: [216378] releases/WebKitGTK/webkit-2.16
Revision
216378
Author
carlo...@webkit.org
Date
2017-05-08 03:23:19 -0700 (Mon, 08 May 2017)

Log Message

Merge r215660 - REGRESSION(r205374): <li> content inside <ul> should mid-word wrap when word-break: break-word is present.
https://bugs.webkit.org/show_bug.cgi?id=171108
<rdar://problem/30271747>

Reviewed by Dan Bernstein.

Source/WebCore:

This patch ensures that we search for mid-word breaks when a zero sized element has been committed on the line
unless it's an image or some other replaced element with special properties (e.g. list-style: inside).

Tests: fast/replaced/ul-li-word-break-break-word.html
       fast/replaced/zero-width-image-force-linebreak.html

* rendering/line/BreakingContext.h:
(WebCore::BreakingContext::handleReplaced):
(WebCore::BreakingContext::handleText): This matches pre-r205374 behaviour, but it's explicit about whether a
replaced width has already been committed on the current line.
* rendering/line/LineWidth.cpp:
(WebCore::LineWidth::commit):
* rendering/line/LineWidth.h:
(WebCore::LineWidth::hasCommittedReplaced):
(WebCore::LineWidth::addUncommittedReplacedWidth): These 2 last functions were removed with r205374 (and now I am adding them back).

LayoutTests:

* fast/replaced/ul-li-word-break-break-word-expected.html: Added.
* fast/replaced/ul-li-word-break-break-word.html: Added.
* fast/replaced/zero-width-image-force-linebreak-expected.html: Added.
* fast/replaced/zero-width-image-force-linebreak.html: Added.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog (216377 => 216378)


--- releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog	2017-05-08 10:17:25 UTC (rev 216377)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog	2017-05-08 10:23:19 UTC (rev 216378)
@@ -1,3 +1,16 @@
+2017-04-21  Zalan Bujtas  <za...@apple.com>
+
+        REGRESSION(r205374): <li> content inside <ul> should mid-word wrap when word-break: break-word is present.
+        https://bugs.webkit.org/show_bug.cgi?id=171108
+        <rdar://problem/30271747>
+
+        Reviewed by Dan Bernstein.
+
+        * fast/replaced/ul-li-word-break-break-word-expected.html: Added.
+        * fast/replaced/ul-li-word-break-break-word.html: Added.
+        * fast/replaced/zero-width-image-force-linebreak-expected.html: Added.
+        * fast/replaced/zero-width-image-force-linebreak.html: Added.
+
 2017-05-08  Carlos Garcia Campos  <cgar...@igalia.com>
 
         Unreviewed. Fix expectations of fast/events/drag-and-drop-link-containing-block.html.

Added: releases/WebKitGTK/webkit-2.16/LayoutTests/fast/replaced/ul-li-word-break-break-word-expected.html (0 => 216378)


--- releases/WebKitGTK/webkit-2.16/LayoutTests/fast/replaced/ul-li-word-break-break-word-expected.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/fast/replaced/ul-li-word-break-break-word-expected.html	2017-05-08 10:23:19 UTC (rev 216378)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests li inside ul with word-break: break-word.</title>
+<style>
+.container {
+    display: inline-block;
+    border: 1px solid green; 
+    font-size: 20px; 
+    width: 80px;
+}
+</style>
+</head>
+<body> 
+<div class=container>
+    <div><li>foobarfoo bar</li></div>
+    <ul><li>foob arfo obar</li></ul>
+</div>
+<div class=container>
+    <div><li>foobar-foobar</li></div>
+    <ul><li>foob ar-foob ar</li></ul>
+</div>
+<br>
+<div class=container>
+    <div><li>foobarfoo bar</li></div>
+    <ul><li>foob arfo o bar</li></ul>
+</div>
+<div class=container>
+    <div style="width: 40px"><li>foob arfo obar</li></div>
+    <ul><li style="width: 20px">fo ob ar fo ob ar</li></ul>
+</div>
+<br>
+<div class=container>
+    <div><li>foobarfoo bar</li></div>
+    <ul style="list-style: inside"><li>foob arfo obar</li></ul>
+</div>
+<div class=container>
+    <div><li>foobarfoo bar</li></div>
+    <ul style="list-style: none"><li>foob arfo obar</li></ul>
+</div>
+<body>
+</html>

Added: releases/WebKitGTK/webkit-2.16/LayoutTests/fast/replaced/ul-li-word-break-break-word.html (0 => 216378)


--- releases/WebKitGTK/webkit-2.16/LayoutTests/fast/replaced/ul-li-word-break-break-word.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/fast/replaced/ul-li-word-break-break-word.html	2017-05-08 10:23:19 UTC (rev 216378)
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests li inside ul with word-break: break-word.</title>
+<style>
+.container {
+    display: inline-block;
+    word-break : break-word;
+    border: 1px solid green; 
+    font-size: 20px; 
+    width: 80px;
+}
+
+ul {
+    word-break : break-word;
+}
+</style>
+</head>
+<body> 
+<div class=container>
+    <div><li>foobarfoobar</li></div>
+    <ul><li>foobarfoobar</li></ul>
+</div>
+<div class=container>
+    <div><li>foobar-foobar</li></div>
+    <ul><li>foobar-foobar</li></ul>
+</div>
+<br>
+<div class=container>
+    <div><li>foobarfoo bar</li></div>
+    <ul><li>foobarfoo bar</li></ul>
+</div>
+<div class=container>
+    <div style="width: 40px"><li>foobarfoobar</li></div>
+    <ul><li style="width: 20px">foobarfoobar</li></ul>
+</div>
+<br>
+<div class=container>
+    <div><li>foobarfoobar</li></div>
+    <ul style="list-style: inside"><li>foobarfoobar</li></ul>
+</div>
+<div class=container>
+    <div><li>foobarfoobar</li></div>
+    <ul style="list-style: none"><li>foobarfoobar</li></ul>
+</div>
+<body>
+</html>

Added: releases/WebKitGTK/webkit-2.16/LayoutTests/fast/replaced/zero-width-image-force-linebreak-expected.html (0 => 216378)


--- releases/WebKitGTK/webkit-2.16/LayoutTests/fast/replaced/zero-width-image-force-linebreak-expected.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/fast/replaced/zero-width-image-force-linebreak-expected.html	2017-05-08 10:23:19 UTC (rev 216378)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that replaced element with zero width forces line break.</title>
+<style>
+.container {
+    word-break : break-word;
+    border: 1px solid green; 
+    font-size: 20px;
+    font-family: ahem;
+    line-height: 20px;
+    width: 50px;
+}
+</style>
+</head>
+<body> 
+<div class=container><br>foobarfoobar</div>
+</body>
+</html>

Added: releases/WebKitGTK/webkit-2.16/LayoutTests/fast/replaced/zero-width-image-force-linebreak.html (0 => 216378)


--- releases/WebKitGTK/webkit-2.16/LayoutTests/fast/replaced/zero-width-image-force-linebreak.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/fast/replaced/zero-width-image-force-linebreak.html	2017-05-08 10:23:19 UTC (rev 216378)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that replaced element with zero width forces line break.</title>
+<style>
+div {
+    word-break : break-word;
+    border: 1px solid green; 
+    font-size: 20px;
+    font-family: ahem;
+    line-height: 20px;
+    width: 50px;
+}
+</style>
+</head>
+<body> 
+<div><img width="0px" height="10px" src=""
+</body>
+</html>

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog (216377 => 216378)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog	2017-05-08 10:17:25 UTC (rev 216377)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog	2017-05-08 10:23:19 UTC (rev 216378)
@@ -1,3 +1,27 @@
+2017-04-21  Zalan Bujtas  <za...@apple.com>
+
+        REGRESSION(r205374): <li> content inside <ul> should mid-word wrap when word-break: break-word is present.
+        https://bugs.webkit.org/show_bug.cgi?id=171108
+        <rdar://problem/30271747>
+
+        Reviewed by Dan Bernstein.
+
+        This patch ensures that we search for mid-word breaks when a zero sized element has been committed on the line
+        unless it's an image or some other replaced element with special properties (e.g. list-style: inside).  
+
+        Tests: fast/replaced/ul-li-word-break-break-word.html
+               fast/replaced/zero-width-image-force-linebreak.html
+
+        * rendering/line/BreakingContext.h:
+        (WebCore::BreakingContext::handleReplaced):
+        (WebCore::BreakingContext::handleText): This matches pre-r205374 behaviour, but it's explicit about whether a 
+        replaced width has already been committed on the current line.
+        * rendering/line/LineWidth.cpp:
+        (WebCore::LineWidth::commit):
+        * rendering/line/LineWidth.h:
+        (WebCore::LineWidth::hasCommittedReplaced):
+        (WebCore::LineWidth::addUncommittedReplacedWidth): These 2 last functions were removed with r205374 (and now I am adding them back). 
+
 2017-04-21  Chris Dumez  <cdu...@apple.com>
 
         Regression(r206240): XMLSerializer.serializeToString() does not properly escape '<' / '>' in attribute values

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/line/BreakingContext.h (216377 => 216378)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/line/BreakingContext.h	2017-05-08 10:17:25 UTC (rev 216377)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/line/BreakingContext.h	2017-05-08 10:23:19 UTC (rev 216378)
@@ -581,9 +581,9 @@
             m_ignoringSpaces = true;
         }
         if (downcast<RenderListMarker>(*m_current.renderer()).isInside())
-            m_width.addUncommittedWidth(replacedLogicalWidth);
+            m_width.addUncommittedReplacedWidth(replacedLogicalWidth);
     } else
-        m_width.addUncommittedWidth(replacedLogicalWidth);
+        m_width.addUncommittedReplacedWidth(replacedLogicalWidth);
     if (is<RenderRubyRun>(*m_current.renderer())) {
         m_width.applyOverhang(downcast<RenderRubyRun>(m_current.renderer()), m_lastObject, m_nextObject);
         downcast<RenderRubyRun>(m_current.renderer())->updatePriorContextFromCachedBreakIterator(m_renderTextInfo.lineBreakIterator);
@@ -800,7 +800,7 @@
     bool breakNBSP = m_autoWrap && m_currentStyle->nbspMode() == SPACE;
     // Auto-wrapping text should wrap in the middle of a word only if it could not wrap before the word,
     // which is only possible if the word is the first thing on the line.
-    bool breakWords = m_currentStyle->breakWords() && ((m_autoWrap && !m_width.hasCommitted()) || m_currWS == PRE);
+    bool breakWords = m_currentStyle->breakWords() && ((m_autoWrap && (!m_width.committedWidth() && !m_width.hasCommittedReplaced())) || m_currWS == PRE);
     bool midWordBreak = false;
     bool breakAll = m_currentStyle->wordBreak() == BreakAllWordBreak && m_autoWrap;
     bool keepAllWords = m_currentStyle->wordBreak() == KeepAllWordBreak;

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/line/LineWidth.cpp (216377 => 216378)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/line/LineWidth.cpp	2017-05-08 10:17:25 UTC (rev 216377)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/line/LineWidth.cpp	2017-05-08 10:23:19 UTC (rev 216378)
@@ -122,6 +122,10 @@
 {
     m_committedWidth += m_uncommittedWidth;
     m_uncommittedWidth = 0;
+    if (m_hasUncommittedReplaced) {
+        m_hasCommittedReplaced = true;
+        m_hasUncommittedReplaced = false;
+    }
     m_hasCommitted = true;
 }
 

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/line/LineWidth.h (216377 => 216378)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/line/LineWidth.h	2017-05-08 10:17:25 UTC (rev 216377)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/line/LineWidth.h	2017-05-08 10:23:19 UTC (rev 216378)
@@ -59,6 +59,7 @@
     float logicalLeftOffset() const { return m_left; }
     
     bool hasCommitted() const { return m_hasCommitted; }
+    bool hasCommittedReplaced() const { return m_hasCommittedReplaced; }
 
     void updateAvailableWidth(LayoutUnit minimumHeight = 0);
     void shrinkAvailableWidthForNewFloatIfNeeded(const FloatingObject&);
@@ -66,6 +67,11 @@
     {
         m_uncommittedWidth += delta;
     }
+    void addUncommittedReplacedWidth(float delta)
+    {
+        addUncommittedWidth(delta);
+        m_hasUncommittedReplaced = true;
+    }
     void commit();
     void applyOverhang(RenderRubyRun*, RenderObject* startRenderer, RenderObject* endRenderer);
     void fitBelowFloats(bool isFirstLine = false);
@@ -91,6 +97,8 @@
     float m_availableWidth { 0 };
     bool m_isFirstLine { true };
     bool m_hasCommitted { false };
+    bool m_hasCommittedReplaced { false };
+    bool m_hasUncommittedReplaced { false };
     IndentTextOrNot m_shouldIndentText;
 };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to