Title: [94710] trunk
Revision
94710
Author
[email protected]
Date
2011-09-07 13:59:39 -0700 (Wed, 07 Sep 2011)

Log Message

<rdar://problem/8881922> Support the hyphenate-limit-lines property
https://bugs.webkit.org/show_bug.cgi?id=67730

Reviewed by Dave Hyatt.

Source/WebCore: 

Tests: fast/css/parsing-hyphenate-limit-lines.html
       fast/text/hyphenate-limit-lines.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Added hyphenate-limit-lines.
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue): Ditto. Valid values are non-negative integers and the keyword
"no-limit".
* css/CSSPropertyNames.in: Added -webkit-hyphenate-limit-lines.
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty): Added hyphenate-limit-lines.
* css/CSSValueKeywords.in: Added the "no-limit" value keyword.
* rendering/RenderBlock.h:
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::layoutRunsAndFloats): Count the number of consecutive hyphenated lines
before the start line and pass it to layoutRunsAndFloatsInRange().
(WebCore::RenderBlock::layoutRunsAndFloatsInRange): Keep track of the number of consecutive
hyphenated lines before the current line and pass it to LineBreaker::nextLineBreak().
(WebCore::tryHyphenating): Added parameters for the number of consecutive hyphenated lines before
the current line and the limit on consecutive hyphenated lines, and an early return if the limit
has been reached.
(WebCore::RenderBlock::LineBreaker::nextLineBreak): Added a parameter for the number of consecutive
hyphenated lines before the current line, which is passed through to tryHyphenating, along with
the value of hyphenate-limit-lines.
* rendering/RootInlineBox.cpp:
(WebCore::RootInlineBox::isHyphenated): Added. Returns true if the line was hyphenated.
* rendering/RootInlineBox.h:
* rendering/style/RenderStyle.h:
(WebCore::InheritedFlags::hyphenationLimitLines): Added this getter.
(WebCore::InheritedFlags::setHyphenationLimitLines): Added this setter.
(WebCore::InheritedFlags::initialHyphenationLimitLines): Added. The initial value is -1,
corresponding to "no-limit".
* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData): Initialize new member variable.
(WebCore::StyleRareInheritedData::operator==): Compare new member variable.
* rendering/style/StyleRareInheritedData.h:

LayoutTests: 

* fast/css/parsing-hyphenate-limit-lines-expected.txt: Added.
* fast/css/parsing-hyphenate-limit-lines.html: Added.
* fast/text/hyphenate-limit-lines.html: Added.
* platform/mac/fast/text/hyphenate-limit-lines-expected.png: Added.
* platform/mac/fast/text/hyphenate-limit-lines-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (94709 => 94710)


--- trunk/LayoutTests/ChangeLog	2011-09-07 20:58:49 UTC (rev 94709)
+++ trunk/LayoutTests/ChangeLog	2011-09-07 20:59:39 UTC (rev 94710)
@@ -1,3 +1,16 @@
+2011-09-07  Dan Bernstein  <[email protected]>
+
+        <rdar://problem/8881922> Support the hyphenate-limit-lines property
+        https://bugs.webkit.org/show_bug.cgi?id=67730
+
+        Reviewed by Dave Hyatt.
+
+        * fast/css/parsing-hyphenate-limit-lines-expected.txt: Added.
+        * fast/css/parsing-hyphenate-limit-lines.html: Added.
+        * fast/text/hyphenate-limit-lines.html: Added.
+        * platform/mac/fast/text/hyphenate-limit-lines-expected.png: Added.
+        * platform/mac/fast/text/hyphenate-limit-lines-expected.txt: Added.
+
 2011-09-07  Csaba Osztrogonác  <[email protected]>
 
         [Qt] Unreviewed gardening after r94697.

Added: trunk/LayoutTests/fast/css/parsing-hyphenate-limit-lines-expected.txt (0 => 94710)


--- trunk/LayoutTests/fast/css/parsing-hyphenate-limit-lines-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/parsing-hyphenate-limit-lines-expected.txt	2011-09-07 20:59:39 UTC (rev 94710)
@@ -0,0 +1,10 @@
+PASS: '-webkit-hyphenate-limit-lines: initial;' parsed as 'initial'
+PASS: '-webkit-hyphenate-limit-lines: inherit;' parsed as 'inherit'
+PASS: '-webkit-hyphenate-limit-lines: no-limit;' parsed as 'no-limit'
+PASS: '-webkit-hyphenate-limit-lines: 0;' parsed as '0'
+PASS: '-webkit-hyphenate-limit-lines: 4;' parsed as '4'
+PASS: '-webkit-hyphenate-limit-lines: 2 2;' parsed as ''
+PASS: '-webkit-hyphenate-limit-lines: 2px;' parsed as ''
+PASS: '-webkit-hyphenate-limit-lines: -1;' parsed as ''
+PASS: '-webkit-hyphenate-limit-lines: "1";' parsed as ''
+

