Changeset 160129 in webkit


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

Add a loading property to WKBrowsingContextController
https://bugs.webkit.org/show_bug.cgi?id=125256

Reviewed by Dan Bernstein.

Source/WebKit2:

  • UIProcess/API/Cocoa/WKBrowsingContextController.h:

Add loading property.

  • UIProcess/API/Cocoa/WKBrowsingContextConteroller.mm:

Implement willChangeIsLoading and didChangeIsLoading and call the relevant KVO methods.

(-[WKBrowsingContextController isLoading]):
Call through to the PageLoadState.

  • UIProcess/PageLoadState.cpp:

(WebKit::PageLoadState::reset):
Use setState.

(WebKit::PageLoadState::isLoading):
Call isLoadingState.

(WebKit::PageLoadState::didStartProvisionalLoad):
Use setState.

(WebKit::PageLoadState::didFailProvisionalLoad):
Use setState.

(WebKit::PageLoadState::didCommitLoad):
Use setState.

(WebKit::PageLoadState::didFinishLoad):
Use setState.

(WebKit::PageLoadState::didFailLoad):
Use setState.

(WebKit::PageLoadState::isLoadingState):
Helper function for determining whether a state is a loading state or not.

(WebKit::PageLoadState::setState):
If setting the state will cause "isLoading" to change, call out to the observers.

  • UIProcess/PageLoadState.h:

Tools:

