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

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Wed, 05 May 2010 11:04:25 +0000

Author: stippi
Date: Wed May  5 11:04:24 2010
New Revision: 488
URL: http://mmlr.dyndns.org/changeset/488

Log:
* Changed the implementation of context menus in DownloadProgressViews. The 
views
  were intercepting mouse messages even if the window was not showing. Now
  secondary clicks are intercepted in DownloadWindow and the target view is 
found,
  which makes this much cheaper.
* Offset context menus by 2 pixels, so the mouse does not start directly over
  an item.

Modified:
   webkit/trunk/WebKit/haiku/API/WebPage.cpp
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h
   webkit/trunk/WebKit/haiku/WebPositive/DownloadProgressView.cpp
   webkit/trunk/WebKit/haiku/WebPositive/DownloadProgressView.h
   webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.cpp
   webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.h

Modified: webkit/trunk/WebKit/haiku/API/WebPage.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebPage.cpp   Wed May  5 10:24:38 2010        
(r487)
+++ webkit/trunk/WebKit/haiku/API/WebPage.cpp   Wed May  5 11:04:24 2010        
(r488)
@@ -1043,7 +1043,8 @@
                                            BMenuItem* item = 
platformMenu->RemoveItem(i);
                                            popupMenu->AddItem(item, 0);
                                        }
-                       BPoint screenLocation(event.globalX(), event.globalY());
+                       BPoint screenLocation(event.globalX() + 2,
+                               event.globalY() + 2);
                    popupMenu->Go(screenLocation, true, true, true);
                    delete platformMenu;
                }

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Wed May  5 
10:24:38 2010        (r487)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Wed May  5 
11:04:24 2010        (r488)
@@ -1300,16 +1300,22 @@
 BrowserWindow::_UpdateTabGroupVisibility()
 {
        if (Lock()) {
-               if (fInterfaceVisible) {
-                       fTabGroup->SetVisible(fShowTabsIfSinglePageOpen
-                               || fTabManager->CountTabs() > 1);
-               }
+               if (fInterfaceVisible)
+                       fTabGroup->SetVisible(_TabGroupShouldBeVisible());
                fTabManager->SetCloseButtonsAvailable(fTabManager->CountTabs() 
> 1);
                Unlock();
        }
 }
 
 
