Changeset 101290 in webkit


Ignore:
Timestamp:
Nov 28, 2011 3:06:56 PM (12 years ago)
Author:
Beth Dakin
Message:

https://bugs.webkit.org/show_bug.cgi?id=72551
When the recommended scrollbar style changes, WKView's tracking options should
adjust accordingly
-and corresponding-
<rdar://problem/10409328>

Reviewed by Darin Adler.

Source/WebCore:

This new ChromeClient function is called when the recommended scrollbar style
changes. This way, WebKit can respond to the change by adjusting its mouse
tracking.

  • page/ChromeClient.h:

(WebCore::ChromeClient::recommendedScrollbarStyleDidChange):

Existing ScrollableArea function scrollbarStyleChanged() now takes an int
indicating the new scrollbar style and a bool indicating whether it is necessary
to force an update. It used to be the case that this function was ONLY used to
force an update (and only called when an updated was needed), but now that it must
also call into the ChromeClient, it is necessary to include a bool tracking
whether we need to force an update. New implementation on FrameView is responsible
for calling ChromeClient, and then that calls into the pre-existing ScrollView
function for the forceUpdate part.

  • page/FrameView.cpp:

(WebCore::FrameView::scrollbarStyleChanged):

  • page/FrameView.h:
  • platform/ScrollView.cpp:

(WebCore::ScrollView:: scrollbarStyleChanged):

  • platform/ScrollView.h:
  • platform/ScrollableArea.h:

(WebCore::ScrollableArea::scrollbarStyleChanged):

  • platform/mac/ScrollAnimatorMac.mm:

(WebCore::ScrollAnimatorMac::updateScrollerStyle):

Source/WebKit2:

These new functions take care of passing along the
recommendedScrollbarStyleDidChange() message that originates in the ChromeClient.

  • UIProcess/API/mac/PageClientImpl.h:
  • UIProcess/PageClient.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::recommendedScrollbarStyleDidChange):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • WebProcess/WebCoreSupport/WebChromeClient.cpp:

(WebKit::WebChromeClient::recommendedScrollbarStyleDidChange):

  • WebProcess/WebCoreSupport/WebChromeClient.h:

This is where we actually respond to the recommendedScrollbarStyleDidChange
message. We remove the existing tracking area and create a new tracking area with
the appropriate tracking options.

  • UIProcess/API/mac/PageClientImpl.mm:

(WebKit::PageClientImpl::recommendedScrollbarStyleDidChange):

BuiltInPDFView inherits from WebCore::ScrollableArea, so scrollbarStyleChanged()
must now take two parameters like the one in ScrollableArea.

  • WebProcess/Plugins/PDF/BuiltInPDFView.cpp:

(WebKit::BuiltInPDFView::scrollbarStyleChanged):

  • WebProcess/Plugins/PDF/BuiltInPDFView.h:
