Changeset 96645 in webkit
- Timestamp:
- Oct 4, 2011 2:23:29 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r96643 r96645 1 2011-10-04 Jon Lee <jonlee@apple.com> 2 3 REGRESSION (WK2): (Shift-)option-tabbing skips over elements when transitioning from chrome to webview 4 https://bugs.webkit.org/show_bug.cgi?id=68412 5 <rdar://problem/9988252> 6 7 Reviewed by Darin Adler. 8 9 The option-key navigation is only relevant to the Mac platform. 10 11 * platform/mac/fast/forms/focus-option-control-on-page-expected.txt: Added. 12 * platform/mac/fast/forms/focus-option-control-on-page.html: Added. 13 * platform/mac/fast/forms/script-tests/focus-option-control-on-page.js: Added. 14 (startTest): 15 (runKeyPresses): 16 (notifyDone): 17 (log): 18 1 19 2011-10-04 David Hyatt <hyatt@apple.com> 2 20 -
trunk/Source/WebKit2/ChangeLog
r96619 r96645 1 2011-10-04 Jon Lee <jonlee@apple.com> 2 3 REGRESSION (WK2): (Shift-)option-tabbing skips over elements when transitioning from chrome to webview 4 https://bugs.webkit.org/show_bug.cgi?id=68412 5 <rdar://problem/9988252> 6 7 Reviewed by Darin Adler. 8 9 In WK1 setInitialFocus() is called on FocusController with the key event that 10 caused the web view to become first responder. In WK2 no event is sent. So if 11 the key stroke that caused the change in first responder status contains the 12 option modifier key, FocusController did not know that it had to switch behavior. 13 14 Because there are multiple ways that the WKView can becomeFirstResponder, I changed 15 the signature to setInitialFocus to express whether the key event parameter is an 16 actual key event. 17 18 * UIProcess/API/C/win/WKView.cpp: 19 (WKViewSetInitialFocus): 20 * UIProcess/API/mac/WKView.mm: 21 (-[WKView becomeFirstResponder]): Take the NSApp currentEvent and pass it along if 22 the event is a keyboard event, otherwise pass an empty event. 23 * UIProcess/WebPageProxy.cpp: 24 (WebKit::WebPageProxy::setInitialFocus): Change in function signature to confirm that 25 the event that caused the initial focus was a keyboard event, and provide the keyboard 26 event itself. 27 * UIProcess/WebPageProxy.h: 28 * UIProcess/win/WebView.cpp: 29 (WebKit::WebView::setInitialFocus): 30 * UIProcess/win/WebView.h: 31 * WebProcess/WebPage/WebPage.cpp: 32 (WebKit::WebPage::setInitialFocus): If we know that the cause of this was a keyboard 33 event, we pass that event to the FocusController. Otherwise we fall back to the original 34 behavior, which is to pass no event at all. 35 * WebProcess/WebPage/WebPage.h: 36 * WebProcess/WebPage/WebPage.messages.in: 37 1 38 2011-10-04 Jeff Miller <jeffm@apple.com> 2 39 -
trunk/Source/WebKit2/UIProcess/API/C/win/WKView.cpp
r95901 r96645 70 70 void WKViewSetInitialFocus(WKViewRef viewRef, bool forward) 71 71 { 72 toImpl(viewRef)->setInitialFocus(forward); 72 bool isKeyboardEventValid = false; 73 toImpl(viewRef)->setInitialFocus(forward, isKeyboardEventValid, WebKeyboardEvent()); 73 74 } 74 75 -
trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm
r95901 r96645 312 312 313 313 _data->_inBecomeFirstResponder = false; 314 315 if (direction != NSDirectSelection) 316 _data->_page->setInitialFocus(direction == NSSelectingNext); 317 314 315 if (direction != NSDirectSelection) { 316 NSEvent *event = [NSApp currentEvent]; 317 NSEvent *keyboardEvent = nil; 318 if ([event type] == NSKeyDown || [event type] == NSKeyUp) 319 keyboardEvent = event; 320 _data->_page->setInitialFocus(direction == NSSelectingNext, keyboardEvent != nil, NativeWebKeyboardEvent(keyboardEvent, self)); 321 } 318 322 return YES; 319 323 } -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r96613 r96645 701 701 } 702 702 703 void WebPageProxy::setInitialFocus(bool forward )704 { 705 if (!isValid()) 706 return; 707 process()->send(Messages::WebPage::SetInitialFocus(forward ), m_pageID);703 void WebPageProxy::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& keyboardEvent) 704 { 705 if (!isValid()) 706 return; 707 process()->send(Messages::WebPage::SetInitialFocus(forward, isKeyboardEventValid, keyboardEvent), m_pageID); 708 708 } 709 709 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r96413 r96645 263 263 void viewWillEndLiveResize(); 264 264 265 void setInitialFocus(bool );265 void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&); 266 266 void setWindowResizerSize(const WebCore::IntSize&); 267 267 -
trunk/Source/WebKit2/UIProcess/win/WebView.cpp
r95901 r96645 1069 1069 } 1070 1070 1071 void WebView::setInitialFocus(bool forward )1072 { 1073 m_page->setInitialFocus(forward );1071 void WebView::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& event) 1072 { 1073 m_page->setInitialFocus(forward, isKeyboardEventValid, event); 1074 1074 } 1075 1075 -
trunk/Source/WebKit2/UIProcess/win/WebView.h
r95901 r96645 80 80 void setIsVisible(bool); 81 81 void setOverrideCursor(HCURSOR); 82 void setInitialFocus(bool forward );82 void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&); 83 83 void setScrollOffsetOnNextResize(const WebCore::IntSize&); 84 84 void setFindIndicatorCallback(WKViewFindIndicatorCallback, void*); -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r96619 r96645 1366 1366 } 1367 1367 1368 void WebPage::setInitialFocus(bool forward )1368 void WebPage::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& event) 1369 1369 { 1370 1370 if (!m_page || !m_page->focusController()) … … 1373 1373 Frame* frame = m_page->focusController()->focusedOrMainFrame(); 1374 1374 frame->document()->setFocusedNode(0); 1375 1376 if (isKeyboardEventValid && event.type() == WebEvent::KeyDown) { 1377 PlatformKeyboardEvent platformEvent(platform(event)); 1378 platformEvent.disambiguateKeyDownEvent(PlatformKeyboardEvent::RawKeyDown); 1379 m_page->focusController()->setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, KeyboardEvent::create(platformEvent, frame->document()->defaultView()).get()); 1380 return; 1381 } 1382 1375 1383 m_page->focusController()->setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, 0); 1376 1384 } -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r96439 r96645 481 481 void setActive(bool); 482 482 void setFocused(bool); 483 void setInitialFocus(bool );483 void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&); 484 484 void setWindowResizerSize(const WebCore::IntSize&); 485 485 void setIsInWindow(bool); -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r96439 r96645 24 24 SetActive(bool active) 25 25 SetFocused(bool focused) 26 SetInitialFocus(bool forward )26 SetInitialFocus(bool forward, bool isKeyboardEventValid, WebKit::WebKeyboardEvent event) 27 27 SetIsInWindow(bool isInWindow) 28 28 -
trunk/Tools/ChangeLog
r96623 r96645 1 2011-10-04 Jon Lee <jonlee@apple.com> 2 3 REGRESSION (WK2): (Shift-)option-tabbing skips over elements when transitioning from chrome to webview 4 https://bugs.webkit.org/show_bug.cgi?id=68412 5 <rdar://problem/9988252> 6 7 Reviewed by Darin Adler. 8 9 In order to create a test for the bug, I had to update DRT and WKTR to create some 10 widget that allows first responder status to move away from the main web view. 11 12 Three methods were added to layoutTestController: addChromeInputField, 13 removeChromeInputField, and focusWebView. addChromeInputField adds a text field 14 that is a sibling to the web view, and sets up the key event loop between the two. 15 removeChromeInputField removes that field. focusWebView moves first responder 16 status to the web view. 17 18 The test makes the call via layoutTestController and passes a callback that it 19 assumes will be executed once the task is completed. In DRT the callback is called 20 synchronously. In WKTR this is handled with message passing between the two 21 processes. 22 23 * DumpRenderTree/LayoutTestController.cpp: 24 (addChromeInputFieldCallback): 25 (removeChromeInputFieldCallback): 26 (focusWebViewCallback): 27 (LayoutTestController::staticFunctions): 28 * DumpRenderTree/LayoutTestController.h: 29 * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp: 30 (LayoutTestController::addChromeInputField): 31 (LayoutTestController::removeChromeInputField): 32 (LayoutTestController::focusWebView): 33 * DumpRenderTree/mac/DumpRenderTree.mm: 34 (resetWebViewToConsistentStateBeforeTesting): When resetting for the next test, 35 make sure to remove the chrome input field. 36 * DumpRenderTree/mac/LayoutTestControllerMac.mm: 37 (LayoutTestController::addChromeInputField): 38 (LayoutTestController::removeChromeInputField): 39 (LayoutTestController::focusWebView): 40 * DumpRenderTree/win/LayoutTestControllerWin.cpp: 41 (LayoutTestController::addChromeInputField): 42 (LayoutTestController::removeChromeInputField): 43 (LayoutTestController::focusWebView): 44 * WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl: 45 * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp: 46 (WTR::InjectedBundle::didReceiveMessage): 47 (WTR::InjectedBundle::postAddChromeInputField): 48 (WTR::InjectedBundle::postRemoveChromeInputField): 49 (WTR::InjectedBundle::postFocusWebView): 50 * WebKitTestRunner/InjectedBundle/InjectedBundle.h: 51 * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp: 52 (WTR::callbackMap): Create a hash map that keeps track of the callbacks provided 53 through JS. 54 (WTR::cacheLayoutTestControllerCallback): 55 (WTR::callLayoutTestControllerCallback): 56 (WTR::LayoutTestController::addChromeInputField): 57 (WTR::LayoutTestController::removeChromeInputField): 58 (WTR::LayoutTestController::focusWebView): 59 (WTR::LayoutTestController::callAddChromeInputFieldCallback): 60 (WTR::LayoutTestController::callRemoveChromeInputFieldCallback): 61 (WTR::LayoutTestController::callFocusWebViewCallback): 62 * WebKitTestRunner/InjectedBundle/LayoutTestController.h: 63 * WebKitTestRunner/PlatformWebView.h: 64 * WebKitTestRunner/TestController.cpp: 65 (WTR::TestController::resetStateToConsistentValues): 66 * WebKitTestRunner/TestInvocation.cpp: 67 (WTR::TestInvocation::didReceiveMessageFromInjectedBundle): 68 * WebKitTestRunner/gtk/PlatformWebViewGtk.cpp: 69 (WTR::PlatformWebView::addChromeInputField): 70 (WTR::PlatformWebView::removeChromeInputField): 71 (WTR::PlatformWebView::makeWebViewFirstResponder): 72 * WebKitTestRunner/mac/PlatformWebViewMac.mm: 73 (WTR::PlatformWebView::addChromeInputField): 74 (WTR::PlatformWebView::removeChromeInputField): 75 (WTR::PlatformWebView::makeWebViewFirstResponder): 76 * WebKitTestRunner/win/PlatformWebViewWin.cpp: 77 (WTR::PlatformWebView::addChromeInputField): 78 (WTR::PlatformWebView::removeChromeInputField): 79 (WTR::PlatformWebView::makeWebViewFirstResponder): 80 81 * DumpRenderTree/mac/LayoutTestControllerMac.mm: These functions have nothing to do 82 with the patch-- just cleaning up style. 83 (LayoutTestController::addDisallowedURL): 84 (originsArrayToJS): 85 (LayoutTestController::queueLoad): 86 (LayoutTestController::setMockDeviceOrientation): 87 (LayoutTestController::setIconDatabaseEnabled): 88 (LayoutTestController::setEditingBehavior): 89 1 90 2011-10-04 Simon Fraser <simon.fraser@apple.com> 2 91 -
trunk/Tools/DumpRenderTree/LayoutTestController.cpp
r94105 r96645 2158 2158 controller->setShouldStayOnPageAfterHandlingBeforeUnload(JSValueToBoolean(context, arguments[0])); 2159 2159 2160 return JSValueMakeUndefined(context); 2161 } 2162 2163 static JSValueRef addChromeInputFieldCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 2164 { 2165 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); 2166 controller->addChromeInputField(); 2167 // the first argument is a callback that is called once the input field has been added 2168 if (argumentCount == 1) 2169 JSObjectCallAsFunction(context, JSValueToObject(context, arguments[0], 0), thisObject, 0, 0, 0); 2170 return JSValueMakeUndefined(context); 2171 } 2172 2173 static JSValueRef removeChromeInputFieldCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 2174 { 2175 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); 2176 controller->removeChromeInputField(); 2177 // the first argument is a callback that is called once the input field has been added 2178 if (argumentCount == 1) 2179 JSObjectCallAsFunction(context, JSValueToObject(context, arguments[0], 0), thisObject, 0, 0, 0); 2180 return JSValueMakeUndefined(context); 2181 } 2182 2183 static JSValueRef focusWebViewCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 2184 { 2185 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); 2186 controller->focusWebView(); 2187 // the first argument is a callback that is called once the input field has been added 2188 if (argumentCount == 1) 2189 JSObjectCallAsFunction(context, JSValueToObject(context, arguments[0], 0), thisObject, 0, 0, 0); 2160 2190 return JSValueMakeUndefined(context); 2161 2191 } … … 2437 2467 { "allowRoundingHacks", allowRoundingHacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 2438 2468 { "setShouldStayOnPageAfterHandlingBeforeUnload", setShouldStayOnPageAfterHandlingBeforeUnloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 2469 { "addChromeInputField", addChromeInputFieldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 2470 { "removeChromeInputField", removeChromeInputFieldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 2471 { "focusWebView", focusWebViewCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 2439 2472 { 0, 0, 0 } 2440 2473 }; -
trunk/Tools/DumpRenderTree/LayoutTestController.h
r94343 r96645 315 315 void setShouldStayOnPageAfterHandlingBeforeUnload(bool shouldStayOnPageAfterHandlingBeforeUnload) { m_shouldStayOnPageAfterHandlingBeforeUnload = shouldStayOnPageAfterHandlingBeforeUnload; } 316 316 317 void addChromeInputField(); 318 void removeChromeInputField(); 319 void focusWebView(); 320 317 321 void setPOSIXLocale(JSStringRef locale); 318 322 -
trunk/Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
r94343 r96645 988 988 { 989 989 } 990 991 void LayoutTestController::addChromeInputField() 992 { 993 } 994 995 void LayoutTestController::removeChromeInputField() 996 { 997 } 998 999 void LayoutTestController::focusWebView() 1000 { 1001 } -
trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm
r96434 r96645 1164 1164 resetDefaultsToConsistentValues(); 1165 1165 1166 if (gLayoutTestController) 1166 if (gLayoutTestController) { 1167 1167 WebCoreTestSupport::resetInternalsObject([mainFrame globalContext]); 1168 // in the case that a test using the chrome input field failed, be sure to clean up for the next test 1169 gLayoutTestController->removeChromeInputField(); 1170 } 1168 1171 1169 1172 [[mainFrame webView] setSmartInsertDeleteEnabled:YES]; -
trunk/Tools/DumpRenderTree/mac/LayoutTestControllerMac.mm
r95588 r96645 120 120 121 121 // Canonicalize the URL 122 NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:(NSString *)urlCF.get()]];122 NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:(NSString *)urlCF.get()]]; 123 123 request = [NSURLProtocol canonicalRequestForRequest:request]; 124 124 … … 169 169 } 170 170 171 JSValueRef originsArrayToJS(JSContextRef context, NSArray *origins)171 JSValueRef originsArrayToJS(JSContextRef context, NSArray *origins) 172 172 { 173 173 NSUInteger count = [origins count]; … … 426 426 427 427 NSURL *nsurl = [NSURL URLWithString:urlNS relativeToURL:[[[mainFrame dataSource] response] URL]]; 428 NSString *nsurlString = [nsurl absoluteString];428 NSString *nsurlString = [nsurl absoluteString]; 429 429 430 430 JSRetainPtr<JSStringRef> absoluteURL(Adopt, JSStringCreateWithUTF8CString([nsurlString UTF8String])); … … 509 509 // DumpRenderTree configured the WebView to use WebDeviceOrientationProviderMock. 510 510 id<WebDeviceOrientationProvider> provider = [[mainFrame webView] _deviceOrientationProvider]; 511 WebDeviceOrientationProviderMock *mockProvider = static_cast<WebDeviceOrientationProviderMock*>(provider);512 WebDeviceOrientation *orientation = [[WebDeviceOrientation alloc] initWithCanProvideAlpha:canProvideAlpha alpha:alpha canProvideBeta:canProvideBeta beta:beta canProvideGamma:canProvideGamma gamma:gamma];511 WebDeviceOrientationProviderMock *mockProvider = static_cast<WebDeviceOrientationProviderMock*>(provider); 512 WebDeviceOrientation *orientation = [[WebDeviceOrientation alloc] initWithCanProvideAlpha:canProvideAlpha alpha:alpha canProvideBeta:canProvideBeta beta:beta canProvideGamma:canProvideGamma gamma:gamma]; 513 513 [mockProvider setOrientation:orientation]; 514 514 [orientation release]; … … 551 551 { 552 552 // FIXME: Workaround <rdar://problem/6480108> 553 static WebIconDatabase *sharedWebIconDatabase = NULL;553 static WebIconDatabase *sharedWebIconDatabase = NULL; 554 554 if (!sharedWebIconDatabase) { 555 555 if (!iconDatabaseEnabled) … … 1152 1152 void LayoutTestController::setEditingBehavior(const char* editingBehavior) 1153 1153 { 1154 NSString *editingBehaviorNS = [[NSString alloc] initWithUTF8String:editingBehavior];1154 NSString *editingBehaviorNS = [[NSString alloc] initWithUTF8String:editingBehavior]; 1155 1155 if ([editingBehaviorNS isEqualToString:@"mac"]) 1156 1156 [[WebPreferences standardPreferences] setEditingBehavior:WebKitEditingMacBehavior]; … … 1203 1203 #endif 1204 1204 } 1205 1206 void LayoutTestController::addChromeInputField() 1207 { 1208 NSTextField *textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 20)]; 1209 textField.tag = 1; 1210 [[[[mainFrame webView] window] contentView] addSubview:textField]; 1211 [textField release]; 1212 1213 [textField setNextKeyView:[mainFrame webView]]; 1214 [[mainFrame webView] setNextKeyView:textField]; 1215 } 1216 1217 void LayoutTestController::removeChromeInputField() 1218 { 1219 NSView* textField = [[[[mainFrame webView] window] contentView] viewWithTag:1]; 1220 if (textField) { 1221 [textField removeFromSuperview]; 1222 focusWebView(); 1223 } 1224 } 1225 1226 void LayoutTestController::focusWebView() 1227 { 1228 [[[mainFrame webView] window] makeFirstResponder:[mainFrame webView]]; 1229 } -
trunk/Tools/DumpRenderTree/win/LayoutTestControllerWin.cpp
r94343 r96645 1541 1541 { 1542 1542 } 1543 1544 void LayoutTestController::addChromeInputField() 1545 { 1546 } 1547 1548 void LayoutTestController::removeChromeInputField() 1549 { 1550 } 1551 1552 void LayoutTestController::focusWebView() 1553 { 1554 } -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
r96405 r96645 122 122 123 123 void setShouldStayOnPageAfterHandlingBeforeUnload(in boolean flag); 124 125 // Focus testing. 126 void addChromeInputField(in object callback); 127 void removeChromeInputField(in object callback); 128 void focusWebView(in object callback); 124 129 }; 125 130 -
trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
r96405 r96645 159 159 return; 160 160 } 161 if (WKStringIsEqualToUTF8CString(messageName, "CallAddChromeInputFieldCallback")) { 162 m_layoutTestController->callAddChromeInputFieldCallback(); 163 return; 164 } 165 if (WKStringIsEqualToUTF8CString(messageName, "CallRemoveChromeInputFieldCallback")) { 166 m_layoutTestController->callRemoveChromeInputFieldCallback(); 167 return; 168 } 169 if (WKStringIsEqualToUTF8CString(messageName, "CallFocusWebViewCallback")) { 170 m_layoutTestController->callFocusWebViewCallback(); 171 return; 172 } 161 173 162 174 WKRetainPtr<WKStringRef> errorMessageName(AdoptWK, WKStringCreateWithUTF8CString("Error")); … … 247 259 } 248 260 261 void InjectedBundle::postAddChromeInputField() 262 { 263 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("AddChromeInputField")); 264 WKBundlePostMessage(m_bundle, messageName.get(), 0); 265 } 266 267 void InjectedBundle::postRemoveChromeInputField() 268 { 269 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("RemoveChromeInputField")); 270 WKBundlePostMessage(m_bundle, messageName.get(), 0); 271 } 272 273 void InjectedBundle::postFocusWebView() 274 { 275 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("FocusWebView")); 276 WKBundlePostMessage(m_bundle, messageName.get(), 0); 277 } 278 249 279 } // namespace WTR -
trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
r96005 r96645 75 75 76 76 void postNewBeforeUnloadReturnValue(bool); 77 void postAddChromeInputField(); 78 void postRemoveChromeInputField(); 79 void postFocusWebView(); 77 80 78 81 private: -
trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
r96405 r96645 514 514 } 515 515 516 typedef WTF::HashMap<unsigned, JSValueRef> CallbackMap; 517 static CallbackMap& callbackMap() 518 { 519 static CallbackMap& map = *new CallbackMap; 520 return map; 521 } 522 523 static void cacheLayoutTestControllerCallback(unsigned index, JSValueRef callback) 524 { 525 WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); 526 JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame); 527 JSValueProtect(context, callback); 528 callbackMap().add(index, callback); 529 } 530 531 static void callLayoutTestControllerCallback(unsigned index) 532 { 533 if (!callbackMap().contains(index)) 534 return; 535 WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); 536 JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame); 537 JSObjectRef callback = JSValueToObject(context, callbackMap().take(index), 0); 538 JSObjectCallAsFunction(context, callback, JSContextGetGlobalObject(context), 0, 0, 0); 539 JSValueUnprotect(context, callback); 540 } 541 542 void LayoutTestController::addChromeInputField(JSValueRef callback) 543 { 544 cacheLayoutTestControllerCallback(1, callback); 545 InjectedBundle::shared().postAddChromeInputField(); 546 } 547 548 void LayoutTestController::removeChromeInputField(JSValueRef callback) 549 { 550 cacheLayoutTestControllerCallback(2, callback); 551 InjectedBundle::shared().postRemoveChromeInputField(); 552 } 553 554 void LayoutTestController::focusWebView(JSValueRef callback) 555 { 556 cacheLayoutTestControllerCallback(3, callback); 557 InjectedBundle::shared().postFocusWebView(); 558 } 559 560 void LayoutTestController::callAddChromeInputFieldCallback() 561 { 562 callLayoutTestControllerCallback(1); 563 } 564 565 void LayoutTestController::callRemoveChromeInputFieldCallback() 566 { 567 callLayoutTestControllerCallback(2); 568 } 569 570 void LayoutTestController::callFocusWebViewCallback() 571 { 572 callLayoutTestControllerCallback(3); 573 } 574 516 575 } // namespace WTR -
trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h
r96405 r96645 177 177 bool globalFlag() const { return m_globalFlag; } 178 178 void setGlobalFlag(bool value) { m_globalFlag = value; } 179 180 void addChromeInputField(JSValueRef); 181 void removeChromeInputField(JSValueRef); 182 void focusWebView(JSValueRef); 183 void callAddChromeInputFieldCallback(); 184 void callRemoveChromeInputFieldCallback(); 185 void callFocusWebViewCallback(); 179 186 180 187 private: -
trunk/Tools/WebKitTestRunner/PlatformWebView.h
r96416 r96645 71 71 WKRect windowFrame(); 72 72 void setWindowFrame(WKRect); 73 74 void addChromeInputField(); 75 void removeChromeInputField(); 76 void makeWebViewFirstResponder(); 73 77 74 78 private: -
trunk/Tools/WebKitTestRunner/TestController.cpp
r96439 r96645 427 427 #endif 428 428 429 // in the case that a test using the chrome input field failed, be sure to clean up for the next test 430 m_mainWebView->removeChromeInputField(); 429 431 m_mainWebView->focus(); 430 432 -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r96005 r96645 249 249 return; 250 250 } 251 252 if (WKStringIsEqualToUTF8CString(messageName, "AddChromeInputField")) { 253 TestController::shared().mainWebView()->addChromeInputField(); 254 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallAddChromeInputFieldCallback")); 255 WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0); 256 return; 257 } 258 259 if (WKStringIsEqualToUTF8CString(messageName, "RemoveChromeInputField")) { 260 TestController::shared().mainWebView()->removeChromeInputField(); 261 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallRemoveChromeInputFieldCallback")); 262 WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0); 263 return; 264 } 265 266 if (WKStringIsEqualToUTF8CString(messageName, "FocusWebView")) { 267 TestController::shared().mainWebView()->makeWebViewFirstResponder(); 268 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallFocusWebViewCallback")); 269 WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0); 270 return; 271 } 251 272 252 273 ASSERT_NOT_REACHED(); -
trunk/Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp
r87760 r96645 98 98 } 99 99 100 void PlatformWebView::addChromeInputField() 101 { 102 } 103 104 void PlatformWebView::removeChromeInputField() 105 { 106 } 107 108 void PlatformWebView::makeWebViewFirstResponder() 109 { 110 } 111 100 112 } // namespace WTR 101 113 -
trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm
r85083 r96645 81 81 } 82 82 83 void PlatformWebView::addChromeInputField() 84 { 85 NSTextField* textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 20)]; 86 textField.tag = 1; 87 [[m_window contentView] addSubview:textField]; 88 [textField release]; 89 90 [textField setNextKeyView:m_view]; 91 [m_view setNextKeyView:textField]; 92 } 93 94 void PlatformWebView::removeChromeInputField() 95 { 96 NSView* textField = [[m_window contentView] viewWithTag:1]; 97 if (textField) { 98 [textField removeFromSuperview]; 99 makeWebViewFirstResponder(); 100 } 101 } 102 103 void PlatformWebView::makeWebViewFirstResponder() 104 { 105 [m_window makeFirstResponder:m_view]; 106 } 107 83 108 } // namespace WTR -
trunk/Tools/WebKitTestRunner/win/PlatformWebViewWin.cpp
r81135 r96645 98 98 } 99 99 100 101 void PlatformWebView::addChromeInputField() 102 { 103 } 104 105 void PlatformWebView::removeChromeInputField() 106 { 107 } 108 109 void PlatformWebView::makeWebViewFirstResponder() 110 { 111 } 112 100 113 } // namespace WTR
Note: See TracChangeset
for help on using the changeset viewer.