Hangable punctuation measurement using the wrong indices.
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Apr 2016 18:01:40 +0000 (18:01 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Apr 2016 18:01:40 +0000 (18:01 +0000)
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199777 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/text/hanging-punctuation-variable-font-size-expected.html [new file with mode: 0644]
LayoutTests/fast/text/hanging-punctuation-variable-font-size.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlockFlow.cpp
Source/WebCore/rendering/RenderText.cpp

index 89b07c4..8c079e4 100644 (file)
@@ -1,3 +1,13 @@
+2016-04-20  Dave Hyatt  <hyatt@apple.com>
+
+        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  <cdumez@apple.com>
 
         Drop [UsePointersEvenForNonNullableObjectArguments] from several Canvas interfaces
diff --git a/LayoutTests/fast/text/hanging-punctuation-variable-font-size-expected.html b/LayoutTests/fast/text/hanging-punctuation-variable-font-size-expected.html
new file mode 100644 (file)
index 0000000..7ee881f
--- /dev/null
@@ -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>
diff --git a/LayoutTests/fast/text/hanging-punctuation-variable-font-size.html b/LayoutTests/fast/text/hanging-punctuation-variable-font-size.html
new file mode 100644 (file)
index 0000000..61816a9
--- /dev/null
@@ -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>
index 84f95d6..a4f5c71 100644 (file)
@@ -1,3 +1,19 @@
+2016-04-20  Dave Hyatt  <hyatt@apple.com>
+
+        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  <cdumez@apple.com>
 
         Drop [UsePointersEvenForNonNullableObjectArguments] from several Canvas interfaces
index 17a375c..0fff02e 100644 (file)
@@ -4114,7 +4114,6 @@ void RenderBlockFlow::computeInlinePreferredLogicalWidths(LayoutUnit& minLogical
             float childMax = 0;
 
             if (!child->isText()) {
-                lastText = nullptr;
                 if (child->isLineBreakOpportunity()) {
                     minLogicalWidth = preferredWidth(minLogicalWidth, inlineMin);
                     inlineMin = 0;
@@ -4134,6 +4133,8 @@ void RenderBlockFlow::computeInlinePreferredLogicalWidths(LayoutUnit& minLogical
                     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();
index 0b727fe..1db6dcc 100644 (file)
@@ -514,9 +514,10 @@ inline bool isHangablePunctuationAtLineEnd(UChar c)
 
 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 @@ float RenderText::hangablePunctuationStartWidth(unsigned index) const
     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 @@ float RenderText::hangablePunctuationEndWidth(unsigned index) const
     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