Changeset 160137 in webkit


Ignore:
Timestamp:
Dec 4, 2013 3:43:37 PM (10 years ago)
Author:
andersca@apple.com
Message:

Make the estimatedProgress property observable using KVO
https://bugs.webkit.org/show_bug.cgi?id=125259

Reviewed by Dan Bernstein.

Source/WebKit2:

  • UIProcess/API/Cocoa/WKBrowsingContextController.mm:
  • UIProcess/PageLoadState.cpp:

(WebKit::PageLoadState::PageLoadState):
(WebKit::PageLoadState::reset):
(WebKit::PageLoadState::activeURL):
(WebKit::PageLoadState::estimatedProgress):
(WebKit::PageLoadState::setPendingAPIRequestURL):
(WebKit::PageLoadState::clearPendingAPIRequestURL):
(WebKit::PageLoadState::didStartProgress):
(WebKit::PageLoadState::didChangeProgress):
(WebKit::PageLoadState::didFinishProgress):

  • UIProcess/PageLoadState.h:

Move m_estimatedProgress to the page load state and call the observers when it changes.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::estimatedProgress):
(WebKit::WebPageProxy::didStartProgress):
(WebKit::WebPageProxy::didChangeProgress):
(WebKit::WebPageProxy::didFinishProgress):
(WebKit::WebPageProxy::resetState):
Call through to m_pageLoadState.

  • UIProcess/WebPageProxy.h:

Tools:

Bind the progress indicator value to the "estimatedProgress" property.

  • MiniBrowser/mac/WK2BrowserWindowController.m:

