Changeset 121904 in webkit
- Timestamp:
- Jul 5, 2012 7:23:45 AM (12 years ago)
- Location:
- trunk/Source/WebKit/chromium
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/chromium/ChangeLog
r121880 r121904 1 2012-07-05 Oli Lan <olilan@chromium.org> 2 3 [chromium] Add a method didChangeFormState to WebViewClient. 4 https://bugs.webkit.org/show_bug.cgi?id=90563 5 6 Reviewed by Adam Barth. 7 8 This patch adds a new method didChangeFormState to WebViewClient, 9 and calls it from ChromeClientImpl::formStateDidChange with the changed node. 10 11 This new method can be used for example by the Android port to update the browser's 12 IME when the state of the currently focused text node has changed. To facilitate this 13 usage, a focused() method has been added to WebNode. 14 15 A new test has been added to WebViewTest. This test checks that didChangeFormState 16 is called when an input's value is changed, and also checks that WebNode::focused() returns 17 the correct value for the provided node, in both the focused and non-focused cases. 18 19 * public/WebNode.h: 20 * public/WebViewClient.h: 21 (WebKit::WebViewClient::didChangeFormState): 22 * src/ChromeClientImpl.cpp: 23 (WebKit::ChromeClientImpl::formStateDidChange): 24 * src/WebNode.cpp: 25 (WebKit::WebNode::focused): 26 (WebKit): 27 * tests/WebViewTest.cpp: 28 (FormChangeWebViewClient): 29 (WebKit::FormChangeWebViewClient::didChangeFormState): 30 (WebKit::FormChangeWebViewClient::reset): 31 (WebKit::FormChangeWebViewClient::called): 32 (WebKit::FormChangeWebViewClient::focused): 33 (WebKit): 34 (WebKit::TEST_F): 35 * tests/data/input_field_set_value_while_focused.html: Added. 36 * tests/data/input_field_set_value_while_not_focused.html: Added. 37 1 38 2012-07-04 Yoshifumi Inoue <yosin@chromium.org> 2 39 -
trunk/Source/WebKit/chromium/public/WebNode.h
r105489 r121904 112 112 WEBKIT_EXPORT WebNodeList getElementsByTagName(const WebString&) const; 113 113 WEBKIT_EXPORT WebElement rootEditableElement() const; 114 WEBKIT_EXPORT bool focused() const; 114 115 115 116 // Returns true if the node has a non-empty bounding box in layout. -
trunk/Source/WebKit/chromium/public/WebViewClient.h
r121483 r121904 188 188 virtual void didExecuteCommand(const WebString& commandName) { } 189 189 virtual void didEndEditing() { } 190 virtual void didChangeFormState(const WebNode&) { } 190 191 191 192 // This method is called in response to WebView's handleInputEvent() -
trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp
r121555 r121904 842 842 void ChromeClientImpl::formStateDidChange(const Node* node) 843 843 { 844 if (m_webView->client()) 845 m_webView->client()->didChangeFormState(WebNode(const_cast<Node*>(node))); 846 844 847 // The current history item is not updated yet. That happens lazily when 845 848 // WebFrame::currentHistoryItem is requested. -
trunk/Source/WebKit/chromium/src/WebNode.cpp
r120637 r121904 214 214 } 215 215 216 bool WebNode::focused() const 217 { 218 return m_private->focused(); 219 } 220 216 221 bool WebNode::hasNonEmptyBoundingBox() const 217 222 { -
trunk/Source/WebKit/chromium/tests/WebViewTest.cpp
r121469 r121904 93 93 }; 94 94 95 class FormChangeWebViewClient : public WebViewClient { 96 public: 97 // WebViewClient methods 98 virtual void didChangeFormState(const WebNode& node) 99 { 100 m_focused = node.focused(); 101 m_called = true; 102 } 103 104 // Local methods 105 void reset() 106 { 107 m_called = false; 108 m_focused = false; 109 } 110 bool called() { return m_called; } 111 bool focused() { return m_focused; } 112 113 private: 114 bool m_called; 115 bool m_focused; 116 }; 117 95 118 class WebViewTest : public testing::Test { 96 119 public: … … 338 361 } 339 362 340 } 363 TEST_F(WebViewTest, FormChange) 364 { 365 FormChangeWebViewClient client; 366 client.reset(); 367 FrameTestHelpers::registerMockedURLLoad(m_baseURL, "input_field_set_value_while_focused.html"); 368 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input_field_set_value_while_focused.html", true, 0, &client); 369 EXPECT_TRUE(client.called()); 370 EXPECT_TRUE(client.focused()); 371 client.reset(); 372 FrameTestHelpers::registerMockedURLLoad(m_baseURL, "input_field_set_value_while_not_focused.html"); 373 webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input_field_set_value_while_not_focused.html", true, 0, &client); 374 EXPECT_TRUE(client.called()); 375 EXPECT_FALSE(client.focused()); 376 webView->close(); 377 } 378 379 }
Note: See TracChangeset
for help on using the changeset viewer.