[haiku-webkit-commits] r560 - webkit/trunk/WebKit/haiku/WebPositive

  • From: noreply@xxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Tue, 28 Dec 2010 07:05:26 +0100 (CET)

Author: leavengood
Date: Tue Dec 28 07:05:25 2010
New Revision: 560
URL: http://webpositive.haiku-os.org/changeset/560

Log:
Implement http://webpositive.haiku-os.org/ticket/61 so that holding the command
key and using the scroll wheel will zoom in and out. Also made it so that the
scroll wheel only works when the mouse is over the view.

Modified:
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Tue Dec 28 
06:07:06 2010        (r559)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Tue Dec 28 
07:05:25 2010        (r560)
@@ -533,16 +533,16 @@
 BrowserWindow::DispatchMessage(BMessage* message, BHandler* target)
 {
        const char* bytes;
-       uint32 modifiers;
+       uint32 modifierKeys;
        if ((message->what == B_KEY_DOWN || message->what == 
B_UNMAPPED_KEY_DOWN)
                && message->FindString("bytes", &bytes) == B_OK
-               && message->FindInt32("modifiers", (int32*)&modifiers) == B_OK) 
{
+               && message->FindInt32("modifiers", (int32*)&modifierKeys) == 
B_OK) {
 
-               modifiers = modifiers & 0x000000ff;
-               if (bytes[0] == B_LEFT_ARROW && modifiers == B_COMMAND_KEY) {
+               modifierKeys = modifierKeys & 0x000000ff;
+               if (bytes[0] == B_LEFT_ARROW && modifierKeys == B_COMMAND_KEY) {
                        PostMessage(GO_BACK);
                        return;
-               } else if (bytes[0] == B_RIGHT_ARROW && modifiers == 
B_COMMAND_KEY) {
+               } else if (bytes[0] == B_RIGHT_ARROW && modifierKeys == 
B_COMMAND_KEY) {
                        PostMessage(GO_FORWARD);
                        return;
                } else if (bytes[0] == B_ESCAPE) {
@@ -576,7 +576,7 @@
                } else if (target == fFindTextControl->TextView()) {
                        // Handle B_RETURN when the find text control has focus.
                        if (bytes[0] == B_RETURN) {
-                               if ((modifiers & B_SHIFT_KEY) != 0)
+                               if ((modifierKeys & B_SHIFT_KEY) != 0)
                                        
_InvokeButtonVisibly(fFindPreviousButton);
                                else
                                        _InvokeButtonVisibly(fFindNextButton);
@@ -594,6 +594,30 @@
                        fLastMouseMovedTime = system_time();
                _CheckAutoHideInterface();
        }
+       if (message->what == B_MOUSE_WHEEL_CHANGED) {
+               BPoint where;
+               uint32 buttons;
+               CurrentWebView()->GetMouse(&where, &buttons, false);
+               // Only do this when the mouse is over the web view
+               if (CurrentWebView()->Bounds().Contains(where)) {
+                       // Zoom and unzoom text on Command + mouse wheel.
+                       // This could of course (and maybe should be) 
implemented in the WebView, but there
+                       // would need to be a way for the WebView to know the 
setting of the
+                       // fZoomTextOnly member here. Plus other clients of the 
API may not want
+                       // this feature.
+                       if ((modifiers() & B_COMMAND_KEY) != 0) {
+                               float dy;
+                               if (message->FindFloat("be:wheel_delta_y", &dy) 
== B_OK) {
+                                       if (dy < 0)
+                                               
CurrentWebView()->IncreaseZoomFactor(fZoomTextOnly);
+                                       else
+                                               
CurrentWebView()->DecreaseZoomFactor(fZoomTextOnly);
+                                       return;
+                               }
+                       }
+               } else // Also don't scroll up and down if the mouse is not 
over the web view
+                       return;
+       }
        BWebWindow::DispatchMessage(message, target);
 }
 

Other related posts: