- Revision
- 238585
- Author
- [email protected]
- Date
- 2018-11-27 16:15:01 -0800 (Tue, 27 Nov 2018)
Log Message
Safe browsing warning text needs to be visible on High Sierra
https://bugs.webkit.org/show_bug.cgi?id=192022
Reviewed by Tim Horton.
Source/WebKit:
Something about AppKit, autolayout, view insertion order, and NSTextView makes the text lay
out with initial size of {0, 0} on High Sierra. Using an NSTextField instead makes the details visible.
Covered by an API test.
* UIProcess/Cocoa/WKSafeBrowsingWarning.h:
* UIProcess/Cocoa/WKSafeBrowsingWarning.mm:
(makeLabel):
(-[WKSafeBrowsingWarning addContent]):
(-[WKSafeBrowsingWarning showDetailsClicked]):
(-[WKSafeBrowsingWarning layoutText]):
(makeTitleLabel): Deleted.
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm:
(TEST):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (238584 => 238585)
--- trunk/Source/WebKit/ChangeLog 2018-11-27 23:54:06 UTC (rev 238584)
+++ trunk/Source/WebKit/ChangeLog 2018-11-28 00:15:01 UTC (rev 238585)
@@ -1,3 +1,23 @@
+2018-11-27 Alex Christensen <[email protected]>
+
+ Safe browsing warning text needs to be visible on High Sierra
+ https://bugs.webkit.org/show_bug.cgi?id=192022
+
+ Reviewed by Tim Horton.
+
+ Something about AppKit, autolayout, view insertion order, and NSTextView makes the text lay
+ out with initial size of {0, 0} on High Sierra. Using an NSTextField instead makes the details visible.
+
+ Covered by an API test.
+
+ * UIProcess/Cocoa/WKSafeBrowsingWarning.h:
+ * UIProcess/Cocoa/WKSafeBrowsingWarning.mm:
+ (makeLabel):
+ (-[WKSafeBrowsingWarning addContent]):
+ (-[WKSafeBrowsingWarning showDetailsClicked]):
+ (-[WKSafeBrowsingWarning layoutText]):
+ (makeTitleLabel): Deleted.
+
2018-11-27 Tim Horton <[email protected]>
WKNavigation.AutomaticViewReloadAfterWebProcessCrash asserts after r238538
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.h (238584 => 238585)
--- trunk/Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.h 2018-11-27 23:54:06 UTC (rev 238584)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.h 2018-11-28 00:15:01 UTC (rev 238585)
@@ -57,7 +57,7 @@
@package
CompletionHandler<void(Variant<WebKit::ContinueUnsafeLoad, WebCore::URL>&&)> _completionHandler;
RefPtr<const WebKit::SafeBrowsingWarning> _warning;
- RetainPtr<NSMutableArray<WKSafeBrowsingTextView *>> _textViews;
+ WeakObjCPtr<WKSafeBrowsingTextView> _details;
}
- (instancetype)initWithFrame:(RectType)frame safeBrowsingWarning:(const WebKit::SafeBrowsingWarning&)warning completionHandler:(CompletionHandler<void(Variant<WebKit::ContinueUnsafeLoad, WebCore::URL>&&)>&&)completionHandler;
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.mm (238584 => 238585)
--- trunk/Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.mm 2018-11-27 23:54:06 UTC (rev 238584)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.mm 2018-11-28 00:15:01 UTC (rev 238585)
@@ -197,12 +197,8 @@
#endif
}
-static ViewType *makeTitleLabel(NSString *title, ViewType *warning)
+static ViewType *makeLabel(NSAttributedString *attributedString)
{
- auto attributedString = [[[NSAttributedString alloc] initWithString:title attributes:@{
- NSFontAttributeName:[FontType boldSystemFontOfSize:titleSize],
- NSForegroundColorAttributeName:colorForItem(WarningItem::TitleText, warning)
- }] autorelease];
#if PLATFORM(MAC)
return [NSTextField labelWithAttributedString:attributedString];
#else
@@ -251,15 +247,19 @@
- (void)addContent
{
auto exclamationPoint = [[WKSafeBrowsingExclamationPoint new] autorelease];
- auto title = makeTitleLabel(_warning->title(), self);
- auto warning = [[[WKSafeBrowsingTextView alloc] initWithAttributedString:[[[NSAttributedString alloc] initWithString:_warning->warning() attributes:@{ NSFontAttributeName:[FontType systemFontOfSize:textSize] }] autorelease] forWarning:self] autorelease];
+ auto title = makeLabel([[[NSAttributedString alloc] initWithString:_warning->title() attributes:@{
+ NSFontAttributeName:[FontType boldSystemFontOfSize:titleSize],
+ NSForegroundColorAttributeName:colorForItem(WarningItem::TitleText, self)
+ }] autorelease]);
+ auto warning = makeLabel([[[NSAttributedString alloc] initWithString:_warning->warning() attributes:@{
+ NSFontAttributeName:[FontType systemFontOfSize:textSize],
+ NSForegroundColorAttributeName:colorForItem(WarningItem::MessageText, self)
+ }] autorelease]);
auto showDetails = makeButton(WarningItem::ShowDetailsButton, self, @selector(showDetailsClicked));
auto goBack = makeButton(WarningItem::GoBackButton, self, @selector(goBackClicked));
auto box = [[ViewType new] autorelease];
setBackground(box, colorForItem(WarningItem::BoxBackground, self));
box.layer.cornerRadius = boxCornerRadius;
- _textViews = adoptNS([NSMutableArray new]);
- [_textViews addObject:warning];
for (ViewType *view in @[exclamationPoint, title, warning, goBack, showDetails]) {
view.translatesAutoresizingMaskIntoConstraints = NO;
@@ -306,7 +306,7 @@
NSMutableAttributedString *text = [[_warning->details() mutableCopy] autorelease];
[text addAttributes:@{ NSFontAttributeName:[FontType systemFontOfSize:textSize] } range:NSMakeRange(0, text.length)];
WKSafeBrowsingTextView *details = [[[WKSafeBrowsingTextView alloc] initWithAttributedString:text forWarning:self] autorelease];
- [_textViews addObject:details];
+ _details = details;
ViewType *bottom = [[ViewType new] autorelease];
setBackground(bottom, colorForItem(WarningItem::BoxBackground, self));
bottom.layer.cornerRadius = boxCornerRadius;
@@ -358,8 +358,7 @@
- (void)layoutText
{
- for (WKSafeBrowsingTextView *view in _textViews.get())
- [view invalidateIntrinsicContentSize];
+ [_details invalidateIntrinsicContentSize];
}
#if PLATFORM(MAC)
Modified: trunk/Tools/ChangeLog (238584 => 238585)
--- trunk/Tools/ChangeLog 2018-11-27 23:54:06 UTC (rev 238584)
+++ trunk/Tools/ChangeLog 2018-11-28 00:15:01 UTC (rev 238585)
@@ -1,3 +1,13 @@
+2018-11-27 Alex Christensen <[email protected]>
+
+ Safe browsing warning text needs to be visible on High Sierra
+ https://bugs.webkit.org/show_bug.cgi?id=192022
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm:
+ (TEST):
+
2018-11-27 Wenson Hsieh <[email protected]>
Unreviewed, fix the watchOS engineering build
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm (238584 => 238585)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm 2018-11-27 23:54:06 UTC (rev 238584)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm 2018-11-28 00:15:01 UTC (rev 238585)
@@ -212,6 +212,7 @@
auto webView = safeBrowsingView();
auto warning = [webView _safeBrowsingWarning];
EXPECT_EQ(warning.subviews.count, 1ull);
+ EXPECT_GT(warning.subviews.firstObject.subviews[2].frame.size.height, 0);
checkTitleAndClick(warning.subviews.firstObject.subviews[4], "Show Details");
EXPECT_EQ(warning.subviews.count, 2ull);
EXPECT_FALSE(committedNavigation);