Changeset 140000 in webkit
- Timestamp:
- Jan 17, 2013 10:56:28 AM (11 years ago)
- Location:
- tags/Safari-537.26.1
- Files:
-
- 23 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
tags/Safari-537.26.1/Source/WebCore/ChangeLog
r139910 r140000 1 2013-01-17 Lucas Forschler <lforschler@apple.com> 2 3 Merge r139796 4 5 2013-01-15 Enrica Casucci <enrica@apple.com> 6 7 Add a new set of WebKit2 APIs for text search and 8 search results management. 9 https://bugs.webkit.org/show_bug.cgi?id=106834. 10 <rdar://problem/12597159> 11 12 Reviewed by Simon Fraser. 13 14 Adding new API to perform text search in WebKit2 without using 15 the stock UI. The new interface provides all the information 16 necessary to write a custom UI for search. 17 18 Added new TextWebKitAPI test. 19 20 * WebCore.exp.in: Added new exported methods. 21 * editing/Editor.cpp: 22 (WebCore::Editor::countMatchesForText): Added new parameter to store 23 all the ranges relative to the matches found. 24 * editing/Editor.h: Modified the interface of countMatchesForText and removed 25 the other definition of countMatchesForText with a different signature. 26 * page/Page.cpp: 27 (WebCore::Page::findStringMatchingRanges): Added. 28 (WebCore::Page::markAllMatchesForText): Changed to use the new unified 29 countMatchesForText. 30 * page/Page.h: 31 1 32 2013-01-16 Lucas Forschler <lforschler@apple.com> 2 33 -
tags/Safari-537.26.1/Source/WebCore/WebCore.exp.in
r139412 r140000 763 763 __ZN7WebCore4Page22nonFastScrollableRectsEPKNS_5FrameE 764 764 __ZN7WebCore4Page23clearUndoRedoOperationsEv 765 __ZN7WebCore4Page24findStringMatchingRangesERKN3WTF6StringEjiPNS1_6VectorINS1_6RefPtrINS_5RangeEEELm0EEERi 765 766 __ZN7WebCore4Page24resumeScriptedAnimationsEv 766 767 __ZN7WebCore4Page24scrollingStateTreeAsTextEv … … 839 840 __ZN7WebCore6Editor18confirmCompositionEv 840 841 __ZN7WebCore6Editor18insertDictatedTextERKN3WTF6StringERKNS1_6VectorINS_20DictationAlternativeELm0EEEPNS_5EventE 841 __ZN7WebCore6Editor19countMatchesForTextERKN3WTF6StringEPNS_5RangeEjjb842 842 __ZN7WebCore6Editor19deleteWithDirectionENS_18SelectionDirectionENS_15TextGranularityEbb 843 843 __ZN7WebCore6Editor19insertUnorderedListEv … … 869 869 __ZN7WebCore6Editor7commandERKN3WTF6StringE 870 870 __ZN7WebCore6Editor7outdentEv 871 __ZN7WebCore6Editor19countMatchesForTextERKN3WTF6StringEPNS_5RangeEjjbPNS1_6VectorINS1_6RefPtrIS5_EELm0EEE 871 872 __ZN7WebCore6JSNode6s_infoE 872 873 __ZN7WebCore6Region5uniteERKS0_ -
tags/Safari-537.26.1/Source/WebCore/editing/Editor.cpp
r139412 r140000 2743 2743 } 2744 2744 2745 unsigned Editor::countMatchesForText(const String& target, FindOptions options, unsigned limit, bool markMatches) 2746 { 2747 return countMatchesForText(target, 0, options, limit, markMatches); 2748 } 2749 2750 unsigned Editor::countMatchesForText(const String& target, Range* range, FindOptions options, unsigned limit, bool markMatches) 2745 unsigned Editor::countMatchesForText(const String& target, Range* range, FindOptions options, unsigned limit, bool markMatches, Vector<RefPtr<Range> >* matches) 2751 2746 { 2752 2747 if (target.isEmpty()) … … 2780 2775 2781 2776 ++matchCount; 2777 if (matches) 2778 matches->append(resultRange); 2779 2782 2780 if (markMatches) 2783 2781 m_frame->document()->markers()->addMarker(resultRange.get(), DocumentMarker::TextMatch); … … 2798 2796 } while (true); 2799 2797 2800 if (markMatches ) {2798 if (markMatches || matches) { 2801 2799 // Do a "fake" paint in order to execute the code that computes the rendered rect for each text match. 2802 2800 if (m_frame->view() && m_frame->contentRenderer()) { -
tags/Safari-537.26.1/Source/WebCore/editing/Editor.h
r139412 r140000 362 362 void respondToChangedSelection(const VisibleSelection& oldSelection, FrameSelection::SetSelectionOptions); 363 363 bool shouldChangeSelection(const VisibleSelection& oldSelection, const VisibleSelection& newSelection, EAffinity, bool stillSelecting) const; 364 unsigned countMatchesForText(const String&, FindOptions, unsigned limit, bool markMatches); 365 unsigned countMatchesForText(const String&, Range*, FindOptions, unsigned limit, bool markMatches); 364 unsigned countMatchesForText(const String&, Range*, FindOptions, unsigned limit, bool markMatches, Vector<RefPtr<Range> >*); 366 365 bool markedTextMatchesAreHighlighted() const; 367 366 void setMarkedTextMatchesAreHighlighted(bool); -
tags/Safari-537.26.1/Source/WebCore/page/Page.cpp
r139589 r140000 570 570 } 571 571 572 void Page::findStringMatchingRanges(const String& target, FindOptions options, int limit, Vector<RefPtr<Range> >* matchRanges, int& indexForSelection) 573 { 574 indexForSelection = 0; 575 if (!mainFrame()) 576 return; 577 578 Frame* frame = mainFrame(); 579 Frame* frameWithSelection = 0; 580 do { 581 frame->editor()->countMatchesForText(target, 0, options, limit ? (limit - matchRanges->size()) : 0, true, matchRanges); 582 if (frame->selection()->isRange()) 583 frameWithSelection = frame; 584 frame = incrementFrame(frame, true, false); 585 } while (frame); 586 587 if (matchRanges->isEmpty()) 588 return; 589 590 if (frameWithSelection) { 591 indexForSelection = NoMatchBeforeUserSelection; 592 RefPtr<Range> selectedRange = frameWithSelection->selection()->selection().firstRange(); 593 for (size_t i = 0; i < matchRanges->size(); ++i) { 594 ExceptionCode ec; 595 if (selectedRange->compareBoundaryPoints(Range::START_TO_END, matchRanges->at(i).get(), ec) < 0) { 596 indexForSelection = i; 597 break; 598 } 599 } 600 } 601 } 602 572 603 PassRefPtr<Range> Page::rangeOfString(const String& target, Range* referenceRange, FindOptions options) 573 604 { … … 613 644 do { 614 645 frame->editor()->setMarkedTextMatchesAreHighlighted(shouldHighlight); 615 matches += frame->editor()->countMatchesForText(target, options, limit ? (limit - matches) : 0, true);646 matches += frame->editor()->countMatchesForText(target, 0, options, limit ? (limit - matches) : 0, true, 0); 616 647 frame = incrementFrame(frame, true, false); 617 648 } while (frame); -
tags/Safari-537.26.1/Source/WebCore/page/Page.h
r138991 r140000 237 237 void unmarkAllTextMatches(); 238 238 239 // find all the Ranges for the matching text. 240 // Upon return, indexForSelection will be one of the following: 241 // 0 if there is no user selection 242 // the index of the first range after the user selection 243 // NoMatchBeforeUserSelection if there is no matching text after the user selection. 244 enum { NoMatchBeforeUserSelection = -1 }; 245 void findStringMatchingRanges(const String&, FindOptions, int maxCount, Vector<RefPtr<Range> >*, int& indexForSelection); 239 246 #if PLATFORM(MAC) 240 247 void addSchedulePair(PassRefPtr<SchedulePair>); -
tags/Safari-537.26.1/Source/WebKit/mac/ChangeLog
r139324 r140000 1 2013-01-17 Lucas Forschler <lforschler@apple.com> 2 3 Merge r139796 4 5 2013-01-15 Enrica Casucci <enrica@apple.com> 6 7 Add a new set of WebKit2 APIs for text search and 8 search results management. 9 https://bugs.webkit.org/show_bug.cgi?id=106834. 10 <rdar://problem/12597159> 11 12 Reviewed by Simon Fraser. 13 14 Adding new API to perform text search in WebKit2 without using 15 the stock UI. The new interface provides all the information 16 necessary to write a custom UI for search. 17 18 Added new TextWebKitAPI test. 19 20 * WebView/WebHTMLView.mm: 21 (-[WebHTMLView countMatchesForText:inDOMRange:options:limit:markMatches:]): 22 Modified to reflect the changes to Editor::countMatchesForText interface. 23 1 24 2013-01-10 Zan Dobersek <zandobersek@gmail.com> 2 25 -
tags/Safari-537.26.1/Source/WebKit/mac/WebView/WebHTMLView.mm
r135882 r140000 6215 6215 return 0; 6216 6216 6217 return coreFrame->editor()->countMatchesForText(string, core(range), coreOptions(options), limit, markMatches );6217 return coreFrame->editor()->countMatchesForText(string, core(range), coreOptions(options), limit, markMatches, 0); 6218 6218 } 6219 6219 -
tags/Safari-537.26.1/Source/WebKit2/ChangeLog
r139910 r140000 1 2013-01-17 Lucas Forschler <lforschler@apple.com> 2 3 Merge r139796 4 5 2013-01-15 Enrica Casucci <enrica@apple.com> 6 7 Add a new set of WebKit2 APIs for text search and 8 search results management. 9 https://bugs.webkit.org/show_bug.cgi?id=106834. 10 <rdar://problem/12597159> 11 12 Reviewed by Simon Fraser. 13 14 Adding new API to perform text search in WebKit2 without using 15 the stock UI. The new interface provides all the information 16 necessary to write a custom UI for search. The main logic is 17 implemented in the new functions added to FindController. 18 19 Added new TextWebKitAPI test. 20 21 * UIProcess/API/C/WKPage.cpp: 22 (WKPageFindStringMatches): Added. 23 (WKPageGetImageForFindMatch): Added. 24 (WKPageSelectFindMatch): Added. 25 (WKPageSetPageFindMatchesClient): Added. 26 * UIProcess/API/C/WKPage.h: Added the new API definitions. 27 * UIProcess/WebFindClient.cpp: Added new client callbacks. 28 (WebKit::WebFindMatchesClient::didFindStringMatches): 29 (WebKit::WebFindMatchesClient::didGetImageForMatchResult): 30 * UIProcess/WebFindClient.h: 31 (WebFindMatchesClient): Added. 32 * UIProcess/WebPageProxy.cpp: Added proxy methods. 33 (WebKit::WebPageProxy::initializeFindMatchesClient): 34 (WebKit::WebPageProxy::findStringMatches): 35 (WebKit::WebPageProxy::getImageForFindMatch): 36 (WebKit::WebPageProxy::selectFindMatch): 37 (WebKit::WebPageProxy::didGetImageForFindMatch): 38 (WebKit::WebPageProxy::didFindStringMatches): 39 * UIProcess/WebPageProxy.h: 40 * UIProcess/WebPageProxy.messages.in: 41 * WebProcess/WebPage/FindController.cpp: 42 (WebKit::FindController::findStringMatches): Finds all the matching 43 text according to the find options. All the matching text ranges are 44 stored in a vector until the next call to findStringMatches or until 45 hideFindUI is called. The message that is sent back to the UI process 46 contains a vector containing an entry for each find match (i.e. for each 47 range) and each entry is represented by a vector of the corresponding 48 text rects. It also returns the index in the vector of matches corresponding 49 to the first match after the user selection. 50 If there is no selection the index is always 0 and if there are no 51 matches after the user selection, the index returned is -1. 52 (WebKit::FindController::getFindIndicatorBitmapAndRect): Helper function 53 to share code between updateFindIndicator and getImageForFindMatch. 54 (WebKit::FindController::getImageForFindMatch): Creates the image corresponding 55 to the text matched at the given match index. 56 (WebKit::FindController::selectFindMatch): creates a selection for the range 57 corresponding to the given match index. 58 (WebKit::FindController::hideFindUI): Added logic to clear the vector 59 of matched ranges. 60 (WebKit::FindController::updateFindIndicator): Updated to use the 61 new helper function getFindIndicatorBitmapAndRect. 62 * WebProcess/WebPage/FindController.h: 63 * WebProcess/WebPage/WebPage.cpp: 64 (WebKit::WebPage::findStringMatches): 65 (WebKit::WebPage::getImageForFindMatch): 66 (WebKit::WebPage::selectFindMatch): 67 * WebProcess/WebPage/WebPage.h: 68 * WebProcess/WebPage/WebPage.messages.in: 69 1 70 2013-01-16 Lucas Forschler <lforschler@apple.com> 2 71 -
tags/Safari-537.26.1/Source/WebKit2/UIProcess/API/C/WKPage.cpp
r139023 r140000 494 494 } 495 495 496 void WKPageFindStringMatches(WKPageRef pageRef, WKStringRef string, WKFindOptions options, unsigned maxMatchCount) 497 { 498 toImpl(pageRef)->findStringMatches(toImpl(string)->string(), toFindOptions(options), maxMatchCount); 499 } 500 501 void WKPageGetImageForFindMatch(WKPageRef pageRef, int32_t matchIndex) 502 { 503 toImpl(pageRef)->getImageForFindMatch(matchIndex); 504 } 505 506 void WKPageSelectFindMatch(WKPageRef pageRef, int32_t matchIndex) 507 { 508 toImpl(pageRef)->selectFindMatch(matchIndex); 509 } 510 496 511 void WKPageFindString(WKPageRef pageRef, WKStringRef string, WKFindOptions options, unsigned maxMatchCount) 497 512 { … … 519 534 { 520 535 toImpl(pageRef)->initializeFindClient(wkClient); 536 } 537 538 void WKPageSetPageFindMatchesClient(WKPageRef pageRef, const WKPageFindMatchesClient* wkClient) 539 { 540 toImpl(pageRef)->initializeFindMatchesClient(wkClient); 521 541 } 522 542 -
tags/Safari-537.26.1/Source/WebKit2/UIProcess/API/C/WKPage.h
r138388 r140000 317 317 }; 318 318 319 // Find match client. 320 typedef void (*WKPageDidFindStringMatchesCallback)(WKPageRef page, WKStringRef string, WKArrayRef matches, int firstIndex, const void* clientInfo); 321 typedef void (*WKPageDidGetImageForMatchResultCallback)(WKPageRef page, WKImageRef image, uint32_t index, const void* clientInfo); 322 323 struct WKPageFindMatchesClient { 324 int version; 325 const void * clientInfo; 326 WKPageDidFindStringMatchesCallback didFindStringMatches; 327 WKPageDidGetImageForMatchResultCallback didGetImageForMatchResult; 328 }; 329 typedef struct WKPageFindMatchesClient WKPageFindMatchesClient; 330 331 enum { kWKPageFindMatchesClientCurrentVersion = 0 }; 332 319 333 // ContextMenu client 320 334 typedef void (*WKPageGetContextMenuFromProposedContextMenuCallback)(WKPageRef page, WKArrayRef proposedMenu, WKArrayRef* newMenu, WKHitTestResultRef hitTestResult, WKTypeRef userData, const void* clientInfo); … … 453 467 WK_EXPORT void WKPageHideFindUI(WKPageRef page); 454 468 WK_EXPORT void WKPageCountStringMatches(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount); 469 WK_EXPORT void WKPageFindStringMatches(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount); 470 WK_EXPORT void WKPageGetImageForFindMatch(WKPageRef page, int32_t matchIndex); 471 WK_EXPORT void WKPageSelectFindMatch(WKPageRef page, int32_t matchIndex); 455 472 456 473 WK_EXPORT void WKPageSetPageContextMenuClient(WKPageRef page, const WKPageContextMenuClient* client); 457 474 WK_EXPORT void WKPageSetPageFindClient(WKPageRef page, const WKPageFindClient* client); 475 WK_EXPORT void WKPageSetPageFindMatchesClient(WKPageRef page, const WKPageFindMatchesClient* client); 458 476 WK_EXPORT void WKPageSetPageFormClient(WKPageRef page, const WKPageFormClient* client); 459 477 WK_EXPORT void WKPageSetPageLoaderClient(WKPageRef page, const WKPageLoaderClient* client); -
tags/Safari-537.26.1/Source/WebKit2/UIProcess/WebFindClient.cpp
r95901 r140000 56 56 } 57 57 58 void WebFindMatchesClient::didFindStringMatches(WebPageProxy* page, const String& string, ImmutableArray* matches, int firstIndex) 59 { 60 if (!m_client.didFindStringMatches) 61 return; 62 63 m_client.didFindStringMatches(toAPI(page), toAPI(string.impl()), toAPI(matches), firstIndex, m_client.clientInfo); 64 } 65 66 void WebFindMatchesClient::didGetImageForMatchResult(WebPageProxy* page, WebImage* image, uint32_t index) 67 { 68 if (!m_client.didGetImageForMatchResult) 69 return; 70 m_client.didGetImageForMatchResult(toAPI(page), toAPI(image), index, m_client.clientInfo); 71 } 72 58 73 } // namespace WebKit 59 74 -
tags/Safari-537.26.1/Source/WebKit2/UIProcess/WebFindClient.h
r95901 r140000 33 33 namespace WebKit { 34 34 35 class ImmutableArray; 35 36 class WebPageProxy; 37 class WebImage; 36 38 37 39 class WebFindClient : public APIClient<WKPageFindClient, kWKPageFindClientCurrentVersion> { … … 42 44 }; 43 45 46 class WebFindMatchesClient : public APIClient<WKPageFindMatchesClient, kWKPageFindMatchesClientCurrentVersion> { 47 public: 48 void didFindStringMatches(WebPageProxy*, const String&, ImmutableArray*, int); 49 void didGetImageForMatchResult(WebPageProxy*, WebImage*, uint32_t); 50 }; 51 44 52 } // namespace WebKit 45 53 -
tags/Safari-537.26.1/Source/WebKit2/UIProcess/WebPageProxy.cpp
r139341 r140000 35 35 #include "EventDispatcherMessages.h" 36 36 #include "FindIndicator.h" 37 #include "ImmutableArray.h" 37 38 #include "Logging.h" 38 39 #include "MessageID.h" … … 368 369 } 369 370 371 void WebPageProxy::initializeFindMatchesClient(const WKPageFindMatchesClient* client) 372 { 373 m_findMatchesClient.initialize(client); 374 } 375 370 376 #if ENABLE(CONTEXT_MENUS) 371 377 void WebPageProxy::initializeContextMenuClient(const WKPageContextMenuClient* client) … … 1683 1689 } 1684 1690 1691 void WebPageProxy::findStringMatches(const String& string, FindOptions options, unsigned maxMatchCount) 1692 { 1693 if (string.isEmpty()) { 1694 didFindStringMatches(string, Vector<Vector<WebCore::IntRect> > (), 0); 1695 return; 1696 } 1697 1698 m_process->send(Messages::WebPage::FindStringMatches(string, options, maxMatchCount), m_pageID); 1699 } 1700 1685 1701 void WebPageProxy::findString(const String& string, FindOptions options, unsigned maxMatchCount) 1686 1702 { … … 1689 1705 else 1690 1706 m_process->send(Messages::WebPage::FindString(string, options, maxMatchCount), m_pageID); 1707 } 1708 1709 void WebPageProxy::getImageForFindMatch(int32_t matchIndex) 1710 { 1711 m_process->send(Messages::WebPage::GetImageForFindMatch(matchIndex), m_pageID); 1712 } 1713 1714 void WebPageProxy::selectFindMatch(int32_t matchIndex) 1715 { 1716 m_process->send(Messages::WebPage::SelectFindMatch(matchIndex), m_pageID); 1691 1717 } 1692 1718 … … 3025 3051 } 3026 3052 3053 void WebPageProxy::didGetImageForFindMatch(const ShareableBitmap::Handle& contentImageHandle, uint32_t matchIndex) 3054 { 3055 m_findMatchesClient.didGetImageForMatchResult(this, WebImage::create(ShareableBitmap::create(contentImageHandle)).get(), matchIndex); 3056 } 3057 3027 3058 void WebPageProxy::setFindIndicator(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut, bool animate) 3028 3059 { … … 3034 3065 { 3035 3066 m_findClient.didFindString(this, string, matchCount); 3067 } 3068 3069 void WebPageProxy::didFindStringMatches(const String& string, Vector<Vector<WebCore::IntRect> > matchRects, int32_t firstIndexAfterSelection) 3070 { 3071 Vector<RefPtr<APIObject> > matches; 3072 matches.reserveInitialCapacity(matchRects.size()); 3073 3074 for (size_t i = 0; i < matchRects.size(); ++i) { 3075 const Vector<WebCore::IntRect>& rects = matchRects[i]; 3076 size_t numRects = matchRects[i].size(); 3077 Vector<RefPtr<APIObject> > apiRects; 3078 apiRects.reserveInitialCapacity(numRects); 3079 3080 for (size_t i = 0; i < numRects; ++i) 3081 apiRects.uncheckedAppend(WebRect::create(toAPI(rects[i]))); 3082 matches.uncheckedAppend(ImmutableArray::adopt(apiRects)); 3083 } 3084 m_findMatchesClient.didFindStringMatches(this, string, ImmutableArray::adopt(matches).get(), firstIndexAfterSelection); 3036 3085 } 3037 3086 -
tags/Safari-537.26.1/Source/WebKit2/UIProcess/WebPageProxy.h
r139910 r140000 278 278 #endif 279 279 void initializeFindClient(const WKPageFindClient*); 280 void initializeFindMatchesClient(const WKPageFindMatchesClient*); 280 281 void initializeFormClient(const WKPageFormClient*); 281 282 void initializeLoaderClient(const WKPageLoaderClient*); … … 537 538 // Find. 538 539 void findString(const String&, FindOptions, unsigned maxMatchCount); 540 void findStringMatches(const String&, FindOptions, unsigned maxMatchCount); 541 void getImageForFindMatch(int32_t matchIndex); 542 void selectFindMatch(int32_t matchIndex); 543 void didGetImageForFindMatch(const ShareableBitmap::Handle& contentImageHandle, uint32_t matchIndex); 539 544 void hideFindUI(); 540 545 void countStringMatches(const String&, FindOptions, unsigned maxMatchCount); … … 543 548 void didFindString(const String&, uint32_t matchCount); 544 549 void didFailToFindString(const String&); 550 void didFindStringMatches(const String&, Vector<Vector<WebCore::IntRect> > matchRects, int32_t firstIndexAfterSelection); 545 551 546 552 void getContentsAsString(PassRefPtr<StringCallback>); … … 1044 1050 WebUIClient m_uiClient; 1045 1051 WebFindClient m_findClient; 1052 WebFindMatchesClient m_findMatchesClient; 1046 1053 #if ENABLE(CONTEXT_MENUS) 1047 1054 WebPageContextMenuClient m_contextMenuClient; -
tags/Safari-537.26.1/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r139341 r140000 214 214 DidFindString(WTF::String string, uint32_t matchCount) 215 215 DidFailToFindString(WTF::String string) 216 DidFindStringMatches(WTF::String string, Vector<Vector<WebCore::IntRect> > matches, int32_t firstIndexAfterSelection) 217 DidGetImageForFindMatch(WebKit::ShareableBitmap::Handle contentImageHandle, uint32_t matchIndex) 216 218 217 219 # PopupMenu messages -
tags/Safari-537.26.1/Source/WebKit2/WebProcess/WebPage/FindController.cpp
r138466 r140000 194 194 } 195 195 196 void FindController::findStringMatches(const String& string, FindOptions options, unsigned maxMatchCount) 197 { 198 m_findMatches.clear(); 199 int indexForSelection; 200 201 m_webPage->corePage()->findStringMatchingRanges(string, core(options), maxMatchCount, &m_findMatches, indexForSelection); 202 203 Vector<Vector<IntRect> > matchRects; 204 for (size_t i = 0; i < m_findMatches.size(); ++i) { 205 Vector<IntRect> rects; 206 m_findMatches[i]->textRects(rects); 207 matchRects.append(rects); 208 } 209 210 m_webPage->send(Messages::WebPageProxy::DidFindStringMatches(string, matchRects, indexForSelection)); 211 } 212 213 bool FindController::getFindIndicatorBitmapAndRect(Frame* frame, ShareableBitmap::Handle& handle, IntRect& selectionRect) 214 { 215 selectionRect = enclosingIntRect(frame->selection()->bounds()); 216 217 // Selection rect can be empty for matches that are currently obscured from view. 218 if (selectionRect.isEmpty()) 219 return false; 220 221 IntSize backingStoreSize = selectionRect.size(); 222 backingStoreSize.scale(m_webPage->corePage()->deviceScaleFactor()); 223 224 // Create a backing store and paint the find indicator text into it. 225 RefPtr<ShareableBitmap> findIndicatorTextBackingStore = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha); 226 if (!findIndicatorTextBackingStore) 227 return false; 228 229 OwnPtr<GraphicsContext> graphicsContext = findIndicatorTextBackingStore->createGraphicsContext(); 230 graphicsContext->scale(FloatSize(m_webPage->corePage()->deviceScaleFactor(), m_webPage->corePage()->deviceScaleFactor())); 231 232 IntRect paintRect = selectionRect; 233 paintRect.move(frame->view()->frameRect().x(), frame->view()->frameRect().y()); 234 paintRect.move(-frame->view()->scrollOffset()); 235 236 graphicsContext->translate(-paintRect.x(), -paintRect.y()); 237 frame->view()->setPaintBehavior(PaintBehaviorSelectionOnly | PaintBehaviorForceBlackText | PaintBehaviorFlattenCompositingLayers); 238 frame->document()->updateLayout(); 239 240 frame->view()->paint(graphicsContext.get(), paintRect); 241 frame->view()->setPaintBehavior(PaintBehaviorNormal); 242 243 if (!findIndicatorTextBackingStore->createHandle(handle)) 244 return false; 245 return true; 246 } 247 248 void FindController::getImageForFindMatch(uint32_t matchIndex) 249 { 250 if (matchIndex >= m_findMatches.size()) 251 return; 252 Frame* frame = m_findMatches[matchIndex]->startContainer()->document()->frame(); 253 if (!frame) 254 return; 255 256 VisibleSelection oldSelection = frame->selection()->selection(); 257 frame->selection()->setSelection(VisibleSelection(m_findMatches[matchIndex].get())); 258 259 IntRect selectionRect; 260 ShareableBitmap::Handle handle; 261 getFindIndicatorBitmapAndRect(frame, handle, selectionRect); 262 263 frame->selection()->setSelection(oldSelection); 264 265 m_webPage->send(Messages::WebPageProxy::DidGetImageForFindMatch(handle, matchIndex)); 266 } 267 268 void FindController::selectFindMatch(uint32_t matchIndex) 269 { 270 if (matchIndex >= m_findMatches.size()) 271 return; 272 Frame* frame = m_findMatches[matchIndex]->startContainer()->document()->frame(); 273 if (!frame) 274 return; 275 frame->selection()->setSelection(VisibleSelection(m_findMatches[matchIndex].get())); 276 } 277 196 278 void FindController::hideFindUI() 197 279 { 280 m_findMatches.clear(); 198 281 if (m_findPageOverlay) 199 282 m_webPage->uninstallPageOverlay(m_findPageOverlay, false); … … 214 297 return false; 215 298 216 IntRect selectionRect = enclosingIntRect(selectedFrame->selection()->bounds()); 217 218 // Selection rect can be empty for matches that are currently obscured from view. 219 if (selectionRect.isEmpty()) 299 IntRect selectionRect; 300 ShareableBitmap::Handle handle; 301 if (!getFindIndicatorBitmapAndRect(selectedFrame, handle, selectionRect)) 220 302 return false; 221 303 222 304 // We want the selection rect in window coordinates. 223 305 IntRect selectionRectInWindowCoordinates = selectedFrame->view()->contentsToWindow(selectionRect); 224 306 225 307 Vector<FloatRect> textRects; 226 308 selectedFrame->selection()->getClippedVisibleTextRectangles(textRects); 227 228 IntSize backingStoreSize = selectionRect.size();229 backingStoreSize.scale(m_webPage->corePage()->deviceScaleFactor());230 231 // Create a backing store and paint the find indicator text into it.232 RefPtr<ShareableBitmap> findIndicatorTextBackingStore = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha);233 if (!findIndicatorTextBackingStore)234 return false;235 236 OwnPtr<GraphicsContext> graphicsContext = findIndicatorTextBackingStore->createGraphicsContext();237 graphicsContext->scale(FloatSize(m_webPage->corePage()->deviceScaleFactor(), m_webPage->corePage()->deviceScaleFactor()));238 239 IntRect paintRect = selectionRect;240 paintRect.move(selectedFrame->view()->frameRect().x(), selectedFrame->view()->frameRect().y());241 paintRect.move(-selectedFrame->view()->scrollOffset());242 243 graphicsContext->translate(-paintRect.x(), -paintRect.y());244 selectedFrame->view()->setPaintBehavior(PaintBehaviorSelectionOnly | PaintBehaviorForceBlackText | PaintBehaviorFlattenCompositingLayers);245 selectedFrame->document()->updateLayout();246 247 selectedFrame->view()->paint(graphicsContext.get(), paintRect);248 selectedFrame->view()->setPaintBehavior(PaintBehaviorNormal);249 250 ShareableBitmap::Handle handle;251 if (!findIndicatorTextBackingStore->createHandle(handle))252 return false;253 309 254 310 // We want the text rects in selection rect coordinates. -
tags/Safari-537.26.1/Source/WebKit2/WebProcess/WebPage/FindController.h
r115681 r140000 28 28 29 29 #include "PageOverlay.h" 30 #include "ShareableBitmap.h" 30 31 #include "WebFindOptions.h" 31 32 #include <WebCore/IntRect.h> … … 36 37 namespace WebCore { 37 38 class Frame; 39 class Range; 38 40 } 39 41 … … 50 52 51 53 void findString(const String&, FindOptions, unsigned maxMatchCount); 54 void findStringMatches(const String&, FindOptions, unsigned maxMatchCount); 55 void getImageForFindMatch(uint32_t matchIndex); 56 void selectFindMatch(uint32_t matchIndex); 52 57 void hideFindUI(); 53 58 void countStringMatches(const String&, FindOptions, unsigned maxMatchCount); … … 69 74 70 75 Vector<WebCore::IntRect> rectsForTextMatches(); 76 bool getFindIndicatorBitmapAndRect(WebCore::Frame*, ShareableBitmap::Handle&, WebCore::IntRect& selectionRect); 71 77 bool updateFindIndicator(WebCore::Frame* selectedFrame, bool isShowingOverlay, bool shouldAnimate = true); 72 78 … … 80 86 bool m_isShowingFindIndicator; 81 87 WebCore::IntRect m_findIndicatorRect; 88 Vector<RefPtr<WebCore::Range> > m_findMatches; 82 89 }; 83 90 -
tags/Safari-537.26.1/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r139910 r140000 2682 2682 } 2683 2683 2684 void WebPage::findStringMatches(const String& string, uint32_t options, uint32_t maxMatchCount) 2685 { 2686 m_findController.findStringMatches(string, static_cast<FindOptions>(options), maxMatchCount); 2687 } 2688 2689 void WebPage::getImageForFindMatch(uint32_t matchIndex) 2690 { 2691 m_findController.getImageForFindMatch(matchIndex); 2692 } 2693 2694 void WebPage::selectFindMatch(uint32_t matchIndex) 2695 { 2696 m_findController.selectFindMatch(matchIndex); 2697 } 2698 2684 2699 void WebPage::hideFindUI() 2685 2700 { -
tags/Safari-537.26.1/Source/WebKit2/WebProcess/WebPage/WebPage.h
r139910 r140000 735 735 736 736 void findString(const String&, uint32_t findOptions, uint32_t maxMatchCount); 737 void findStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount); 738 void getImageForFindMatch(uint32_t matchIndex); 739 void selectFindMatch(uint32_t matchIndex); 737 740 void hideFindUI(); 738 741 void countStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount); -
tags/Safari-537.26.1/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r139910 r140000 152 152 # Find. 153 153 FindString(WTF::String string, uint32_t findOptions, unsigned maxMatchCount) 154 FindStringMatches(WTF::String string, uint32_t findOptions, unsigned maxMatchCount) 155 GetImageForFindMatch(uint32_t matchIndex) 156 SelectFindMatch(uint32_t matchIndex) 154 157 HideFindUI() 155 158 CountStringMatches(WTF::String string, uint32_t findOptions, unsigned maxMatchCount) -
tags/Safari-537.26.1/Tools/ChangeLog
r139613 r140000 1 2013-01-17 Lucas Forschler <lforschler@apple.com> 2 3 Merge r139796 4 5 2013-01-15 Enrica Casucci <enrica@apple.com> 6 7 Add a new set of WebKit2 APIs for text search and 8 search results management. 9 https://bugs.webkit.org/show_bug.cgi?id=106834. 10 <rdar://problem/12597159> 11 12 Added new test for the new WebKit2 API for 13 text search. 14 15 Reviewed by Simon Fraser. 16 17 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 18 * TestWebKitAPI/Tests/WebKit2/FindMatches.mm: Added. 19 1 20 2013-01-14 Andrey Lushnikov <lushnikov@chromium.org> 2 21 -
tags/Safari-537.26.1/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r139012 r140000 178 178 C0C5D3C61459912900A802A6 /* GetBackingScaleFactor_Bundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */; }; 179 179 C507E8A714C6545B005D6B3B /* InspectorBar.mm in Sources */ = {isa = PBXBuildFile; fileRef = C507E8A614C6545B005D6B3B /* InspectorBar.mm */; }; 180 C51AFB99169F49FF009CCF66 /* FindMatches.mm in Sources */ = {isa = PBXBuildFile; fileRef = C51AFB98169F49FF009CCF66 /* FindMatches.mm */; }; 180 181 C540F776152E4DA000A40C8C /* SimplifyMarkup.mm in Sources */ = {isa = PBXBuildFile; fileRef = C540F775152E4DA000A40C8C /* SimplifyMarkup.mm */; }; 181 182 C540F784152E5A9A00A40C8C /* verboseMarkup.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C540F783152E5A7800A40C8C /* verboseMarkup.html */; }; … … 446 447 C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor_Bundle.mm; sourceTree = "<group>"; }; 447 448 C507E8A614C6545B005D6B3B /* InspectorBar.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InspectorBar.mm; sourceTree = "<group>"; }; 449 C51AFB98169F49FF009CCF66 /* FindMatches.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FindMatches.mm; sourceTree = "<group>"; }; 448 450 C540F775152E4DA000A40C8C /* SimplifyMarkup.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SimplifyMarkup.mm; sourceTree = "<group>"; }; 449 451 C540F783152E5A7800A40C8C /* verboseMarkup.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = verboseMarkup.html; sourceTree = "<group>"; }; … … 615 617 BCC8B95A12611F4700DE46A4 /* FailedLoad.cpp */, 616 618 1A02C84E125D4A8400E3F4BD /* Find.cpp */, 619 C51AFB98169F49FF009CCF66 /* FindMatches.mm */, 617 620 1ADBEFAD130C689C00D61D19 /* ForceRepaint.cpp */, 618 621 BCBD370F125AA2EB00D2C29F /* FrameMIMETypeHTML.cpp */, … … 1059 1062 BC9099941256ACF100083756 /* WKStringJSString.cpp in Sources */, 1060 1063 265AF55015D1E48A00B0CB4A /* WTFString.cpp in Sources */, 1064 C51AFB99169F49FF009CCF66 /* FindMatches.mm in Sources */, 1061 1065 ); 1062 1066 runOnlyForDeploymentPostprocessing = 0;
Note: See TracChangeset
for help on using the changeset viewer.