Title: [160129] trunk
Revision
160129
Author
[email protected]
Date
2013-12-04 14:51:37 -0800 (Wed, 04 Dec 2013)

Log 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]):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (160128 => 160129)


--- trunk/Source/WebKit2/ChangeLog	2013-12-04 22:42:46 UTC (rev 160128)
+++ trunk/Source/WebKit2/ChangeLog	2013-12-04 22:51:37 UTC (rev 160129)
@@ -1,3 +1,49 @@
+2013-12-04  Anders Carlsson  <[email protected]>
+
+        Add a loading property to WKBrowsingContextController
+        https://bugs.webkit.org/show_bug.cgi?id=125256
+
+        Reviewed by Dan Bernstein.
+
+        * 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:
+
 2013-12-04  Nick Diego Yamane  <[email protected]>
 
         [EFL][GTK][WK2] Remove unnecessary reinterpret_casts when setting API clients

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.h (160128 => 160129)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.h	2013-12-04 22:42:46 UTC (rev 160128)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.h	2013-12-04 22:51:37 UTC (rev 160129)
@@ -106,6 +106,8 @@
 
 #pragma mark Active Load Introspection
 
+@property (readonly, getter=isLoading) BOOL loading;
+
 /* URL for the active load. This is the URL that should be shown in user interface. */
 @property(readonly) NSURL *activeURL;
 

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm (160128 => 160129)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm	2013-12-04 22:42:46 UTC (rev 160128)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm	2013-12-04 22:51:37 UTC (rev 160129)
@@ -61,6 +61,16 @@
     }
 
 private:
