Changeset 106216 in webkit
- Timestamp:
- Jan 29, 2012 11:22:59 PM (12 years ago)
- Location:
- trunk/Source/WebKit/chromium
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/chromium/ChangeLog
r106214 r106216 1 2012-01-29 Kent Tamura <tkent@chromium.org> 2 3 [Chromium] REGRESSION(r87067): WebFrame::setFindEndstateFocusAndSelection() 4 doesn't set the selection for <input> and <textarea> 5 https://bugs.webkit.org/show_bug.cgi?id=77186 6 7 Reviewed by Hajime Morita. 8 9 When the find-in-page box is closed, WebFrame::stopFinding(false) is 10 called. It calls setFindEndstateFocusAndSelection(). Before r87067, 11 m_activeMatch was stored as the normal selection in <input> or 12 <textarea> by accident. r87067 stopped this accidental behavior. 13 14 However the behavior of pre-r87067 is useful and we should support it 15 for contentEditable elements too. 16 17 * src/WebFrameImpl.cpp: 18 (WebKit::WebFrameImpl::setFindEndstateFocusAndSelection): 19 - Add special handing for <input> and <textarea> to find a focusable parent. 20 - Sets the active match as the selection even if a focusable parent is found. 21 * tests/WebFrameTest.cpp: 22 (WebKit::TEST_F): Add tests for find() and stopFinding(). 23 * tests/data/find.html: Added. 24 1 25 2012-01-29 Nico Weber <nicolasweber@gmx.de> 2 26 -
trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp
r105489 r106216 2165 2165 // example, focus links if we have found text within the link. 2166 2166 Node* node = m_activeMatch->firstNode(); 2167 if (node && node->isInShadowTree()) { 2168 Node* host = node->shadowAncestorNode(); 2169 if (host->hasTagName(HTMLNames::inputTag) || host->hasTagName(HTMLNames::textareaTag)) 2170 node = host; 2171 } 2167 2172 while (node && !node->isFocusable() && node != frame()->document()) 2168 2173 node = node->parentNode(); 2169 2174 2170 2175 if (node && node != frame()->document()) { 2171 // Found a focusable parent node. Set focus to it. 2176 // Found a focusable parent node. Set the active match as the 2177 // selection and focus to the focusable node. 2178 frame()->selection()->setSelection(m_activeMatch.get()); 2172 2179 frame()->document()->setFocusedNode(node); 2173 2180 return; -
trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp
r99940 r106216 34 34 #include "ResourceError.h" 35 35 #include "WebDocument.h" 36 #include "WebFindOptions.h" 36 37 #include "WebFormElement.h" 37 38 #include "WebFrame.h" 38 39 #include "WebFrameClient.h" 40 #include "WebRange.h" 39 41 #include "WebScriptSource.h" 40 42 #include "WebSearchableFormData.h" … … 380 382 } 381 383 384 TEST_F(WebFrameTest, FindInPage) 385 { 386 registerMockedHttpURLLoad("find.html"); 387 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find.html"); 388 WebFrame* frame = webView->mainFrame(); 389 const int findIdentifier = 12345; 390 WebFindOptions options; 391 392 // Find in a <div> element. 393 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar1"), options, false, 0)); 394 frame->stopFinding(false); 395 WebRange range = frame->selectionRange(); 396 EXPECT_EQ(5, range.startOffset()); 397 EXPECT_EQ(9, range.endOffset()); 398 EXPECT_TRUE(frame->document().focusedNode().isNull()); 399 400 // Find in an <input> value. 401 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar2"), options, false, 0)); 402 // Confirm stopFinding(false) sets the selection on the found text. 403 frame->stopFinding(false); 404 range = frame->selectionRange(); 405 ASSERT_FALSE(range.isNull()); 406 EXPECT_EQ(5, range.startOffset()); 407 EXPECT_EQ(9, range.endOffset()); 408 EXPECT_EQ(WebString::fromUTF8("INPUT"), frame->document().focusedNode().nodeName()); 409 410 // Find in a <textarea> content. 411 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar3"), options, false, 0)); 412 // Confirm stopFinding(false) sets the selection on the found text. 413 frame->stopFinding(false); 414 range = frame->selectionRange(); 415 ASSERT_FALSE(range.isNull()); 416 EXPECT_EQ(5, range.startOffset()); 417 EXPECT_EQ(9, range.endOffset()); 418 EXPECT_EQ(WebString::fromUTF8("TEXTAREA"), frame->document().focusedNode().nodeName()); 419 420 // Find in a contentEditable element. 421 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar4"), options, false, 0)); 422 // Confirm stopFinding(false) sets the selection on the found text. 423 frame->stopFinding(false); 424 range = frame->selectionRange(); 425 ASSERT_FALSE(range.isNull()); 426 EXPECT_EQ(0, range.startOffset()); 427 EXPECT_EQ(4, range.endOffset()); 428 // "bar4" is surrounded by <span>, but the focusable node should be the parent <div>. 429 EXPECT_EQ(WebString::fromUTF8("DIV"), frame->document().focusedNode().nodeName()); 430 431 webView->close(); 432 } 433 382 434 } // namespace
Note: See TracChangeset
for help on using the changeset viewer.