[haiku-webkit-commits] r232 - in webkit/trunk/WebKit/haiku: API HaikuLauncher

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Sat, 27 Feb 2010 11:01:36 +0000

Author: stippi
Date: Sat Feb 27 11:01:36 2010
New Revision: 232
URL: http://mmlr.dyndns.org/changeset/232

Log:
* Use the proper channels for reloading. (Added BWebView/BWebPage::Reload().)
* Catch B_RETURN key down messages, when the target is the URL text view.
  Don't let the text view send a message, but react on B_RETURN only, in the
  window, also letting the Go button flash for a bonus. This fixes unprovoked
  (re-)loading of pages when the text control went out of focus and thought the
  text had changed, sending GOTO_URL. This could happen when just grabbing the
  scrollbar so that the text control looses focus. Also makes the m_loadedURL
  string superfluous, which I added for the same purpose.

Modified:
   webkit/trunk/WebKit/haiku/API/WebPage.cpp
   webkit/trunk/WebKit/haiku/API/WebPage.h
   webkit/trunk/WebKit/haiku/API/WebView.cpp
   webkit/trunk/WebKit/haiku/API/WebView.h
   webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp
   webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.h

Modified: webkit/trunk/WebKit/haiku/API/WebPage.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebPage.cpp   Sat Feb 27 01:48:18 2010        
(r231)
+++ webkit/trunk/WebKit/haiku/API/WebPage.cpp   Sat Feb 27 11:01:36 2010        
(r232)
@@ -88,6 +88,7 @@
     HANDLE_SHUTDOWN = 'sdwn',
 
     HANDLE_LOAD_URL = 'lurl',
+    HANDLE_RELOAD = 'reld',
     HANDLE_GO_BACK = 'back',
     HANDLE_GO_FORWARD = 'fwrd',
     HANDLE_STOP_LOADING = 'stop',
@@ -238,6 +239,12 @@
     Looper()->PostMessage(&message, this);
 }
 
+void BWebPage::Reload()
+{
+    BMessage message(HANDLE_RELOAD);
+    Looper()->PostMessage(&message, this);
+}
+
 void BWebPage::GoBack()
 {
     BMessage message(HANDLE_GO_BACK);
@@ -615,6 +622,9 @@
     case HANDLE_LOAD_URL:
         handleLoadURL(message);
         break;
+    case HANDLE_RELOAD:
+       handleReload(message);
+       break;
     case HANDLE_GO_BACK:
         handleGoBack(message);
         break;
@@ -756,6 +766,11 @@
     m_mainFrame->LoadURL(urlString);
 }
 
+void BWebPage::handleReload(const BMessage* message)
+{
+    m_mainFrame->Reload();
+}
+
 void BWebPage::handleGoBack(const BMessage* message)
 {
     m_page->goBack();

Modified: webkit/trunk/WebKit/haiku/API/WebPage.h
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebPage.h     Sat Feb 27 01:48:18 2010        
(r231)
+++ webkit/trunk/WebKit/haiku/API/WebPage.h     Sat Feb 27 11:01:36 2010        
(r232)
@@ -83,6 +83,7 @@
                                // NOTE: Using the BWebView requires locking 
it's looper!
 
                        void                            LoadURL(const char* 
urlString);
+                       void                            Reload();
                        void                            GoBack();
                        void                            GoForward();
                        void                            StopLoading();
@@ -172,6 +173,7 @@
        void skipToLastMessage(BMessage*& message);
 
        void handleLoadURL(const BMessage* message);
+       void handleReload(const BMessage* message);
        void handleGoBack(const BMessage* message);
        void handleGoForward(const BMessage* message);
        void handleStop(const BMessage* message);

Modified: webkit/trunk/WebKit/haiku/API/WebView.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebView.cpp   Sat Feb 27 01:48:18 2010        
(r231)
+++ webkit/trunk/WebKit/haiku/API/WebView.cpp   Sat Feb 27 11:01:36 2010        
(r232)
@@ -237,6 +237,11 @@
     fWebPage->LoadURL(urlString);
 }
 
