: m_webPage(webPage)
, m_findPageOverlay(0)
, m_isShowingFindIndicator(false)
+#if ENABLE(TIZEN_FIND_STRING)
+ , m_activeMatchIndexInCurrentFrame(0)
+#endif
{
}
}
}
+#if ENABLE(TIZEN_FIND_STRING)
+void FindController::setActiveMatchHighlight(int activeMatchIndex)
+{
+ if (activeMatchIndex >= static_cast<int>(m_findMatches.size()))
+ m_activeMatchIndexInCurrentFrame = 0;
+ else if (activeMatchIndex < 0)
+ m_activeMatchIndexInCurrentFrame = m_findMatches.size() - 1;
+ else
+ m_activeMatchIndexInCurrentFrame = activeMatchIndex;
+
+ Frame* frame = m_findMatches[m_activeMatchIndexInCurrentFrame]->startContainer()->document()->frame();
+ if (!frame)
+ return;
+
+ m_activeMatch = m_findMatches[m_activeMatchIndexInCurrentFrame];
+
+ // Scroll to the position of the active matching text.
+ m_activeMatch->firstNode()->renderer()->scrollRectToVisible(m_activeMatch->boundingBox(),
+ ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded);
+
+ frame->document()->markers()->addTextMatchMarker(m_activeMatch.get(), true);
+ frame->document()->markers()->setMarkersActive(m_activeMatch.get(), true);
+}
+#endif
+
void FindController::findString(const String& string, FindOptions options, unsigned maxMatchCount)
{
+#if ENABLE(TIZEN_FIND_STRING)
+ m_findMatches.clear();
+ int indexForSelection;
+
+ m_webPage->corePage()->findStringMatchingRanges(string, core(options), maxMatchCount, &m_findMatches, indexForSelection);
+
+ bool found = !m_findMatches.isEmpty();
+
+ // highlight the text matches found.
+ m_webPage->drawingArea()->dispatchAfterEnsuringUpdatedScrollPosition(WTF::bind(&FindController::updateFindUIAfterPageScroll, this, found, string, options, maxMatchCount));
+
+ if (!found) {
+ m_activeMatchIndexInCurrentFrame = -1;
+ return;
+ }
+
+ if (!m_oldString || m_oldString != string) {
+ m_oldString = string;
+ if (options & FindOptionsBackwards)
+ setActiveMatchHighlight(m_findMatches.size() - 1); // Should we use m_lastMatchCount instead of m_findMatches.size()
+ else
+ setActiveMatchHighlight(0);
+ } else {
+ if (options & FindOptionsBackwards)
+ setActiveMatchHighlight(m_activeMatchIndexInCurrentFrame - 1);
+ else
+ setActiveMatchHighlight(m_activeMatchIndexInCurrentFrame + 1);
+ }
+#else
bool found = m_webPage->corePage()->findString(string, core(options));
m_webPage->drawingArea()->dispatchAfterEnsuringUpdatedScrollPosition(WTF::bind(&FindController::updateFindUIAfterPageScroll, this, found, string, options, maxMatchCount));
+#endif
}
void FindController::findStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
bool updateFindIndicator(WebCore::Frame* selectedFrame, bool isShowingOverlay, bool shouldAnimate = true);
void updateFindUIAfterPageScroll(bool found, const String&, FindOptions, unsigned maxMatchCount);
+#if ENABLE(TIZEN_FIND_STRING)
+ void setActiveMatchHighlight(int activeMatchIndex);
+#endif
WebPage* m_webPage;
PageOverlay* m_findPageOverlay;
bool m_isShowingFindIndicator;
WebCore::IntRect m_findIndicatorRect;
Vector<RefPtr<WebCore::Range> > m_findMatches;
+
+#if ENABLE(TIZEN_FIND_STRING)
+ String m_oldString;
+ // The range of the active match for the current frame.
+ RefPtr<WebCore::Range> m_activeMatch;
+ // The index of the active match for the current frame.
+ int m_activeMatchIndexInCurrentFrame;
+#endif
};
} // namespace WebKit