+bool
+BrowserWindow::_TabGroupShouldBeVisible() const
+{
+       return (fShowTabsIfSinglePageOpen || fTabManager->CountTabs() > 1)
+               && (fVisibleInterfaceElements & INTERFACE_ELEMENT_TABS) != 0;
+}
+
+
 void
 BrowserWindow::_ShutdownTab(int32 index)
 {
@@ -1868,9 +1874,7 @@
                fMenuGroup->SetVisible(
                        (fVisibleInterfaceElements & INTERFACE_ELEMENT_MENU) != 
0);
 #endif
-               fTabGroup->SetVisible((fShowTabsIfSinglePageOpen
-                               || fTabManager->CountTabs() > 1)
-                       && (fVisibleInterfaceElements & INTERFACE_ELEMENT_TABS) 
!= 0);
+               fTabGroup->SetVisible(_TabGroupShouldBeVisible());
                fNavigationGroup->SetVisible(
                        (fVisibleInterfaceElements & 
INTERFACE_ELEMENT_NAVIGATION) != 0);
                fStatusGroup->SetVisible(

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h       Wed May  5 
10:24:38 2010        (r487)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h       Wed May  5 
11:04:24 2010        (r488)
@@ -152,6 +152,7 @@
 private:
                        void                            _UpdateTitle(const 
BString &title);
                        void                            
_UpdateTabGroupVisibility();
+                       bool                            
_TabGroupShouldBeVisible() const;
                        void                            _ShutdownTab(int32 
index);
                        void                            _TabChanged(int32 
index);
 

Modified: webkit/trunk/WebKit/haiku/WebPositive/DownloadProgressView.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/DownloadProgressView.cpp      Wed May 
 5 10:24:38 2010        (r487)
+++ webkit/trunk/WebKit/haiku/WebPositive/DownloadProgressView.cpp      Wed May 
 5 11:04:24 2010        (r488)
@@ -208,10 +208,6 @@
 bool
 DownloadProgressView::Init(BMessage* archive)
 {
-       // We need to receive mouse events even for the areas of children views,
-       // so we can pop up a context menu.
-       SetEventMask(B_POINTER_EVENTS);
-
        fCurrentSize = 0;
        fExpectedSize = 0;
        fLastUpdateTime = 0;
@@ -340,35 +336,6 @@
 
 
 void
-DownloadProgressView::MouseDown(BPoint where)
-{
-       if (!Bounds().Contains(where))
-               return;
-
-       int32 buttons;
-       if (Window()->CurrentMessage()->FindInt32("buttons", &buttons) != B_OK)
-               return;
-
-       if ((buttons & B_SECONDARY_MOUSE_BUTTON) == 0)
-               return;
-
-       where = ConvertToScreen(where) + BPoint(2, 2);
-
-       BPopUpMenu* contextMenu = new BPopUpMenu("download context");
-       BMenuItem* copyURL = new BMenuItem("Copy URL to clipboard",
-               new BMessage(COPY_URL_TO_CLIPBOARD));
-       copyURL->SetEnabled(fURL.Length() > 0);
-       contextMenu->AddItem(copyURL);
-       BMenuItem* openFolder = new BMenuItem("Open containing folder",
-               new BMessage(OPEN_CONTAINING_FOLDER));
-       contextMenu->AddItem(openFolder);
-
-       contextMenu->SetTargetForItems(this);
-       contextMenu->Go(where, true, true, true);
-}
-
-
-void
 DownloadProgressView::Draw(BRect updateRect)
 {
        BRect bounds(Bounds());
@@ -588,6 +555,25 @@
 }
 
 
+void
+DownloadProgressView::ShowContextMenu(BPoint screenWhere)
+{
+       screenWhere += BPoint(2, 2);
+
+       BPopUpMenu* contextMenu = new BPopUpMenu("download context");
+       BMenuItem* copyURL = new BMenuItem("Copy URL to clipboard",
+               new BMessage(COPY_URL_TO_CLIPBOARD));
+       copyURL->SetEnabled(fURL.Length() > 0);
+       contextMenu->AddItem(copyURL);
+       BMenuItem* openFolder = new BMenuItem("Open containing folder",
+               new BMessage(OPEN_CONTAINING_FOLDER));
+       contextMenu->AddItem(openFolder);
+
+       contextMenu->SetTargetForItems(this);
+       contextMenu->Go(screenWhere, true, true, true);
+}
+
+
 BWebDownload*
 DownloadProgressView::Download() const
 {

Modified: webkit/trunk/WebKit/haiku/WebPositive/DownloadProgressView.h
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/DownloadProgressView.h        Wed May 
 5 10:24:38 2010        (r487)
+++ webkit/trunk/WebKit/haiku/WebPositive/DownloadProgressView.h        Wed May 
 5 11:04:24 2010        (r488)
@@ -57,12 +57,12 @@
        virtual void                            DetachedFromWindow();
        virtual void                            AllAttached();
 
-       virtual void                            MouseDown(BPoint where);
-
        virtual void                            Draw(BRect updateRect);
 
        virtual void                            MessageReceived(BMessage* 
message);
 
+                       void                            ShowContextMenu(BPoint 
screenWhere);
+
                        BWebDownload*           Download() const;
                        const BString&          URL() const;
                        bool                            IsMissing() const;

Modified: webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.cpp    Wed May  5 
10:24:38 2010        (r487)
+++ webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.cpp    Wed May  5 
11:04:24 2010        (r488)
@@ -199,6 +199,36 @@
 
 
 void
+DownloadWindow::DispatchMessage(BMessage* message, BHandler* target)
+{
+       // We need to intercept mouse down events inside the area of download
+       // progress views (regardless of whether they have children at the 
click),
+       // so that they may display a context menu.
+       BPoint where;
+       int32 buttons;
+       if (message->what == B_MOUSE_DOWN
+               && message->FindPoint("screen_where", &where) == B_OK
+               && message->FindInt32("buttons", &buttons) == B_OK
+               && (buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
+               for (int32 i = fDownloadViewsLayout->CountItems() - 1;
+                               BLayoutItem* item = 
fDownloadViewsLayout->ItemAt(i); i--) {
+                       DownloadProgressView* view = 
dynamic_cast<DownloadProgressView*>(
+                               item->View());
+                       if (!view)
+                               continue;
+                       BPoint viewWhere(where);
+                       view->ConvertFromScreen(&viewWhere);
+                       if (view->Bounds().Contains(viewWhere)) {
+                               view->ShowContextMenu(where);
+                               return;
+                       }
+               }
+       }
+       BWindow::DispatchMessage(message, target);
+}
+
+
+void
 DownloadWindow::MessageReceived(BMessage* message)
 {
        switch (message->what) {

Modified: webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.h
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.h      Wed May  5 
10:24:38 2010        (r487)
+++ webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.h      Wed May  5 
11:04:24 2010        (r488)
@@ -45,6 +45,8 @@
                                                                        
SettingsMessage* settings);
        virtual                                         ~DownloadWindow();
 
+       virtual void                            DispatchMessage(BMessage* 
message,
+                                                                       
BHandler* target);
        virtual void                            MessageReceived(BMessage* 
message);
        virtual bool                            QuitRequested();
 

Other related posts:

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