+void BWebView::Reload()
+{
+    fWebPage->Reload();
+}
+
 void BWebView::GoBack()
 {
     fWebPage->GoBack();

Modified: webkit/trunk/WebKit/haiku/API/WebView.h
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebView.h     Sat Feb 27 01:48:18 2010        
(r231)
+++ webkit/trunk/WebKit/haiku/API/WebView.h     Sat Feb 27 11:01:36 2010        
(r232)
@@ -71,6 +71,7 @@
                        BString                         MainFrameURL() const;
 
                        void                            LoadURL(const char* 
urlString);
+                       void                            Reload();
                        void                            GoBack();
                        void                            GoForward();
                        void                            StopLoading();

Modified: webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp  Sat Feb 27 
01:48:18 2010        (r231)
+++ webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp  Sat Feb 27 
11:01:36 2010        (r232)
@@ -151,11 +151,11 @@
         m_StopButton->TrimIcon();
 
         // URL
-        m_url = new BTextControl("url", "", "", new BMessage(GOTO_URL));
+        m_url = new BTextControl("url", "", "", NULL);
         m_url->SetDivider(50.0);
 
         // Go
-        BButton* button = new BButton("", "Go", new BMessage(RELOAD));
+        m_goButton = new BButton("", "Go", new BMessage(GOTO_URL));
 
         // Status Bar
         m_statusText = new BStringView("status", "");
@@ -201,7 +201,7 @@
                 .Add(m_ForwardButton, 1, 0)
                 .Add(m_StopButton, 2, 0)
                 .Add(m_url, 3, 0)
-                .Add(button, 4, 0)
+                .Add(m_goButton, 4, 0)
                 .SetInsets(kInsetSpacing, kInsetSpacing, kInsetSpacing, 
kInsetSpacing)
             )
             .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
@@ -223,6 +223,8 @@
     } else {
         m_BackButton = 0;
         m_ForwardButton = 0;
+        m_StopButton = 0;
+        m_goButton = 0;
         m_url = 0;
         m_menuBar = 0;
         m_statusText = 0;
@@ -253,6 +255,27 @@
 {
 }
 
+void LauncherWindow::DispatchMessage(BMessage* message, BHandler* target)
+{
+       if (m_url && message->what == B_KEY_DOWN && target == 
m_url->TextView()) {
+               // Handle B_RETURN in the URL text control. This is the easiest
+               // way to react *only* when the user presses the return key in 
the
+               // address bar, as opposed to trying to load whatever is in 
there when
+               // the text control just goes out of focus.
+           const char* bytes;
+           if (message->FindString("bytes", &bytes) == B_OK
+               && bytes[0] == B_RETURN) {
+               // Do it in such a way that the user sees the Go-button go down.
+               m_goButton->SetValue(B_CONTROL_ON);
+               UpdateIfNeeded();
+               m_goButton->Invoke();
+               snooze(1000);
+               m_goButton->SetValue(B_CONTROL_OFF);
+           }
+       }
+       BWebWindow::DispatchMessage(message, target);
+}
+
 void LauncherWindow::MessageReceived(BMessage* message)
 {
     switch (message->what) {
@@ -265,13 +288,13 @@
         }
        break;
     case RELOAD:
-        CurrentWebView()->LoadURL(m_url->Text());
+        CurrentWebView()->Reload();
         break;
     case GOTO_URL: {
-        BString url = m_url->Text();
-        message->FindString("url", &url);
-        if (m_loadedURL != url)
-            CurrentWebView()->LoadURL(url.String());
+        BString url;
+        if (message->FindString("url", &url) != B_OK)
+               url = m_url->Text();
+        CurrentWebView()->LoadURL(url.String());
         break;
     }
     case GO_BACK:
@@ -502,8 +525,6 @@
     if (view != CurrentWebView())
         return;
 
-    m_loadedURL = url;
-
        // This hook is invoked when the load is commited.
     if (m_url)
         m_url->SetText(url.String());
@@ -542,7 +563,6 @@
     if (view != CurrentWebView())
         return;
 
-    m_loadedURL = url;
     BString status(url);
     status << " finished.";
     StatusChanged(status, view);

Modified: webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.h
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.h    Sat Feb 27 
01:48:18 2010        (r231)
+++ webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.h    Sat Feb 27 
11:01:36 2010        (r232)
@@ -64,6 +64,7 @@
         ToolbarPolicy = HaveToolbar);
     virtual ~LauncherWindow();
 
+       virtual void DispatchMessage(BMessage* message, BHandler* target);
     virtual void MessageReceived(BMessage* message);
     virtual bool QuitRequested();
     virtual void MenusBeginning();
@@ -102,8 +103,8 @@
     IconButton* m_BackButton;
     IconButton* m_ForwardButton;
     IconButton* m_StopButton;
+    BButton* m_goButton;
     BTextControl* m_url;
-    BString m_loadedURL;
     BStringView* m_statusText;
     BStatusBar* m_loadingProgressBar;
     BLayoutItem* m_findGroup;

Other related posts:

  • » [haiku-webkit-commits] r232 - in webkit/trunk/WebKit/haiku: API HaikuLauncher - webkit