Added: trunk/LayoutTests/fast/css/parsing-hyphenate-limit-lines.html (0 => 94710)


--- trunk/LayoutTests/fast/css/parsing-hyphenate-limit-lines.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/parsing-hyphenate-limit-lines.html	2011-09-07 20:59:39 UTC (rev 94710)
@@ -0,0 +1,31 @@
+<pre id="console"></pre>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    function log(message)
+    {
+        document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
+    }
+
+    function test(declaration, expectedHyphenateLimit)
+    {
+        var element = document.createElement("div");
+        element.style.cssText = declaration;
+        var hyphenateLimit = element.style.webkitHyphenateLimitLines;
+        if (hyphenateLimit === expectedHyphenateLimit)
+            log("PASS: '" + declaration + "' parsed as '" + hyphenateLimit + "'");
+        else
+            log("FAIL: '" + declaration + "' parsed as '" + hyphenateLimit + "'");
+    }
+
+    test('-webkit-hyphenate-limit-lines: initial;', 'initial');
+    test('-webkit-hyphenate-limit-lines: inherit;', 'inherit');
+    test('-webkit-hyphenate-limit-lines: no-limit;', 'no-limit');
+    test('-webkit-hyphenate-limit-lines: 0;', '0');
+    test('-webkit-hyphenate-limit-lines: 4;', '4');
+    test('-webkit-hyphenate-limit-lines: 2 2;', '');
+    test('-webkit-hyphenate-limit-lines: 2px;', '');
+    test('-webkit-hyphenate-limit-lines: -1;', '');
+    test('-webkit-hyphenate-limit-lines: "1";', '');
+</script>

Added: trunk/LayoutTests/fast/text/hyphenate-limit-lines.html (0 => 94710)


--- trunk/LayoutTests/fast/text/hyphenate-limit-lines.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/hyphenate-limit-lines.html	2011-09-07 20:59:39 UTC (rev 94710)
@@ -0,0 +1,51 @@
+<style>
+    div {
+        width: 200px;
+        font-size: 26px;
+        -webkit-hyphens: auto;
+        text-align: justify;
+        margin: 0 4px;
+        float: left;
+        border: solid thin lightblue;
+        -webkit-locale: "en_US";
+    }
+</style>
+<div style="-webkit-hyphenate-limit-lines: no-limit;">
+    also the division of the mind into the rational, concupiscent, and
+    irascible elements, or of pleasures and desires into necessary and
+    unnecessary&mdash;these and other great forms of thought are all of them
+    to be found in the Republic, and were probably first invented by
+    Plato.
+</div>
+
+<div style="-webkit-hyphenate-limit-lines: 3;">
+    also the division of the mind into the rational, concupiscent, and
+    irascible elements, or of pleasures and desires into necessary and
+    unnecessary&mdash;these and other great forms of thought are all of them
+    to be found in the Republic, and were probably first invented by
+    Plato.
+</div>
+
+<div style="-webkit-hyphenate-limit-lines: 2;">
+    also the division of the mind into the rational, concupiscent, and
+    irascible elements, or of pleasures and desires into necessary and
+    unnecessary&mdash;these and other great forms of thought are all of them
+    to be found in the Republic, and were probably first invented by
+    Plato.
+</div>
+
+<div style="-webkit-hyphenate-limit-lines: 1;">
+    also the division of the mind into the rational, concupiscent, and
+    irascible elements, or of pleasures and desires into necessary and
+    unnecessary&mdash;these and other great forms of thought are all of them
+    to be found in the Republic, and were probably first invented by
+    Plato.
+</div>
+
+<div style="-webkit-hyphenate-limit-lines: 0;">
+    also the division of the mind into the rational, concupiscent, and
+    irascible elements, or of pleasures and desires into necessary and
+    unnecessary&mdash;these and other great forms of thought are all of them
+    to be found in the Republic, and were probably first invented by
+    Plato.
+</div>

Added: trunk/LayoutTests/platform/mac/fast/text/hyphenate-limit-lines-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/fast/text/hyphenate-limit-lines-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/fast/text/hyphenate-limit-lines-expected.txt (0 => 94710)


--- trunk/LayoutTests/platform/mac/fast/text/hyphenate-limit-lines-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/text/hyphenate-limit-lines-expected.txt	2011-09-07 20:59:39 UTC (rev 94710)
@@ -0,0 +1,111 @@
+layer at (0,0) size 785x1066
+  RenderView at (0,0) size 785x600
+layer at (0,0) size 785x1066
+  RenderBlock {HTML} at (0,0) size 785x1066
+    RenderBody {BODY} at (8,8) size 769x584
+      RenderBlock (floating) {DIV} at (4,0) size 202x498 [border: (1px solid #ADD8E6)]
+        RenderText {#text} at (1,1) size 200x496
+          text run at (1,1) width 200: "also the division of"
+          text run at (1,32) width 200: "the mind into the"
+          text run at (1,63) width 200: "rational, concupis" + hyphen string "-"
+          text run at (1,94) width 111: "cent, and "
+          text run at (112,94) width 89: "irascible"
+          text run at (1,125) width 200: "elements, or of"
+          text run at (1,156) width 200: "pleasures and de" + hyphen string "-"
+          text run at (1,187) width 200: "sires into neces" + hyphen string "-"
+          text run at (1,218) width 106: "sary and "
+          text run at (107,218) width 94: "unneces" + hyphen string "-"
+          text run at (1,249) width 200: "sary\x{2014}these and"
+          text run at (1,280) width 200: "other great forms"
+          text run at (1,311) width 200: "of thought are all"
+          text run at (1,342) width 128: "of them "
+          text run at (129,342) width 72: "to be"
+          text run at (1,373) width 200: "found in the Re" + hyphen string "-"
+          text run at (1,404) width 200: "public, and were"
+          text run at (1,435) width 200: "probably first in" + hyphen string "-"
+          text run at (1,466) width 110: "vented by "
+          text run at (111,466) width 60: "Plato."
+      RenderBlock (floating) {DIV} at (214,0) size 202x498 [border: (1px solid #ADD8E6)]
+        RenderText {#text} at (1,1) size 200x496
+          text run at (1,1) width 200: "also the division of"
+          text run at (1,32) width 200: "the mind into the"
+          text run at (1,63) width 200: "rational, concupis" + hyphen string "-"
+          text run at (1,94) width 111: "cent, and "
+          text run at (112,94) width 89: "irascible"
+          text run at (1,125) width 200: "elements, or of"
+          text run at (1,156) width 200: "pleasures and de" + hyphen string "-"
+          text run at (1,187) width 200: "sires into neces" + hyphen string "-"
+          text run at (1,218) width 106: "sary and "
+          text run at (107,218) width 94: "unneces" + hyphen string "-"
+          text run at (1,249) width 200: "sary\x{2014}these and"
+          text run at (1,280) width 200: "other great forms"
+          text run at (1,311) width 200: "of thought are all"
+          text run at (1,342) width 128: "of them "
+          text run at (129,342) width 72: "to be"
+          text run at (1,373) width 200: "found in the Re" + hyphen string "-"
+          text run at (1,404) width 200: "public, and were"
+          text run at (1,435) width 200: "probably first in" + hyphen string "-"
+          text run at (1,466) width 110: "vented by "
+          text run at (111,466) width 60: "Plato."
+      RenderBlock (floating) {DIV} at (424,0) size 202x529 [border: (1px solid #ADD8E6)]
+        RenderText {#text} at (1,1) size 200x527
+          text run at (1,1) width 200: "also the division of"
+          text run at (1,32) width 200: "the mind into the"
+          text run at (1,63) width 200: "rational, concupis" + hyphen string "-"
+          text run at (1,94) width 111: "cent, and "
+          text run at (112,94) width 89: "irascible"
+          text run at (1,125) width 200: "elements, or of"
+          text run at (1,156) width 200: "pleasures and de" + hyphen string "-"
+          text run at (1,187) width 200: "sires into neces" + hyphen string "-"
+          text run at (1,218) width 200: "sary and"
+          text run at (1,249) width 155: "unnecessary\x{2014}"
+          text run at (1,280) width 200: "these and other"
+          text run at (1,311) width 200: "great forms of"
+          text run at (1,342) width 200: "thought are all of"
+          text run at (1,373) width 66: "them "
+          text run at (67,373) width 134: "to be found"
+          text run at (1,404) width 200: "in the Republic,"
+          text run at (1,435) width 200: "and were probably"
+          text run at (1,466) width 200: "first invented by"
+          text run at (1,497) width 60: "Plato."
+      RenderBlock (floating) {DIV} at (4,529) size 202x529 [border: (1px solid #ADD8E6)]
+        RenderText {#text} at (1,1) size 200x527
+          text run at (1,1) width 200: "also the division of"
+          text run at (1,32) width 200: "the mind into the"
+          text run at (1,63) width 200: "rational, concupis" + hyphen string "-"
+          text run at (1,94) width 111: "cent, and "
+          text run at (112,94) width 89: "irascible"
+          text run at (1,125) width 200: "elements, or of"
+          text run at (1,156) width 200: "pleasures and de" + hyphen string "-"
+          text run at (1,187) width 200: "sires into"
+          text run at (1,218) width 200: "necessary and"
+          text run at (1,249) width 155: "unnecessary\x{2014}"
+          text run at (1,280) width 200: "these and other"
+          text run at (1,311) width 200: "great forms of"
+          text run at (1,342) width 200: "thought are all of"
+          text run at (1,373) width 66: "them "
+          text run at (67,373) width 134: "to be found"
+          text run at (1,404) width 200: "in the Republic,"
+          text run at (1,435) width 200: "and were probably"
+          text run at (1,466) width 200: "first invented by"
+          text run at (1,497) width 60: "Plato."
+      RenderBlock (floating) {DIV} at (214,529) size 202x529 [border: (1px solid #ADD8E6)]
+        RenderText {#text} at (1,1) size 200x527
+          text run at (1,1) width 200: "also the division of"
+          text run at (1,32) width 200: "the mind into the"
+          text run at (1,63) width 87: "rational,"
+          text run at (1,94) width 200: "concupiscent, and"
+          text run at (1,125) width 200: "irascible elements,"
+          text run at (1,156) width 200: "or of pleasures"
+          text run at (1,187) width 200: "and desires into"
+          text run at (1,218) width 200: "necessary and"
+          text run at (1,249) width 155: "unnecessary\x{2014}"
+          text run at (1,280) width 200: "these and other"
+          text run at (1,311) width 200: "great forms of"
+          text run at (1,342) width 200: "thought are all of"
+          text run at (1,373) width 66: "them "
+          text run at (67,373) width 134: "to be found"
+          text run at (1,404) width 200: "in the Republic,"
+          text run at (1,435) width 200: "and were probably"
+          text run at (1,466) width 200: "first invented by"
+          text run at (1,497) width 60: "Plato."

Modified: trunk/Source/WebCore/ChangeLog (94709 => 94710)


--- trunk/Source/WebCore/ChangeLog	2011-09-07 20:58:49 UTC (rev 94709)
+++ trunk/Source/WebCore/ChangeLog	2011-09-07 20:59:39 UTC (rev 94710)
@@ -1,3 +1,47 @@
+2011-09-07  Dan Bernstein  <[email protected]>
+
+        <rdar://problem/8881922> Support the hyphenate-limit-lines property
+        https://bugs.webkit.org/show_bug.cgi?id=67730
+
+        Reviewed by Dave Hyatt.
+
+        Tests: fast/css/parsing-hyphenate-limit-lines.html
+               fast/text/hyphenate-limit-lines.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Added hyphenate-limit-lines.
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue): Ditto. Valid values are non-negative integers and the keyword
+        "no-limit".
+        * css/CSSPropertyNames.in: Added -webkit-hyphenate-limit-lines.
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty): Added hyphenate-limit-lines.
+        * css/CSSValueKeywords.in: Added the "no-limit" value keyword.
+        * rendering/RenderBlock.h:
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlock::layoutRunsAndFloats): Count the number of consecutive hyphenated lines
+        before the start line and pass it to layoutRunsAndFloatsInRange().
+        (WebCore::RenderBlock::layoutRunsAndFloatsInRange): Keep track of the number of consecutive
+        hyphenated lines before the current line and pass it to LineBreaker::nextLineBreak().
+        (WebCore::tryHyphenating): Added parameters for the number of consecutive hyphenated lines before
+        the current line and the limit on consecutive hyphenated lines, and an early return if the limit
+        has been reached.
+        (WebCore::RenderBlock::LineBreaker::nextLineBreak): Added a parameter for the number of consecutive
+        hyphenated lines before the current line, which is passed through to tryHyphenating, along with
+        the value of hyphenate-limit-lines.
+        * rendering/RootInlineBox.cpp:
+        (WebCore::RootInlineBox::isHyphenated): Added. Returns true if the line was hyphenated.
+        * rendering/RootInlineBox.h:
+        * rendering/style/RenderStyle.h:
+        (WebCore::InheritedFlags::hyphenationLimitLines): Added this getter.
+        (WebCore::InheritedFlags::setHyphenationLimitLines): Added this setter.
+        (WebCore::InheritedFlags::initialHyphenationLimitLines): Added. The initial value is -1,
+        corresponding to "no-limit".
+        * rendering/style/StyleRareInheritedData.cpp:
+        (WebCore::StyleRareInheritedData::StyleRareInheritedData): Initialize new member variable.
+        (WebCore::StyleRareInheritedData::operator==): Compare new member variable.
+        * rendering/style/StyleRareInheritedData.h:
+
 2011-09-02  Ojan Vafai  <[email protected]>
 
         split overrideSize into overrideHeight and overrideWidth

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (94709 => 94710)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2011-09-07 20:58:49 UTC (rev 94709)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2011-09-07 20:59:39 UTC (rev 94710)
@@ -215,6 +215,7 @@
     CSSPropertyWebkitHyphenateCharacter,
     CSSPropertyWebkitHyphenateLimitAfter,
     CSSPropertyWebkitHyphenateLimitBefore,
+    CSSPropertyWebkitHyphenateLimitLines,
     CSSPropertyWebkitHyphens,
     CSSPropertyWebkitLineBoxContain,
     CSSPropertyWebkitLineBreak,
@@ -1308,6 +1309,10 @@
             if (style->hyphenationLimitBefore() < 0)
                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
             return CSSPrimitiveValue::create(style->hyphenationLimitBefore(), CSSPrimitiveValue::CSS_NUMBER);
+        case CSSPropertyWebkitHyphenateLimitLines:
+            if (style->hyphenationLimitLines() < 0)
+                return CSSPrimitiveValue::createIdentifier(CSSValueNoLimit);
+            return CSSPrimitiveValue::create(style->hyphenationLimitLines(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyWebkitBorderFit:
             if (style->borderFit() == BorderFitBorder)
                 return primitiveValueCache->createIdentifierValue(CSSValueBorder);

Modified: trunk/Source/WebCore/css/CSSParser.cpp (94709 => 94710)


--- trunk/Source/WebCore/css/CSSParser.cpp	2011-09-07 20:58:49 UTC (rev 94709)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2011-09-07 20:59:39 UTC (rev 94710)
@@ -1899,6 +1899,11 @@
             validPrimitive = true;
         break;
 
+    case CSSPropertyWebkitHyphenateLimitLines:
+        if (id == CSSValueNoLimit || validUnit(value, FInteger | FNonNeg, true))
+            validPrimitive = true;
+        break;
+
     case CSSPropertyWebkitLocale:
         if (id == CSSValueAuto || value->unit == CSSPrimitiveValue::CSS_STRING)
             validPrimitive = true;

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (94709 => 94710)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2011-09-07 20:58:49 UTC (rev 94709)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2011-09-07 20:59:39 UTC (rev 94710)
@@ -257,6 +257,7 @@
 -webkit-hyphenate-character
 -webkit-hyphenate-limit-after
 -webkit-hyphenate-limit-before
+-webkit-hyphenate-limit-lines
 -webkit-hyphens
 -epub-hyphens = -webkit-hyphens
 -webkit-line-box-contain

Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (94709 => 94710)


--- trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-09-07 20:58:49 UTC (rev 94709)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-09-07 20:59:39 UTC (rev 94710)
@@ -3551,6 +3551,14 @@
             m_style->setHyphenationLimitBefore(primitiveValue->getValue<short>(CSSPrimitiveValue::CSS_NUMBER));
         return;
     }
+    case CSSPropertyWebkitHyphenateLimitLines: {
+        HANDLE_INHERIT_AND_INITIAL(hyphenationLimitLines, HyphenationLimitLines);
+        if (primitiveValue->getIdent() == CSSValueNoLimit)
+            m_style->setHyphenationLimitLines(-1);
+        else
+            m_style->setHyphenationLimitLines(primitiveValue->getValue<short>(CSSPrimitiveValue::CSS_NUMBER));
+        return;
+    }
     case CSSPropertyWebkitLocale: {
         HANDLE_INHERIT_AND_INITIAL(locale, Locale);
         if (primitiveValue->getIdent() == CSSValueAuto)

Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (94709 => 94710)


--- trunk/Source/WebCore/css/CSSValueKeywords.in	2011-09-07 20:58:49 UTC (rev 94709)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in	2011-09-07 20:59:39 UTC (rev 94710)
@@ -776,6 +776,9 @@
 minimized
 windowed
 
+// -webkit-hyphenate-limit-lines
+no-limit
+
 // -webkit-hyphens
 // none
 manual

Modified: trunk/Source/WebCore/rendering/RenderBlock.h (94709 => 94710)


--- trunk/Source/WebCore/rendering/RenderBlock.h	2011-09-07 20:58:49 UTC (rev 94709)
+++ trunk/Source/WebCore/rendering/RenderBlock.h	2011-09-07 20:59:39 UTC (rev 94710)
@@ -563,7 +563,7 @@
             reset();
         }
 
-        InlineIterator nextLineBreak(InlineBidiResolver&, LineInfo&, LineBreakIteratorInfo&, FloatingObject* lastFloatFromPreviousLine);
+        InlineIterator nextLineBreak(InlineBidiResolver&, LineInfo&, LineBreakIteratorInfo&, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines);
 
         bool lineWasHyphenated() { return m_hyphenated; }
         const Vector<RenderBox*>& positionedObjects() { return m_positionedObjects; }
@@ -795,7 +795,7 @@
     // Helper function for layoutInlineChildren()
     RootInlineBox* createLineBoxesFromBidiRuns(BidiRunList<BidiRun>&, const InlineIterator& end, LineInfo&, VerticalPositionCache&, BidiRun* trailingSpaceRun);
     void layoutRunsAndFloats(LineLayoutState&, bool hasInlineChild);
-    void layoutRunsAndFloatsInRange(LineLayoutState&, InlineBidiResolver&, const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiStatus);
+    void layoutRunsAndFloatsInRange(LineLayoutState&, InlineBidiResolver&, const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiStatus, unsigned consecutiveHyphenatedLines);
     void linkToEndLineIfNeeded(LineLayoutState&);
     static void repaintDirtyFloats(Vector<FloatWithRect>& floats);
 

Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (94709 => 94710)


--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2011-09-07 20:58:49 UTC (rev 94709)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2011-09-07 20:59:39 UTC (rev 94710)
@@ -936,6 +936,12 @@
     InlineBidiResolver resolver;
     RootInlineBox* startLine = determineStartPosition(layoutState, resolver);
 
+    unsigned consecutiveHyphenatedLines = 0;
+    if (startLine) {
+        for (RootInlineBox* line = startLine->prevRootBox(); line && line->isHyphenated(); line = line->prevRootBox())
+            consecutiveHyphenatedLines++;
+    }
+
     // FIXME: This would make more sense outside of this function, but since
     // determineStartPosition can change the fullLayout flag we have to do this here. Failure to call
     // determineStartPosition first will break fast/repaint/line-flow-with-floats-9.html.
@@ -984,12 +990,12 @@
         }
     }
 
-    layoutRunsAndFloatsInRange(layoutState, resolver, cleanLineStart, cleanLineBidiStatus);
+    layoutRunsAndFloatsInRange(layoutState, resolver, cleanLineStart, cleanLineBidiStatus, consecutiveHyphenatedLines);
     linkToEndLineIfNeeded(layoutState);
     repaintDirtyFloats(layoutState.floats());
 }
 
-void RenderBlock::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, InlineBidiResolver& resolver, const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiStatus)
+void RenderBlock::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, InlineBidiResolver& resolver, const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiStatus, unsigned consecutiveHyphenatedLines)
 {
     bool paginated = view()->layoutState() && view()->layoutState()->isPaginated();
     LineMidpointState& lineMidpointState = resolver.midpointState();
@@ -1015,7 +1021,7 @@
         InlineIterator oldEnd = end;
         bool isNewUBAParagraph = layoutState.lineInfo().previousLineBrokeCleanly();
         FloatingObject* lastFloatFromPreviousLine = (m_floatingObjects && !m_floatingObjects->set().isEmpty()) ? m_floatingObjects->set().last() : 0;
-        end = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), lineBreakIteratorInfo, lastFloatFromPreviousLine);
+        end = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), lineBreakIteratorInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines);
         if (resolver.position().atEnd()) {
             // FIXME: We shouldn't be creating any runs in findNextLineBreak to begin with!
             // Once BidiRunList is separated from BidiResolver this will not be needed.
@@ -1045,8 +1051,11 @@
 
             BidiRun* trailingSpaceRun = !layoutState.lineInfo().previousLineBrokeCleanly() ? handleTrailingSpaces(bidiRuns, resolver.context()) : 0;
 
-            if (bidiRuns.runCount() && lineBreaker.lineWasHyphenated())
+            if (bidiRuns.runCount() && lineBreaker.lineWasHyphenated()) {
                 bidiRuns.logicallyLastRun()->m_hasHyphen = true;
+                consecutiveHyphenatedLines++;
+            } else
+                consecutiveHyphenatedLines = 0;
 
             // Now that the runs have been ordered, we create the line boxes.
             // At the same time we figure out where border/padding/margin should be applied for
@@ -1679,7 +1688,7 @@
     return font.width(run);
 }
 
-static void tryHyphenating(RenderText* text, const Font& font, const AtomicString& localeIdentifier, int minimumPrefixLength, int minimumSuffixLength, int lastSpace, int pos, float xPos, int availableWidth, bool isFixedPitch, bool collapseWhiteSpace, int lastSpaceWordSpacing, InlineIterator& lineBreak, int nextBreakable, bool& hyphenated)
+static void tryHyphenating(RenderText* text, const Font& font, const AtomicString& localeIdentifier, unsigned consecutiveHyphenatedLines, int consecutiveHyphenatedLinesLimit, int minimumPrefixLength, int minimumSuffixLength, int lastSpace, int pos, float xPos, int availableWidth, bool isFixedPitch, bool collapseWhiteSpace, int lastSpaceWordSpacing, InlineIterator& lineBreak, int nextBreakable, bool& hyphenated)
 {
     // Map 'hyphenate-limit-{before,after}: auto;' to 2.
     if (minimumPrefixLength < 0)
@@ -1691,6 +1700,9 @@
     if (pos - lastSpace <= minimumSuffixLength)
         return;
 
+    if (consecutiveHyphenatedLinesLimit >= 0 && consecutiveHyphenatedLines >= static_cast<unsigned>(consecutiveHyphenatedLinesLimit))
+        return;
+
     const AtomicString& hyphenString = text->style()->hyphenString();
     int hyphenWidth = font.width(RenderBlock::constructTextRun(text, font, hyphenString.string(), text->style()));
 
@@ -1949,7 +1961,7 @@
 }
 
 InlineIterator RenderBlock::LineBreaker::nextLineBreak(InlineBidiResolver& resolver, LineInfo& lineInfo,
-    LineBreakIteratorInfo& lineBreakIteratorInfo, FloatingObject* lastFloatFromPreviousLine)
+    LineBreakIteratorInfo& lineBreakIteratorInfo, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines)
 {
     reset();
 
@@ -2268,7 +2280,7 @@
                         }
                         if (lineWasTooWide || !width.fitsOnLine()) {
                             if (canHyphenate && !width.fitsOnLine()) {
-                                tryHyphenating(t, f, style->locale(), style->hyphenationLimitBefore(), style->hyphenationLimitAfter(), lastSpace, current.m_pos, width.currentWidth() - additionalTmpW, width.availableWidth(), isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, current.m_nextBreakablePosition, m_hyphenated);
+                                tryHyphenating(t, f, style->locale(), consecutiveHyphenatedLines, m_block->style()->hyphenationLimitLines(), style->hyphenationLimitBefore(), style->hyphenationLimitAfter(), lastSpace, current.m_pos, width.currentWidth() - additionalTmpW, width.availableWidth(), isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, current.m_nextBreakablePosition, m_hyphenated);
                                 if (m_hyphenated)
                                     goto end;
                             }
@@ -2386,7 +2398,7 @@
 
             if (!width.fitsOnLine()) {
                 if (canHyphenate)
-                    tryHyphenating(t, f, style->locale(), style->hyphenationLimitBefore(), style->hyphenationLimitAfter(), lastSpace, current.m_pos, width.currentWidth() - additionalTmpW, width.availableWidth(), isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, current.m_nextBreakablePosition, m_hyphenated);
+                    tryHyphenating(t, f, style->locale(), consecutiveHyphenatedLines, m_block->style()->hyphenationLimitLines(), style->hyphenationLimitBefore(), style->hyphenationLimitAfter(), lastSpace, current.m_pos, width.currentWidth() - additionalTmpW, width.availableWidth(), isFixedPitch, collapseWhiteSpace, lastSpaceWordSpacing, lBreak, current.m_nextBreakablePosition, m_hyphenated);
 
                 if (!m_hyphenated && lBreak.previousInSameNode() == softHyphen && style->hyphens() != HyphensNone)
                     m_hyphenated = true;

Modified: trunk/Source/WebCore/rendering/RootInlineBox.cpp (94709 => 94710)


--- trunk/Source/WebCore/rendering/RootInlineBox.cpp	2011-09-07 20:58:49 UTC (rev 94709)
+++ trunk/Source/WebCore/rendering/RootInlineBox.cpp	2011-09-07 20:59:39 UTC (rev 94710)
@@ -88,6 +88,18 @@
     }
 }
 
+bool RootInlineBox::isHyphenated() const
+{
+    for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) {
+        if (box->isInlineTextBox()) {
+            if (toInlineTextBox(box)->hasHyphen())
+                return true;
+        }
+    }
+
+    return false;
+}
+
 bool RootInlineBox::lineCanAccommodateEllipsis(bool ltr, int blockEdge, int lineBoxEdge, int ellipsisWidth)
 {
     // First sanity-check the unoverflowed width of the whole line to see if there is sufficient room.

Modified: trunk/Source/WebCore/rendering/RootInlineBox.h (94709 => 94710)


--- trunk/Source/WebCore/rendering/RootInlineBox.h	2011-09-07 20:58:49 UTC (rev 94709)
+++ trunk/Source/WebCore/rendering/RootInlineBox.h	2011-09-07 20:59:39 UTC (rev 94710)
@@ -96,6 +96,8 @@
 
     virtual void clearTruncation();
 
+    bool isHyphenated() const;
+
     virtual int baselinePosition(FontBaseline baselineType) const { return boxModelObject()->baselinePosition(baselineType, m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); }
     virtual int lineHeight() const { return boxModelObject()->lineHeight(m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); }
 

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (94709 => 94710)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2011-09-07 20:58:49 UTC (rev 94709)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2011-09-07 20:59:39 UTC (rev 94710)
@@ -714,6 +714,7 @@
     Hyphens hyphens() const { return static_cast<Hyphens>(rareInheritedData->hyphens); }
     short hyphenationLimitBefore() const { return rareInheritedData->hyphenationLimitBefore; }
     short hyphenationLimitAfter() const { return rareInheritedData->hyphenationLimitAfter; }
+    short hyphenationLimitLines() const { return rareInheritedData->hyphenationLimitLines; }
     const AtomicString& hyphenationString() const { return rareInheritedData->hyphenationString; }
     const AtomicString& locale() const { return rareInheritedData->locale; }
     EBorderFit borderFit() const { return static_cast<EBorderFit>(rareNonInheritedData->m_borderFit); }
@@ -1094,6 +1095,7 @@
     void setHyphens(Hyphens h) { SET_VAR(rareInheritedData, hyphens, h); }
     void setHyphenationLimitBefore(short limit) { SET_VAR(rareInheritedData, hyphenationLimitBefore, limit); }
     void setHyphenationLimitAfter(short limit) { SET_VAR(rareInheritedData, hyphenationLimitAfter, limit); }
+    void setHyphenationLimitLines(short limit) { SET_VAR(rareInheritedData, hyphenationLimitLines, limit); }
     void setHyphenationString(const AtomicString& h) { SET_VAR(rareInheritedData, hyphenationString, h); }
     void setLocale(const AtomicString& locale) { SET_VAR(rareInheritedData, locale, locale); }
     void setBorderFit(EBorderFit b) { SET_VAR(rareNonInheritedData, m_borderFit, b); }
@@ -1376,6 +1378,7 @@
     static Hyphens initialHyphens() { return HyphensManual; }
     static short initialHyphenationLimitBefore() { return -1; }
     static short initialHyphenationLimitAfter() { return -1; }
+    static short initialHyphenationLimitLines() { return -1; }
     static const AtomicString& initialHyphenationString() { return nullAtom; }
     static const AtomicString& initialLocale() { return nullAtom; }
     static EBorderFit initialBorderFit() { return BorderFitBorder; }

Modified: trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp (94709 => 94710)


--- trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp	2011-09-07 20:58:49 UTC (rev 94709)
+++ trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp	2011-09-07 20:59:39 UTC (rev 94710)
@@ -55,6 +55,7 @@
     , m_imageRendering(RenderStyle::initialImageRendering())
     , hyphenationLimitBefore(-1)
     , hyphenationLimitAfter(-1)
+    , hyphenationLimitLines(-1)
 {
 }
 
@@ -91,6 +92,7 @@
     , hyphenationString(o.hyphenationString)
     , hyphenationLimitBefore(o.hyphenationLimitBefore)
     , hyphenationLimitAfter(o.hyphenationLimitAfter)
+    , hyphenationLimitLines(o.hyphenationLimitLines)
     , locale(o.locale)
     , textEmphasisCustomMark(o.textEmphasisCustomMark)
 {
@@ -136,6 +138,7 @@
         && hyphens == o.hyphens
         && hyphenationLimitBefore == o.hyphenationLimitBefore
         && hyphenationLimitAfter == o.hyphenationLimitAfter
+        && hyphenationLimitLines == o.hyphenationLimitLines
         && textEmphasisFill == o.textEmphasisFill
         && textEmphasisMark == o.textEmphasisMark
         && textEmphasisPosition == o.textEmphasisPosition

Modified: trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h (94709 => 94710)


--- trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h	2011-09-07 20:58:49 UTC (rev 94709)
+++ trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h	2011-09-07 20:59:39 UTC (rev 94710)
@@ -92,6 +92,7 @@
     AtomicString hyphenationString;
     short hyphenationLimitBefore;
     short hyphenationLimitAfter;
+    short hyphenationLimitLines;
 
     AtomicString locale;
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to