LayoutTests/ChangeLog

 12011-09-22 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 NOBODY (OOPS!).
 8
 9 * fast/forms/focus-option-control-on-page-expected.txt: Added.
 10 * fast/forms/focus-option-control-on-page.html: Added.
 11
1122011-09-19 Dmitry Lomov <dslomov@google.com>
213
314 [Chromium] Rebaseline expectations due to r95402.

LayoutTests/fast/forms/focus-option-control-on-page-expected.txt

 1<https://bugs.webkit.org/show_bug.cgi?id=68412> This test checks to see if option(alt)-tabbing properly focuses form elements that are normally not focused. For testing, the assumption is that by default pressing tab will skip over buttons, and option-tab will include buttons.
 2
 3
 4Tab:
 50:2
 61:
 72:2
 83:
 9Shift-tab:
 100:2
 111:
 122:2
 133:
 14Option-tab:
 150:1
 161:2
 172:3
 183:
 19Shift-option-tab:
 200:3
 211:2
 222:1
 233:

LayoutTests/fast/forms/focus-option-control-on-page.html

 1<p>&lt;https://bugs.webkit.org/show_bug.cgi?id=68412&gt; This test checks to see if option(alt)-tabbing properly focuses form elements that are normally not focused. For testing, the assumption is that by default pressing tab will skip over buttons, and option-tab will include buttons.</p>
 2<hr>
 3<input type="button" onfocus="log(1)" value="button">
 4<input type="text" id="textField" onfocus="log(2)" value="text">
 5<input type="button" onfocus="log(3)" value="button">
 6<hr>
 7<p id="log"></p>
 8
 9<script>
 10
 11function log(str)
 12{
 13 document.getElementById("log").innerHTML += str;
 14}
 15
 16window.onload = function()
 17{
 18 if (!window.layoutTestController || !window.eventSender)
 19 return;
 20
 21 if (!layoutTestController.addChromeInputField)
 22 return;
 23
 24 layoutTestController.dumpAsText();
 25 layoutTestController.waitUntilDone();
 26 layoutTestController.addChromeInputField(startTest);
 27}
 28
 29var iteration = 0;
 30var modifiers;
 31function startTest() {
 32 log("Tab:");
 33 modifiers = undefined;
 34 layoutTestController.focusWebView(runKeyPresses);
 35 setTimeout(function() {layoutTestController.removeChromeInputField(notifyDone)}, 2000);
 36}
 37
 38function runKeyPresses() {
 39 for (var i = 0; i < 4; ++i) {
 40 log("<br/>" + i + ":");
 41 eventSender.keyDown("\t", modifiers);
 42 }
 43
 44 iteration++;
 45 switch (iteration) {
 46 case 1:
 47 log("<br/>Shift-tab:");
 48 modifiers = ["shiftKey"];
 49 layoutTestController.focusWebView(runKeyPresses);
 50 break;
 51 case 2:
 52 log("<br/>Option-tab:");
 53 modifiers = ["altKey"];
 54 layoutTestController.focusWebView(runKeyPresses);
 55 break;
 56 case 3:
 57 log("<br/>Shift-option-tab:");
 58 modifiers = ["shiftKey", "altKey"];
 59 layoutTestController.focusWebView(runKeyPresses);
 60 break;
 61 case 4:
 62 layoutTestController.removeChromeInputField(notifyDone);
 63 break;
 64 }
 65}
 66
 67function notifyDone() {
 68 layoutTestController.notifyDone();
 69}
 70</script>

Source/WebKit2/ChangeLog

 12011-09-22 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 NOBODY (OOPS!).
 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/mac/WKView.mm:
 19 (-[WKView becomeFirstResponder]): Take the NSApp currentEvent and pass it along if
 20 the event is a keyboard event, otherwise pass an empty event.
 21 * UIProcess/WebPageProxy.cpp:
 22 (WebKit::WebPageProxy::setInitialFocus): Change in function signature to confirm that
 23 the event that caused the initial focus was a keyboard event, and provide the keyboard
 24 event itself.
 25 * UIProcess/WebPageProxy.h:
 26 * WebProcess/WebPage/WebPage.cpp:
 27 (WebKit::WebPage::setInitialFocus): If we know that the cause of this was a keyboard
 28 event, we pass that event to the FocusController. Otherwise we fall back to the original
 29 behavior, which is to pass no event at all.
 30 * WebProcess/WebPage/WebPage.h:
 31 * WebProcess/WebPage/WebPage.messages.in:
 32
1332011-09-14 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
234
335 [Qt] [WK2] Implement popup menus in QDesktopWebView using QComboBox

Source/WebKit2/UIProcess/API/mac/WKView.mm

@@struct WKViewInterpretKeyEventsParameters {
304304- (BOOL)becomeFirstResponder
305305{
306306 NSSelectionDirection direction = [[self window] keyViewSelectionDirection];
307 
 307
308308 _data->_inBecomeFirstResponder = true;
309309
310310 [self _updateSecureInputState];
311311 _data->_page->viewStateDidChange(WebPageProxy::ViewIsFocused);
312 
 312
313313 _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 if ([event type] == NSKeyDown || [event type] == NSKeyUp)
 318 _data->_page->setInitialFocus(direction == NSSelectingNext, true, NativeWebKeyboardEvent(event, self));
 319 else
 320 _data->_page->setInitialFocus(direction == NSSelectingNext, false, NativeWebKeyboardEvent(0, self));
 321 }
318322 return YES;
319323}
320324

Source/WebKit2/UIProcess/WebPageProxy.cpp

@@IntSize WebPageProxy::viewSize() const
684684 return m_pageClient->viewSize();
685685}
686686
687 void WebPageProxy::setInitialFocus(bool forward)
 687void WebPageProxy::setInitialFocus(bool forward, bool isKeyboardEventValid, const NativeWebKeyboardEvent& keyboardEvent)
688688{
689689 if (!isValid())
690690 return;
691  process()->send(Messages::WebPage::SetInitialFocus(forward), m_pageID);
 691 process()->send(Messages::WebPage::SetInitialFocus(forward, isKeyboardEventValid, keyboardEvent), m_pageID);
692692}
693693
694694void WebPageProxy::setWindowResizerSize(const IntSize& windowResizerSize)

Source/WebKit2/UIProcess/WebPageProxy.h

@@public:
262262 void viewWillStartLiveResize();
263263 void viewWillEndLiveResize();
264264
265  void setInitialFocus(bool);
 265 void setInitialFocus(bool, bool, const NativeWebKeyboardEvent&);
266266 void setWindowResizerSize(const WebCore::IntSize&);
267267
268268 void clearSelection();

Source/WebKit2/WebProcess/WebPage/WebPage.cpp

@@void WebPage::setFocused(bool isFocused)
12921292 m_page->focusController()->setFocused(isFocused);
12931293}
12941294
1295 void WebPage::setInitialFocus(bool forward)
 1295void WebPage::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& event)
12961296{
12971297 if (!m_page || !m_page->focusController())
12981298 return;
12991299
 1300
13001301 Frame* frame = m_page->focusController()->focusedOrMainFrame();
13011302 frame->document()->setFocusedNode(0);
1302  m_page->focusController()->setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, 0);
 1303
 1304 if (isKeyboardEventValid && event.type() == WebEvent::KeyDown) {
 1305 PlatformKeyboardEvent platformEvent(platform(event));
 1306 platformEvent.disambiguateKeyDownEvent(PlatformKeyboardEvent::RawKeyDown);
 1307 m_page->focusController()->setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, KeyboardEvent::create(platformEvent, frame->document()->defaultView()).get());
 1308 } else
 1309 m_page->focusController()->setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, 0);
13031310}
13041311
13051312void WebPage::setWindowResizerSize(const IntSize& windowResizerSize)

Source/WebKit2/WebProcess/WebPage/WebPage.h

@@private:
468468 void tryRestoreScrollPosition();
469469 void setActive(bool);
470470 void setFocused(bool);
471  void setInitialFocus(bool);
 471 void setInitialFocus(bool, bool, const WebKeyboardEvent&);
