Changeset 64091 in webkit
- Timestamp:
- Jul 26, 2010 5:00:51 PM (14 years ago)
- Location:
- trunk/WebKit2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit2/ChangeLog
r64086 r64091 1 2010-07-26 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Anders Carlsson. 4 5 Part 2 of https://bugs.webkit.org/show_bug.cgi?id=43013 6 <rdar://problem/8152434> 7 Add support for scrolling using the keyboard in WebKit2 8 9 Add support for scrolling with the space bar and ensure that we don't scroll 10 if WebCore is handling the event in another way. 11 12 * WebProcess/WebPage/WebPage.cpp: 13 (WebKit::WebPage::keyEvent): 14 (WebKit::getScrollMapping): 15 (WebKit::WebPage::performDefaultBehaviorForKeyEvent): 16 * WebProcess/WebPage/WebPage.h: 17 1 18 2010-07-26 Sam Weinig <sam@webkit.org> 2 19 -
trunk/WebKit2/WebProcess/WebPage/WebPage.cpp
r64086 r64091 345 345 } 346 346 347 static bool getScrollMapping(const WebKeyboardEvent& event, ScrollDirection& direction, ScrollGranularity& granularity)348 {349 if (event.type() != WebEvent::KeyDown && event.type() != WebEvent::RawKeyDown)350 return false;351 352 switch (event.windowsVirtualKeyCode()) {353 case VK_LEFT:354 granularity = ScrollByLine;355 direction = ScrollLeft;356 break;357 case VK_RIGHT:358 granularity = ScrollByLine;359 direction = ScrollRight;360 break;361 case VK_UP:362 granularity = ScrollByLine;363 direction = ScrollUp;364 break;365 case VK_DOWN:366 granularity = ScrollByLine;367 direction = ScrollDown;368 break;369 case VK_HOME:370 granularity = ScrollByDocument;371 direction = ScrollUp;372 break;373 case VK_END:374 granularity = ScrollByDocument;375 direction = ScrollDown;376 break;377 case VK_PRIOR:378 granularity = ScrollByPage;379 direction = ScrollUp;380 break;381 case VK_NEXT:382 granularity = ScrollByPage;383 direction = ScrollDown;384 break;385 default:386 return false;387 }388 389 return true;390 }391 347 392 348 void WebPage::keyEvent(const WebKeyboardEvent& keyboardEvent) … … 400 356 401 357 PlatformKeyboardEvent platformKeyboardEvent = platform(keyboardEvent); 402 403 Frame* frame = m_page->focusController()->focusedOrMainFrame(); 404 frame->eventHandler()->keyEvent(platformKeyboardEvent); 405 406 ScrollDirection direction; 407 ScrollGranularity granularity; 408 if (getScrollMapping(keyboardEvent, direction, granularity)) 409 frame->eventHandler()->scrollRecursively(direction, granularity); 358 if (m_page->focusController()->focusedOrMainFrame()->eventHandler()->keyEvent(platformKeyboardEvent)) 359 return; 360 361 performDefaultBehaviorForKeyEvent(keyboardEvent); 410 362 } 411 363 … … 499 451 } 500 452 453 static bool getScrollMapping(const WebKeyboardEvent& event, ScrollDirection& direction, ScrollGranularity& granularity) 454 { 455 if (event.type() != WebEvent::KeyDown && event.type() != WebEvent::RawKeyDown) 456 return false; 457 458 switch (event.windowsVirtualKeyCode()) { 459 case VK_SPACE: 460 granularity = ScrollByPage; 461 direction = event.shiftKey() ? ScrollUp : ScrollDown; 462 break; 463 case VK_LEFT: 464 granularity = ScrollByLine; 465 direction = ScrollLeft; 466 break; 467 case VK_RIGHT: 468 granularity = ScrollByLine; 469 direction = ScrollRight; 470 break; 471 case VK_UP: 472 granularity = ScrollByLine; 473 direction = ScrollUp; 474 break; 475 case VK_DOWN: 476 granularity = ScrollByLine; 477 direction = ScrollDown; 478 break; 479 case VK_HOME: 480 granularity = ScrollByDocument; 481 direction = ScrollUp; 482 break; 483 case VK_END: 484 granularity = ScrollByDocument; 485 direction = ScrollDown; 486 break; 487 case VK_PRIOR: 488 granularity = ScrollByPage; 489 direction = ScrollUp; 490 break; 491 case VK_NEXT: 492 granularity = ScrollByPage; 493 direction = ScrollDown; 494 break; 495 default: 496 return false; 497 } 498 499 return true; 500 } 501 502 void WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboardEvent) 503 { 504 ScrollDirection direction; 505 ScrollGranularity granularity; 506 if (getScrollMapping(keyboardEvent, direction, granularity)) 507 m_page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity); 508 } 509 501 510 void WebPage::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder& arguments) 502 511 { -
trunk/WebKit2/WebProcess/WebPage/WebPage.h
r64063 r64091 118 118 void platformInitialize(); 119 119 static const char* interpretKeyEvent(const WebCore::KeyboardEvent*); 120 void performDefaultBehaviorForKeyEvent(const WebKeyboardEvent&); 120 121 121 122 // Actions
Note: See TracChangeset
for help on using the changeset viewer.