WebKit Bugzilla
Attachment 368731 Details for
Bug 197443
: Safe browsing warning should update colors when a user switches between light and dark appearance
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197443-20190501162455.patch (text/plain), 6.99 KB, created by
Alex Christensen
on 2019-05-01 16:24:56 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Alex Christensen
Created:
2019-05-01 16:24:56 PDT
Size:
6.99 KB
patch
obsolete
>Index: Source/WebKit/ChangeLog >=================================================================== >--- Source/WebKit/ChangeLog (revision 244810) >+++ Source/WebKit/ChangeLog (working copy) >@@ -1,3 +1,26 @@ >+2019-05-01 Alex Christensen <achristensen@webkit.org> >+ >+ Safe browsing warning should update colors when a user switches between light and dark appearance >+ https://bugs.webkit.org/show_bug.cgi?id=197443 >+ <rdar://problem/49883917> >+ >+ Reviewed by Tim Horton. >+ >+ We draw the WKSafeBrowsingExclamationPoint ourselves, so we need to call setNeedsDisplay when viewDidChangeEffectiveAppearance is called. >+ Instead of setting NSView.layer.backgroundColor we need to make an NSView subclass I call WKSafeBrowsingBox and we need to set its layer's >+ backgroundColor in updateLayer, otherwise the CGColor isn't updated from the NSColor. >+ >+ * UIProcess/Cocoa/WKSafeBrowsingWarning.h: >+ * UIProcess/Cocoa/WKSafeBrowsingWarning.mm: >+ (colorForItem): >+ (-[WKSafeBrowsingExclamationPoint viewDidChangeEffectiveAppearance]): >+ (-[WKSafeBrowsingBox setSafeBrowsingBackgroundColor:]): >+ (-[WKSafeBrowsingBox updateLayer]): >+ (-[WKSafeBrowsingWarning initWithFrame:safeBrowsingWarning:completionHandler:]): >+ (-[WKSafeBrowsingWarning addContent]): >+ (-[WKSafeBrowsingWarning showDetailsClicked]): >+ (setBackground): Deleted. >+ > 2019-04-30 Chris Dumez <cdumez@apple.com> > > Regression(PSON) URL scheme handlers can no longer respond asynchronously >Index: Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.h >=================================================================== >--- Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.h (revision 244759) >+++ Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.h (working copy) >@@ -45,10 +45,25 @@ OBJC_CLASS WKSafeBrowsingTextView; > #if PLATFORM(MAC) > using ViewType = NSView; > using RectType = NSRect; >-@interface WKSafeBrowsingWarning : NSView<NSTextViewDelegate> >+using ColorType = NSColor; > #else > using ViewType = UIView; > using RectType = CGRect; >+using ColorType = UIColor; >+#endif >+ >+@interface WKSafeBrowsingBox : ViewType { >+@package >+#if PLATFORM(MAC) >+ RetainPtr<ColorType> _backgroundColor; >+#endif >+} >+- (void)setSafeBrowsingBackgroundColor:(ColorType *)color; >+@end >+ >+#if PLATFORM(MAC) >+@interface WKSafeBrowsingWarning : WKSafeBrowsingBox<NSTextViewDelegate> >+#else > @interface WKSafeBrowsingWarning : UIScrollView<UITextViewDelegate> > #endif > { >@@ -56,7 +71,7 @@ using RectType = CGRect; > CompletionHandler<void(Variant<WebKit::ContinueUnsafeLoad, URL>&&)> _completionHandler; > RefPtr<const WebKit::SafeBrowsingWarning> _warning; > WeakObjCPtr<WKSafeBrowsingTextView> _details; >- WeakObjCPtr<ViewType> _box; >+ WeakObjCPtr<WKSafeBrowsingBox> _box; > #if PLATFORM(WATCHOS) > WeakObjCPtr<UIResponder> _previousFirstResponder; > #endif >Index: Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.mm >=================================================================== >--- Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.mm (revision 244759) >+++ Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.mm (working copy) >@@ -50,14 +50,12 @@ constexpr CGFloat maxWidth = 675; > #endif > > #if PLATFORM(MAC) >-using ColorType = NSColor; > using FontType = NSFont; > using TextViewType = NSTextView; > using ButtonType = NSButton; > using AlignmentType = NSLayoutAttribute; > using SizeType = NSSize; > #else >-using ColorType = UIColor; > using FontType = UIFont; > using TextViewType = UITextView; > using ButtonType = UIButton; >@@ -200,6 +198,13 @@ - (void)drawRect:(RectType)rect > [exclamationPoint fill]; > } > >+#if PLATFORM(MAC) >+- (void)viewDidChangeEffectiveAppearance >+{ >+ [self setNeedsDisplay:YES]; >+} >+#endif >+ > - (NSSize)intrinsicContentSize > { > return { exclamationPointSize, exclamationPointSize }; >@@ -254,16 +259,27 @@ static ViewType *makeLabel(NSAttributedS > #endif > } > >-static void setBackground(ViewType *view, ColorType *color) >+@implementation WKSafeBrowsingBox >+ >+- (void)setSafeBrowsingBackgroundColor:(ColorType *)color > { > #if PLATFORM(MAC) >- view.wantsLayer = YES; >- view.layer.backgroundColor = color.CGColor; >+ _backgroundColor = color; >+ self.wantsLayer = YES; > #else >- view.backgroundColor = color; >+ self.backgroundColor = color; > #endif > } > >+#if PLATFORM(MAC) >+- (void)updateLayer >+{ >+ self.layer.backgroundColor = [_backgroundColor CGColor]; >+} >+#endif >+ >+@end >+ > @interface WKSafeBrowsingTextView : TextViewType { > @package > WeakObjCPtr<WKSafeBrowsingWarning> _warning; >@@ -287,9 +303,11 @@ - (instancetype)initWithFrame:(RectType) > completionHandler(WTFMove(result)); > }; > _warning = makeRef(warning); >- setBackground(self, colorForItem(WarningItem::Background, self)); > #if PLATFORM(MAC) >+ [self setSafeBrowsingBackgroundColor:colorForItem(WarningItem::Background, self)]; > [self addContent]; >+#else >+ [self setBackgroundColor:colorForItem(WarningItem::Background, self)]; > #endif > > #if PLATFORM(WATCHOS) >@@ -317,9 +335,9 @@ - (void)addContent > }] autorelease]); > auto showDetails = makeButton(WarningItem::ShowDetailsButton, self, @selector(showDetailsClicked)); > auto goBack = makeButton(WarningItem::GoBackButton, self, @selector(goBackClicked)); >- auto box = [[ViewType new] autorelease]; >+ auto box = [[WKSafeBrowsingBox new] autorelease]; > _box = box; >- setBackground(box, colorForItem(WarningItem::BoxBackground, self)); >+ [box setSafeBrowsingBackgroundColor:colorForItem(WarningItem::BoxBackground, self)]; > box.layer.cornerRadius = boxCornerRadius; > > for (ViewType *view in @[exclamationPoint, title, warning, goBack, showDetails]) { >@@ -392,7 +410,7 @@ - (void)addContent > > - (void)showDetailsClicked > { >- ViewType *box = _box.get().get(); >+ WKSafeBrowsingBox *box = _box.get().get(); > ButtonType *showDetails = box.subviews.lastObject; > [showDetails removeFromSuperview]; > >@@ -400,8 +418,8 @@ - (void)showDetailsClicked > [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]; >- setBackground(bottom, colorForItem(WarningItem::BoxBackground, self)); >+ WKSafeBrowsingBox *bottom = [[WKSafeBrowsingBox new] autorelease]; >+ [bottom setSafeBrowsingBackgroundColor:colorForItem(WarningItem::BoxBackground, self)]; > bottom.layer.cornerRadius = boxCornerRadius; > > #if HAVE(SAFE_BROWSING) >@@ -416,8 +434,8 @@ - (void)showDetailsClicked > #endif > #endif > >- ViewType *line = [[ViewType new] autorelease]; >- setBackground(line, [ColorType lightGrayColor]); >+ WKSafeBrowsingBox *line = [[WKSafeBrowsingBox new] autorelease]; >+ [line setSafeBrowsingBackgroundColor:[ColorType lightGrayColor]]; > for (ViewType *view in @[details, bottom, line]) > view.translatesAutoresizingMaskIntoConstraints = NO; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197443
:
368626
|
368630
|
368634
| 368731