Title: [200582] trunk/Source/WebCore
Revision
200582
Author
timothy_hor...@apple.com
Date
2016-05-09 11:05:20 -0700 (Mon, 09 May 2016)

Log Message

Download progress on attachment elements sometimes exceeds element bounds
https://bugs.webkit.org/show_bug.cgi?id=157440
<rdar://problem/25245440>

Reviewed by Darin Adler.

In the case of very large dynamic type sizes, we can overflow the
bounds of the attachment. It turns out that we used to limit to one
line in many cases anyway, so only wrap if we have only a title and/or icon.
This looks better when you have many of the other elements even in
non-large-type modes.

* rendering/RenderThemeIOS.mm:
(WebCore::AttachmentInfo::buildTitleLines):
(WebCore::AttachmentInfo::AttachmentInfo):
Limit the title to a single line if we have anything
other than a title and icon.

(WebCore::attachmentBorderPath):
(WebCore::paintAttachmentBorder):
(WebCore::RenderThemeIOS::paintAttachment):
Clip to the border, so that even if somehow we paint outside of
the bounds, we don't paint over other parts of the page.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (200581 => 200582)


--- trunk/Source/WebCore/ChangeLog	2016-05-09 17:48:49 UTC (rev 200581)
+++ trunk/Source/WebCore/ChangeLog	2016-05-09 18:05:20 UTC (rev 200582)
@@ -1,3 +1,29 @@
+2016-05-09  Tim Horton  <timothy_hor...@apple.com>
+
+        Download progress on attachment elements sometimes exceeds element bounds
+        https://bugs.webkit.org/show_bug.cgi?id=157440
+        <rdar://problem/25245440>
+
+        Reviewed by Darin Adler.
+
+        In the case of very large dynamic type sizes, we can overflow the
+        bounds of the attachment. It turns out that we used to limit to one
+        line in many cases anyway, so only wrap if we have only a title and/or icon.
+        This looks better when you have many of the other elements even in
+        non-large-type modes.
+
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::AttachmentInfo::buildTitleLines):
+        (WebCore::AttachmentInfo::AttachmentInfo):
+        Limit the title to a single line if we have anything
+        other than a title and icon.
+
+        (WebCore::attachmentBorderPath):
+        (WebCore::paintAttachmentBorder):
+        (WebCore::RenderThemeIOS::paintAttachment):
+        Clip to the border, so that even if somehow we paint outside of
+        the bounds, we don't paint over other parts of the page.
+
 2016-05-09  Ryosuke Niwa  <rn...@webkit.org>
 
         REGRESSION (198056): Unable to use edit buttons on WordPress

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (200581 => 200582)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2016-05-09 17:48:49 UTC (rev 200581)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2016-05-09 18:05:20 UTC (rev 200582)
@@ -1397,7 +1397,7 @@
     CGFloat contentYOrigin { 0 };
 
 private:
-    void buildTitleLines(const RenderAttachment&);
+    void buildTitleLines(const RenderAttachment&, unsigned maximumLineCount);
     void buildSingleLine(const String&, CTFontRef, UIColor *);
 
     void addLine(CTLineRef);
@@ -1418,7 +1418,7 @@
     lines.append(labelLine);
 }
 
-void AttachmentInfo::buildTitleLines(const RenderAttachment& attachment)
+void AttachmentInfo::buildTitleLines(const RenderAttachment& attachment, unsigned maximumLineCount)
 {
     RetainPtr<CTFontRef> font = attachmentTitleFont();
 
@@ -1444,17 +1444,16 @@
     if (!lineCount)
         return;
 
-    // Lay out and record the first (attachmentTitleMaximumLineCount - 1) lines.
+    // Lay out and record the first (maximumLineCount - 1) lines.
     CFIndex lineIndex = 0;
-    for (; lineIndex < std::min(attachmentTitleMaximumLineCount - 1, lineCount); ++lineIndex) {
-        CTLineRef line = (CTLineRef)CFArrayGetValueAtIndex(ctLines, lineIndex);
-        addLine(line);
-    }
+    CFIndex nonTruncatedLineCount = std::min<CFIndex>(maximumLineCount - 1, lineCount);
+    for (; lineIndex < nonTruncatedLineCount; ++lineIndex)
+        addLine((CTLineRef)CFArrayGetValueAtIndex(ctLines, lineIndex));
 
     if (lineIndex == lineCount)
         return;
 
-    // We had text that didn't fit in the first (attachmentTitleMaximumLineCount - 1) lines.
+    // We had text that didn't fit in the first (maximumLineCount - 1) lines.
     // Combine it into one last line, and center-truncate it.
     CTLineRef firstRemainingLine = (CTLineRef)CFArrayGetValueAtIndex(ctLines, lineIndex);
     CFIndex remainingRangeStart = CTLineGetStringRange(firstRemainingLine).location;
@@ -1573,7 +1572,8 @@
     } else
         buildSingleLine(action, attachmentActionFont().get(), attachmentActionColor(attachment));
 
-    buildTitleLines(attachment);
+    bool forceSingleLineTitle = !action.isEmpty() || !subtitle.isEmpty() || hasProgress;
+    buildTitleLines(attachment, forceSingleLineTitle ? 1 : attachmentTitleMaximumLineCount);
     buildSingleLine(subtitle, attachmentSubtitleFont().get(), attachmentSubtitleColor());
 
     if (!lines.isEmpty()) {
@@ -1643,10 +1643,15 @@
     context.fillPath(progressPath);
 }
 
-static void paintAttachmentBorder(GraphicsContext& context, AttachmentInfo& info)
+static Path attachmentBorderPath(AttachmentInfo& info)
 {
     Path borderPath;
     borderPath.addRoundedRect(info.attachmentRect, FloatSize(attachmentBorderRadius, attachmentBorderRadius));
+    return borderPath;
+}
+
+static void paintAttachmentBorder(GraphicsContext& context, Path& borderPath)
+{
     context.setStrokeColor(attachmentBorderColor());
     context.setStrokeThickness(1);
     context.strokePath(borderPath);
@@ -1666,7 +1671,9 @@
 
     context.translate(toFloatSize(paintRect.location()));
 
-    paintAttachmentBorder(context, info);
+    Path borderPath = attachmentBorderPath(info);
+    paintAttachmentBorder(context, borderPath);
+    context.clipPath(borderPath);
 
     context.translate(FloatSize(0, info.contentYOrigin));
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to