Title: [237537] branches/safari-606-branch/Source/WebCore
Revision
237537
Author
[email protected]
Date
2018-10-28 22:33:42 -0700 (Sun, 28 Oct 2018)

Log Message

Cherry-pick r237466. rdar://problem/45562436

    Use dark appearance scrollbar when page background is dark or document supports dark mode.
    https://bugs.webkit.org/show_bug.cgi?id=190937
    rdar://problem/41225839

    Reviewed by Beth Dakin.

    Source/WebCore:

    * page/FrameView.cpp:
    (WebCore::FrameView::useDarkAppearance const): Added. Ask the document.
    (WebCore::FrameView::paintScrollCorner): Set LocalDefaultSystemAppearance based
    on the scrollbar overlay style too.
    * page/FrameView.h:
    * platform/ScrollableArea.h:
    (WebCore::ScrollableArea::useDarkAppearance const): Added. Default to false.
    * platform/mac/ScrollAnimatorMac.mm:
    (-[WebScrollerImpDelegate effectiveAppearanceForScrollerImp:]): Added.
    Ask the ScrollableArea if a dark appearance is desired.

    Source/WebCore/PAL:

    * pal/spi/mac/NSScrollerImpSPI.h: Added effectiveAppearanceForScrollerImp:.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237466 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-606-branch/Source/WebCore/ChangeLog (237536 => 237537)


--- branches/safari-606-branch/Source/WebCore/ChangeLog	2018-10-29 02:01:38 UTC (rev 237536)
+++ branches/safari-606-branch/Source/WebCore/ChangeLog	2018-10-29 05:33:42 UTC (rev 237537)
@@ -1,5 +1,54 @@
 2018-10-28  Babak Shafiei  <[email protected]>
 
+        Cherry-pick r237466. rdar://problem/45562436
+
+    Use dark appearance scrollbar when page background is dark or document supports dark mode.
+    https://bugs.webkit.org/show_bug.cgi?id=190937
+    rdar://problem/41225839
+    
+    Reviewed by Beth Dakin.
+    
+    Source/WebCore:
+    
+    * page/FrameView.cpp:
+    (WebCore::FrameView::useDarkAppearance const): Added. Ask the document.
+    (WebCore::FrameView::paintScrollCorner): Set LocalDefaultSystemAppearance based
+    on the scrollbar overlay style too.
+    * page/FrameView.h:
+    * platform/ScrollableArea.h:
+    (WebCore::ScrollableArea::useDarkAppearance const): Added. Default to false.
+    * platform/mac/ScrollAnimatorMac.mm:
+    (-[WebScrollerImpDelegate effectiveAppearanceForScrollerImp:]): Added.
+    Ask the ScrollableArea if a dark appearance is desired.
+    
+    Source/WebCore/PAL:
+    
+    * pal/spi/mac/NSScrollerImpSPI.h: Added effectiveAppearanceForScrollerImp:.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237466 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-10-26  Timothy Hatcher  <[email protected]>
+
+            Use dark appearance scrollbar when page background is dark or document supports dark mode.
+            https://bugs.webkit.org/show_bug.cgi?id=190937
+            rdar://problem/41225839
+
+            Reviewed by Beth Dakin.
+
+            * page/FrameView.cpp:
+            (WebCore::FrameView::useDarkAppearance const): Added. Ask the document.
+            (WebCore::FrameView::paintScrollCorner): Set LocalDefaultSystemAppearance based
+            on the scrollbar overlay style too.
+            * page/FrameView.h:
+            * platform/ScrollableArea.h:
+            (WebCore::ScrollableArea::useDarkAppearance const): Added. Default to false.
+            * platform/mac/ScrollAnimatorMac.mm:
+            (-[WebScrollerImpDelegate effectiveAppearanceForScrollerImp:]): Added.
+            Ask the ScrollableArea if a dark appearance is desired.
+
+2018-10-28  Babak Shafiei  <[email protected]>
+
         Cherry-pick r237060. rdar://problem/45435468
 
     IOS 12 - Service worker cache not shared when added to homescreen

Modified: branches/safari-606-branch/Source/WebCore/PAL/ChangeLog (237536 => 237537)


