Title: [211222] trunk
Revision
211222
Author
za...@apple.com
Date
2017-01-26 11:36:27 -0800 (Thu, 26 Jan 2017)

Log Message

Simple line layout: Add support for -webkit-hyphenate-limit-after and -webkit-hyphenate-limit-before
https://bugs.webkit.org/show_bug.cgi?id=167439
<rdar://problem/30180184>

Reviewed by Antti Koivisto.

Source/WebCore:

Implement pre and post hyphen length constrains for simple line layout.

Tests: fast/text/simple-line-layout-hyphen-limit-after.html
       fast/text/simple-line-layout-hyphen-limit-before.html

* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::canUseForStyle):
(WebCore::SimpleLineLayout::printReason):
* rendering/SimpleLineLayoutTextFragmentIterator.cpp:
(WebCore::SimpleLineLayout::TextFragmentIterator::Style::Style): Same as normal line layout default values.
(WebCore::SimpleLineLayout::TextFragmentIterator::lastHyphenPosition):
* rendering/SimpleLineLayoutTextFragmentIterator.h:

LayoutTests:

* fast/text/simple-line-layout-hyphen-limit-after.html: Added.
* fast/text/simple-line-layout-hyphen-limit-before-expected.html: Added.
* fast/text/simple-line-layout-hyphen-limit-before.html: Added.
* platform/mac/fast/text/hyphenate-limit-before-after-expected.txt: progression.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (211221 => 211222)


--- trunk/LayoutTests/ChangeLog	2017-01-26 19:25:12 UTC (rev 211221)
+++ trunk/LayoutTests/ChangeLog	2017-01-26 19:36:27 UTC (rev 211222)
@@ -1,3 +1,16 @@
+2017-01-26  Zalan Bujtas  <za...@apple.com>
+
+        Simple line layout: Add support for -webkit-hyphenate-limit-after and -webkit-hyphenate-limit-before
+        https://bugs.webkit.org/show_bug.cgi?id=167439
+        <rdar://problem/30180184>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/text/simple-line-layout-hyphen-limit-after.html: Added.
+        * fast/text/simple-line-layout-hyphen-limit-before-expected.html: Added.
+        * fast/text/simple-line-layout-hyphen-limit-before.html: Added.
+        * platform/mac/fast/text/hyphenate-limit-before-after-expected.txt: progression.
+
 2017-01-26  Ryan Haddad  <ryanhad...@apple.com>
 
         Marking swipe/main-frame-pinning-requirement.html as flaky on El Capitan.

Added: trunk/LayoutTests/fast/text/simple-line-layout-hyphen-limit-after-expected.html (0 => 211222)


--- trunk/LayoutTests/fast/text/simple-line-layout-hyphen-limit-after-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/simple-line-layout-hyphen-limit-after-expected.html	2017-01-26 19:36:27 UTC (rev 211222)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that simple and normal line layout produce the same lines with hyphenate-limit-after</title>
+<style>
+div {
+  display: inline-block;
+  -webkit-hyphens: auto;
+  width: 50px;
+  border: 1px solid green;
+  margin-right: 50px;
+  vertical-align: top;
+}
+</style>
+<script>
+if (internal.settings)
+    internals.settings.setSimpleLineLayoutEnabled(false);
+</script>
+</head>
+<body>
+<div style="-webkit-hyphenate-limit-after: 1;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-after: 2;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-after: 3;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-after: 4;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-after: 5;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-after: 6;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-after: 7;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-after: 8;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/simple-line-layout-hyphen-limit-after.html (0 => 211222)