472472 void setWindowResizerSize(const WebCore::IntSize&);
473473 void setIsInWindow(bool);
474474 void validateCommand(const String&, uint64_t);

Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

2323messages -> WebPage {
2424 SetActive(bool active)
2525 SetFocused(bool focused)
26  SetInitialFocus(bool forward)
 26 SetInitialFocus(bool forward, bool isKeyboardEventValid, WebKit::WebKeyboardEvent event)
2727 SetIsInWindow(bool isInWindow)
2828
2929 SetDrawsBackground(bool drawsBackground)

Tools/ChangeLog

 12011-09-22 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 NOBODY (OOPS!).
 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/mac/LayoutTestControllerMac.mm:
 30 (LayoutTestController::addChromeInputField):
 31 (LayoutTestController::removeChromeInputField):
 32 (LayoutTestController::focusWebView):
 33 * WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
 34 * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
 35 (WTR::InjectedBundle::didReceiveMessage):
 36 (WTR::InjectedBundle::postAddChromeInputField):
 37 (WTR::InjectedBundle::postRemoveChromeInputField):
 38 (WTR::InjectedBundle::postFocusWebView):
 39 * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
 40 * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
 41 (WTR::callbackMap): Create a hash map that keeps track of the callbacks provided
 42 through JS.
 43 (WTR::cacheLayoutTestControllerCallback):
 44 (WTR::callLayoutTestControllerCallback):
 45 (WTR::LayoutTestController::addChromeInputField):
 46 (WTR::LayoutTestController::removeChromeInputField):
 47 (WTR::LayoutTestController::focusWebView):
 48 (WTR::LayoutTestController::callAddChromeInputFieldCallback):
 49 (WTR::LayoutTestController::callRemoveChromeInputFieldCallback):
 50 (WTR::LayoutTestController::callFocusWebViewCallback):
 51 * WebKitTestRunner/InjectedBundle/LayoutTestController.h:
 52 * WebKitTestRunner/PlatformWebView.h:
 53 * WebKitTestRunner/TestInvocation.cpp:
 54 (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
 55 * WebKitTestRunner/mac/PlatformWebViewMac.mm:
 56 (WTR::PlatformWebView::addChromeTextField):
 57 (WTR::PlatformWebView::removeChromeTextField):
 58 (WTR::PlatformWebView::makeWebViewFirstResponder):
 59
1602011-09-16 Elliot Poger <epoger@google.com>
261
362 add non-CG Webkit-Mac builds to flakiness dashboard

Tools/DumpRenderTree/LayoutTestController.cpp

@@static JSValueRef setShouldStayOnPageAfterHandlingBeforeUnloadCallback(JSContext
21602160 return JSValueMakeUndefined(context);
21612161}
21622162
 2163static 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
 2173static 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
 2183static 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);
 2190 return JSValueMakeUndefined(context);
 2191}
 2192
21632193// Static Values
21642194
21652195static JSValueRef getGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)

