void FindController::updateFindUIAfterPageScroll(bool found, const String& string, FindOptions options, unsigned maxMatchCount) { Frame* selectedFrame = frameWithSelection(m_webPage->corePage()); bool shouldShowOverlay = false; if (!found) { // Clear the selection. if (selectedFrame) selectedFrame->selection()->clear(); hideFindIndicator(); m_webPage->send(Messages::WebPageProxy::DidFailToFindString(string)); } else { shouldShowOverlay = options & FindOptionsShowOverlay; bool shouldShowHighlight = options & FindOptionsShowHighlight; unsigned matchCount = 1; if (shouldShowOverlay || shouldShowHighlight) { if (maxMatchCount == numeric_limits<unsigned>::max()) --maxMatchCount; matchCount = m_webPage->corePage()->markAllMatchesForText(string, core(options), shouldShowHighlight, maxMatchCount + 1); // Check if we have more matches than allowed. if (matchCount > maxMatchCount) { shouldShowOverlay = false; matchCount = static_cast<unsigned>(kWKMoreThanMaximumMatchCount); } } m_webPage->send(Messages::WebPageProxy::DidFindString(string, matchCount)); if (!(options & FindOptionsShowFindIndicator) || !updateFindIndicator(selectedFrame, shouldShowOverlay)) { // Either we shouldn't show the find indicator, or we couldn't update it. hideFindIndicator(); } } if (!shouldShowOverlay) { if (m_findPageOverlay) { // Get rid of the overlay. m_webPage->uninstallPageOverlay(m_findPageOverlay, false); } ASSERT(!m_findPageOverlay); } else { if (!m_findPageOverlay) { RefPtr<PageOverlay> findPageOverlay = PageOverlay::create(this); m_findPageOverlay = findPageOverlay.get(); m_webPage->installPageOverlay(findPageOverlay.release()); } else { // The page overlay needs to be repainted. m_findPageOverlay->setNeedsDisplay(); } } }
void FindController::showFindIndicatorInSelection() { Frame* selectedFrame = m_webPage->corePage()->focusController()->focusedOrMainFrame(); if (!selectedFrame) return; updateFindIndicator(selectedFrame, false); }
void FindController::deviceScaleFactorDidChange() { ASSERT(isShowingOverlay()); Frame* selectedFrame = frameWithSelection(m_webPage->corePage()); if (!selectedFrame) return; updateFindIndicator(selectedFrame, true, false); }
void FindController::redraw() { if (!m_isShowingFindIndicator) return; Frame* selectedFrame = frameWithSelection(m_webPage->corePage()); if (!selectedFrame) return; updateFindIndicator(*selectedFrame, isShowingOverlay(), false); }
void FindController::updateFindUIAfterPageScroll(bool found, const String& string, FindOptions options, unsigned maxMatchCount) { Frame* selectedFrame = frameWithSelection(m_webPage->corePage()); PluginView* pluginView = pluginViewForFrame(m_webPage->mainFrame()); bool shouldShowOverlay = false; if (!found) { if (!pluginView) m_webPage->corePage()->unmarkAllTextMatches(); if (selectedFrame) selectedFrame->selection().clear(); hideFindIndicator(); m_webPage->send(Messages::WebPageProxy::DidFailToFindString(string)); } else { shouldShowOverlay = options & FindOptionsShowOverlay; bool shouldShowHighlight = options & FindOptionsShowHighlight; unsigned matchCount = 1; if (shouldShowOverlay || shouldShowHighlight) { if (maxMatchCount == std::numeric_limits<unsigned>::max()) --maxMatchCount; if (pluginView) { matchCount = pluginView->countFindMatches(string, core(options), maxMatchCount + 1); shouldShowOverlay = false; } else { m_webPage->corePage()->unmarkAllTextMatches(); matchCount = m_webPage->corePage()->markAllMatchesForText(string, core(options), shouldShowHighlight, maxMatchCount + 1); } // If we have a large number of matches, we don't want to take the time to paint the overlay. if (matchCount > maxMatchCount) { shouldShowOverlay = false; matchCount = static_cast<unsigned>(kWKMoreThanMaximumMatchCount); } } m_webPage->send(Messages::WebPageProxy::DidFindString(string, matchCount)); if (!(options & FindOptionsShowFindIndicator) || !updateFindIndicator(selectedFrame, shouldShowOverlay)) hideFindIndicator(); } if (!shouldShowOverlay) { if (m_findPageOverlay) m_webPage->uninstallPageOverlay(m_findPageOverlay, true); } else { if (!m_findPageOverlay) { RefPtr<PageOverlay> findPageOverlay = PageOverlay::create(this); m_findPageOverlay = findPageOverlay.get(); m_webPage->installPageOverlay(findPageOverlay.release(), true); m_findPageOverlay->setNeedsDisplay(); } else m_findPageOverlay->setNeedsDisplay(); } }