Bug 183418

Summary: Allow WebViews to disable system appearance
Product: WebKit Reporter: Megan Gardner <megan_gardner>
Component: New BugsAssignee: Megan Gardner <megan_gardner>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, bdakin, dino, ews-watchlist, rniwa, thorton, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Archive of layout-test-results from ews101 for mac-sierra
none
Archive of layout-test-results from ews117 for mac-sierra
none
Archive of layout-test-results from ews107 for mac-sierra-wk2
none
Patch
none
Archive of layout-test-results from ews101 for mac-sierra
none
Archive of layout-test-results from ews114 for mac-sierra
none
Archive of layout-test-results from ews126 for ios-simulator-wk2
none
Patch
none
Archive of layout-test-results from ews104 for mac-sierra-wk2
none
Archive of layout-test-results from ews101 for mac-sierra
none
Archive of layout-test-results from ews115 for mac-sierra
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
thorton: review+
Patch thorton: review+

Megan Gardner
Reported 2018-03-07 15:38:59 PST
Allow WebViews to disable system appearance
Attachments
Patch (46.67 KB, patch)
2018-03-07 15:46 PST, Megan Gardner
no flags
Patch (47.64 KB, patch)
2018-03-07 16:40 PST, Megan Gardner
no flags
Archive of layout-test-results from ews101 for mac-sierra (2.89 MB, application/zip)
2018-03-07 17:54 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews117 for mac-sierra (2.41 MB, application/zip)
2018-03-07 18:24 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews107 for mac-sierra-wk2 (2.92 MB, application/zip)
2018-03-07 18:27 PST, EWS Watchlist
no flags
Patch (50.76 KB, patch)
2018-03-07 19:24 PST, Megan Gardner
no flags
Archive of layout-test-results from ews101 for mac-sierra (2.64 MB, application/zip)
2018-03-07 20:33 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews114 for mac-sierra (1.68 MB, application/zip)
2018-03-07 20:47 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews126 for ios-simulator-wk2 (2.22 MB, application/zip)
2018-03-07 21:00 PST, EWS Watchlist
no flags
Patch (51.76 KB, patch)
2018-03-07 22:10 PST, Megan Gardner
no flags
Archive of layout-test-results from ews104 for mac-sierra-wk2 (2.28 MB, application/zip)
2018-03-07 23:11 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews101 for mac-sierra (2.51 MB, application/zip)
2018-03-07 23:36 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews115 for mac-sierra (1.46 MB, application/zip)
2018-03-07 23:44 PST, EWS Watchlist
no flags
Patch (55.06 KB, patch)
2018-03-08 09:48 PST, Megan Gardner
no flags
Patch (55.06 KB, patch)
2018-03-08 10:25 PST, Megan Gardner
no flags
Patch (55.98 KB, patch)
2018-03-08 10:38 PST, Megan Gardner
no flags
Patch (56.18 KB, patch)
2018-03-08 11:36 PST, Megan Gardner
no flags
Patch (56.98 KB, patch)
2018-03-08 11:48 PST, Megan Gardner
no flags
Patch (57.47 KB, patch)
2018-03-08 13:24 PST, Megan Gardner
no flags
Patch (57.67 KB, patch)
2018-03-08 13:46 PST, Megan Gardner
no flags
Patch (57.89 KB, patch)
2018-03-08 16:19 PST, Megan Gardner
no flags
Patch (57.31 KB, patch)
2018-03-08 17:24 PST, Megan Gardner
no flags
Patch (57.94 KB, patch)
2018-03-08 18:17 PST, Megan Gardner
no flags
Patch (53.29 KB, patch)
2018-03-08 19:54 PST, Megan Gardner
thorton: review+
Patch (53.18 KB, patch)
2018-03-08 20:39 PST, Megan Gardner
thorton: review+
Megan Gardner
Comment 1 2018-03-07 15:46:10 PST
Megan Gardner
Comment 2 2018-03-07 15:48:32 PST
Tim Horton
Comment 3 2018-03-07 16:20:27 PST
Comment on attachment 335229 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=335229&action=review > Source/WebCore/css/StyleColor.cpp:40 > +Color StyleColor::colorFromKeyword(CSSValueID keyword, bool useSystemAppearance) Not necessary to do in this patch but it would probably be better to make this an enum class > Source/WebCore/css/StyleResolver.cpp:1825 > + return RenderTheme::focusRingColor(document().page()->useSystemAppearance()); Can page be null? > Source/WebCore/css/StyleResolver.cpp:1832 > + return StyleColor::colorFromKeyword(identifier, document().page()->useSystemAppearance()); Can page be null? > Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp:87 > + context->drawFocusRing(path, 1, 1, RenderTheme::focusRingColor(element.document().page()->useSystemAppearance())); Can Page be null? > Source/WebCore/platform/mac/ThemeMac.mm:76 > + WebCore::LocalDefaultSystemAppearance localAppearence(useSystemAppearance); This local is spelled wrong. There might be others, maybe grep for "appearence" > Source/WebCore/rendering/RenderTheme.h:153 > + virtual Color platformFocusRingColor(bool useSystemAppearance) const { UNUSED_PARAM(useSystemAppearance); return Color(0, 0, 0); } You can just leave the name off the arg instead, then you don't have to UNUSED_PARAM
Tim Horton
Comment 4 2018-03-07 16:35:40 PST
Comment on attachment 335229 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=335229&action=review >> Source/WebCore/css/StyleColor.cpp:40 >> +Color StyleColor::colorFromKeyword(CSSValueID keyword, bool useSystemAppearance) > > Not necessary to do in this patch but it would probably be better to make this an enum class Something like: enum class UseSystemAppearance { Yes, No } and then you'd use it like UseSystemAppearance::Yes.
Megan Gardner
Comment 5 2018-03-07 16:40:36 PST
EWS Watchlist
Comment 6 2018-03-07 17:54:18 PST Comment hidden (obsolete)
EWS Watchlist
Comment 7 2018-03-07 17:54:19 PST Comment hidden (obsolete)
EWS Watchlist
Comment 8 2018-03-07 18:24:37 PST Comment hidden (obsolete)
EWS Watchlist
Comment 9 2018-03-07 18:24:38 PST Comment hidden (obsolete)
EWS Watchlist
Comment 10 2018-03-07 18:27:17 PST Comment hidden (obsolete)
EWS Watchlist
Comment 11 2018-03-07 18:27:18 PST Comment hidden (obsolete)
Megan Gardner
Comment 12 2018-03-07 19:24:59 PST
EWS Watchlist
Comment 13 2018-03-07 20:33:11 PST
Comment on attachment 335251 [details] Patch Attachment 335251 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/6848895 Number of test failures exceeded the failure limit.
EWS Watchlist
Comment 14 2018-03-07 20:33:12 PST
Created attachment 335256 [details] Archive of layout-test-results from ews101 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews101 Port: mac-sierra Platform: Mac OS X 10.12.6
EWS Watchlist
Comment 15 2018-03-07 20:47:32 PST
Comment on attachment 335251 [details] Patch Attachment 335251 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/6848887 Number of test failures exceeded the failure limit.
EWS Watchlist
Comment 16 2018-03-07 20:47:33 PST
Created attachment 335257 [details] Archive of layout-test-results from ews114 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews114 Port: mac-sierra Platform: Mac OS X 10.12.6
EWS Watchlist
Comment 17 2018-03-07 20:59:59 PST
Comment on attachment 335251 [details] Patch Attachment 335251 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/6848970 Number of test failures exceeded the failure limit.
EWS Watchlist
Comment 18 2018-03-07 21:00:01 PST
Created attachment 335258 [details] Archive of layout-test-results from ews126 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews126 Port: ios-simulator-wk2 Platform: Mac OS X 10.12.6
Tim Horton
Comment 19 2018-03-07 21:36:46 PST
Comment on attachment 335251 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=335251&action=review > Source/WebCore/html/canvas/CanvasStyle.cpp:-74 > - return parseColor(colorString); It’s pretty clear from the crashes that canvas can be null. > Source/WebCore/html/canvas/CanvasStyle.cpp:74 > + CSSParserContext context = CSSParserContext(canvas->document()); Not sure it’s a good idea to make a CSSParserContext here that’s missing most of its context -- we might enable features that we don’t want to, etc., because we don’t create it correctly. Right? Or is this all we need to fill one in?
Megan Gardner
Comment 20 2018-03-07 22:10:42 PST
EWS Watchlist
Comment 21 2018-03-07 23:10:58 PST
Comment on attachment 335263 [details] Patch Attachment 335263 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/6850889 Number of test failures exceeded the failure limit.
EWS Watchlist
Comment 22 2018-03-07 23:11:00 PST
Created attachment 335265 [details] Archive of layout-test-results from ews104 for mac-sierra-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-sierra-wk2 Platform: Mac OS X 10.12.6
EWS Watchlist
Comment 23 2018-03-07 23:36:19 PST
Comment on attachment 335263 [details] Patch Attachment 335263 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/6851132 Number of test failures exceeded the failure limit.
EWS Watchlist
Comment 24 2018-03-07 23:36:20 PST
Created attachment 335269 [details] Archive of layout-test-results from ews101 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews101 Port: mac-sierra Platform: Mac OS X 10.12.6
EWS Watchlist
Comment 25 2018-03-07 23:44:25 PST
Comment on attachment 335263 [details] Patch Attachment 335263 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/6851095 Number of test failures exceeded the failure limit.
EWS Watchlist
Comment 26 2018-03-07 23:44:26 PST
Created attachment 335270 [details] Archive of layout-test-results from ews115 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews115 Port: mac-sierra Platform: Mac OS X 10.12.6
Megan Gardner
Comment 27 2018-03-08 09:48:52 PST
Megan Gardner
Comment 28 2018-03-08 10:25:04 PST
Megan Gardner
Comment 29 2018-03-08 10:38:21 PST
Megan Gardner
Comment 30 2018-03-08 11:36:18 PST
Megan Gardner
Comment 31 2018-03-08 11:48:45 PST
Megan Gardner
Comment 32 2018-03-08 13:24:17 PST
Megan Gardner
Comment 33 2018-03-08 13:46:15 PST
Tim Horton
Comment 34 2018-03-08 13:49:19 PST
Comment on attachment 335339 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=335339&action=review > Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp:89 > + if (element.document().page()) You could probably make this all a lot neater if you put a helper on document that did the null checking for you. Then you'd not need to sprinkle it throughout.
Megan Gardner
Comment 35 2018-03-08 16:19:14 PST
Tim Horton
Comment 36 2018-03-08 16:44:41 PST
Comment on attachment 335365 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=335365&action=review > Source/WebCore/page/Page.h:328 > +#if PLATFORM(MAC) If you do the same treatment here as you do in Document, you can avoid more #ifs elsewhere. > Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h:33 > -OBJC_CLASS NSAppearence; > +@class NSAppearance; OBJC_CLASS is generally preferred because it works in C++-only files too! There's no reason this header shouldn't be importable in C++ files. > Source/WebKit/ChangeLog:310 > +>>>>>>> .r229431 Please clean this up
Dean Jackson
Comment 37 2018-03-08 16:48:06 PST
Comment on attachment 335365 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=335365&action=review > Source/WebCore/html/canvas/CanvasStyle.cpp:118 > +CanvasStyle CanvasStyle::createFromString(const String& colorString, HTMLCanvasElement* canvas) There isn't anything you can do about this, but an OffscreenCanvas won't have a document, and thus won't be able to follow the system appearance. Although, maybe the system appearance query could be somewhere other than the document/page? Could it be on RenderTheme? > Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h:33 > -OBJC_CLASS NSAppearence; > +@class NSAppearance; Why change from OBJC_CLASS? > Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h:46 > RetainPtr<NSAppearance> m_savedSystemAppearance; > + bool m_didSetSystemAppearance; Rather than have the boolean, why not just check the nullness of m_savedSystemAppearance? > Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm:50 > + if (m_didSetSystemAppearance) > + [NSAppearance setCurrentAppearance:m_savedSystemAppearance.get()]; So this would become if (m_savedSystemAppearance) [NSApp....
Tim Horton
Comment 38 2018-03-08 16:56:04 PST
Comment on attachment 335365 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=335365&action=review > Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:944 > + setStrokeStyle(CanvasStyle::createFromStringWithOverrideAlpha(color, alpha.value(), &downcast<HTMLCanvasElement>(canvasBase()))); Dino says to leave it for now, but in the future: "hand in the canvasBase() itself, and then on canvasBase() add a virtual useSystemApperance() that HTMLCanvasElement implements and grabs from Page"
Megan Gardner
Comment 39 2018-03-08 17:24:29 PST
Megan Gardner
Comment 40 2018-03-08 18:17:07 PST
Megan Gardner
Comment 41 2018-03-08 19:54:23 PST
Wenson Hsieh
Comment 42 2018-03-08 20:10:32 PST
Comment on attachment 335387 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=335387&action=review > Source/WebKit/UIProcess/WebPageProxy.cpp:6961 > + if (useSystemAppearance == m_alwaysShowsHorizontalScroller) I think you meant to compare against m_useSystemAppearance, not m_alwaysShowsHorizontalScroller
Tim Horton
Comment 43 2018-03-08 20:15:03 PST
Comment on attachment 335387 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=335387&action=review > Source/WebCore/page/Page.h:706 > + bool m_useSystemAppearance {false}; Spaces inside the braces! > Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h:33 > -OBJC_CLASS NSAppearence; > +OBJC_CLASS NSAppearance; How did this even compile before? Maybe you don't need it? > Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm:36 > + This newline is wrong. > Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm:48 > + m_savedSystemAppearance = nil; Why bother? You're in the destructor. > Source/WebCore/rendering/RenderThemeMac.mm:500 > + return m_systemColorCache.ensure(cssValueID, [this, cssValueID, useSystemAppearance] () -> Color { Probably need to (perhaps in a future patch) clear this cache when things change > Source/WebKitLegacy/mac/WebView/WebView.mm:5195 > +#if PLATFORM(MAC) Do you still need these PLATFORM(MAC)s?
Megan Gardner
Comment 44 2018-03-08 20:39:07 PST
Megan Gardner
Comment 45 2018-03-08 21:01:21 PST
Alex Christensen
Comment 46 2018-03-09 10:54:35 PST
Comment on attachment 335389 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=335389&action=review > Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:442 > +@property (nonatomic, readwrite, setter=_setUseSystemAppearance:) BOOL _useSystemAppearance WK_API_AVAILABLE(macosx(WK_MAC_TBA)); Don't we need corresponding C API in WKPage.cpp?
Tim Horton
Comment 47 2018-03-09 11:01:14 PST
(In reply to Alex Christensen from comment #46) > Comment on attachment 335389 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=335389&action=review > > > Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:442 > > +@property (nonatomic, readwrite, setter=_setUseSystemAppearance:) BOOL _useSystemAppearance WK_API_AVAILABLE(macosx(WK_MAC_TBA)); > > Don't we need corresponding C API in WKPage.cpp? Hopefully not.
Note You need to log in before you can comment on or make changes to this bug.