+    virtual void willChangeIsLoading() OVERRIDE
+    {
+        [m_controller willChangeValueForKey:@"loading"];
+    }
+
+    virtual void didChangeIsLoading() OVERRIDE
+    {
+        [m_controller didChangeValueForKey:@"loading"];
+    }
+
     virtual void willChangeTitle() OVERRIDE
     {
         [m_controller willChangeValueForKey:@"title"];
@@ -269,6 +279,11 @@
 
 #pragma mark Active Load Introspection
 
+- (BOOL)isLoading
+{
+    return _page->pageLoadState().isLoading();
+}
+
 - (NSURL *)activeURL
 {
     return [NSURL _web_URLWithWTFString:_page->pageLoadState().activeURL()];

Modified: trunk/Source/WebKit2/UIProcess/PageLoadState.cpp (160128 => 160129)


--- trunk/Source/WebKit2/UIProcess/PageLoadState.cpp	2013-12-04 22:42:46 UTC (rev 160128)
+++ trunk/Source/WebKit2/UIProcess/PageLoadState.cpp	2013-12-04 22:51:37 UTC (rev 160129)
@@ -55,7 +55,8 @@
 
 void PageLoadState::reset()
 {
-    m_state = State::Finished;
+    setState(State::Finished);
+
     m_pendingAPIRequestURL = String();
     m_provisionalURL = String();
     m_url = String();
@@ -68,6 +69,11 @@
     callObserverCallback(&Observer::didChangeTitle);
 }
 
+bool PageLoadState::isLoading() const
+{
+    return isLoadingState(m_state);
+}
+
 String PageLoadState::activeURL() const
 {
     // If there is a currently pending URL, it is the active URL,
@@ -111,7 +117,8 @@
 {
     ASSERT(m_provisionalURL.isEmpty());
 
-    m_state = State::Provisional;
+    setState(State::Provisional);
+
     m_provisionalURL = url;
 
     setUnreachableURL(unreachableURL);
@@ -128,7 +135,8 @@
 {
     ASSERT(m_state == State::Provisional);
 
-    m_state = State::Finished;
+    setState(State::Finished);
+
     m_provisionalURL = String();
     m_unreachableURL = m_lastUnreachableURL;
 }
@@ -137,7 +145,8 @@
 {
     ASSERT(m_state == State::Provisional);
 
-    m_state = State::Committed;
+    setState(State::Committed);
+
     m_url = m_provisionalURL;
     m_provisionalURL = String();
 
@@ -149,14 +158,14 @@
     ASSERT(m_state == State::Committed);
     ASSERT(m_provisionalURL.isEmpty());
 
-    m_state = State::Finished;
+    setState(State::Finished);
 }
 
 void PageLoadState::didFailLoad()
 {
     ASSERT(m_provisionalURL.isEmpty());
 
-    m_state = State::Finished;
+    setState(State::Finished);
 }
 
 void PageLoadState::didSameDocumentNavigation(const String& url)
@@ -184,6 +193,40 @@
     callObserverCallback(&Observer::didChangeTitle);
 }
 
+bool PageLoadState::isLoadingState(State state)
+{
+    switch (state) {
+    case State::Provisional:
+    case State::Committed:
+        return true;
+
+    case State::Finished:
+        return false;
+    }
+
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
+void PageLoadState::setState(State state)
+{
+    if (m_state == state)
+        return;
+
+    bool isLoadingIsChanging = false;
+
+    if (isLoadingState(m_state) != isLoadingState(state))
+        isLoadingIsChanging = true;
+
+    if (isLoadingIsChanging)
+        callObserverCallback(&Observer::willChangeIsLoading);
+
+    m_state = state;
+
+    if (isLoadingIsChanging)
+        callObserverCallback(&Observer::didChangeIsLoading);
+}
+
 void PageLoadState::callObserverCallback(void (Observer::*callback)())
 {
     for (auto* observer : m_observers)

Modified: trunk/Source/WebKit2/UIProcess/PageLoadState.h (160128 => 160129)


--- trunk/Source/WebKit2/UIProcess/PageLoadState.h	2013-12-04 22:42:46 UTC (rev 160128)
+++ trunk/Source/WebKit2/UIProcess/PageLoadState.h	2013-12-04 22:51:37 UTC (rev 160129)
@@ -45,6 +45,9 @@
     public:
         virtual ~Observer() { }
 
+        virtual void willChangeIsLoading() = 0;
+        virtual void didChangeIsLoading() = 0;
+
         virtual void willChangeTitle() = 0;
         virtual void didChangeTitle() = 0;
     };
@@ -54,6 +57,8 @@
 
     void reset();
 
+    bool isLoading() const;
+
     const String& provisionalURL() const { return m_provisionalURL; }
     const String& url() const { return m_url; }
     const String& unreachableURL() const { return m_unreachableURL; }
@@ -80,6 +85,9 @@
     void setTitle(const String&);
 
 private:
+    static bool isLoadingState(State);
+    void setState(State);
+
     void callObserverCallback(void (Observer::*)());
 
     Vector<Observer*> m_observers;

Modified: trunk/Tools/ChangeLog (160128 => 160129)


--- trunk/Tools/ChangeLog	2013-12-04 22:42:46 UTC (rev 160128)
+++ trunk/Tools/ChangeLog	2013-12-04 22:51:37 UTC (rev 160129)
@@ -1,3 +1,18 @@
+2013-12-04  Anders Carlsson  <[email protected]>
+
+        Add a loading property to WKBrowsingContextController
+        https://bugs.webkit.org/show_bug.cgi?id=125256
+
+        Reviewed by Dan Bernstein.
+
+        Bind the progress indicator visibility to the "loading" property.
+
+        * MiniBrowser/mac/WK2BrowserWindowController.m:
+        (-[WK2BrowserWindowController dealloc]):
+        (-[WK2BrowserWindowController awakeFromNib]):
+        (-[WK2BrowserWindowController didStartProgress]):
+        (-[WK2BrowserWindowController didFinishProgress]):
+
 2013-12-04  Nick Diego Yamane  <[email protected]>
 
         [EFL][WK2] Buildfix after r160104

Modified: trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m (160128 => 160129)


--- trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m	2013-12-04 22:42:46 UTC (rev 160128)
+++ trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m	2013-12-04 22:51:37 UTC (rev 160129)
@@ -67,6 +67,8 @@
 
 - (void)dealloc
 {
+    [progressIndicator unbind:NSHiddenBinding];
+
     WKRelease(_context);
     WKRelease(_pageGroup);
     _webView.browsingContextController.policyDelegate = nil;
@@ -614,7 +616,9 @@
 
     [_webView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
     [containerView addSubview:_webView];
-    
+
+    [progressIndicator bind:NSHiddenBinding toObject:_webView.browsingContextController withKeyPath:@"loading" options:@{ NSValueTransformerNameBindingOption : NSNegateBooleanTransformerName }];
+
     WKPageLoaderClientV3 loadClient = {
         { 3, self },
         didStartProvisionalLoadForFrame,
@@ -713,7 +717,6 @@
 - (void)didStartProgress
 {
     [progressIndicator setDoubleValue:0.0];
-    [progressIndicator setHidden:NO];
 }
 
 - (void)didChangeProgress:(double)value
@@ -723,7 +726,6 @@
 
 - (void)didFinishProgress
 {
-    [progressIndicator setHidden:YES];
     [progressIndicator setDoubleValue:1.0];
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to