Location:
trunk/Source
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r101288 r101290  
     12011-11-28  Beth Dakin  <bdakin@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=72551
     4        When the recommended scrollbar style changes, WKView's tracking options should
     5        adjust accordingly
     6        -and corresponding-
     7        <rdar://problem/10409328>
     8
     9        Reviewed by Darin Adler.
     10
     11        This new ChromeClient function is called when the recommended scrollbar style
     12        changes. This way, WebKit can respond to the change by adjusting its mouse
     13        tracking.
     14        * page/ChromeClient.h:
     15        (WebCore::ChromeClient::recommendedScrollbarStyleDidChange):
     16
     17        Existing ScrollableArea function scrollbarStyleChanged() now takes an int
     18        indicating the new scrollbar style and a bool indicating whether it is necessary
     19        to force an update. It used to be the case that this function was ONLY used to
     20        force an update (and only called when an updated was needed), but now that it must
     21        also call into the ChromeClient, it is necessary to include a bool tracking
     22        whether we need to force an update. New implementation on FrameView is responsible
     23        for calling ChromeClient, and then that calls into the pre-existing ScrollView
     24        function for the forceUpdate part.
     25        * page/FrameView.cpp:
     26        (WebCore::FrameView::scrollbarStyleChanged):
     27        * page/FrameView.h:
     28        * platform/ScrollView.cpp:
     29        (WebCore::ScrollView:: scrollbarStyleChanged):
     30        * platform/ScrollView.h:
     31        * platform/ScrollableArea.h:
     32        (WebCore::ScrollableArea::scrollbarStyleChanged):
     33        * platform/mac/ScrollAnimatorMac.mm:
     34        (WebCore::ScrollAnimatorMac::updateScrollerStyle):
     35
    1362011-11-28  Julien Chaffraix  <jchaffraix@webkit.org>
    237
  • trunk/Source/WebCore/page/ChromeClient.h

    r100842 r101290  
    326326       
    327327        virtual void notifyScrollerThumbIsVisibleInRect(const IntRect&) { }
     328        virtual void recommendedScrollbarStyleDidChange(int /*newStyle*/) { }
    328329
    329330        enum DialogType {
  • trunk/Source/WebCore/page/FrameView.cpp

    r100842 r101290  
    24492449}
    24502450
     2451void FrameView::scrollbarStyleChanged(int newStyle, bool forceUpdate)
     2452{
     2453    Page* page = m_frame->page();
     2454    if (!page)
     2455        return;
     2456    if (page->mainFrame() != m_frame)
     2457        return;
     2458    page->chrome()->client()->recommendedScrollbarStyleDidChange(newStyle);
     2459
     2460    if (forceUpdate)
     2461        ScrollView::scrollbarStyleChanged(newStyle, forceUpdate);
     2462}
     2463
    24512464void FrameView::setAnimatorsAreActive()
    24522465{
  • trunk/Source/WebCore/page/FrameView.h

    r100842 r101290  
    293293
    294294    virtual bool shouldSuspendScrollAnimations() const;
     295    virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate);
    295296
    296297    void setAnimatorsAreActive();
  • trunk/Source/WebCore/platform/ScrollView.cpp

    r100842 r101290  
    974974}
    975975
    976 void ScrollView::scrollbarStyleChanged()
    977 {
     976void ScrollView::scrollbarStyleChanged(int, bool forceUpdate)
     977{
     978    if (!forceUpdate)
     979        return;
     980
    978981    contentsResized();
    979982    updateScrollbars(scrollOffset());
  • trunk/Source/WebCore/platform/ScrollView.h

    r100842 r101290  
    6060    virtual void notifyPageThatContentAreaWillPaint() const;
    6161    virtual bool isScrollCornerVisible() const;
    62     virtual void scrollbarStyleChanged();
     62    virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate);
    6363
    6464    // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea.
  • trunk/Source/WebCore/platform/ScrollableArea.h

    r100842 r101290  
    140140   
    141141    virtual bool shouldSuspendScrollAnimations() const { return true; }
    142     virtual void scrollbarStyleChanged() { }
     142    virtual void scrollbarStyleChanged(int /*newStyle*/, bool /*forceUpdate*/) { }
    143143    virtual void setVisibleScrollerThumbRect(const IntRect&) { }
    144144
  • trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm

    r100842 r101290  
    14621462    // If needsScrollerStyleUpdate() is true, then the page is restoring from the page cache, and
    14631463    // a relayout will happen on its own. Otherwise, we must initiate a re-layout ourselves.
    1464     if (!needsScrollerStyleUpdate())
    1465         scrollableArea()->scrollbarStyleChanged();
     1464    scrollableArea()->scrollbarStyleChanged(newStyle, !needsScrollerStyleUpdate());
    14661465
    14671466    setNeedsScrollerStyleUpdate(false);
  • trunk/Source/WebKit2/ChangeLog

    r101269 r101290  
     12011-11-28  Beth Dakin  <bdakin@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=72551
     4        When the recommended scrollbar style changes, WKView's tracking options should
     5        adjust accordingly
     6        -and corresponding-
     7        <rdar://problem/10409328>
     8
     9        Reviewed by Darin Adler.
     10
     11        These new functions take care of passing along the
     12        recommendedScrollbarStyleDidChange() message that originates in the ChromeClient.
     13        * UIProcess/API/mac/PageClientImpl.h:
     14        * UIProcess/PageClient.h:
     15        * UIProcess/WebPageProxy.cpp:
     16        (WebKit::WebPageProxy::recommendedScrollbarStyleDidChange):
     17        * UIProcess/WebPageProxy.h:
     18        * UIProcess/WebPageProxy.messages.in:
     19        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     20        (WebKit::WebChromeClient::recommendedScrollbarStyleDidChange):
     21        * WebProcess/WebCoreSupport/WebChromeClient.h:
     22
     23        This is where we actually respond to the recommendedScrollbarStyleDidChange
     24        message. We remove the existing tracking area and create a new tracking area with
     25        the appropriate tracking options.
     26        * UIProcess/API/mac/PageClientImpl.mm:
     27        (WebKit::PageClientImpl::recommendedScrollbarStyleDidChange):
     28
     29        BuiltInPDFView inherits from WebCore::ScrollableArea, so scrollbarStyleChanged()
     30        must now take two parameters like the one in ScrollableArea.
     31        * WebProcess/Plugins/PDF/BuiltInPDFView.cpp:
     32        (WebKit::BuiltInPDFView::scrollbarStyleChanged):
     33        * WebProcess/Plugins/PDF/BuiltInPDFView.h:
     34
    1352011-11-28  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
    236
  • trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h

    r100842 r101290  
    123123    virtual void recordAutocorrectionResponse(WebCore::EditorClient::AutocorrectionResponseType, const String& replacedString, const String& replacementString);
    124124
     125    virtual void recommendedScrollbarStyleDidChange(int32_t newStyle);
     126
    125127    virtual WKView* wkView() const { return m_wkView; }
    126128
  • trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm

    r100842 r101290  
    461461}
    462462
     463void PageClientImpl::recommendedScrollbarStyleDidChange(int32_t newStyle)
     464{
     465#if !defined(BUILDING_ON_SNOW_LEOPARD)
     466    NSArray *trackingAreas = [m_wkView trackingAreas];
     467    NSUInteger count = [trackingAreas count];
     468    ASSERT(count == 1);
     469   
     470    for (NSUInteger i = 0; i < count; ++i)
     471        [m_wkView removeTrackingArea:[trackingAreas objectAtIndex:i]];
     472
     473    // Now re-create a tracking area with the appropriate options given the new scrollbar style
     474    NSTrackingAreaOptions options = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect;
     475    if (newStyle == NSScrollerStyleLegacy)
     476        options |= NSTrackingActiveAlways;
     477    else
     478        options |= NSTrackingActiveInKeyWindow;
     479
     480    NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:[m_wkView frame]
     481                                                                options:options
     482                                                                  owner:m_wkView
     483                                                               userInfo:nil];
     484    [m_wkView addTrackingArea:trackingArea];
     485    [trackingArea release];
     486#else
     487    UNUSED_PARAM(newStyle);
     488#endif
     489}
     490
    463491bool PageClientImpl::executeSavedCommandBySelector(const String& selectorString)
    464492{
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r100842 r101290  
    178178    virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel) = 0;
    179179    virtual void recordAutocorrectionResponse(WebCore::EditorClient::AutocorrectionResponseType, const String& replacedString, const String& replacementString) = 0;
     180    virtual void recommendedScrollbarStyleDidChange(int32_t newStyle) = 0;
    180181   
    181182    virtual WKView* wkView() const = 0;
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r101259 r101290  
    33033303}
    33043304
     3305void WebPageProxy::recommendedScrollbarStyleDidChange(int32_t newStyle)
     3306{
     3307#if PLATFORM(MAC)
     3308    m_pageClient->recommendedScrollbarStyleDidChange(newStyle);
     3309#endif
     3310}
     3311
    33053312void WebPageProxy::didChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar)
    33063313{
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r100842 r101290  
    671671    void runModal();
    672672    void notifyScrollerThumbIsVisibleInRect(const WebCore::IntRect&);
     673    void recommendedScrollbarStyleDidChange(int32_t newStyle);
    673674    void didChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar);
    674675    void didChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide);
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r100842 r101290  
    6262    RunModal()
    6363    NotifyScrollerThumbIsVisibleInRect(WebCore::IntRect scrollerThumb)
     64    RecommendedScrollbarStyleDidChange(int32_t newStyle)
    6465    DidChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar)
    6566    DidChangeScrollOffsetPinningForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar)
  • trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp

    r100842 r101290  
    673673}
    674674
    675 void BuiltInPDFView::scrollbarStyleChanged()
    676 {
     675void BuiltInPDFView::scrollbarStyleChanged(int, bool forceUpdate)
     676{
     677    if (!forceUpdate)
     678        return;
     679
    677680    // If the PDF was scrolled all the way to bottom right and scrollbars change to overlay style, we don't want to display white rectangles where scrollbars were.
    678681    IntPoint newScrollOffset = IntPoint(m_scrollOffset).shrunkTo(maximumScrollPosition());
  • trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h

    r100842 r101290  
    135135    virtual void disconnectFromPage() { m_page = 0; }
    136136    virtual bool shouldSuspendScrollAnimations() const { return false; } // If we return true, ScrollAnimatorMac will keep cycling a timer forever, waiting for a good time to animate.
    137     virtual void scrollbarStyleChanged();
     137    virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate);
    138138    virtual void zoomAnimatorTransformChanged(float, float, float, ZoomAnimationState) { }
    139139
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r101167 r101290  
    781781}
    782782
     783void WebChromeClient::recommendedScrollbarStyleDidChange(int32_t newStyle)
     784{
     785    m_page->send(Messages::WebPageProxy::RecommendedScrollbarStyleDidChange(newStyle));
     786}
     787
    783788bool WebChromeClient::shouldRubberBandInDirection(WebCore::ScrollDirection direction) const
    784789{
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h

    r100842 r101290  
    215215
    216216    virtual void notifyScrollerThumbIsVisibleInRect(const WebCore::IntRect&) OVERRIDE;
     217    virtual void recommendedScrollbarStyleDidChange(int32_t newStyle) OVERRIDE;
    217218    virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const OVERRIDE;
    218219   
Note: See TracChangeset for help on using the changeset viewer.