@@JSStaticFunction* LayoutTestController::staticFunctions()
24362466 { "setTextDirection", setTextDirectionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
24372467 { "allowRoundingHacks", allowRoundingHacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
24382468 { "setShouldStayOnPageAfterHandlingBeforeUnload", setShouldStayOnPageAfterHandlingBeforeUnloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
 2469 { "addChromeInputField", addChromeInputFieldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
 2470 { "removeChromeInputField", removeChromeInputFieldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
 2471 { "focusWebView", focusWebViewCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
24392472 { 0, 0, 0 }
24402473 };
24412474

Tools/DumpRenderTree/LayoutTestController.h

@@public:
314314 bool shouldStayOnPageAfterHandlingBeforeUnload() const { return m_shouldStayOnPageAfterHandlingBeforeUnload; }
315315 void setShouldStayOnPageAfterHandlingBeforeUnload(bool shouldStayOnPageAfterHandlingBeforeUnload) { m_shouldStayOnPageAfterHandlingBeforeUnload = shouldStayOnPageAfterHandlingBeforeUnload; }
316316
 317 void addChromeInputField();
 318 void removeChromeInputField();
 319 void focusWebView();
 320
317321 void setPOSIXLocale(JSStringRef locale);
318322
319323 void setWebViewEditable(bool);

Tools/DumpRenderTree/mac/LayoutTestControllerMac.mm

@@void LayoutTestController::setTextDirection(JSStringRef directionName)
11431143 ASSERT_NOT_REACHED();
11441144#endif
11451145}
 1146
 1147void LayoutTestController::addChromeInputField()
 1148{
 1149 NSTextField* textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 20)];
 1150 textField.tag = 1;
 1151 [[[[mainFrame webView] window] contentView] addSubview:textField];
 1152 [textField release];
 1153
 1154 [textField setNextKeyView:[mainFrame webView]];
 1155 [[mainFrame webView] setNextKeyView:textField];
 1156}
 1157
 1158void LayoutTestController::removeChromeInputField()
 1159{
 1160 [[[[[mainFrame webView] window] contentView] viewWithTag:1] removeFromSuperview];
 1161 focusWebView();
 1162}
 1163
 1164void LayoutTestController::focusWebView()
 1165{
 1166 [[[mainFrame webView] window] makeFirstResponder:[mainFrame webView]];
 1167}

Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl

@@module WTR {
117117 void setWillSendRequestReturnsNull(in boolean flag);
118118
119119 void setShouldStayOnPageAfterHandlingBeforeUnload(in boolean flag);
 120
 121 // Focus testing.
 122 void addChromeInputField(in object callback);
 123 void removeChromeInputField(in object callback);
 124 void focusWebView(in object callback);
120125 };
121126
122127}

Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

@@void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messag
158158
159159 return;
160160 }
 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 }
161173
162174 WKRetainPtr<WKStringRef> errorMessageName(AdoptWK, WKStringCreateWithUTF8CString("Error"));
163175 WKRetainPtr<WKStringRef> errorMessageBody(AdoptWK, WKStringCreateWithUTF8CString("Unknown"));

@@void InjectedBundle::postNewBeforeUnloadReturnValue(bool value)
241253 WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
242254}
243255
 256void InjectedBundle::postAddChromeInputField()
 257{
 258 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("AddChromeInputField"));
 259 WKBundlePostMessage(m_bundle, messageName.get(), 0);
 260}
 261
 262void InjectedBundle::postRemoveChromeInputField()
 263{
 264 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("RemoveChromeInputField"));
 265 WKBundlePostMessage(m_bundle, messageName.get(), 0);
 266}
 267
 268void InjectedBundle::postFocusWebView()
 269{
 270 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("FocusWebView"));
 271 WKBundlePostMessage(m_bundle, messageName.get(), 0);
 272}
 273
244274} // namespace WTR

Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h

@@public:
7373 bool shouldDumpPixels() const { return m_dumpPixels; }
7474
7575 void postNewBeforeUnloadReturnValue(bool);
 76 void postAddChromeInputField();
 77 void postRemoveChromeInputField();
 78 void postFocusWebView();
7679
7780private:
7881 InjectedBundle();

Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp

