[haiku-webkit-commits] r466 - in webkit/trunk/WebKit/haiku: API WebPositive

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Fri, 30 Apr 2010 15:40:36 +0000

Author: stippi
Date: Fri Apr 30 15:40:36 2010
New Revision: 466
URL: http://mmlr.dyndns.org/changeset/466

Log:
* After a recent commit, _TabChanged() was accessing "webView" when it really
  meant CurrentWebView(). This also fixed the focus restoration, since it
  remembered the current focus for the wrong web view when the user data was
  already stored.
* Refactored _TabChanged() so that this code is now executed in the now
  virtual SetCurrentWebView(), which makes the features also work for new tabs.

Modified:
   webkit/trunk/WebKit/haiku/API/WebWindow.h
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h

Modified: webkit/trunk/WebKit/haiku/API/WebWindow.h
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebWindow.h   Fri Apr 30 15:08:05 2010        
(r465)
+++ webkit/trunk/WebKit/haiku/API/WebWindow.h   Fri Apr 30 15:40:36 2010        
(r466)
@@ -49,7 +49,7 @@
        // You can have as many BWebViews in your derived window as you want,
        // but for some situations, the BWebWindow needs to know the current 
one,
        // so always make it known here.
-                       void                            
SetCurrentWebView(BWebView* view);
+       virtual void                            SetCurrentWebView(BWebView* 
view);
                        BWebView*                       CurrentWebView() const;
 
        // Derived windows can implement this notification API.

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Fri Apr 30 
15:08:05 2010        (r465)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Fri Apr 30 
15:40:36 2010        (r466)
@@ -750,9 +750,9 @@
 
        // Iterate over all tabs to delete all BWebViews.
        // Do this here, so WebKit tear down happens earlier.
+       SetCurrentWebView(NULL);
        while (fTabManager->CountTabs() > 0)
                _ShutdownTab(0);
-       SetCurrentWebView(NULL);
 
        BMessage message(WINDOW_CLOSED);
        message.AddRect("window frame", Frame());
@@ -769,6 +769,69 @@
 }
 
 
+static bool
+viewIsChild(const BView* parent, const BView* view)
+{
+       if (parent == view)
+               return true;
+
+       int32 count = parent->CountChildren();
+       for (int32 i = 0; i < count; i++) {
+               BView* child = parent->ChildAt(i);
+               if (viewIsChild(child, view))
+                       return true;
+       }
+       return false;
+}
+
+
+void
+BrowserWindow::SetCurrentWebView(BWebView* webView)
+{
+       if (webView == CurrentWebView())
+               return;
+
+       if (CurrentWebView() != NULL) {
+               // Remember the currently focused view before switching tabs,
+               // so that we can revert the focus when switching back to this 
tab
+               // later.
+               PageUserData* userData = static_cast<PageUserData*>(
+                       CurrentWebView()->GetUserData());
+               if (userData)
+                       userData->SetFocusedView(CurrentFocus());
+               else
+                       CurrentWebView()->SetUserData(new 
PageUserData(CurrentFocus()));
+       }
+
+       BWebWindow::SetCurrentWebView(webView);
+
+       if (webView != NULL) {
+               _UpdateTitle(webView->MainFrameTitle());
+
+               // Restore the previous focus or focus the web view.
+               PageUserData* userData = static_cast<PageUserData*>(
+                       webView->GetUserData());
+               BView* focusedView = NULL;
+               if (userData != NULL) {
+                       focusedView = userData->FocusedView();
+                       fURLInputGroup->SetPageIcon(userData->PageIcon());
+               }
+
+               if (focusedView != NULL
+                       && viewIsChild(GetLayout()->View(), focusedView)) {
+                       focusedView->MakeFocus(true);
+               } else
+                       webView->MakeFocus(true);
+
+               fURLInputGroup->SetText(webView->MainFrameURL());
+               // Trigger update of the interface to the new page, by 
requesting
+               // to resend all notifications.
+               webView->WebPage()->ResendNotifications();
+       } else
+               _UpdateTitle("");
+}
+
+
 void
 BrowserWindow::CreateNewTab(const BString& _url, bool select, BWebView* 
webView)
 {
@@ -1150,47 +1213,7 @@
 void
 BrowserWindow::_TabChanged(int32 index)
 {
-       BWebView* webView = 
dynamic_cast<BWebView*>(fTabManager->ViewForTab(index));
-       if (webView == CurrentWebView())
-               return;
-
-       if (CurrentWebView() != NULL) {
-               // Remember the currently focused view before switching tabs,
-               // so that we can revert the focus when switching back to this 
tab
-               // later.
-               PageUserData* userData = static_cast<PageUserData*>(
-                       webView->GetUserData());
-               if (userData)
-                       userData->SetFocusedView(CurrentFocus());
-               else
-                       CurrentWebView()->SetUserData(new 
PageUserData(CurrentFocus()));
-       }
-
-       SetCurrentWebView(webView);
-
-       if (webView != NULL) {
-               _UpdateTitle(webView->MainFrameTitle());
-
-               // Restore the previous focus or focus the web view.
-               PageUserData* userData = static_cast<PageUserData*>(
-                       webView->GetUserData());
-               BView* focusedView = NULL;
-               if (userData != NULL) {
-                       focusedView = userData->FocusedView();
-                       fURLInputGroup->SetPageIcon(userData->PageIcon());
-               }
-               
-               if (focusedView != NULL)
-                       focusedView->MakeFocus(true);
-               else
-                       webView->MakeFocus(true);
-
-               fURLInputGroup->SetText(webView->MainFrameURL());
-               // Trigger update of the interface to the new page, by 
requesting
-               // to resend all notifications.
-               webView->WebPage()->ResendNotifications();
-       } else
-               _UpdateTitle("");
+       
SetCurrentWebView(dynamic_cast<BWebView*>(fTabManager->ViewForTab(index)));
 }
 
 

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h       Fri Apr 30 
15:08:05 2010        (r465)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h       Fri Apr 30 
15:40:36 2010        (r466)
@@ -89,6 +89,8 @@
        virtual bool                            QuitRequested();
        virtual void                            MenusBeginning();
 
+       virtual void                            SetCurrentWebView(BWebView* 
view);
+
                        void                            CreateNewTab(const 
BString& url, bool select,
                                                                        
BWebView* webView = 0);
 

Other related posts:

  • » [haiku-webkit-commits] r466 - in webkit/trunk/WebKit/haiku: API WebPositive - webkit