Title: [239014] trunk/Source/WebKit
Revision
239014
Author
[email protected]
Date
2018-12-08 17:55:52 -0800 (Sat, 08 Dec 2018)

Log Message

Safe browsing warning should respect text size from settings
https://bugs.webkit.org/show_bug.cgi?id=192205

Reviewed by Tim Horton.

* UIProcess/Cocoa/WKSafeBrowsingWarning.mm:
(fontWithSize):
(makeButton):
(-[WKSafeBrowsingWarning addContent]):
(-[WKSafeBrowsingWarning showDetailsClicked]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (239013 => 239014)


--- trunk/Source/WebKit/ChangeLog	2018-12-08 23:53:29 UTC (rev 239013)
+++ trunk/Source/WebKit/ChangeLog	2018-12-09 01:55:52 UTC (rev 239014)
@@ -1,3 +1,16 @@
+2018-12-08  Alex Christensen  <[email protected]>
+
+        Safe browsing warning should respect text size from settings
+        https://bugs.webkit.org/show_bug.cgi?id=192205
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/Cocoa/WKSafeBrowsingWarning.mm:
+        (fontWithSize):
+        (makeButton):
+        (-[WKSafeBrowsingWarning addContent]):
+        (-[WKSafeBrowsingWarning showDetailsClicked]):
+
 2018-12-08  Frederic Wang  <[email protected]>
 
         Allow control over child order when adding nodes to the scrolling tree

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.mm (239013 => 239014)


--- trunk/Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.mm	2018-12-08 23:53:29 UTC (rev 239013)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.mm	2018-12-09 01:55:52 UTC (rev 239014)
@@ -34,7 +34,6 @@
 #import <wtf/Language.h>
 
 constexpr CGFloat exclamationPointSize = 30;
-constexpr CGFloat titleSize = 26;
 constexpr CGFloat boxCornerRadius = 6;
 #if HAVE(SAFE_BROWSING)
 constexpr CGFloat marginSize = 20;
@@ -42,7 +41,6 @@
 #endif
 
 #if PLATFORM(MAC)
-constexpr CGFloat textSize = 14;
 using ColorType = NSColor;
 using FontType = NSFont;
 using TextViewType = NSTextView;
@@ -51,7 +49,6 @@
 using ViewType = NSView;
 using SizeType = NSSize;
 #else
-constexpr CGFloat textSize = 20;
 using ColorType = UIColor;
 using FontType = UIFont;
 using TextViewType = UITextView;
@@ -71,6 +68,30 @@
     GoBackButton
 };
 
+enum class WarningTextSize : uint8_t {
+    Title,
+    Body
+};
+
+static FontType *fontOfSize(WarningTextSize size)
+{
+#if PLATFORM(MAC)
+    switch (size) {
+    case WarningTextSize::Title:
+        return [NSFont boldSystemFontOfSize:26];
+    case WarningTextSize::Body:
+        return [NSFont systemFontOfSize:14];
+    }
+#else
+    switch (size) {
+    case WarningTextSize::Title:
+        return [UIFont preferredFontForTextStyle:UIFontTextStyleLargeTitle];
+    case WarningTextSize::Body:
+        return [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
+    }
+#endif
+}
+
 static ColorType *colorForItem(WarningItem item, ViewType *warning)
 {
     ASSERT([warning isKindOfClass:[WKSafeBrowsingWarning class]]);
@@ -189,7 +210,7 @@
         NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle),
         NSUnderlineColorAttributeName:[UIColor whiteColor],
         NSForegroundColorAttributeName:colorForItem(item, warning),
-        NSFontAttributeName:[FontType systemFontOfSize:textSize]
+        NSFontAttributeName:fontOfSize(WarningTextSize::Body)
     }] autorelease];
     [button setAttributedTitle:attributedTitle forState:UIControlStateNormal];
     [button addTarget:warning action:action forControlEvents:UIControlEventTouchUpInside];
@@ -248,11 +269,11 @@
 {
     auto exclamationPoint = [[WKSafeBrowsingExclamationPoint new] autorelease];
     auto title = makeLabel([[[NSAttributedString alloc] initWithString:_warning->title() attributes:@{
-        NSFontAttributeName:[FontType boldSystemFontOfSize:titleSize],
+        NSFontAttributeName:fontOfSize(WarningTextSize::Title),
         NSForegroundColorAttributeName:colorForItem(WarningItem::TitleText, self)
     }] autorelease]);
     auto warning = makeLabel([[[NSAttributedString alloc] initWithString:_warning->warning() attributes:@{
-        NSFontAttributeName:[FontType systemFontOfSize:textSize],
+        NSFontAttributeName:fontOfSize(WarningTextSize::Body),
         NSForegroundColorAttributeName:colorForItem(WarningItem::MessageText, self)
     }] autorelease]);
     auto showDetails = makeButton(WarningItem::ShowDetailsButton, self, @selector(showDetailsClicked));
@@ -304,7 +325,7 @@
     [showDetails removeFromSuperview];
 
     NSMutableAttributedString *text = [[_warning->details() mutableCopy] autorelease];
-    [text addAttributes:@{ NSFontAttributeName:[FontType systemFontOfSize:textSize] } range:NSMakeRange(0, text.length)];
+    [text addAttributes:@{ NSFontAttributeName:fontOfSize(WarningTextSize::Body) } range:NSMakeRange(0, text.length)];
     WKSafeBrowsingTextView *details = [[[WKSafeBrowsingTextView alloc] initWithAttributedString:text forWarning:self] autorelease];
     _details = details;
     ViewType *bottom = [[ViewType new] autorelease];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to