Changeset 287849 in webkit
- Timestamp:
- Jan 10, 2022, 11:19:54 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/page/ModalContainerObserver.cpp (modified) (3 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/ModalContainerObservation.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r287848 r287849 1 2022-01-10 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Modal container observer fails detection when rendered text is inserted after the container 4 https://bugs.webkit.org/show_bug.cgi?id=234752 5 rdar://87200177 6 7 Reviewed by Tim Horton. 8 9 Teach ModalContainerObserver to detect modal containers whose text content is set by script after the container 10 element itself has already been inserted into the document and laid out. See below for more details. 11 12 Test: ModalContainerObservation.DetectModalContainerAfterSettingText 13 14 * page/ModalContainerObserver.cpp: 15 (WebCore::searchForMatch): 16 17 Change this to return two `bool`s: one indicating whether a match was found (i.e. the original return value), 18 and another indicating whether any rendered text was discovered in the process of searching. In the case where 19 the viewport-constrained element did not contain any rendered text at all, we avoid adding the element to the 20 `m_elementsToIgnoreWhenSearching` set, thereby allowing us to search it again in the future. 21 22 (WebCore::ModalContainerObserver::updateModalContainerIfNeeded): 23 (WebCore::containsMatchingText): Deleted. 24 1 25 2022-01-10 Alex Christensen <achristensen@webkit.org> 2 26 -
trunk/Source/WebCore/page/ModalContainerObserver.cpp
r287777 r287849 148 148 } 149 149 150 static bool containsMatchingText(RenderLayerModelObject& renderer, const AtomString& searchTerm) 151 { 150 struct TextSearchResult { 151 bool foundMatch { false }; 152 bool containsAnyText { false }; 153 }; 154 155 static TextSearchResult searchForMatch(RenderLayerModelObject& renderer, const AtomString& searchTerm) 156 { 157 TextSearchResult result; 152 158 for (auto& textRenderer : descendantsOfType<RenderText>(renderer)) { 153 if (RefPtr textNode = textRenderer.textNode(); textNode && matchesSearchTerm(*textNode, searchTerm)) 154 return !isInsideNavigationElement(*textNode); 155 } 156 return false; 159 result.containsAnyText = true; 160 if (RefPtr textNode = textRenderer.textNode(); textNode && matchesSearchTerm(*textNode, searchTerm)) { 161 result.foundMatch = !isInsideNavigationElement(*textNode); 162 return result; 163 } 164 } 165 return result; 157 166 } 158 167 … … 214 223 continue; 215 224 216 if ( !m_elementsToIgnoreWhenSearching.add(*element).isNewEntry)225 if (m_elementsToIgnoreWhenSearching.contains(*element)) 217 226 continue; 218 227 219 if (containsMatchingText(renderer, searchTerm)) { 228 auto [foundMatch, containsAnyText] = searchForMatch(renderer, searchTerm); 229 230 if (containsAnyText) 231 m_elementsToIgnoreWhenSearching.add(*element); 232 233 if (foundMatch) { 220 234 setContainer(*element); 221 235 return; … … 231 245 continue; 232 246 233 if ( containsMatchingText(*renderView, searchTerm)) {247 if (searchForMatch(*renderView, searchTerm).foundMatch) { 234 248 setContainer(*element, &frameOwner); 235 249 return; -
trunk/Tools/ChangeLog
r287848 r287849 1 2022-01-10 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Modal container observer fails detection when rendered text is inserted after the container 4 https://bugs.webkit.org/show_bug.cgi?id=234752 5 rdar://87200177 6 7 Reviewed by Tim Horton. 8 9 Add a new API test to exercise the change. 10 11 * TestWebKitAPI/Tests/WebKitCocoa/ModalContainerObservation.mm: 12 (TestWebKitAPI::TEST): 13 1 14 2022-01-10 Alex Christensen <achristensen@webkit.org> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ModalContainerObservation.mm
r287777 r287849 318 318 } 319 319 320 TEST(ModalContainerObservation, DetectModalContainerAfterSettingText) 321 { 322 auto webView = createModalContainerWebView(); 323 [webView loadBundlePage:@"modal-container-custom"]; 324 [webView objectByEvaluatingJavaScript:@"show(`<div id='content'></div>`)"]; 325 [webView waitForNextPresentationUpdate]; 326 [webView evaluate:@"document.getElementById('content').innerHTML = `hello world <a href='#'>no</a>`" andDecidePolicy:_WKModalContainerDecisionHideAndIgnore]; 327 EXPECT_FALSE([[webView contentsAsString] containsString:@"hello world"]); 328 EXPECT_EQ([webView lastModalContainerInfo].availableTypes, _WKModalContainerControlTypeNegative); 329 } 330 320 331 } // namespace TestWebKitAPI
Note:
See TracChangeset
for help on using the changeset viewer.