Changeset 244875 in webkit
- Timestamp:
- May 2, 2019 10:38:07 AM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r244869 r244875 1 2019-05-02 Alex Christensen <achristensen@webkit.org> 2 3 Safe browsing warning should update colors when a user switches between light and dark appearance 4 https://bugs.webkit.org/show_bug.cgi?id=197443 5 <rdar://problem/49883917> 6 7 Reviewed by Tim Horton. 8 9 We draw the WKSafeBrowsingExclamationPoint ourselves, so we need to call setNeedsDisplay when viewDidChangeEffectiveAppearance is called. 10 Instead of setting NSView.layer.backgroundColor we need to make an NSView subclass I call WKSafeBrowsingBox and we need to set its layer's 11 backgroundColor in updateLayer, otherwise the CGColor isn't updated from the NSColor. 12 13 * UIProcess/Cocoa/WKSafeBrowsingWarning.h: 14 * UIProcess/Cocoa/WKSafeBrowsingWarning.mm: 15 (colorForItem): 16 (-[WKSafeBrowsingExclamationPoint viewDidChangeEffectiveAppearance]): 17 (-[WKSafeBrowsingBox setSafeBrowsingBackgroundColor:]): 18 (-[WKSafeBrowsingBox updateLayer]): 19 (-[WKSafeBrowsingWarning initWithFrame:safeBrowsingWarning:completionHandler:]): 20 (-[WKSafeBrowsingWarning addContent]): 21 (-[WKSafeBrowsingWarning showDetailsClicked]): 22 (setBackground): Deleted. 23 1 24 2019-05-02 Frederic Wang <fwang@igalia.com> 2 25 -
trunk/Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.h
r241125 r244875 46 46 using ViewType = NSView; 47 47 using RectType = NSRect; 48 @interface WKSafeBrowsingWarning : NSView<NSTextViewDelegate> 48 using ColorType = NSColor; 49 49 #else 50 50 using ViewType = UIView; 51 51 using RectType = CGRect; 52 using ColorType = UIColor; 53 #endif 54 55 @interface WKSafeBrowsingBox : ViewType { 56 @package 57 #if PLATFORM(MAC) 58 RetainPtr<ColorType> _backgroundColor; 59 #endif 60 } 61 - (void)setSafeBrowsingBackgroundColor:(ColorType *)color; 62 @end 63 64 #if PLATFORM(MAC) 65 @interface WKSafeBrowsingWarning : WKSafeBrowsingBox<NSTextViewDelegate> 66 #else 52 67 @interface WKSafeBrowsingWarning : UIScrollView<UITextViewDelegate> 53 68 #endif … … 57 72 RefPtr<const WebKit::SafeBrowsingWarning> _warning; 58 73 WeakObjCPtr<WKSafeBrowsingTextView> _details; 59 WeakObjCPtr< ViewType> _box;74 WeakObjCPtr<WKSafeBrowsingBox> _box; 60 75 #if PLATFORM(WATCHOS) 61 76 WeakObjCPtr<UIResponder> _previousFirstResponder; -
trunk/Source/WebKit/UIProcess/Cocoa/WKSafeBrowsingWarning.mm
r244319 r244875 51 51 52 52 #if PLATFORM(MAC) 53 using ColorType = NSColor;54 53 using FontType = NSFont; 55 54 using TextViewType = NSTextView; … … 58 57 using SizeType = NSSize; 59 58 #else 60 using ColorType = UIColor;61 59 using FontType = UIFont; 62 60 using TextViewType = UITextView; … … 201 199 } 202 200 201 #if PLATFORM(MAC) 202 - (void)viewDidChangeEffectiveAppearance 203 { 204 [self setNeedsDisplay:YES]; 205 } 206 #endif 207 203 208 - (NSSize)intrinsicContentSize 204 209 { … … 255 260 } 256 261 257 static void setBackground(ViewType *view, ColorType *color) 258 { 259 #if PLATFORM(MAC) 260 view.wantsLayer = YES; 261 view.layer.backgroundColor = color.CGColor; 262 #else 263 view.backgroundColor = color; 264 #endif 265 } 262 @implementation WKSafeBrowsingBox 263 264 - (void)setSafeBrowsingBackgroundColor:(ColorType *)color 265 { 266 #if PLATFORM(MAC) 267 _backgroundColor = color; 268 self.wantsLayer = YES; 269 #else 270 self.backgroundColor = color; 271 #endif 272 } 273 274 #if PLATFORM(MAC) 275 - (void)updateLayer 276 { 277 self.layer.backgroundColor = [_backgroundColor CGColor]; 278 } 279 #endif 280 281 @end 266 282 267 283 @interface WKSafeBrowsingTextView : TextViewType { … … 288 304 }; 289 305 _warning = makeRef(warning); 290 setBackground(self, colorForItem(WarningItem::Background, self)); 291 #if PLATFORM(MAC) 306 #if PLATFORM(MAC) 307 [self setSafeBrowsingBackgroundColor:colorForItem(WarningItem::Background, self)]; 292 308 [self addContent]; 309 #else 310 [self setBackgroundColor:colorForItem(WarningItem::Background, self)]; 293 311 #endif 294 312 … … 318 336 auto showDetails = makeButton(WarningItem::ShowDetailsButton, self, @selector(showDetailsClicked)); 319 337 auto goBack = makeButton(WarningItem::GoBackButton, self, @selector(goBackClicked)); 320 auto box = [[ ViewTypenew] autorelease];338 auto box = [[WKSafeBrowsingBox new] autorelease]; 321 339 _box = box; 322 setBackground(box, colorForItem(WarningItem::BoxBackground, self));340 [box setSafeBrowsingBackgroundColor:colorForItem(WarningItem::BoxBackground, self)]; 323 341 box.layer.cornerRadius = boxCornerRadius; 324 342 … … 393 411 - (void)showDetailsClicked 394 412 { 395 ViewType*box = _box.get().get();413 WKSafeBrowsingBox *box = _box.get().get(); 396 414 ButtonType *showDetails = box.subviews.lastObject; 397 415 [showDetails removeFromSuperview]; … … 401 419 WKSafeBrowsingTextView *details = [[[WKSafeBrowsingTextView alloc] initWithAttributedString:text forWarning:self] autorelease]; 402 420 _details = details; 403 ViewType *bottom = [[ViewTypenew] autorelease];404 setBackground(bottom, colorForItem(WarningItem::BoxBackground, self));421 WKSafeBrowsingBox *bottom = [[WKSafeBrowsingBox new] autorelease]; 422 [bottom setSafeBrowsingBackgroundColor:colorForItem(WarningItem::BoxBackground, self)]; 405 423 bottom.layer.cornerRadius = boxCornerRadius; 406 424 … … 417 435 #endif 418 436 419 ViewType *line = [[ViewTypenew] autorelease];420 setBackground(line, [ColorType lightGrayColor]);437 WKSafeBrowsingBox *line = [[WKSafeBrowsingBox new] autorelease]; 438 [line setSafeBrowsingBackgroundColor:[ColorType lightGrayColor]]; 421 439 for (ViewType *view in @[details, bottom, line]) 422 440 view.translatesAutoresizingMaskIntoConstraints = NO;
Note: See TracChangeset
for help on using the changeset viewer.