[haiku-webkit-commits] r251 - webkit/trunk/WebKit/haiku/API

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Mon, 01 Mar 2010 06:50:21 +0000

Author: leavengood
Date: Mon Mar  1 06:50:21 2010
New Revision: 251
URL: http://mmlr.dyndns.org/changeset/251

Log:
Add some rudimentary support for keyboard scrolling.

For those wondering, the EditorClientHaiku stuff only applies for text areas
and such. I took a look at the Qt port to see how they handled this and it was
similar to what I'm doing here.

I'm pretty sure more needs to be done since right now this only works on key up.
I guess WebCore is eating key down. Key repeat also isn't working probably
because those are key downs. Please improve :)

Modified:
   webkit/trunk/WebKit/haiku/API/WebPage.cpp

Modified: webkit/trunk/WebKit/haiku/API/WebPage.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebPage.cpp   Mon Mar  1 04:31:07 2010        
(r250)
+++ webkit/trunk/WebKit/haiku/API/WebPage.cpp   Mon Mar  1 06:50:21 2010        
(r251)
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2010 Ryan Leavengood <leavengood@xxxxxxxxx>
  * Copyright (C) 2010 Stephan Aßmus <superstippi@xxxxxx>
  *
  * All rights reserved.
@@ -844,7 +845,50 @@
         return;
 
     PlatformKeyboardEvent event(message);
-    frame->eventHandler()->keyEvent(event);
+       // Try to let WebCore handle this event
+       if (!frame->eventHandler()->keyEvent(event)) {
+               // Handle keyboard scrolling (probably should be extracted to a 
method.)
+               ScrollDirection direction;
+               ScrollGranularity granularity;
+               BString bytes = message->FindString("bytes");
+               switch (bytes.ByteAt(0)) {
+                       case B_UP_ARROW:
+                               granularity = ScrollByLine;
+                               direction = ScrollUp;
+                               break;
+                       case B_DOWN_ARROW:
+                               granularity = ScrollByLine;
+                               direction = ScrollDown;
+                               break;
+                       case B_LEFT_ARROW:
+                               granularity = ScrollByLine;
+                               direction = ScrollLeft;
+                               break;
+                       case B_RIGHT_ARROW:
+                               granularity = ScrollByLine;
+                               direction = ScrollRight;
+                               break;
+                       case B_HOME:
+                               granularity = ScrollByDocument;
+                               direction = ScrollUp;
+                               break;
+                       case B_END:
+                               granularity = ScrollByDocument;
+                               direction = ScrollDown;
+                               break;
+                       case B_PAGE_UP:
+                               granularity = ScrollByPage;
+                               direction = ScrollUp;
+                               break;
+                       case B_PAGE_DOWN:
+                               granularity = ScrollByPage;
+                               direction = ScrollDown;
+                               break;
+                       default:
+                               return;
+               }
+               frame->eventHandler()->scrollRecursively(direction, 
granularity);
+       }
 }
 
 void BWebPage::handleChangeTextSize(BMessage* message)

Other related posts:

  • » [haiku-webkit-commits] r251 - webkit/trunk/WebKit/haiku/API - webkit