Title: [199777] trunk
Revision
199777
Author
[email protected]
Date
2016-04-20 11:01:40 -0700 (Wed, 20 Apr 2016)

Log Message

Hangable punctuation measurement using the wrong indices.
https://bugs.webkit.org/show_bug.cgi?id=155899

Reviewed by Simon Fraser.

Source/WebCore:

New tests in fast/text.

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::computeInlinePreferredLogicalWidths):
* rendering/RenderText.cpp:
(WebCore::RenderText::hangablePunctuationStartWidth):
(WebCore::RenderText::hangablePunctuationEndWidth):
(WebCore::RenderText::isHangableStopOrComma):

LayoutTests:

* fast/text/hanging-punctuation-variable-font-size-expected.html: Added.
* fast/text/hanging-punctuation-variable-font-size.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (199776 => 199777)


--- trunk/LayoutTests/ChangeLog	2016-04-20 17:40:02 UTC (rev 199776)
+++ trunk/LayoutTests/ChangeLog	2016-04-20 18:01:40 UTC (rev 199777)
@@ -1,3 +1,13 @@
+2016-04-20  Dave Hyatt  <[email protected]>
+
+        Hangable punctuation measurement using the wrong indices.
+        https://bugs.webkit.org/show_bug.cgi?id=155899
+
+        Reviewed by Simon Fraser.
+
+        * fast/text/hanging-punctuation-variable-font-size-expected.html: Added.
+        * fast/text/hanging-punctuation-variable-font-size.html: Added.
+
 2016-04-20  Chris Dumez  <[email protected]>
 
         Drop [UsePointersEvenForNonNullableObjectArguments] from several Canvas interfaces

Added: trunk/LayoutTests/fast/text/hanging-punctuation-variable-font-size-expected.html (0 => 199777)


--- trunk/LayoutTests/fast/text/hanging-punctuation-variable-font-size-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/hanging-punctuation-variable-font-size-expected.html	2016-04-20 18:01:40 UTC (rev 199777)
@@ -0,0 +1,11 @@
+<head>
+<style>
+    body { font-family: 'Ahem'; color:green }
+    .hang { white-space: nowrap; margin:1em; border:1px solid black; float:left }
+</style>
+</head>
+<body>
+
+<div class="hang" style="font-size:32px"><span style="font-size:16px; margin-left:-1em">(</span>1234</div>
+
+<div class="hang" style="font-size:32px">1234<span style="font-size:16px; margin-right:-1em">)</span></div>

Added: trunk/LayoutTests/fast/text/hanging-punctuation-variable-font-size.html (0 => 199777)


--- trunk/LayoutTests/fast/text/hanging-punctuation-variable-font-size.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/hanging-punctuation-variable-font-size.html	2016-04-20 18:01:40 UTC (rev 199777)
@@ -0,0 +1,11 @@
+<head>
+<style>
+    body { font-family: 'Ahem'; color:green }
+    .hang { hanging-punctuation: first last; margin:1em; border:1px solid black; float:left }
+</style>
+</head>
+<body>
+
+<div class="hang" style="font-size:32px"><span style="font-size:16px">(</span>1234</div>
+
+<div class="hang" style="font-size:32px">1234<span style="font-size:16px">)</span></div>

Modified: trunk/Source/WebCore/ChangeLog (199776 => 199777)


--- trunk/Source/WebCore/ChangeLog	2016-04-20 17:40:02 UTC (rev 199776)
+++ trunk/Source/WebCore/ChangeLog	2016-04-20 18:01:40 UTC (rev 199777)
@@ -1,3 +1,19 @@
+2016-04-20  Dave Hyatt  <[email protected]>
+
+        Hangable punctuation measurement using the wrong indices.
+        https://bugs.webkit.org/show_bug.cgi?id=155899
+
+        Reviewed by Simon Fraser.
+
+        New tests in fast/text.
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::computeInlinePreferredLogicalWidths):
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::hangablePunctuationStartWidth):
+        (WebCore::RenderText::hangablePunctuationEndWidth):
+        (WebCore::RenderText::isHangableStopOrComma):
+
 2016-04-20  Chris Dumez  <[email protected]>
 
         Drop [UsePointersEvenForNonNullableObjectArguments] from several Canvas interfaces

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (199776 => 199777)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2016-04-20 17:40:02 UTC (rev 199776)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2016-04-20 18:01:40 UTC (rev 199777)
@@ -4114,7 +4114,6 @@
             float childMax = 0;
 
             if (!child->isText()) {
-                lastText = nullptr;
                 if (child->isLineBreakOpportunity()) {
                     minLogicalWidth = preferredWidth(minLogicalWidth, inlineMin);
                     inlineMin = 0;
@@ -4134,6 +4133,8 @@
                     child->setPreferredLogicalWidthsDirty(false);
                 } else {
                     // Inline replaced elts add in their margins to their min/max values.
+                    if (!child->isFloating())
+                        lastText = nullptr;
                     LayoutUnit margins = 0;
                     Length startMargin = childStyle.marginStart();
                     Length endMargin = childStyle.marginEnd();

Modified: trunk/Source/WebCore/rendering/RenderText.cpp (199776 => 199777)


--- trunk/Source/WebCore/rendering/RenderText.cpp	2016-04-20 17:40:02 UTC (rev 199776)
+++ trunk/Source/WebCore/rendering/RenderText.cpp	2016-04-20 18:01:40 UTC (rev 199777)
@@ -514,9 +514,10 @@
 
 float RenderText::hangablePunctuationStartWidth(unsigned index) const
 {
-    if (!textLength())
+    unsigned len = textLength();
+    if (!len || index >= len)
         return 0;
-    
+
     ASSERT(m_text);
     StringImpl& text = *m_text.impl();
     
@@ -526,12 +527,13 @@
     const RenderStyle& style = this->style();
     const FontCascade& font = style.fontCascade();
         
-    return widthFromCache(font, 0, 1, 0, 0, 0, style);
+    return widthFromCache(font, index, 1, 0, 0, 0, style);
 }
 
 float RenderText::hangablePunctuationEndWidth(unsigned index) const
 {
-    if (!textLength())
+    unsigned len = textLength();
+    if (!len || index >= len)
         return 0;
     
     ASSERT(m_text);
@@ -543,7 +545,7 @@
     const RenderStyle& style = this->style();
     const FontCascade& font = style.fontCascade();
     
-    return widthFromCache(font, 0, 1, 0, 0, 0, style);
+    return widthFromCache(font, index, 1, 0, 0, 0, style);
 }
 
 bool RenderText::isHangableStopOrComma(UChar c) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to