From 4576aa36e9a9671459299c7963ac95aa94beaea9 Mon Sep 17 00:00:00 2001 From: "Shimeng (Simon) Wang" Date: Tue, 7 Dec 2010 17:22:45 -0800 Subject: Merge WebKit at r73109: Initial merge by git. Change-Id: I61f1a66d9642e3d8405d3ac6ccab2a53421c75d8 --- WebCore/page/Page.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'WebCore/page/Page.cpp') diff --git a/WebCore/page/Page.cpp b/WebCore/page/Page.cpp index 5453e1e..2726142 100644 --- a/WebCore/page/Page.cpp +++ b/WebCore/page/Page.cpp @@ -525,25 +525,31 @@ static Frame* incrementFrame(Frame* curr, bool forward, bool wrapFlag) bool Page::findString(const String& target, TextCaseSensitivity caseSensitivity, FindDirection direction, bool shouldWrap) { + return findString(target, (caseSensitivity == TextCaseInsensitive ? CaseInsensitive : 0) | (direction == FindDirectionBackward ? Backwards : 0) | (shouldWrap ? WrapAround : 0)); +} + +bool Page::findString(const String& target, FindOptions options) +{ if (target.isEmpty() || !mainFrame()) return false; + bool shouldWrap = options & WrapAround; Frame* frame = focusController()->focusedOrMainFrame(); Frame* startFrame = frame; do { - if (frame->editor()->findString(target, direction == FindDirectionForward, caseSensitivity == TextCaseSensitive, false, true)) { + if (frame->editor()->findString(target, (options & ~WrapAround) | StartInSelection)) { if (frame != startFrame) startFrame->selection()->clear(); focusController()->setFocusedFrame(frame); return true; } - frame = incrementFrame(frame, direction == FindDirectionForward, shouldWrap); + frame = incrementFrame(frame, !(options & Backwards), shouldWrap); } while (frame && frame != startFrame); // Search contents of startFrame, on the other side of the selection that we did earlier. // We cheat a bit and just research with wrap on if (shouldWrap && !startFrame->selection()->isNone()) { - bool found = startFrame->editor()->findString(target, direction == FindDirectionForward, caseSensitivity == TextCaseSensitive, true, true); + bool found = startFrame->editor()->findString(target, options | WrapAround | StartInSelection); focusController()->setFocusedFrame(frame); return found; } @@ -553,6 +559,11 @@ bool Page::findString(const String& target, TextCaseSensitivity caseSensitivity, unsigned int Page::markAllMatchesForText(const String& target, TextCaseSensitivity caseSensitivity, bool shouldHighlight, unsigned limit) { + return markAllMatchesForText(target, caseSensitivity == TextCaseInsensitive ? CaseInsensitive : 0, shouldHighlight, limit); +} + +unsigned int Page::markAllMatchesForText(const String& target, FindOptions options, bool shouldHighlight, unsigned limit) +{ if (target.isEmpty() || !mainFrame()) return 0; @@ -561,7 +572,7 @@ unsigned int Page::markAllMatchesForText(const String& target, TextCaseSensitivi Frame* frame = mainFrame(); do { frame->editor()->setMarkedTextMatchesAreHighlighted(shouldHighlight); - matches += frame->editor()->countMatchesForText(target, caseSensitivity == TextCaseSensitive, limit ? (limit - matches) : 0, true); + matches += frame->editor()->countMatchesForText(target, options, limit ? (limit - matches) : 0, true); frame = incrementFrame(frame, true, false); } while (frame); -- cgit v1.1