@@void LayoutTestController::setShouldStayOnPageAfterHandlingBeforeUnload(bool sho
500500 InjectedBundle::shared().postNewBeforeUnloadReturnValue(!shouldStayOnPage);
501501}
502502
 503typedef WTF::HashMap<unsigned, JSValueRef> CallbackMap;
 504static CallbackMap& callbackMap()
 505{
 506 static CallbackMap& map = *new CallbackMap;
 507 return map;
 508}
 509
 510static void cacheLayoutTestControllerCallback(unsigned index, JSValueRef callback)
 511{
 512 WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
 513 JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
 514 JSValueProtect(context, callback);
 515 callbackMap().add(index, callback);
 516}
 517
 518static void callLayoutTestControllerCallback(unsigned index)
 519{
 520 if (!callbackMap().contains(index))
 521 return;
 522 WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
 523 JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
 524 JSObjectRef callback = JSValueToObject(context, callbackMap().take(index), 0);
 525 JSObjectCallAsFunction(context, callback, JSContextGetGlobalObject(context), 0, 0, 0);
 526 JSValueUnprotect(context, callback);
 527}
 528
 529void LayoutTestController::addChromeInputField(JSValueRef callback)
 530{
 531 cacheLayoutTestControllerCallback(1, callback);
 532 InjectedBundle::shared().postAddChromeInputField();
 533}
 534
 535void LayoutTestController::removeChromeInputField(JSValueRef callback)
 536{
 537 cacheLayoutTestControllerCallback(2, callback);
 538 InjectedBundle::shared().postRemoveChromeInputField();
 539}
 540
 541void LayoutTestController::focusWebView(JSValueRef callback)
 542{
 543 cacheLayoutTestControllerCallback(3, callback);
 544 InjectedBundle::shared().postFocusWebView();
 545}
 546
 547void LayoutTestController::callAddChromeInputFieldCallback()
 548{
 549 callLayoutTestControllerCallback(1);
 550}
 551
 552void LayoutTestController::callRemoveChromeInputFieldCallback()
 553{
 554 callLayoutTestControllerCallback(2);
 555}
 556
 557void LayoutTestController::callFocusWebViewCallback()
 558{
 559 callLayoutTestControllerCallback(3);
 560}
 561
503562} // namespace WTR

Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h

@@public:
172172
173173 bool globalFlag() const { return m_globalFlag; }
174174 void setGlobalFlag(bool value) { m_globalFlag = value; }
 175
 176 void addChromeInputField(JSValueRef);
 177 void removeChromeInputField(JSValueRef);
 178 void focusWebView(JSValueRef);
 179 void callAddChromeInputFieldCallback();
 180 void callRemoveChromeInputFieldCallback();
 181 void callFocusWebViewCallback();
175182
176183private:
177184 static const double waitToDumpWatchdogTimerInterval;

Tools/WebKitTestRunner/PlatformWebView.h

@@public:
6767
6868 WKRect windowFrame();
6969 void setWindowFrame(WKRect);
 70
 71 void addChromeTextField();
 72 void removeChromeTextField();
 73 void makeWebViewFirstResponder();
7074
7175private:
7276 PlatformWKView m_view;

Tools/WebKitTestRunner/TestInvocation.cpp

@@void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
245245 TestController::shared().setBeforeUnloadReturnValue(WKBooleanGetValue(beforeUnloadReturnValue));
246246 return;
247247 }
 248
 249 if (WKStringIsEqualToUTF8CString(messageName, "AddChromeInputField")) {
 250 TestController::shared().mainWebView()->addChromeTextField();
 251 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallAddChromeInputFieldCallback"));
 252 WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0);
 253 return;
 254 }
 255
 256 if (WKStringIsEqualToUTF8CString(messageName, "RemoveChromeInputField")) {
 257 TestController::shared().mainWebView()->removeChromeTextField();
 258 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallRemoveChromeInputFieldCallback"));
 259 WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0);
 260 return;
 261 }
 262
 263 if (WKStringIsEqualToUTF8CString(messageName, "FocusWebView")) {
 264 TestController::shared().mainWebView()->makeWebViewFirstResponder();
 265 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallFocusWebViewCallback"));
 266 WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0);
 267 return;
 268 }
248269
249270 ASSERT_NOT_REACHED();
250271}

Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm

@@void PlatformWebView::setWindowFrame(WKRect frame)
8080 [m_window setFrame:NSMakeRect(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height) display:YES];
8181}
8282
 83void PlatformWebView::addChromeTextField()
 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
 94void PlatformWebView::removeChromeTextField()
 95{
 96 [[[m_window contentView] viewWithTag:1] removeFromSuperview];
 97 makeWebViewFirstResponder();
 98}
 99
 100void PlatformWebView::makeWebViewFirstResponder()
 101{
 102 [m_window makeFirstResponder:m_view];
 103}
 104
83105} // namespace WTR