Changeset 109506 in webkit
- Timestamp:
- Mar 1, 2012 10:10:34 PM (12 years ago)
- Location:
- trunk/Source/WebKit/blackberry
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/blackberry/Api/WebPage.cpp
r109150 r109506 5586 5586 } 5587 5587 5588 } 5589 } 5588 void WebPagePrivate::frameUnloaded(const Frame* frame) 5589 { 5590 m_inputHandler->frameUnloaded(frame); 5591 m_inPageSearchManager->frameUnloaded(frame); 5592 } 5593 5594 } 5595 } -
trunk/Source/WebKit/blackberry/Api/WebPage_p.h
r109051 r109506 393 393 void clearDocumentData(const WebCore::Document*); 394 394 395 void frameUnloaded(const WebCore::Frame*); 396 395 397 static WebCore::RenderLayer* enclosingPositionedAncestorOrSelfIfPositioned(WebCore::RenderLayer*); 396 398 static WebCore::RenderLayer* enclosingFixedPositionedAncestorOrSelfIfFixedPositioned(WebCore::RenderLayer*); -
trunk/Source/WebKit/blackberry/ChangeLog
r109475 r109506 1 2012-03-01 Andy Chen <andchen@rim.com> 2 3 [BlackBerry] Implement features for find-in-page 4 https://bugs.webkit.org/show_bug.cgi?id=79820 5 6 Reviewed by Antonio Gomes. 7 8 - Make it be able to search text around the whole page instead of single frame. 9 - Make it be able to start new search from active selection and last active match. 10 11 No new tests as this patch doesn't change behavior. 12 13 * Api/WebPage.cpp: 14 (BlackBerry::WebKit::WebPagePrivate::frameUnloaded): 15 * Api/WebPage_p.h: 16 * WebCoreSupport/FrameLoaderClientBlackBerry.cpp: 17 (WebCore::FrameLoaderClientBlackBerry::dispatchWillClose): 18 (WebCore::FrameLoaderClientBlackBerry::detachedFromParent2): 19 * WebKitSupport/DOMSupport.cpp: 20 (BlackBerry::WebKit::DOMSupport::incrementFrame): 21 * WebKitSupport/DOMSupport.h: 22 * WebKitSupport/InPageSearchManager.cpp: 23 (BlackBerry::WebKit::InPageSearchManager::findNextString): 24 (BlackBerry::WebKit::InPageSearchManager::shouldSearchForText): 25 (BlackBerry::WebKit::InPageSearchManager::findAndMarkText): 26 (BlackBerry::WebKit::InPageSearchManager::setMarkerActive): 27 (BlackBerry::WebKit::InPageSearchManager::frameUnloaded): 28 * WebKitSupport/InPageSearchManager.h: 29 * WebKitSupport/InputHandler.cpp: 30 (BlackBerry::WebKit::InputHandler::frameUnloaded): 31 * WebKitSupport/InputHandler.h: 32 1 33 2012-03-01 Charles Wei <charles.wei@torchmobile.com.cn> 2 34 -
trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp
r108763 r109506 791 791 void FrameLoaderClientBlackBerry::dispatchWillClose() 792 792 { 793 m_webPagePrivate-> m_inputHandler->frameUnloaded(m_frame);793 m_webPagePrivate->frameUnloaded(m_frame); 794 794 } 795 795 … … 927 927 m_webPagePrivate->clearDocumentData(m_frame->document()); 928 928 929 m_webPagePrivate-> m_inputHandler->frameUnloaded(m_frame);929 m_webPagePrivate->frameUnloaded(m_frame); 930 930 m_webPagePrivate->m_client->notifyFrameDetached(m_frame); 931 931 } -
trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp
r109430 r109506 400 400 } 401 401 402 // This function is copied from WebCore/page/Page.cpp. 403 Frame* incrementFrame(Frame* curr, bool forward, bool wrapFlag) 404 { 405 return forward 406 ? curr->tree()->traverseNextWithWrap(wrapFlag) 407 : curr->tree()->traversePreviousWithWrap(wrapFlag); 408 } 409 402 410 } // DOMSupport 403 411 } // WebKit -
trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.h
r109284 r109506 82 82 WebCore::VisibleSelection visibleSelectionForClosestActualWordStart(const WebCore::VisibleSelection&); 83 83 84 WebCore::Frame* incrementFrame(WebCore::Frame* curr, bool forward, bool wrapFlag); 85 84 86 } // DOMSupport 85 87 } // WebKit -
trunk/Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.cpp
r107736 r109506 20 20 #include "InPageSearchManager.h" 21 21 22 #include "DOMSupport.h" 22 23 #include "Document.h" 23 24 #include "DocumentMarkerController.h" … … 52 53 } 53 54 54 if (m_activeSearchString != text) { 55 clearTextMatches(); 55 if (!shouldSearchForText(text)) { 56 56 m_activeSearchString = text; 57 m_activeMatchCount = m_webPage->m_page->markAllMatchesForText(text, WebCore::CaseInsensitive, true, TextMatchMarkerLimit); 58 } else 59 setMarkerActive(m_activeMatch.get(), false); 57 return false; 58 } 60 59 61 if (!m_activeMatchCount) 60 // Validate the range in case any node has been removed since last search. 61 if (m_activeMatch && !m_activeMatch->boundaryPointsValid()) 62 m_activeMatch = 0; 63 64 RefPtr<Range> searchStartingPoint(m_activeMatch); 65 if (m_activeSearchString != text) { // Start a new search. 66 m_activeSearchString = text; 67 m_webPage->m_page->unmarkAllTextMatches(); 68 m_activeMatchCount = m_webPage->m_page->markAllMatchesForText(text, CaseInsensitive, true /* shouldHighlight */, TextMatchMarkerLimit); 69 if (!m_activeMatchCount) { 70 clearTextMatches(); 71 return false; 72 } 73 } else { // Search same string for next occurrence. 74 setMarkerActive(m_activeMatch.get(), false /* active */); 75 // Searching for same string should start from the end of last match. 76 if (m_activeMatch) { 77 if (forward) 78 searchStartingPoint->setStart(searchStartingPoint->endPosition()); 79 else 80 searchStartingPoint->setEnd(searchStartingPoint->startPosition()); 81 } 82 } 83 84 // If there is any active selection, new search should start from the beginning of it. 85 VisibleSelection selection = m_webPage->focusedOrMainFrame()->selection()->selection(); 86 if (!selection.isNone()) { 87 searchStartingPoint = selection.firstRange().get(); 88 m_webPage->focusedOrMainFrame()->selection()->clear(); 89 } 90 91 Frame* currentActiveMatchFrame = selection.isNone() && m_activeMatch ? m_activeMatch->ownerDocument()->frame() : m_webPage->focusedOrMainFrame(); 92 93 const FindOptions findOptions = (forward ? 0 : Backwards) 94 | CaseInsensitive 95 | StartInSelection; 96 97 if (findAndMarkText(text, searchStartingPoint.get(), currentActiveMatchFrame, findOptions)) 98 return true; 99 100 Frame* startFrame = currentActiveMatchFrame; 101 do { 102 currentActiveMatchFrame = DOMSupport::incrementFrame(currentActiveMatchFrame, forward, true /* wrapFlag */); 103 if (findAndMarkText(text, 0, currentActiveMatchFrame, findOptions)) 104 return true; 105 } while (currentActiveMatchFrame && startFrame != currentActiveMatchFrame); 106 107 clearTextMatches(); 108 109 ASSERT_NOT_REACHED(); 110 return false; 111 } 112 113 bool InPageSearchManager::shouldSearchForText(const String& text) 114 { 115 if (text == m_activeSearchString) 116 return m_activeMatchCount; 117 118 // If the previous search string is prefix of new search string, 119 // don't search if the previous one has zero result. 120 if (!m_activeMatchCount 121 && m_activeSearchString.length() 122 && text.length() > m_activeSearchString.length() 123 && m_activeSearchString == text.substring(0, m_activeSearchString.length())) 62 124 return false; 125 return true; 126 } 63 127 64 const FindOptions findOptions = (forward ? 0 : WebCore::Backwards) 65 | WebCore::CaseInsensitive 66 | WebCore::WrapAround; // TODO should wrap around in page, not in frame 67 68 // TODO StartInSelection 69 70 m_activeMatch = m_webPage->mainFrame()->editor()->findStringAndScrollToVisible(text, m_activeMatch.get(), findOptions); 71 setMarkerActive(m_activeMatch.get(), true); 72 73 return true; 128 bool InPageSearchManager::findAndMarkText(const String& text, Range* range, Frame* frame, const FindOptions& options) 129 { 130 m_activeMatch = frame->editor()->findStringAndScrollToVisible(text, range, options); 131 if (m_activeMatch) { 132 setMarkerActive(m_activeMatch.get(), true /* active */); 133 return true; 134 } 135 return false; 74 136 } 75 137 … … 80 142 } 81 143 82 void InPageSearchManager::setMarkerActive( WebCore::Range* range, bool active)144 void InPageSearchManager::setMarkerActive(Range* range, bool active) 83 145 { 84 146 if (!range) 85 147 return; 86 WebCore::Document* doc = m_webPage->mainFrame()->document();148 Document* doc = m_activeMatch->ownerDocument(); 87 149 if (!doc) 88 150 return; … … 90 152 } 91 153 154 void InPageSearchManager::frameUnloaded(const Frame* frame) 155 { 156 if (!m_activeMatch) { 157 if (m_webPage->mainFrame() == frame && m_activeSearchString.length()) 158 m_activeSearchString = String(); 159 return; 160 } 161 162 Frame* currentActiveMatchFrame = m_activeMatch->ownerDocument()->frame(); 163 if (currentActiveMatchFrame == frame) { 164 m_activeMatch = 0; 165 m_activeSearchString = String(); 166 m_activeMatchCount = 0; 167 // FIXME: We need to notify client here. 168 if (frame == m_webPage->mainFrame()) // Don't need to unmark because the page will be destroyed. 169 return; 170 m_webPage->m_page->unmarkAllTextMatches(); 171 } 172 } 173 92 174 } 93 175 } -
trunk/Source/WebKit/blackberry/WebKitSupport/InPageSearchManager.h
r107736 r109506 20 20 #define InPageSearchManager_h 21 21 22 #include "FindOptions.h" 22 23 #include "WTFString.h" 23 24 24 #include <wtf/RefPtr.h>25 26 25 namespace WebCore { 26 class Frame; 27 27 class Range; 28 class VisibleSelection; 28 29 } 29 30 … … 40 41 41 42 bool findNextString(const String& text, bool forward); 43 void frameUnloaded(const WebCore::Frame*); 42 44 43 45 private: 44 46 void clearTextMatches(); 45 void setMarkerActive(WebCore::Range*, bool active); 47 void setMarkerActive(WebCore::Range*, bool); 48 bool findAndMarkText(const String&, WebCore::Range*, WebCore::Frame*, const WebCore::FindOptions&); 49 bool shouldSearchForText(const String&); 46 50 47 51 WebPagePrivate* m_webPage; -
trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp
r109284 r109506 711 711 } 712 712 713 void InputHandler::frameUnloaded( Frame* frame)713 void InputHandler::frameUnloaded(const Frame* frame) 714 714 { 715 715 if (!isActiveTextEdit()) -
trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h
r108702 r109506 61 61 void nodeTextChanged(const WebCore::Node*); 62 62 void selectionChanged(); 63 void frameUnloaded( WebCore::Frame*);63 void frameUnloaded(const WebCore::Frame*); 64 64 65 65 bool handleKeyboardInput(const BlackBerry::Platform::KeyboardEvent&, bool changeIsPartOfComposition = false);
Note: See TracChangeset
for help on using the changeset viewer.