(-[WK2BrowserWindowController dealloc]):
(-[WK2BrowserWindowController awakeFromNib]):

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r160136 r160137  
     12013-12-04  Anders Carlsson  <andersca@apple.com>
     2
     3        Make the estimatedProgress property observable using KVO
     4        https://bugs.webkit.org/show_bug.cgi?id=125259
     5
     6        Reviewed by Dan Bernstein.
     7
     8        * UIProcess/API/Cocoa/WKBrowsingContextController.mm:
     9        * UIProcess/PageLoadState.cpp:
     10        (WebKit::PageLoadState::PageLoadState):
     11        (WebKit::PageLoadState::reset):
     12        (WebKit::PageLoadState::activeURL):
     13        (WebKit::PageLoadState::estimatedProgress):
     14        (WebKit::PageLoadState::setPendingAPIRequestURL):
     15        (WebKit::PageLoadState::clearPendingAPIRequestURL):
     16        (WebKit::PageLoadState::didStartProgress):
     17        (WebKit::PageLoadState::didChangeProgress):
     18        (WebKit::PageLoadState::didFinishProgress):
     19        * UIProcess/PageLoadState.h:
     20        Move m_estimatedProgress to the page load state and call the observers when it changes.
     21
     22        * UIProcess/WebPageProxy.cpp:
     23        (WebKit::WebPageProxy::WebPageProxy):
     24        (WebKit::WebPageProxy::estimatedProgress):
     25        (WebKit::WebPageProxy::didStartProgress):
     26        (WebKit::WebPageProxy::didChangeProgress):
     27        (WebKit::WebPageProxy::didFinishProgress):
     28        (WebKit::WebPageProxy::resetState):
     29        Call through to m_pageLoadState.
     30
     31        * UIProcess/WebPageProxy.h:
     32
    1332013-12-04  Nick Diego Yamane  <nick.yamane@openbossa.org>
    234
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm

    r160129 r160137  
    8282    }
    8383
     84    virtual void willChangeEstimatedProgress() OVERRIDE
     85    {
     86        [m_controller willChangeValueForKey:@"estimatedProgress"];
     87    }
     88
     89    virtual void didChangeEstimatedProgress() OVERRIDE
     90    {
     91        [m_controller didChangeValueForKey:@"estimatedProgress"];
     92    }
     93
    8494    WKBrowsingContextController *m_controller;
    8595};
  • trunk/Source/WebKit2/UIProcess/PageLoadState.cpp

    r160129 r160137  
    3131PageLoadState::PageLoadState()
    3232    : m_state(State::Finished)
     33    , m_estimatedProgress(0)
    3334{
    3435}
     
    6869    m_title = String();
    6970    callObserverCallback(&Observer::didChangeTitle);
     71
     72    callObserverCallback(&Observer::willChangeEstimatedProgress);
     73    m_estimatedProgress = 0;
     74    callObserverCallback(&Observer::didChangeEstimatedProgress);
    7075}
    7176
     
    96101    ASSERT_NOT_REACHED();
    97102    return String();
    98 
     103}
     104
     105// Always start progress at initialProgressValue. This helps provide feedback as
     106// soon as a load starts.
     107
     108static const double initialProgressValue = 0.1;
     109
     110double PageLoadState::estimatedProgress() const
     111{
     112    if (!m_pendingAPIRequestURL.isNull())
     113        return initialProgressValue;
     114
     115    return m_estimatedProgress;
    99116}
    100117
     
    106123void PageLoadState::setPendingAPIRequestURL(const String& pendingAPIRequestURL)
    107124{
     125    callObserverCallback(&Observer::willChangeEstimatedProgress);
    108126    m_pendingAPIRequestURL = pendingAPIRequestURL;
     127    callObserverCallback(&Observer::didChangeEstimatedProgress);
    109128}
    110129
    111130void PageLoadState::clearPendingAPIRequestURL()
    112131{
     132    callObserverCallback(&Observer::willChangeEstimatedProgress);
    113133    m_pendingAPIRequestURL = String();
     134    callObserverCallback(&Observer::didChangeEstimatedProgress);
    114135}
    115136
     
    192213    m_title = title;
    193214    callObserverCallback(&Observer::didChangeTitle);
     215}
     216
     217void PageLoadState::didStartProgress()
     218{
     219    callObserverCallback(&Observer::willChangeEstimatedProgress);
     220    m_estimatedProgress = initialProgressValue;
     221    callObserverCallback(&Observer::didChangeEstimatedProgress);
     222}
     223
     224void PageLoadState::didChangeProgress(double value)
     225{
     226    callObserverCallback(&Observer::willChangeEstimatedProgress);
     227    m_estimatedProgress = value;
     228    callObserverCallback(&Observer::didChangeEstimatedProgress);
     229}
     230
     231void PageLoadState::didFinishProgress()
     232{
     233    callObserverCallback(&Observer::willChangeEstimatedProgress);
     234    m_estimatedProgress = 1;
     235    callObserverCallback(&Observer::didChangeEstimatedProgress);
    194236}
    195237
  • trunk/Source/WebKit2/UIProcess/PageLoadState.h

    r160129 r160137  
    5151        virtual void willChangeTitle() = 0;
    5252        virtual void didChangeTitle() = 0;
     53
     54        virtual void willChangeEstimatedProgress() = 0;
     55        virtual void didChangeEstimatedProgress() = 0;
    5356    };
    5457
     
    6568
    6669    String activeURL() const;
     70
     71    double estimatedProgress() const;
    6772
    6873    const String& pendingAPIRequestURL() const;
     
    8590    void setTitle(const String&);
    8691
     92    void didStartProgress();
     93    void didChangeProgress(double);
     94    void didFinishProgress();
     95
    8796private:
    8897    static bool isLoadingState(State);
     
    104113
    105114    String m_title;
     115
     116    double m_estimatedProgress;
    106117};
    107118
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r159988 r160137  
    236236    , m_geolocationPermissionRequestManager(*this)
    237237    , m_notificationPermissionRequestManager(*this)
    238     , m_estimatedProgress(0)
    239238    , m_viewState(ViewState::NoFlags)
    240239    , m_backForwardList(WebBackForwardList::create(*this))
     
    20402039}
    20412040
    2042 // Always start progress at initialProgressValue. This helps provide feedback as
    2043 // soon as a load starts.
    2044 
    2045 static const double initialProgressValue = 0.1;
    2046 
    20472041double WebPageProxy::estimatedProgress() const
    20482042{
    2049     if (!m_pageLoadState.pendingAPIRequestURL().isNull())
    2050         return initialProgressValue;
    2051 
    2052     return m_estimatedProgress;
     2043    return m_pageLoadState.estimatedProgress();
    20532044}
    20542045
    20552046void WebPageProxy::didStartProgress()
    20562047{
    2057     m_estimatedProgress = initialProgressValue;
     2048    m_pageLoadState.didStartProgress();
    20582049
    20592050    m_loaderClient.didStartProgress(this);
     
    20622053void WebPageProxy::didChangeProgress(double value)
    20632054{
    2064     m_estimatedProgress = value;
     2055    m_pageLoadState.didChangeProgress(value);
    20652056
    20662057    m_loaderClient.didChangeProgress(this);
     
    20692060void WebPageProxy::didFinishProgress()
    20702061{
    2071     m_estimatedProgress = 1.0;
     2062    m_pageLoadState.didFinishProgress();
    20722063
    20732064    m_loaderClient.didFinishProgress(this);
     
    37583749
    37593750    m_activePopupMenu = 0;
    3760 
    3761     m_estimatedProgress = 0.0;
    37623751}
    37633752
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r160075 r160137  
    12071207    NotificationPermissionRequestManagerProxy m_notificationPermissionRequestManager;
    12081208
    1209     double m_estimatedProgress;
    1210 
    12111209    ViewState::Flags m_viewState;
    12121210
  • trunk/Tools/ChangeLog

    r160129 r160137  
     12013-12-04  Anders Carlsson  <andersca@apple.com>
     2
     3        Make the estimatedProgress property observable using KVO
     4        https://bugs.webkit.org/show_bug.cgi?id=125259
     5
     6        Reviewed by Dan Bernstein.
     7
     8        Bind the progress indicator value to the "estimatedProgress" property.
     9
     10        * MiniBrowser/mac/WK2BrowserWindowController.m:
     11        (-[WK2BrowserWindowController dealloc]):
     12        (-[WK2BrowserWindowController awakeFromNib]):
     13
    1142013-12-04  Anders Carlsson  <andersca@apple.com>
    215
  • trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m

    r160129 r160137  
    3737
    3838@interface WK2BrowserWindowController () <WKBrowsingContextPolicyDelegate>
    39 - (void)didStartProgress;
    40 - (void)didChangeProgress:(double)value;
    41 - (void)didFinishProgress;
    4239- (void)didStartProvisionalLoadForFrame:(WKFrameRef)frame;
    4340- (void)didCommitLoadForFrame:(WKFrameRef)frame;
     
    6966{
    7067    [progressIndicator unbind:NSHiddenBinding];
     68    [progressIndicator unbind:NSValueBinding];
    7169
    7270    WKRelease(_context);
     
    389387}
    390388 
    391 static void didStartProgress(WKPageRef page, const void *clientInfo)
    392 {
    393     [(WK2BrowserWindowController *)clientInfo didStartProgress];
    394 }
    395 
    396 static void didChangeProgress(WKPageRef page, const void *clientInfo)
    397 {
    398     [(WK2BrowserWindowController *)clientInfo didChangeProgress:WKPageGetEstimatedProgress(page)];
    399 }
    400 
    401 static void didFinishProgress(WKPageRef page, const void *clientInfo)
    402 {
    403     [(WK2BrowserWindowController *)clientInfo didFinishProgress];
    404 }
    405 
    406389static void didBecomeUnresponsive(WKPageRef page, const void *clientInfo)
    407390{
     
    619602
    620603    [progressIndicator bind:NSHiddenBinding toObject:_webView.browsingContextController withKeyPath:@"loading" options:@{ NSValueTransformerNameBindingOption : NSNegateBooleanTransformerName }];
     604    [progressIndicator bind:NSValueBinding toObject:_webView.browsingContextController withKeyPath:@"estimatedProgress" options:nil];
    621605
    622606    WKPageLoaderClientV3 loadClient = {
     
    638622        0, // canAuthenticateAgainstProtectionSpaceInFrame
    639623        0, // didReceiveAuthenticationChallengeInFrame
    640         didStartProgress,
    641         didChangeProgress,
    642         didFinishProgress,
     624        0, // didStartProgress,
     625        0, // didChangeProgress,
     626        0, // didFinishProgress,
    643627        didBecomeUnresponsive,
    644628        didBecomeResponsive,
     
    715699}
    716700
    717 - (void)didStartProgress
    718 {
    719     [progressIndicator setDoubleValue:0.0];
    720 }
    721 
    722 - (void)didChangeProgress:(double)value
    723 {
    724     [progressIndicator setDoubleValue:value];
    725 }
    726 
    727 - (void)didFinishProgress
    728 {
    729     [progressIndicator setDoubleValue:1.0];
    730 }
    731 
    732701- (void)updateTextFieldFromURL:(WKURLRef)URLRef
    733702{
Note: See TracChangeset for help on using the changeset viewer.