--- trunk/LayoutTests/fast/text/simple-line-layout-hyphen-limit-after.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/simple-line-layout-hyphen-limit-after.html	2017-01-26 19:36:27 UTC (rev 211222)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that simple and normal line layout produce the same lines with hyphenate-limit-after</title>
+<style>
+div {
+  display: inline-block;
+  -webkit-hyphens: auto;
+  width: 50px;
+  border: 1px solid green;
+  margin-right: 50px;
+  vertical-align: top;
+}
+</style>
+</head>
+<body>
+<div style="-webkit-hyphenate-limit-after: 1;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-after: 2;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-after: 3;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-after: 4;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-after: 5;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-after: 6;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-after: 7;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-after: 8;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/simple-line-layout-hyphen-limit-before-expected.html (0 => 211222)


--- trunk/LayoutTests/fast/text/simple-line-layout-hyphen-limit-before-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/simple-line-layout-hyphen-limit-before-expected.html	2017-01-26 19:36:27 UTC (rev 211222)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that simple and normal line layout produce the same lines with hyphenate-limit-before</title>
+<style>
+div {
+  display: inline-block;
+  -webkit-hyphens: auto;
+  width: 50px;
+  border: 1px solid green;
+  margin-right: 50px;
+  vertical-align: top;
+}
+</style>
+<script>
+if (internal.settings)
+    internals.settings.setSimpleLineLayoutEnabled(false);
+</script>
+</head>
+<body>
+<div style="-webkit-hyphenate-limit-before: 0;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-before: 1;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-before: 2;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-before: 3;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-before: 4;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-before: 5;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-before: 6;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-before: 7;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/simple-line-layout-hyphen-limit-before.html (0 => 211222)


--- trunk/LayoutTests/fast/text/simple-line-layout-hyphen-limit-before.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/simple-line-layout-hyphen-limit-before.html	2017-01-26 19:36:27 UTC (rev 211222)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that simple and normal line layout produce the same lines with hyphenate-limit-before</title>
+<style>
+div {
+  display: inline-block;
+  -webkit-hyphens: auto;
+  width: 50px;
+  border: 1px solid green;
+  margin-right: 50px;
+  vertical-align: top;
+}
+</style>
+</head>
+<body>
+<div style="-webkit-hyphenate-limit-before: 0;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-before: 1;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-before: 2;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-before: 3;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-before: 4;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-before: 5;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-before: 6;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+<div style="-webkit-hyphenate-limit-before: 7;">accoutrements accessories anomalistic auspicious favorable prosperous circumlocution conviviality coruscant cuddlesome cynosure equanimity excogitate gasconading idiosyncratic luminescent magnanimous nidificate penultimate perfidiousness perspicacious proficuous profitable advantageous remunerative profitability saxicolous sesquipedalian superabundant unencumbered responsibilities unparagoned peerless</div>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/mac/fast/text/hyphenate-limit-before-after-expected.txt (211221 => 211222)