--- branches/safari-606-branch/Source/WebCore/PAL/ChangeLog	2018-10-29 02:01:38 UTC (rev 237536)
+++ branches/safari-606-branch/Source/WebCore/PAL/ChangeLog	2018-10-29 05:33:42 UTC (rev 237537)
@@ -1,5 +1,45 @@
 2018-10-28  Babak Shafiei  <[email protected]>
 
+        Cherry-pick r237466. rdar://problem/45562436
+
+    Use dark appearance scrollbar when page background is dark or document supports dark mode.
+    https://bugs.webkit.org/show_bug.cgi?id=190937
+    rdar://problem/41225839
+    
+    Reviewed by Beth Dakin.
+    
+    Source/WebCore:
+    
+    * page/FrameView.cpp:
+    (WebCore::FrameView::useDarkAppearance const): Added. Ask the document.
+    (WebCore::FrameView::paintScrollCorner): Set LocalDefaultSystemAppearance based
+    on the scrollbar overlay style too.
+    * page/FrameView.h:
+    * platform/ScrollableArea.h:
+    (WebCore::ScrollableArea::useDarkAppearance const): Added. Default to false.
+    * platform/mac/ScrollAnimatorMac.mm:
+    (-[WebScrollerImpDelegate effectiveAppearanceForScrollerImp:]): Added.
+    Ask the ScrollableArea if a dark appearance is desired.
+    
+    Source/WebCore/PAL:
+    
+    * pal/spi/mac/NSScrollerImpSPI.h: Added effectiveAppearanceForScrollerImp:.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237466 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-10-26  Timothy Hatcher  <[email protected]>
+
+            Use dark appearance scrollbar when page background is dark or document supports dark mode.
+            https://bugs.webkit.org/show_bug.cgi?id=190937
+            rdar://problem/41225839
+
+            Reviewed by Beth Dakin.
+
+            * pal/spi/mac/NSScrollerImpSPI.h: Added effectiveAppearanceForScrollerImp:.
+
+2018-10-28  Babak Shafiei  <[email protected]>
+
         Apply patch. rdar://problem/45523764
 
     2018-10-28  John Wilander  <[email protected]>

Modified: branches/safari-606-branch/Source/WebCore/PAL/pal/spi/mac/NSScrollerImpSPI.h (237536 => 237537)


--- branches/safari-606-branch/Source/WebCore/PAL/pal/spi/mac/NSScrollerImpSPI.h	2018-10-29 02:01:38 UTC (rev 237536)
+++ branches/safari-606-branch/Source/WebCore/PAL/pal/spi/mac/NSScrollerImpSPI.h	2018-10-29 05:33:42 UTC (rev 237537)
@@ -106,6 +106,7 @@
 - (NSPoint)mouseLocationInScrollerForScrollerImp:(NSScrollerImp *)scrollerImp;
 - (NSRect)convertRectToLayer:(NSRect)aRect;
 - (BOOL)shouldUseLayerPerPartForScrollerImp:(NSScrollerImp *)scrollerImp;
+- (NSAppearance *)effectiveAppearanceForScrollerImp:(NSScrollerImp *)scrollerImp;
 @end
 
 @protocol NSScrollerImpPairDelegate;

Modified: branches/safari-606-branch/Source/WebCore/page/FrameView.cpp (237536 => 237537)


--- branches/safari-606-branch/Source/WebCore/page/FrameView.cpp	2018-10-29 02:01:38 UTC (rev 237536)
+++ branches/safari-606-branch/Source/WebCore/page/FrameView.cpp	2018-10-29 05:33:42 UTC (rev 237537)
@@ -118,6 +118,10 @@
 #include "LegacyTileCache.h"
 #endif
 
+#if PLATFORM(MAC)
+#include "LocalDefaultSystemAppearance.h"
+#endif
+
 #define RELEASE_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(frame().page() && frame().page()->isAlwaysOnLoggingAllowed(), Layout, "%p - FrameView::" fmt, this, ##__VA_ARGS__)
 
 namespace WebCore {
@@ -2024,6 +2028,13 @@
     return page && page->isVisible() && page->focusController().isActive();
 }
 
