Changeset 73337 in webkit
- Timestamp:
- Dec 4, 2010 7:21:16 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r73335 r73337 1 2010-12-04 Dan Bernstein <mitz@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 WebCore part of <rdar://problem/8145955> Add text search API for counting/marking/highlighting matches in a range 6 https://bugs.webkit.org/show_bug.cgi?id=50530 7 8 * WebCore.exp.in: Export Range version of countMatchesForText(). 9 * editing/Editor.cpp: 10 (WebCore::isFrameInRange): Added this helper method. 11 (WebCore::Editor::countMatchesForText): Added a Range parameter and restricted the result to 12 matches that occur in the range. 13 * editing/Editor.h: 14 1 15 2010-12-04 Gavin Peters <gavinp@chromium.org> 2 16 -
trunk/WebCore/WebCore.exp.in
r73281 r73337 677 677 __ZN7WebCore6Editor18confirmCompositionERKN3WTF6StringE 678 678 __ZN7WebCore6Editor18confirmCompositionEv 679 __ZN7WebCore6Editor19countMatchesForTextERKN3WTF6StringE jjb679 __ZN7WebCore6Editor19countMatchesForTextERKN3WTF6StringEPNS_5RangeEjjb 680 680 __ZN7WebCore6Editor19deleteWithDirectionENS_19SelectionController10EDirectionENS_15TextGranularityEbb 681 681 __ZN7WebCore6Editor19insertUnorderedListEv -
trunk/WebCore/editing/Editor.cpp
r73287 r73337 52 52 #include "FrameTree.h" 53 53 #include "FrameView.h" 54 #include "HTMLFrameOwnerElement.h" 54 55 #include "HTMLInputElement.h" 55 56 #include "HTMLTextAreaElement.h" … … 3350 3351 } 3351 3352 3353 static bool isFrameInRange(Frame* frame, Range* range) 3354 { 3355 bool inRange = false; 3356 for (HTMLFrameOwnerElement* ownerElement = frame->ownerElement(); ownerElement; ownerElement = ownerElement->document()->ownerElement()) { 3357 if (ownerElement->document() == range->ownerDocument()) { 3358 ExceptionCode ec = 0; 3359 inRange = range->intersectsNode(ownerElement, ec); 3360 break; 3361 } 3362 } 3363 return inRange; 3364 } 3365 3352 3366 unsigned Editor::countMatchesForText(const String& target, FindOptions options, unsigned limit, bool markMatches) 3367 { 3368 return countMatchesForText(target, 0, options, limit, markMatches); 3369 } 3370 3371 unsigned Editor::countMatchesForText(const String& target, Range* range, FindOptions options, unsigned limit, bool markMatches) 3353 3372 { 3354 3373 if (target.isEmpty()) 3355 3374 return 0; 3356 3375 3357 RefPtr<Range> searchRange(rangeOfContents(m_frame->document())); 3376 RefPtr<Range> originalSearchRange; 3377 if (range) { 3378 if (range->ownerDocument() == m_frame->document()) 3379 originalSearchRange = range; 3380 else if (!isFrameInRange(m_frame, range)) 3381 return 0; 3382 } 3383 if (!originalSearchRange) 3384 originalSearchRange = rangeOfContents(m_frame->document()); 3385 3386 RefPtr<Range> searchRange(originalSearchRange); 3358 3387 3359 3388 ExceptionCode exception = 0; … … 3365 3394 break; 3366 3395 3367 searchRange = rangeOfContents(m_frame->document());3396 searchRange = originalSearchRange; 3368 3397 searchRange->setStartAfter(resultRange->startContainer()->shadowAncestorNode(), exception); 3369 3398 continue; -
trunk/WebCore/editing/Editor.h
r73287 r73337 349 349 350 350 unsigned countMatchesForText(const String&, FindOptions, unsigned limit, bool markMatches); 351 unsigned countMatchesForText(const String&, Range*, FindOptions, unsigned limit, bool markMatches); 351 352 bool markedTextMatchesAreHighlighted() const; 352 353 void setMarkedTextMatchesAreHighlighted(bool); -
trunk/WebKit/mac/ChangeLog
r73312 r73337 1 2010-12-04 Dan Bernstein <mitz@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 WebKit part of <rdar://problem/8145955> Add text search API for counting/marking/highlighting matches in a range 6 https://bugs.webkit.org/show_bug.cgi?id=50530 7 8 * WebView/WebDocumentInternal.h: Added a DOMRange parameter to -countMatchesForText:options:limit:markMatches: 9 * WebView/WebHTMLView.mm: 10 (-[WebHTMLView countMatchesForText:inDOMRange:options:limit:markMatches:]): Added DOMRange parameter, 11 which is passed through to WebCore. 12 * WebView/WebPDFView.mm: 13 (isFrameInRange): Added this helper function. 14 (-[WebPDFView countMatchesForText:inDOMRange:options:limit:markMatches:]): Added DOMRange parameter and 15 a check if the frame is in the range. 16 * WebView/WebView.mm: 17 (-[WebView countMatchesForText:options:highlight:limit:markMatches:]): Now calls the inDOMRange: version. 18 (-[WebView countMatchesForText:inDOMRange:options:highlight:limit:markMatches:]): Added DOMRange 19 parameter, which is passed to document views' -countMatchesForText:inDOMRange:options:limit:markMatches:. 20 * WebView/WebViewPrivate.h: 21 1 22 2010-12-03 Sam Weinig <sam@webkit.org> 2 23 -
trunk/WebKit/mac/WebView/WebDocumentInternal.h
r72887 r73337 63 63 - (void)setMarkedTextMatchesAreHighlighted:(BOOL)newValue; 64 64 - (BOOL)markedTextMatchesAreHighlighted; 65 - (WebNSUInteger)countMatchesForText:(NSString *)string options:(WebFindOptions)options limit:(WebNSUInteger)limit markMatches:(BOOL)markMatches;65 - (WebNSUInteger)countMatchesForText:(NSString *)string inDOMRange:(DOMRange *)range options:(WebFindOptions)options limit:(WebNSUInteger)limit markMatches:(BOOL)markMatches; 66 66 - (void)unmarkAllTextMatches; 67 67 - (NSArray *)rectsForTextMatches; -
trunk/WebKit/mac/WebView/WebHTMLView.mm
r72887 r73337 6229 6229 } 6230 6230 6231 - (NSUInteger)countMatchesForText:(NSString *)string options:(WebFindOptions)options limit:(NSUInteger)limit markMatches:(BOOL)markMatches6231 - (NSUInteger)countMatchesForText:(NSString *)string inDOMRange:(DOMRange *)range options:(WebFindOptions)options limit:(NSUInteger)limit markMatches:(BOOL)markMatches 6232 6232 { 6233 6233 Frame* coreFrame = core([self _frame]); 6234 6234 if (!coreFrame) 6235 6235 return 0; 6236 return coreFrame->editor()->countMatchesForText(string, coreOptions(options), limit, markMatches); 6236 6237 return coreFrame->editor()->countMatchesForText(string, core(range), coreOptions(options), limit, markMatches); 6237 6238 } 6238 6239 -
trunk/WebKit/mac/WebView/WebPDFView.mm
r72887 r73337 29 29 #import "WebPDFView.h" 30 30 31 #import "DOMNodeInternal.h" 32 #import "DOMRangeInternal.h" 31 33 #import "WebDataSourceInternal.h" 32 34 #import "WebDelegateImplementationCaching.h" … … 54 56 #import <WebCore/FrameLoader.h> 55 57 #import <WebCore/HTMLFormElement.h> 58 #import <WebCore/HTMLFrameOwnerElement.h> 56 59 #import <WebCore/KURL.h> 57 60 #import <WebCore/KeyboardEvent.h> … … 627 630 } 628 631 629 - (NSUInteger)countMatchesForText:(NSString *)string options:(WebFindOptions)options limit:(NSUInteger)limit markMatches:(BOOL)markMatches 630 { 632 static BOOL isFrameInRange(WebFrame *frame, DOMRange *range) 633 { 634 BOOL inRange = NO; 635 for (HTMLFrameOwnerElement* ownerElement = core(frame)->ownerElement(); ownerElement; ownerElement = ownerElement->document()->frame()->ownerElement()) { 636 if (ownerElement->document() == core(range)->ownerDocument()) { 637 inRange = [range intersectsNode:kit(ownerElement)]; 638 break; 639 } 640 } 641 return inRange; 642 } 643 644 - (NSUInteger)countMatchesForText:(NSString *)string inDOMRange:(DOMRange *)range options:(WebFindOptions)options limit:(NSUInteger)limit markMatches:(BOOL)markMatches 645 { 646 if (range && !isFrameInRange([dataSource webFrame], range)) 647 return 0; 648 631 649 PDFSelection *previousMatch = nil; 632 650 NSMutableArray *matches = [[NSMutableArray alloc] initWithCapacity:limit]; -
trunk/WebKit/mac/WebView/WebView.mm
r72887 r73337 4519 4519 - (NSUInteger)countMatchesForText:(NSString *)string options:(WebFindOptions)options highlight:(BOOL)highlight limit:(NSUInteger)limit markMatches:(BOOL)markMatches 4520 4520 { 4521 return [self countMatchesForText:string inDOMRange:nil options:options highlight:highlight limit:limit markMatches:markMatches]; 4522 } 4523 4524 - (NSUInteger)countMatchesForText:(NSString *)string inDOMRange:(DOMRange *)range options:(WebFindOptions)options highlight:(BOOL)highlight limit:(NSUInteger)limit markMatches:(BOOL)markMatches 4525 { 4521 4526 if (_private->closed) 4522 4527 return 0; … … 4531 4536 4532 4537 ASSERT(limit == 0 || matchCount < limit); 4533 matchCount += [(NSView <WebMultipleTextMatches>*)view countMatchesForText:string options:options limit:(limit == 0 ? 0 : limit - matchCount) markMatches:markMatches];4538 matchCount += [(NSView <WebMultipleTextMatches>*)view countMatchesForText:string inDOMRange:range options:options limit:(limit == 0 ? 0 : limit - matchCount) markMatches:markMatches]; 4534 4539 4535 4540 // Stop looking if we've reached the limit. A limit of 0 means no limit. -
trunk/WebKit/mac/WebView/WebViewPrivate.h
r72887 r73337 183 183 - (BOOL)canMarkAllTextMatches; 184 184 - (WebNSUInteger)countMatchesForText:(NSString *)string options:(WebFindOptions)options highlight:(BOOL)highlight limit:(WebNSUInteger)limit markMatches:(BOOL)markMatches; 185 - (WebNSUInteger)countMatchesForText:(NSString *)string inDOMRange:(DOMRange *)range options:(WebFindOptions)options highlight:(BOOL)highlight limit:(WebNSUInteger)limit markMatches:(BOOL)markMatches; 185 186 - (void)unmarkAllTextMatches; 186 187 - (NSArray *)rectsForTextMatches;
Note: See TracChangeset
for help on using the changeset viewer.