Shrink and hyphenate safe browsing warning text on watchOS
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2019 18:22:12 +0000 (18:22 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2019 18:22:12 +0000 (18:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194361
<rdar://problem/47466549>

Reviewed by Geoffrey Garen.

Some internationalizations use long words that didn't fit on small watches.

* UIProcess/Cocoa/WKSafeBrowsingWarning.mm:
(fontOfSize):
(-[WKSafeBrowsingWarning addContent]):
(-[WKSafeBrowsingTextView initWithAttributedString:forWarning:]):

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.mm

index e2486af..4fd03fe 100644 (file)
@@ -1,3 +1,18 @@
+2019-02-07  Alex Christensen  <achristensen@webkit.org>
+
+        Shrink and hyphenate safe browsing warning text on watchOS
+        https://bugs.webkit.org/show_bug.cgi?id=194361
+        <rdar://problem/47466549>
+
+        Reviewed by Geoffrey Garen.
+
+        Some internationalizations use long words that didn't fit on small watches.
+
+        * UIProcess/Cocoa/WKSafeBrowsingWarning.mm:
+        (fontOfSize):
+        (-[WKSafeBrowsingWarning addContent]):
+        (-[WKSafeBrowsingTextView initWithAttributedString:forWarning:]):
+
 2019-02-07  Miguel Gomez  <magomez@igalia.com>
 
         [WPE] Implement GStreamer based holepunch
index 05ad950..0cfdc9a 100644 (file)
@@ -37,7 +37,7 @@ constexpr CGFloat exclamationPointSize = 30;
 constexpr CGFloat boxCornerRadius = 6;
 #if HAVE(SAFE_BROWSING)
 #if PLATFORM(WATCHOS)
-constexpr CGFloat marginSize = 10;
+constexpr CGFloat marginSize = 9;
 #else
 constexpr CGFloat marginSize = 20;
 #endif
@@ -88,7 +88,7 @@ static FontType *fontOfSize(WarningTextSize size)
     switch (size) {
     case WarningTextSize::Title:
 #if PLATFORM(WATCHOS)
-        return [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
+        return [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline];
 #else
         return [UIFont preferredFontForTextStyle:UIFontTextStyleLargeTitle];
 #endif
@@ -289,10 +289,16 @@ static void setBackground(ViewType *view, ColorType *color)
     auto title = makeLabel([[[NSAttributedString alloc] initWithString:_warning->title() attributes:@{
         NSFontAttributeName:fontOfSize(WarningTextSize::Title),
         NSForegroundColorAttributeName:colorForItem(WarningItem::TitleText, self)
+#if PLATFORM(WATCHOS)
+        , NSHyphenationFactorDocumentAttribute:@1
+#endif
     }] autorelease]);
     auto warning = makeLabel([[[NSAttributedString alloc] initWithString:_warning->warning() attributes:@{
         NSFontAttributeName:fontOfSize(WarningTextSize::Body),
         NSForegroundColorAttributeName:colorForItem(WarningItem::MessageText, self)
+#if PLATFORM(WATCHOS)
+        , NSHyphenationFactorDocumentAttribute:@1
+#endif
     }] autorelease]);
     auto showDetails = makeButton(WarningItem::ShowDetailsButton, self, @selector(showDetailsClicked));
     auto goBack = makeButton(WarningItem::GoBackButton, self, @selector(goBackClicked));
@@ -368,7 +374,6 @@ static void setBackground(ViewType *view, ColorType *color)
 {
     ViewType *box = _box.get().get();
     ButtonType *showDetails = box.subviews.lastObject;
-    WTFLogAlways("SHOW DETAILS BUTTON? %@", showDetails);
     [showDetails removeFromSuperview];
 
     NSMutableAttributedString *text = [[_warning->details() mutableCopy] autorelease];
@@ -537,6 +542,9 @@ static void setBackground(ViewType *view, ColorType *color)
 #if !PLATFORM(MAC)
     self.scrollEnabled = NO;
 #endif
+#if PLATFORM(WATCHOS)
+    self.layoutManager.hyphenationFactor = 1;
+#endif
 
     return self;
 }