+bool FrameView::useDarkAppearance() const
+{
+    ASSERT(frame().document());
+    auto& document = *frame().document();
+    return document.useSystemAppearance() && document.useDarkAppearance();
+}
+
 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect)
 {
     if (!m_viewportConstrainedObjects || m_viewportConstrainedObjects->isEmpty()) {
@@ -3881,6 +3892,14 @@
         return;
     }
 
+#if PLATFORM(MAC)
+    // If dark appearance is used or the overlay style is light (because of a dark page background), set the dark apppearance.
+    // Keep this in sync with ScrollAnimatorMac's effectiveAppearanceForScrollerImp:.
+    auto* document = frame().document();
+    bool useDarkAppearance = (document && document->useSystemAppearance() && document->useDarkAppearance()) || scrollbarOverlayStyle() == WebCore::ScrollbarOverlayStyleLight;
+    LocalDefaultSystemAppearance localAppearance(true, useDarkAppearance);
+#endif
+
     ScrollView::paintScrollCorner(context, cornerRect);
 }
 

Modified: branches/safari-606-branch/Source/WebCore/page/FrameView.h (237536 => 237537)


--- branches/safari-606-branch/Source/WebCore/page/FrameView.h	2018-10-29 02:01:38 UTC (rev 237536)
+++ branches/safari-606-branch/Source/WebCore/page/FrameView.h	2018-10-29 05:33:42 UTC (rev 237537)
@@ -503,6 +503,8 @@
     bool isHandlingWheelEvent() const final;
     bool shouldSetCursor() const;
 
+    bool useDarkAppearance() const final;
+
     // FIXME: Remove this method once plugin loading is decoupled from layout.
     void flushAnyPendingPostLayoutTasks();
 

Modified: branches/safari-606-branch/Source/WebCore/platform/ScrollableArea.h (237536 => 237537)


--- branches/safari-606-branch/Source/WebCore/platform/ScrollableArea.h	2018-10-29 02:01:38 UTC (rev 237536)
+++ branches/safari-606-branch/Source/WebCore/platform/ScrollableArea.h	2018-10-29 05:33:42 UTC (rev 237537)
@@ -251,6 +251,8 @@
     // The totalContentsSize() is equivalent to the contentsSize() plus the header and footer heights.
     WEBCORE_EXPORT IntSize totalContentsSize() const;
 
+    virtual bool useDarkAppearance() const { return false; }
+
     virtual bool shouldSuspendScrollAnimations() const { return true; }
     WEBCORE_EXPORT virtual void scrollbarStyleChanged(ScrollbarStyle /*newStyle*/, bool /*forceUpdate*/);
     virtual void setVisibleScrollerThumbRect(const IntRect&) { }

Modified: branches/safari-606-branch/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (237536 => 237537)


--- branches/safari-606-branch/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2018-10-29 02:01:38 UTC (rev 237536)
+++ branches/safari-606-branch/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2018-10-29 05:33:42 UTC (rev 237537)
@@ -527,6 +527,21 @@
     return _scrollbar->supportsUpdateOnSecondaryThread();
 }
 
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+- (NSAppearance *)effectiveAppearanceForScrollerImp:(NSScrollerImp *)scrollerImp
+{
+    UNUSED_PARAM(scrollerImp);
+
+    if (!_scrollbar)
+        return [NSAppearance currentAppearance];
+
+    // If dark appearance is used or the overlay style is light (because of a dark page background), return the dark apppearance.
+    // Keep this in sync with FrameView::paintScrollCorner.
+    bool useDarkAppearance = _scrollbar->scrollableArea().useDarkAppearance() || _scrollbar->scrollableArea().scrollbarOverlayStyle() == WebCore::ScrollbarOverlayStyleLight;
+    return [NSAppearance appearanceNamed:useDarkAppearance ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua];
+}
+#endif
+
 - (void)setUpAlphaAnimation:(RetainPtr<WebScrollbarPartAnimation>&)scrollbarPartAnimation scrollerPainter:(NSScrollerImp *)scrollerPainter part:(WebCore::ScrollbarPart)part animateAlphaTo:(CGFloat)newAlpha duration:(NSTimeInterval)duration
 {
     // If the user has scrolled the page, then the scrollbars must be animated here.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to