--- trunk/LayoutTests/platform/mac/fast/text/hyphenate-limit-before-after-expected.txt	2017-01-26 19:25:12 UTC (rev 211221)
+++ trunk/LayoutTests/platform/mac/fast/text/hyphenate-limit-before-after-expected.txt	2017-01-26 19:36:27 UTC (rev 211222)
@@ -53,15 +53,15 @@
       RenderText {#text} at (434,123) size 4x18
         text run at (434,123) width 4: " "
       RenderBlock {DIV} at (446,84) size 126x60 [border: (3px solid #000000)]
-        RenderText {#text} at (3,3) size 74x54
+        RenderText {#text} at (3,3) size 89x54
           text run at (3,3) width 74: "There is re" + hyphen string "-"
-          text run at (3,21) width 60: "markable"
-          text run at (3,39) width 61: "evidence."
+          text run at (3,21) width 89: "markable evi" + hyphen string "-"
+          text run at (3,39) width 42: "dence."
       RenderText {#text} at (580,123) size 4x18
         text run at (580,123) width 4: " "
       RenderBlock {DIV} at (592,84) size 126x60 [border: (3px solid #000000)]
-        RenderText {#text} at (3,3) size 72x54
+        RenderText {#text} at (3,3) size 101x54
           text run at (3,3) width 52: "There is"
-          text run at (3,21) width 72: "remarkable"
-          text run at (3,39) width 61: "evidence."
+          text run at (3,21) width 101: "remarkable evi" + hyphen string "-"
+          text run at (3,39) width 42: "dence."
       RenderText {#text} at (0,0) size 0x0

Modified: trunk/Source/WebCore/ChangeLog (211221 => 211222)


--- trunk/Source/WebCore/ChangeLog	2017-01-26 19:25:12 UTC (rev 211221)
+++ trunk/Source/WebCore/ChangeLog	2017-01-26 19:36:27 UTC (rev 211222)
@@ -1,3 +1,24 @@
+2017-01-26  Zalan Bujtas  <za...@apple.com>
+
+        Simple line layout: Add support for -webkit-hyphenate-limit-after and -webkit-hyphenate-limit-before
+        https://bugs.webkit.org/show_bug.cgi?id=167439
+        <rdar://problem/30180184>
+
+        Reviewed by Antti Koivisto.
+
+        Implement pre and post hyphen length constrains for simple line layout.
+
+        Tests: fast/text/simple-line-layout-hyphen-limit-after.html
+               fast/text/simple-line-layout-hyphen-limit-before.html
+
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::canUseForStyle):
+        (WebCore::SimpleLineLayout::printReason):
+        * rendering/SimpleLineLayoutTextFragmentIterator.cpp:
+        (WebCore::SimpleLineLayout::TextFragmentIterator::Style::Style): Same as normal line layout default values.
+        (WebCore::SimpleLineLayout::TextFragmentIterator::lastHyphenPosition):
+        * rendering/SimpleLineLayoutTextFragmentIterator.h:
+
 2017-01-26  Brady Eidson  <beid...@apple.com>
 
         Gamepad support shows wrong values for PS4 controllers (D-pad is missing).

Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (211221 => 211222)


--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2017-01-26 19:25:12 UTC (rev 211221)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2017-01-26 19:36:27 UTC (rev 211222)
@@ -86,7 +86,7 @@
     FlowHasRTLOrdering                    = 1LLU  << 20,
     FlowHasLineAlignEdges                 = 1LLU  << 21,
     FlowHasLineSnap                       = 1LLU  << 22,
-    FlowHasHypensLimit                    = 1LLU  << 23,
+    FlowHasHypensLineLimit                = 1LLU  << 23,
     FlowHasTextEmphasisFillOrMark         = 1LLU  << 24,
     FlowHasTextShadow                     = 1LLU  << 25,
     FlowHasPseudoFirstLine                = 1LLU  << 26,
@@ -237,10 +237,8 @@
         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasLineAlignEdges, reasons, includeReasons);
     if (style.lineSnap() != LineSnapNone)
         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasLineSnap, reasons, includeReasons);
-    if (style.hyphenationLimitBefore() != RenderStyle::initialHyphenationLimitBefore()
-        || style.hyphenationLimitAfter() != RenderStyle::initialHyphenationLimitAfter()
-        || style.hyphenationLimitLines() != RenderStyle::initialHyphenationLimitLines())
-        SET_REASON_AND_RETURN_IF_NEEDED(FlowHasHypensLimit, reasons, includeReasons);
+    if (style.hyphenationLimitLines() != RenderStyle::initialHyphenationLimitLines())
+        SET_REASON_AND_RETURN_IF_NEEDED(FlowHasHypensLineLimit, reasons, includeReasons);
     if (style.textEmphasisFill() != TextEmphasisFillFilled || style.textEmphasisMark() != TextEmphasisMarkNone)
         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasTextEmphasisFillOrMark, reasons, includeReasons);
     if (style.textShadow())
@@ -991,8 +989,8 @@
     case FlowHasLineSnap:
         stream << "-webkit-line-snap property";
         break;
-    case FlowHasHypensLimit:
-        stream << "hyphen-limit-* property";
+    case FlowHasHypensLineLimit:
+        stream << "-webkit-hyphenate-limit-lines property";
         break;
     case FlowHasTextEmphasisFillOrMark:
         stream << "text-emphasis (fill/mark)";

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp (211221 => 211222)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp	2017-01-26 19:25:12 UTC (rev 211221)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp	2017-01-26 19:36:27 UTC (rev 211222)
@@ -49,6 +49,8 @@
     , tabWidth(collapseWhitespace ? 0 : style.tabSize())
     , shouldHyphenate(style.hyphens() == HyphensAuto && canHyphenate(style.locale()))
     , hyphenStringWidth(shouldHyphenate ? font.width(TextRun(style.hyphenString())) : 0)
+    , hyphenLimitBefore(style.hyphenationLimitBefore() < 0 ? 2 : style.hyphenationLimitBefore())
+    , hyphenLimitAfter(style.hyphenationLimitAfter() < 0 ? 2 : style.hyphenationLimitAfter())
     , locale(style.locale())
 {
 }
@@ -176,20 +178,28 @@
     return runWidth(segment, from, to, xPosition);
 }
 
-std::optional<unsigned> TextFragmentIterator::lastHyphenPosition(const TextFragmentIterator::TextFragment& run, unsigned beforeIndex) const
+std::optional<unsigned> TextFragmentIterator::lastHyphenPosition(const TextFragmentIterator::TextFragment& run, unsigned before) const
 {
-    ASSERT(run.start() < beforeIndex);
+    ASSERT(run.start() < before);
     auto& segment = *m_currentSegment;
-    ASSERT(segment.start <= beforeIndex && beforeIndex <= segment.end);
+    ASSERT(segment.start <= before && before <= segment.end);
     ASSERT(is<RenderText>(segment.renderer));
     if (!m_style.shouldHyphenate || run.type() != TextFragment::NonWhitespace)
         return std::nullopt;
-    
+    // Check if there are enough characters in the run.
+    unsigned runLength = run.end() - run.start();
+    if (m_style.hyphenLimitBefore >= runLength || m_style.hyphenLimitAfter >= runLength || m_style.hyphenLimitBefore + m_style.hyphenLimitAfter > runLength)
+        return std::nullopt;
     auto runStart = segment.toSegmentPosition(run.start());
-    auto before = segment.toSegmentPosition(beforeIndex) - runStart;
+    auto beforeIndex = segment.toSegmentPosition(before) - runStart;
+    if (beforeIndex <= m_style.hyphenLimitBefore)
+        return std::nullopt;
+    // Adjust before index to accommodate the limit-after value (this is the last potential hyphen location).
+    beforeIndex = std::min(beforeIndex, runLength - m_style.hyphenLimitAfter + 1);
     auto substringForHyphenation = StringView(segment.text).substring(runStart, run.end() - run.start());
-    auto hyphenLocation = lastHyphenLocation(substringForHyphenation, before, m_style.locale);
-    if (hyphenLocation)
+    auto hyphenLocation = lastHyphenLocation(substringForHyphenation, beforeIndex, m_style.locale);
+    // Check if there are enough characters before and after the hyphen.
+    if (hyphenLocation && hyphenLocation >= m_style.hyphenLimitBefore && m_style.hyphenLimitAfter <= (runLength - hyphenLocation))
         return segment.toRenderPosition(hyphenLocation + runStart);
     return std::nullopt;
 }

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h (211221 => 211222)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h	2017-01-26 19:25:12 UTC (rev 211221)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h	2017-01-26 19:36:27 UTC (rev 211222)
@@ -118,6 +118,8 @@
         unsigned tabWidth;
         bool shouldHyphenate;
         float hyphenStringWidth;
+        unsigned hyphenLimitBefore;
+        unsigned hyphenLimitAfter;
         AtomicString locale;
     };
     const Style& style() const { return m_style; }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to