Changeset 127594 in webkit
- Timestamp:
- Sep 5, 2012 8:38:09 AM (12 years ago)
- Location:
- trunk/Source/WebKit/blackberry
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/blackberry/Api/WebPageClient.h
r127489 r127594 274 274 virtual void requestUserMedia(const Platform::WebUserMediaRequest&) = 0; 275 275 virtual void cancelUserMediaRequest(const Platform::WebUserMediaRequest&) = 0; 276 virtual void updateFindStringResult(int numMatches, int currentIndex) = 0; 276 277 }; 277 278 } // namespace WebKit -
trunk/Source/WebKit/blackberry/ChangeLog
r127515 r127594 1 2012-09-05 Andy Chen <andchen@rim.com> 2 3 [BlackBerry] Implement number of matches and current active match index for find-on-page 4 https://bugs.webkit.org/show_bug.cgi?id=95801 5 6 Reviewed by Antonio Gomes. 7 8 - Calculate current match index for find-on-page 9 - Notify client when number of matches and current match index update. 10 PR 162090 162091. 11 Internally reviewed by Mike Fenton and Joe Mason 12 13 * Api/WebPageClient.h: 14 * WebKitSupport/InPageSearchManager.cpp: 15 (BlackBerry::WebKit::InPageSearchManager::DeferredScopeStringMatches::DeferredScopeStringMatches): 16 (BlackBerry::WebKit::InPageSearchManager::DeferredScopeStringMatches::doTimeout): 17 (InPageSearchManager::DeferredScopeStringMatches): 18 (BlackBerry::WebKit::InPageSearchManager::findNextString): 19 (BlackBerry::WebKit::InPageSearchManager::findAndMarkText): 20 (BlackBerry::WebKit::InPageSearchManager::scopeStringMatches): 21 (BlackBerry::WebKit::InPageSearchManager::scopeStringMatchesSoon): 22 (BlackBerry::WebKit::InPageSearchManager::callScopeStringMatches): 23 * WebKitSupport/InPageSearchManager.h: 24 (InPageSearchManager): 25 1 26 2012-09-04 Rob Buis <rbuis@rim.com> 2 27 -
trunk/Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.cpp
r120005 r127594 41 41 class InPageSearchManager::DeferredScopeStringMatches { 42 42 public: 43 DeferredScopeStringMatches(InPageSearchManager* ipsm, Frame* scopingFrame, const String& text, bool reset )43 DeferredScopeStringMatches(InPageSearchManager* ipsm, Frame* scopingFrame, const String& text, bool reset, bool locateActiveMatchOnly) 44 44 : m_searchManager(ipsm) 45 45 , m_scopingFrame(scopingFrame) … … 47 47 , m_searchText(text) 48 48 , m_reset(reset) 49 , m_locateActiveMatchOnly(locateActiveMatchOnly) 49 50 { 50 51 m_timer.startOneShot(0.0); … … 54 55 void doTimeout(Timer<DeferredScopeStringMatches>*) 55 56 { 56 m_searchManager->callScopeStringMatches(this, m_scopingFrame, m_searchText, m_reset );57 m_searchManager->callScopeStringMatches(this, m_scopingFrame, m_searchText, m_reset, m_locateActiveMatchOnly); 57 58 } 58 59 InPageSearchManager* m_searchManager; … … 61 62 String m_searchText; 62 63 bool m_reset; 64 bool m_locateActiveMatchOnly; 63 65 }; 64 66 … … 89 91 cancelPendingScopingEffort(); 90 92 m_activeSearchString = String(); 93 m_webPage->m_client->updateFindStringResult(m_activeMatchCount, m_activeMatchIndex); 91 94 return false; 92 95 } … … 94 97 if (!shouldSearchForText(text)) { 95 98 m_activeSearchString = text; 99 m_webPage->m_client->updateFindStringResult(m_activeMatchCount, m_activeMatchIndex); 96 100 return false; 97 101 } … … 121 125 122 126 // If there is any active selection, new search should start from the beginning of it. 127 bool startFromSelection = false; 123 128 VisibleSelection selection = m_webPage->focusedOrMainFrame()->selection()->selection(); 124 129 if (!selection.isNone()) { 125 130 searchStartingPoint = selection.firstRange().get(); 126 131 m_webPage->focusedOrMainFrame()->selection()->clear(); 132 startFromSelection = true; 127 133 } 128 134 129 135 Frame* currentActiveMatchFrame = selection.isNone() && m_activeMatch ? m_activeMatch->ownerDocument()->frame() : m_webPage->focusedOrMainFrame(); 130 136 131 if (findAndMarkText(text, searchStartingPoint.get(), currentActiveMatchFrame, findOptions, newSearch ))137 if (findAndMarkText(text, searchStartingPoint.get(), currentActiveMatchFrame, findOptions, newSearch, startFromSelection)) 132 138 return true; 133 139 … … 140 146 // matches and we're not wrapping. We have searched every frame. 141 147 ASSERT(!wrap); 148 m_webPage->m_client->updateFindStringResult(m_activeMatchCount, m_activeMatchIndex); 142 149 return false; 143 150 } 144 151 145 if (findAndMarkText(text, 0, currentActiveMatchFrame, findOptions, newSearch ))152 if (findAndMarkText(text, 0, currentActiveMatchFrame, findOptions, newSearch, startFromSelection)) 146 153 return true; 147 154 } while (startFrame != currentActiveMatchFrame); … … 149 156 clearTextMatches(); 150 157 151 // FIXME: We need to notify client here.158 m_webPage->m_client->updateFindStringResult(m_activeMatchCount, m_activeMatchIndex); 152 159 return false; 153 160 } … … 169 176 } 170 177 171 bool InPageSearchManager::findAndMarkText(const String& text, Range* range, Frame* frame, const FindOptions& options, bool isNewSearch )178 bool InPageSearchManager::findAndMarkText(const String& text, Range* range, Frame* frame, const FindOptions& options, bool isNewSearch, bool startFromSelection) 172 179 { 173 180 if (RefPtr<Range> match = frame->editor()->findStringAndScrollToVisible(text, range, options)) { 174 181 // Move the highlight to the new match. 175 182 setActiveMatchAndMarker(match); 176 177 if (m_highlightAllMatches) { 178 // FIXME: If it is a not new search, we need to calculate activeMatchIndex and notify client. 179 if (isNewSearch) 180 scopeStringMatches(text, true /* reset */); 183 if (isNewSearch) { 184 scopeStringMatches(text, true /* reset */, false /* locateActiveMatchOnly */); 185 return true; 186 } 187 if (startFromSelection || m_locatingActiveMatch) { 188 // We are finding next, but 189 // - starting from a new node, or 190 // - last locating active match effort is not done yet 191 if (!m_scopingComplete) { 192 // Last scoping is not done yet, let's restart it. 193 scopeStringMatches(text, true /* reset */, false /* locateActiveMatchOnly */); 194 } else { 195 // Last scoping is done, but we are jumping to somewhere instead of 196 // searching one by one, or there is another locating active match effort, 197 // let's start a scoping effort to locate active match only. 198 scopeStringMatches(text, true /* reset */, true /* locateActiveMatchOnly */); 199 } 181 200 } else { 182 // When only showing single matches, cancel any scoping effort and ensure 183 // only the single active match is marked. 184 cancelPendingScopingEffort(); 201 // We are finding next one by one, let's calculate active match index 202 // There is at least one match, because otherwise we won't get into this block, 203 // so m_activeMatchIndex is at least one. 204 ASSERT(m_activeMatchCount); 205 if (!(options & WebCore::Backwards)) 206 m_activeMatchIndex = m_activeMatchIndex + 1 > m_activeMatchCount ? 1 : m_activeMatchIndex + 1; 207 else 208 m_activeMatchIndex = m_activeMatchIndex - 1 < 1 ? m_activeMatchCount : m_activeMatchIndex - 1; 209 m_webPage->m_client->updateFindStringResult(m_activeMatchCount, m_activeMatchIndex); 210 } 211 if (!m_highlightAllMatches) { 212 // When only showing single matches, the scoping effort won't highlight 213 // all matches but count them. 185 214 m_webPage->m_page->unmarkAllTextMatches(); 186 215 m_activeMatch->ownerDocument()->markers()->addTextMatchMarker(m_activeMatch.get(), true); 187 216 frame->editor()->setMarkedTextMatchesAreHighlighted(true /* highlight */); 188 m_activeMatchCount = 1;189 m_activeMatchIndex = 1;190 217 } 191 218 … … 240 267 } 241 268 242 void InPageSearchManager::scopeStringMatches(const String& text, bool reset, Frame* scopingFrame)269 void InPageSearchManager::scopeStringMatches(const String& text, bool reset, bool locateActiveMatchOnly, Frame* scopingFrame) 243 270 { 244 271 if (reset) { 245 m_activeMatchCount = 0; 272 if (!locateActiveMatchOnly) { 273 m_activeMatchCount = 0; 274 m_scopingComplete = false; 275 } 246 276 m_resumeScopingFromRange = 0; 247 m_scopingComplete = false;248 277 m_locatingActiveMatch = true; 278 m_activeMatchIndex = 0; 249 279 // New search should always start from mainFrame. 250 scopeStringMatchesSoon(m_webPage->mainFrame(), text, false /* reset */ );280 scopeStringMatchesSoon(m_webPage->mainFrame(), text, false /* reset */, locateActiveMatchOnly); 251 281 return; 252 282 } … … 285 315 foundActiveMatch = true; 286 316 m_locatingActiveMatch = false; 317 if (locateActiveMatchOnly) { 318 m_activeMatchIndex += matchCount; 319 m_webPage->m_client->updateFindStringResult(m_activeMatchCount, m_activeMatchIndex); 320 return; 321 } 287 322 m_activeMatchIndex = m_activeMatchCount + matchCount; 288 // FIXME: We need to notify client with m_activeMatchIndex.289 }290 resultRange->ownerDocument()->markers()->addTextMatchMarker(resultRange.get(), foundActiveMatch);323 } 324 if (!locateActiveMatchOnly && m_highlightAllMatches) 325 resultRange->ownerDocument()->markers()->addTextMatchMarker(resultRange.get(), foundActiveMatch); 291 326 292 327 searchRange->setStart(resultRange->endContainer(ec), resultRange->endOffset(ec), ec); … … 299 334 300 335 if (matchCount > 0) { 301 scopingFrame->editor()->setMarkedTextMatchesAreHighlighted(true /* highlight */); 302 m_activeMatchCount += matchCount; 336 if (locateActiveMatchOnly) { 337 // We have not found it yet. 338 // m_activeMatchIndex now temporarily remember where we left over in this time slot. 339 m_activeMatchIndex += matchCount; 340 } else { 341 if (m_highlightAllMatches) 342 scopingFrame->editor()->setMarkedTextMatchesAreHighlighted(true /* highlight */); 343 m_activeMatchCount += matchCount; 344 m_webPage->m_client->updateFindStringResult(m_activeMatchCount, m_activeMatchIndex); 345 } 303 346 } 304 347 305 348 if (timeout) 306 scopeStringMatchesSoon(scopingFrame, text, false /* reset */ );349 scopeStringMatchesSoon(scopingFrame, text, false /* reset */, locateActiveMatchOnly); 307 350 else { 308 351 // Scoping is done for this frame. … … 312 355 return; // Scoping is done for all frames; 313 356 } 314 scopeStringMatchesSoon(nextFrame, text, false /* reset */ );315 } 316 } 317 318 void InPageSearchManager::scopeStringMatchesSoon(Frame* scopingFrame, const String& text, bool reset )319 { 320 m_deferredScopingWork.append(new DeferredScopeStringMatches(this, scopingFrame, text, reset ));321 } 322 323 void InPageSearchManager::callScopeStringMatches(DeferredScopeStringMatches* caller, Frame* scopingFrame, const String& text, bool reset )357 scopeStringMatchesSoon(nextFrame, text, false /* reset */, locateActiveMatchOnly); 358 } 359 } 360 361 void InPageSearchManager::scopeStringMatchesSoon(Frame* scopingFrame, const String& text, bool reset, bool locateActiveMatchOnly) 362 { 363 m_deferredScopingWork.append(new DeferredScopeStringMatches(this, scopingFrame, text, reset, locateActiveMatchOnly)); 364 } 365 366 void InPageSearchManager::callScopeStringMatches(DeferredScopeStringMatches* caller, Frame* scopingFrame, const String& text, bool reset, bool locateActiveMatchOnly) 324 367 { 325 368 m_deferredScopingWork.remove(m_deferredScopingWork.find(caller)); 326 scopeStringMatches(text, reset, scopingFrame);369 scopeStringMatches(text, reset, locateActiveMatchOnly, scopingFrame); 327 370 delete caller; 328 371 } -
trunk/Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.h
r127040 r127594 49 49 void clearTextMatches(); 50 50 void setActiveMatchAndMarker(PassRefPtr<WebCore::Range>); 51 bool findAndMarkText(const String&, WebCore::Range*, WebCore::Frame*, const WebCore::FindOptions&, bool );51 bool findAndMarkText(const String&, WebCore::Range*, WebCore::Frame*, const WebCore::FindOptions&, bool /* isNewSearch */, bool /* startFromSelection */); 52 52 bool shouldSearchForText(const String&); 53 void scopeStringMatches(const String& text, bool reset, WebCore::Frame* scopingFrame = 0);54 void scopeStringMatchesSoon(WebCore::Frame* scopingFrame, const String& text, bool reset );55 void callScopeStringMatches(DeferredScopeStringMatches* caller, WebCore::Frame* scopingFrame, const String& text, bool reset );53 void scopeStringMatches(const String& text, bool reset, bool locateActiveMatchOnly, WebCore::Frame* scopingFrame = 0); 54 void scopeStringMatchesSoon(WebCore::Frame* scopingFrame, const String& text, bool reset, bool locateActiveMatchOnly); 55 void callScopeStringMatches(DeferredScopeStringMatches* caller, WebCore::Frame* scopingFrame, const String& text, bool reset, bool locateActiveMatchOnly); 56 56 void cancelPendingScopingEffort(); 57 57
Note: See TracChangeset
for help on using the changeset viewer.