Bind the progress indicator visibility to the "loading" property.

  • MiniBrowser/mac/WK2BrowserWindowController.m:

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

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r160128 r160129  
     12013-12-04  Anders Carlsson  <andersca@apple.com>
     2
     3        Add a loading property to WKBrowsingContextController
     4        https://bugs.webkit.org/show_bug.cgi?id=125256
     5
     6        Reviewed by Dan Bernstein.
     7
     8        * UIProcess/API/Cocoa/WKBrowsingContextController.h:
     9        Add loading property.
     10
     11        * UIProcess/API/Cocoa/WKBrowsingContextConteroller.mm:
     12        Implement willChangeIsLoading and didChangeIsLoading and call the relevant KVO methods.
     13
     14        (-[WKBrowsingContextController isLoading]):
     15        Call through to the PageLoadState.
     16
     17        * UIProcess/PageLoadState.cpp:
     18        (WebKit::PageLoadState::reset):
     19        Use setState.
     20
     21        (WebKit::PageLoadState::isLoading):
     22        Call isLoadingState.
     23
     24        (WebKit::PageLoadState::didStartProvisionalLoad):
     25        Use setState.
     26
     27        (WebKit::PageLoadState::didFailProvisionalLoad):
     28        Use setState.
     29
     30        (WebKit::PageLoadState::didCommitLoad):
     31        Use setState.
     32
     33        (WebKit::PageLoadState::didFinishLoad):
     34        Use setState.
     35
     36        (WebKit::PageLoadState::didFailLoad):
     37        Use setState.
     38
     39        (WebKit::PageLoadState::isLoadingState):
     40        Helper function for determining whether a state is a loading state or not.
     41
     42        (WebKit::PageLoadState::setState):
     43        If setting the state will cause "isLoading" to change, call out to the observers.
     44
     45        * UIProcess/PageLoadState.h:
     46
    1472013-12-04  Nick Diego Yamane  <nick.yamane@openbossa.org>
    248
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.h

    r159875 r160129  
    107107#pragma mark Active Load Introspection
    108108
     109@property (readonly, getter=isLoading) BOOL loading;
     110
    109111/* URL for the active load. This is the URL that should be shown in user interface. */
    110112@property(readonly) NSURL *activeURL;
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm

    r160104 r160129  
    6262
    6363private:
     64    virtual void willChangeIsLoading() OVERRIDE
     65    {
     66        [m_controller willChangeValueForKey:@"loading"];
     67    }
     68
     69    virtual void didChangeIsLoading() OVERRIDE
     70    {
     71        [m_controller didChangeValueForKey:@"loading"];
     72    }
     73
    6474    virtual void willChangeTitle() OVERRIDE
    6575    {
     
    269279
    270280#pragma mark Active Load Introspection
     281
     282- (BOOL)isLoading
     283{
     284    return _page->pageLoadState().isLoading();
     285}
    271286
    272287- (NSURL *)activeURL
  • trunk/Source/WebKit2/UIProcess/PageLoadState.cpp

    r159701 r160129  
    5656void PageLoadState::reset()
    5757{
    58     m_state = State::Finished;
     58    setState(State::Finished);
     59
    5960    m_pendingAPIRequestURL = String();
    6061    m_provisionalURL = String();
     
    6768    m_title = String();
    6869    callObserverCallback(&Observer::didChangeTitle);
     70}
     71
     72bool PageLoadState::isLoading() const
     73{
     74    return isLoadingState(m_state);
    6975}
    7076
     
    112118    ASSERT(m_provisionalURL.isEmpty());
    113119
    114     m_state = State::Provisional;
     120    setState(State::Provisional);
     121
    115122    m_provisionalURL = url;
    116123
     
    129136    ASSERT(m_state == State::Provisional);
    130137
    131     m_state = State::Finished;
     138    setState(State::Finished);
     139
    132140    m_provisionalURL = String();
    133141    m_unreachableURL = m_lastUnreachableURL;
     
    138146    ASSERT(m_state == State::Provisional);
    139147
    140     m_state = State::Committed;
     148    setState(State::Committed);
     149
    141150    m_url = m_provisionalURL;
    142151    m_provisionalURL = String();
     
    150159    ASSERT(m_provisionalURL.isEmpty());
    151160
    152     m_state = State::Finished;
     161    setState(State::Finished);
    153162}
    154163
     
    157166    ASSERT(m_provisionalURL.isEmpty());
    158167
    159     m_state = State::Finished;
     168    setState(State::Finished);
    160169}
    161170
     
    185194}
    186195
     196bool PageLoadState::isLoadingState(State state)
     197{
     198    switch (state) {
     199    case State::Provisional:
     200    case State::Committed:
     201        return true;
     202
     203    case State::Finished:
     204        return false;
     205    }
     206
     207    ASSERT_NOT_REACHED();
     208    return false;
     209}
     210
     211void PageLoadState::setState(State state)
     212{
     213    if (m_state == state)
     214        return;
     215
     216    bool isLoadingIsChanging = false;
     217
     218    if (isLoadingState(m_state) != isLoadingState(state))
     219        isLoadingIsChanging = true;
     220
     221    if (isLoadingIsChanging)
     222        callObserverCallback(&Observer::willChangeIsLoading);
     223
     224    m_state = state;
     225
     226    if (isLoadingIsChanging)
     227        callObserverCallback(&Observer::didChangeIsLoading);
     228}
     229
    187230void PageLoadState::callObserverCallback(void (Observer::*callback)())
    188231{
  • trunk/Source/WebKit2/UIProcess/PageLoadState.h

    r159701 r160129  
    4646        virtual ~Observer() { }
    4747
     48        virtual void willChangeIsLoading() = 0;
     49        virtual void didChangeIsLoading() = 0;
     50
    4851        virtual void willChangeTitle() = 0;
    4952        virtual void didChangeTitle() = 0;
     
    5457
    5558    void reset();
     59
     60    bool isLoading() const;
    5661
    5762    const String& provisionalURL() const { return m_provisionalURL; }
     
    8186
    8287private:
     88    static bool isLoadingState(State);
     89    void setState(State);
     90
    8391    void callObserverCallback(void (Observer::*)());
    8492
  • trunk/Tools/ChangeLog

    r160128 r160129  
     12013-12-04  Anders Carlsson  <andersca@apple.com>
     2
     3        Add a loading property to WKBrowsingContextController
     4        https://bugs.webkit.org/show_bug.cgi?id=125256
     5
     6        Reviewed by Dan Bernstein.
     7
     8        Bind the progress indicator visibility to the "loading" property.
     9
     10        * MiniBrowser/mac/WK2BrowserWindowController.m:
     11        (-[WK2BrowserWindowController dealloc]):
     12        (-[WK2BrowserWindowController awakeFromNib]):
     13        (-[WK2BrowserWindowController didStartProgress]):
     14        (-[WK2BrowserWindowController didFinishProgress]):
     15
    1162013-12-04  Nick Diego Yamane  <nick.yamane@openbossa.org>
    217
  • trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m

    r160104 r160129  
    6868- (void)dealloc
    6969{
     70    [progressIndicator unbind:NSHiddenBinding];
     71
    7072    WKRelease(_context);
    7173    WKRelease(_pageGroup);
     
    615617    [_webView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
    616618    [containerView addSubview:_webView];
    617    
     619
     620    [progressIndicator bind:NSHiddenBinding toObject:_webView.browsingContextController withKeyPath:@"loading" options:@{ NSValueTransformerNameBindingOption : NSNegateBooleanTransformerName }];
     621
    618622    WKPageLoaderClientV3 loadClient = {
    619623        { 3, self },
     
    714718{
    715719    [progressIndicator setDoubleValue:0.0];
    716     [progressIndicator setHidden:NO];
    717720}
    718721
     
    724727- (void)didFinishProgress
    725728{
    726     [progressIndicator setHidden:YES];
    727729    [progressIndicator setDoubleValue:1.0];
    728730}
Note: See TracChangeset for help on using the changeset viewer.