Log Message
<attachment> action label doesn't wrap, but needs to for some localizations https://bugs.webkit.org/show_bug.cgi?id=160431 <rdar://problem/27526464>
Reviewed by Simon Fraser. Test: fast/attachment/attachment-wrapping-action.html * rendering/RenderThemeIOS.mm: (WebCore::AttachmentInfo::buildWrappedLines): (WebCore::AttachmentInfo::AttachmentInfo): (WebCore::AttachmentInfo::buildTitleLines): Deleted. Rework buildTitleLines into buildWrappedLines so that we have a generic way to add lines that wrap up to N lines and then center-truncate. Make use of it for the action text, and follow the same rules/width as the title text already does. * fast/attachment/attachment-wrapping-action-expected-mismatch.html: Added. * fast/attachment/attachment-wrapping-action.html: Added. Add a test that ensures that the action label wraps by filling one with non-breaking and breaking spaces, which will wrap onto two lines, and one with just a single space, which will always fit in one line, and ensuring that they do not match.
Modified Paths
- trunk/LayoutTests/ChangeLog
- trunk/LayoutTests/TestExpectations
- trunk/LayoutTests/platform/ios-simulator/TestExpectations
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/rendering/RenderThemeIOS.mm
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (204004 => 204005)
--- trunk/LayoutTests/ChangeLog 2016-08-02 00:31:26 UTC (rev 204004)
+++ trunk/LayoutTests/ChangeLog 2016-08-02 01:39:26 UTC (rev 204005)
@@ -1,3 +1,18 @@
+2016-08-01 Tim Horton <[email protected]>
+
+ <attachment> action label doesn't wrap, but needs to for some localizations
+ https://bugs.webkit.org/show_bug.cgi?id=160431
+ <rdar://problem/27526464>
+
+ Reviewed by Simon Fraser.
+
+ * fast/attachment/attachment-wrapping-action-expected-mismatch.html: Added.
+ * fast/attachment/attachment-wrapping-action.html: Added.
+ Add a test that ensures that the action label wraps by filling one with
+ non-breaking and breaking spaces, which will wrap onto two lines, and one
+ with just a single space, which will always fit in one line, and ensuring
+ that they do not match.
+
2016-08-01 Chris Dumez <[email protected]>
[iOS] Fix fast/events/touch/document-create-touch-list-ios.html
Modified: trunk/LayoutTests/TestExpectations (204004 => 204005)
--- trunk/LayoutTests/TestExpectations 2016-08-02 00:31:26 UTC (rev 204004)
+++ trunk/LayoutTests/TestExpectations 2016-08-02 01:39:26 UTC (rev 204005)
@@ -58,6 +58,9 @@
# This test only makes sense on Mac
fast/attachment/attachment-subtitle-resize.html
+# This test only makes sense on iOS
+fast/attachment/attachment-wrapping-action.html
+
#//////////////////////////////////////////////////////////////////////////////////////////
# End platform-specific tests.
#//////////////////////////////////////////////////////////////////////////////////////////
Added: trunk/LayoutTests/fast/attachment/attachment-wrapping-action-expected-mismatch.html (0 => 204005)
--- trunk/LayoutTests/fast/attachment/attachment-wrapping-action-expected-mismatch.html (rev 0)
+++ trunk/LayoutTests/fast/attachment/attachment-wrapping-action-expected-mismatch.html 2016-08-02 01:39:26 UTC (rev 204005)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<script>
+ if (window.internals)
+ window.internals.settings.setAttachmentElementEnabled(true)
+</script>
+<body>
+<attachment action="" " title="title"></attachment>
+</body>
+</html>
Added: trunk/LayoutTests/fast/attachment/attachment-wrapping-action.html (0 => 204005)
--- trunk/LayoutTests/fast/attachment/attachment-wrapping-action.html (rev 0)
+++ trunk/LayoutTests/fast/attachment/attachment-wrapping-action.html 2016-08-02 01:39:26 UTC (rev 204005)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<script>
+ if (window.internals)
+ window.internals.settings.setAttachmentElementEnabled(true)
+</script>
+<body>
+<attachment action="" " title="title"></attachment>
+</body>
+</html>
Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (204004 => 204005)
--- trunk/LayoutTests/platform/ios-simulator/TestExpectations 2016-08-02 00:31:26 UTC (rev 204004)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations 2016-08-02 01:39:26 UTC (rev 204005)
@@ -3158,3 +3158,5 @@
media/W3C/audio/canPlayType/canPlayType_supported_but_no_codecs_parameter_1.html [ Failure ]
media/video-seek-to-current-time.html [ Failure ]
+
+fast/attachment/attachment-wrapping-action.html [ Pass ]
Modified: trunk/Source/WebCore/ChangeLog (204004 => 204005)
--- trunk/Source/WebCore/ChangeLog 2016-08-02 00:31:26 UTC (rev 204004)
+++ trunk/Source/WebCore/ChangeLog 2016-08-02 01:39:26 UTC (rev 204005)
@@ -1,3 +1,23 @@
+2016-08-01 Tim Horton <[email protected]>
+
+ <attachment> action label doesn't wrap, but needs to for some localizations
+ https://bugs.webkit.org/show_bug.cgi?id=160431
+ <rdar://problem/27526464>
+
+ Reviewed by Simon Fraser.
+
+ Test: fast/attachment/attachment-wrapping-action.html
+
+ * rendering/RenderThemeIOS.mm:
+ (WebCore::AttachmentInfo::buildWrappedLines):
+ (WebCore::AttachmentInfo::AttachmentInfo):
+ (WebCore::AttachmentInfo::buildTitleLines): Deleted.
+ Rework buildTitleLines into buildWrappedLines so that we have a
+ generic way to add lines that wrap up to N lines and then center-truncate.
+
+ Make use of it for the action text, and follow the same rules/width as
+ the title text already does.
+
2016-08-01 Anders Carlsson <[email protected]>
Build fix.
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (204004 => 204005)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2016-08-02 00:31:26 UTC (rev 204004)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2016-08-02 01:39:26 UTC (rev 204005)
@@ -1380,8 +1380,8 @@
const CGFloat attachmentItemMargin = 8;
-const CGFloat attachmentTitleMaximumWidth = 140;
-const CFIndex attachmentTitleMaximumLineCount = 2;
+const CGFloat attachmentWrappingTextMaximumWidth = 140;
+const CFIndex attachmentWrappingTextMaximumLineCount = 2;
static RetainPtr<CTFontRef> attachmentActionFont()
{
@@ -1432,7 +1432,7 @@
CGFloat contentYOrigin { 0 };
private:
- void buildTitleLines(const RenderAttachment&, unsigned maximumLineCount);
+ void buildWrappedLines(const String&, CTFontRef, UIColor *, unsigned maximumLineCount);
void buildSingleLine(const String&, CTFontRef, UIColor *);
void addLine(CTLineRef);
@@ -1453,28 +1453,25 @@
lines.append(labelLine);
}
-void AttachmentInfo::buildTitleLines(const RenderAttachment& attachment, unsigned maximumLineCount)
+void AttachmentInfo::buildWrappedLines(const String& text, CTFontRef font, UIColor *color, unsigned maximumLineCount)
{
- RetainPtr<CTFontRef> font = attachmentTitleFont();
-
- String title = attachment.attachmentElement().attachmentTitle();
- if (title.isEmpty())
+ if (text.isEmpty())
return;
NSDictionary *textAttributes = @{
- (id)kCTFontAttributeName: (id)font.get(),
- (id)kCTForegroundColorAttributeName: attachmentTitleColor()
+ (id)kCTFontAttributeName: (id)font,
+ (id)kCTForegroundColorAttributeName: color
};
- RetainPtr<NSAttributedString> attributedTitle = adoptNS([[NSAttributedString alloc] initWithString:title attributes:textAttributes]);
- RetainPtr<CTFramesetterRef> titleFramesetter = adoptCF(CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attributedTitle.get()));
+ RetainPtr<NSAttributedString> attributedText = adoptNS([[NSAttributedString alloc] initWithString:text attributes:textAttributes]);
+ RetainPtr<CTFramesetterRef> framesetter = adoptCF(CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attributedText.get()));
CFRange fitRange;
- CGSize titleTextSize = CTFramesetterSuggestFrameSizeWithConstraints(titleFramesetter.get(), CFRangeMake(0, 0), nullptr, CGSizeMake(attachmentTitleMaximumWidth, CGFLOAT_MAX), &fitRange);
+ CGSize textSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter.get(), CFRangeMake(0, 0), nullptr, CGSizeMake(attachmentWrappingTextMaximumWidth, CGFLOAT_MAX), &fitRange);
- RetainPtr<CGPathRef> titlePath = adoptCF(CGPathCreateWithRect(CGRectMake(0, 0, titleTextSize.width, titleTextSize.height), nullptr));
- RetainPtr<CTFrameRef> titleFrame = adoptCF(CTFramesetterCreateFrame(titleFramesetter.get(), fitRange, titlePath.get(), nullptr));
+ RetainPtr<CGPathRef> textPath = adoptCF(CGPathCreateWithRect(CGRectMake(0, 0, textSize.width, textSize.height), nullptr));
+ RetainPtr<CTFrameRef> textFrame = adoptCF(CTFramesetterCreateFrame(framesetter.get(), fitRange, textPath.get(), nullptr));
- CFArrayRef ctLines = CTFrameGetLines(titleFrame.get());
+ CFArrayRef ctLines = CTFrameGetLines(textFrame.get());
CFIndex lineCount = CFArrayGetCount(ctLines);
if (!lineCount)
return;
@@ -1492,12 +1489,12 @@
// Combine it into one last line, and center-truncate it.
CTLineRef firstRemainingLine = (CTLineRef)CFArrayGetValueAtIndex(ctLines, lineIndex);
CFIndex remainingRangeStart = CTLineGetStringRange(firstRemainingLine).location;
- NSRange remainingRange = NSMakeRange(remainingRangeStart, [attributedTitle length] - remainingRangeStart);
- NSAttributedString *remainingString = [attributedTitle attributedSubstringFromRange:remainingRange];
+ NSRange remainingRange = NSMakeRange(remainingRangeStart, [attributedText length] - remainingRangeStart);
+ NSAttributedString *remainingString = [attributedText attributedSubstringFromRange:remainingRange];
RetainPtr<CTLineRef> remainingLine = adoptCF(CTLineCreateWithAttributedString((CFAttributedStringRef)remainingString));
RetainPtr<NSAttributedString> ellipsisString = adoptNS([[NSAttributedString alloc] initWithString:@"\u2026" attributes:textAttributes]);
RetainPtr<CTLineRef> ellipsisLine = adoptCF(CTLineCreateWithAttributedString((CFAttributedStringRef)ellipsisString.get()));
- RetainPtr<CTLineRef> truncatedLine = adoptCF(CTLineCreateTruncatedLine(remainingLine.get(), attachmentTitleMaximumWidth, kCTLineTruncationMiddle, ellipsisLine.get()));
+ RetainPtr<CTLineRef> truncatedLine = adoptCF(CTLineCreateTruncatedLine(remainingLine.get(), attachmentWrappingTextMaximumWidth, kCTLineTruncationMiddle, ellipsisLine.get()));
if (!truncatedLine)
truncatedLine = remainingLine;
@@ -1587,6 +1584,7 @@
hasProgress = getAttachmentProgress(attachment, progress);
+ String title = attachment.attachmentElement().attachmentTitle();
String action = ""
String subtitle = attachment.attachmentElement().attributeWithoutSynchronization(subtitleAttr);
@@ -1605,10 +1603,10 @@
yOffset += iconRect.height() + attachmentItemMargin;
}
} else
- buildSingleLine(action, attachmentActionFont().get(), attachmentActionColor(attachment));
+ buildWrappedLines(action, attachmentActionFont().get(), attachmentActionColor(attachment), attachmentWrappingTextMaximumLineCount);
bool forceSingleLineTitle = !action.isEmpty() || !subtitle.isEmpty() || hasProgress;
- buildTitleLines(attachment, forceSingleLineTitle ? 1 : attachmentTitleMaximumLineCount);
+ buildWrappedLines(title, attachmentTitleFont().get(), attachmentTitleColor(), forceSingleLineTitle ? 1 : attachmentWrappingTextMaximumLineCount);
buildSingleLine(subtitle, attachmentSubtitleFont().get(), attachmentSubtitleColor());
if (!lines.isEmpty()) {
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
