[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

mitz at apple.com mitz at apple.com
Wed Dec 22 17:59:58 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 1506e87430cacfe0c63385fb163ebe5e5aee4e00
Author: mitz at apple.com <mitz at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Dec 5 03:21:16 2010 +0000

    2010-12-04  Dan Bernstein  <mitz at apple.com>
    
            Reviewed by Sam Weinig.
    
            WebKit part of <rdar://problem/8145955> Add text search API for counting/marking/highlighting matches in a range
            https://bugs.webkit.org/show_bug.cgi?id=50530
    
            * WebView/WebDocumentInternal.h: Added a DOMRange parameter to -countMatchesForText:options:limit:markMatches:
            * WebView/WebHTMLView.mm:
            (-[WebHTMLView countMatchesForText:inDOMRange:options:limit:markMatches:]): Added DOMRange parameter,
            which is passed through to WebCore.
            * WebView/WebPDFView.mm:
            (isFrameInRange): Added this helper function.
            (-[WebPDFView countMatchesForText:inDOMRange:options:limit:markMatches:]): Added DOMRange parameter and
            a check if the frame is in the range.
            * WebView/WebView.mm:
            (-[WebView countMatchesForText:options:highlight:limit:markMatches:]): Now calls the inDOMRange: version.
            (-[WebView countMatchesForText:inDOMRange:options:highlight:limit:markMatches:]): Added DOMRange
            parameter, which is passed to document views' -countMatchesForText:inDOMRange:options:limit:markMatches:.
            * WebView/WebViewPrivate.h:
    2010-12-04  Dan Bernstein  <mitz at apple.com>
    
            Reviewed by Sam Weinig.
    
            WebCore part of <rdar://problem/8145955> Add text search API for counting/marking/highlighting matches in a range
            https://bugs.webkit.org/show_bug.cgi?id=50530
    
            * WebCore.exp.in: Export Range version of countMatchesForText().
            * editing/Editor.cpp:
            (WebCore::isFrameInRange): Added this helper method.
            (WebCore::Editor::countMatchesForText): Added a Range parameter and restricted the result to
            matches that occur in the range.
            * editing/Editor.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73337 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 8959080..b8f335b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,17 @@
+2010-12-04  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        WebCore part of <rdar://problem/8145955> Add text search API for counting/marking/highlighting matches in a range
+        https://bugs.webkit.org/show_bug.cgi?id=50530
+
+        * WebCore.exp.in: Export Range version of countMatchesForText().
+        * editing/Editor.cpp:
+        (WebCore::isFrameInRange): Added this helper method.
+        (WebCore::Editor::countMatchesForText): Added a Range parameter and restricted the result to
+        matches that occur in the range.
+        * editing/Editor.h:
+
 2010-12-04  Gavin Peters  <gavinp at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/WebCore/WebCore.exp.in b/WebCore/WebCore.exp.in
index a12d364..99ca93a 100644
--- a/WebCore/WebCore.exp.in
+++ b/WebCore/WebCore.exp.in
@@ -676,7 +676,7 @@ __ZN7WebCore6Editor16pasteAsPlainTextEv
 __ZN7WebCore6Editor17insertOrderedListEv
 __ZN7WebCore6Editor18confirmCompositionERKN3WTF6StringE
 __ZN7WebCore6Editor18confirmCompositionEv
-__ZN7WebCore6Editor19countMatchesForTextERKN3WTF6StringEjjb
+__ZN7WebCore6Editor19countMatchesForTextERKN3WTF6StringEPNS_5RangeEjjb
 __ZN7WebCore6Editor19deleteWithDirectionENS_19SelectionController10EDirectionENS_15TextGranularityEbb
 __ZN7WebCore6Editor19insertUnorderedListEv
 __ZN7WebCore6Editor21applyStyleToSelectionEPNS_19CSSStyleDeclarationENS_10EditActionE
diff --git a/WebCore/editing/Editor.cpp b/WebCore/editing/Editor.cpp
index 6aa7b20..816ae90 100644
--- a/WebCore/editing/Editor.cpp
+++ b/WebCore/editing/Editor.cpp
@@ -51,6 +51,7 @@
 #include "Frame.h"
 #include "FrameTree.h"
 #include "FrameView.h"
+#include "HTMLFrameOwnerElement.h"
 #include "HTMLInputElement.h"
 #include "HTMLTextAreaElement.h"
 #include "HitTestResult.h"
@@ -3349,12 +3350,40 @@ bool Editor::findString(const String& target, FindOptions options)
     return true;
 }
 
+static bool isFrameInRange(Frame* frame, Range* range)
+{
+    bool inRange = false;
+    for (HTMLFrameOwnerElement* ownerElement = frame->ownerElement(); ownerElement; ownerElement = ownerElement->document()->ownerElement()) {
+        if (ownerElement->document() == range->ownerDocument()) {
+            ExceptionCode ec = 0;
+            inRange = range->intersectsNode(ownerElement, ec);
+            break;
+        }
+    }
+    return inRange;
+}
+
 unsigned Editor::countMatchesForText(const String& target, FindOptions options, unsigned limit, bool markMatches)
 {
+    return countMatchesForText(target, 0, options, limit, markMatches);
+}
+
+unsigned Editor::countMatchesForText(const String& target, Range* range, FindOptions options, unsigned limit, bool markMatches)
+{
     if (target.isEmpty())
         return 0;
 
-    RefPtr<Range> searchRange(rangeOfContents(m_frame->document()));
+    RefPtr<Range> originalSearchRange;
+    if (range) {
+        if (range->ownerDocument() == m_frame->document())
+            originalSearchRange = range;
+        else if (!isFrameInRange(m_frame, range))
+            return 0;
+    }
+    if (!originalSearchRange)
+        originalSearchRange = rangeOfContents(m_frame->document());
+
+    RefPtr<Range> searchRange(originalSearchRange);
 
     ExceptionCode exception = 0;
     unsigned matchCount = 0;
@@ -3364,7 +3393,7 @@ unsigned Editor::countMatchesForText(const String& target, FindOptions options,
             if (!resultRange->startContainer()->isInShadowTree())
                 break;
 
-            searchRange = rangeOfContents(m_frame->document());
+            searchRange = originalSearchRange;
             searchRange->setStartAfter(resultRange->startContainer()->shadowAncestorNode(), exception);
             continue;
         }
diff --git a/WebCore/editing/Editor.h b/WebCore/editing/Editor.h
index 068760b..469e51f 100644
--- a/WebCore/editing/Editor.h
+++ b/WebCore/editing/Editor.h
@@ -348,6 +348,7 @@ public:
     RenderStyle* styleForSelectionStart(Node*& nodeToRemove) const;
 
     unsigned countMatchesForText(const String&, FindOptions, unsigned limit, bool markMatches);
+    unsigned countMatchesForText(const String&, Range*, FindOptions, unsigned limit, bool markMatches);
     bool markedTextMatchesAreHighlighted() const;
     void setMarkedTextMatchesAreHighlighted(bool);
 
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 8a128e5..ff8bd91 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,24 @@
+2010-12-04  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        WebKit part of <rdar://problem/8145955> Add text search API for counting/marking/highlighting matches in a range
+        https://bugs.webkit.org/show_bug.cgi?id=50530
+
+        * WebView/WebDocumentInternal.h: Added a DOMRange parameter to -countMatchesForText:options:limit:markMatches:
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView countMatchesForText:inDOMRange:options:limit:markMatches:]): Added DOMRange parameter,
+        which is passed through to WebCore.
+        * WebView/WebPDFView.mm:
+        (isFrameInRange): Added this helper function.
+        (-[WebPDFView countMatchesForText:inDOMRange:options:limit:markMatches:]): Added DOMRange parameter and
+        a check if the frame is in the range.
+        * WebView/WebView.mm:
+        (-[WebView countMatchesForText:options:highlight:limit:markMatches:]): Now calls the inDOMRange: version.
+        (-[WebView countMatchesForText:inDOMRange:options:highlight:limit:markMatches:]): Added DOMRange
+        parameter, which is passed to document views' -countMatchesForText:inDOMRange:options:limit:markMatches:.
+        * WebView/WebViewPrivate.h:
+
 2010-12-03  Sam Weinig  <sam at webkit.org>
 
         Reviewed by Maciej Stachowiak.
diff --git a/WebKit/mac/WebView/WebDocumentInternal.h b/WebKit/mac/WebView/WebDocumentInternal.h
index 0b86ba8..4bf11d1 100644
--- a/WebKit/mac/WebView/WebDocumentInternal.h
+++ b/WebKit/mac/WebView/WebDocumentInternal.h
@@ -62,7 +62,7 @@
 @protocol WebMultipleTextMatches <NSObject>
 - (void)setMarkedTextMatchesAreHighlighted:(BOOL)newValue;
 - (BOOL)markedTextMatchesAreHighlighted;
-- (WebNSUInteger)countMatchesForText:(NSString *)string options:(WebFindOptions)options limit:(WebNSUInteger)limit markMatches:(BOOL)markMatches;
+- (WebNSUInteger)countMatchesForText:(NSString *)string inDOMRange:(DOMRange *)range options:(WebFindOptions)options limit:(WebNSUInteger)limit markMatches:(BOOL)markMatches;
 - (void)unmarkAllTextMatches;
 - (NSArray *)rectsForTextMatches;
 @end
diff --git a/WebKit/mac/WebView/WebHTMLView.mm b/WebKit/mac/WebView/WebHTMLView.mm
index db78c37..ee478bc 100644
--- a/WebKit/mac/WebView/WebHTMLView.mm
+++ b/WebKit/mac/WebView/WebHTMLView.mm
@@ -6228,12 +6228,13 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
     return [[[WebElementDictionary alloc] initWithHitTestResult:coreFrame->eventHandler()->hitTestResultAtPoint(IntPoint(point), allow)] autorelease];
 }
 
-- (NSUInteger)countMatchesForText:(NSString *)string options:(WebFindOptions)options limit:(NSUInteger)limit markMatches:(BOOL)markMatches
+- (NSUInteger)countMatchesForText:(NSString *)string inDOMRange:(DOMRange *)range options:(WebFindOptions)options limit:(NSUInteger)limit markMatches:(BOOL)markMatches
 {
     Frame* coreFrame = core([self _frame]);
     if (!coreFrame)
         return 0;
-    return coreFrame->editor()->countMatchesForText(string, coreOptions(options), limit, markMatches);
+
+    return coreFrame->editor()->countMatchesForText(string, core(range), coreOptions(options), limit, markMatches);
 }
 
 - (void)setMarkedTextMatchesAreHighlighted:(BOOL)newValue
diff --git a/WebKit/mac/WebView/WebPDFView.mm b/WebKit/mac/WebView/WebPDFView.mm
index 35d44f7..032a112 100644
--- a/WebKit/mac/WebView/WebPDFView.mm
+++ b/WebKit/mac/WebView/WebPDFView.mm
@@ -28,6 +28,8 @@
 
 #import "WebPDFView.h"
 
+#import "DOMNodeInternal.h"
+#import "DOMRangeInternal.h"
 #import "WebDataSourceInternal.h"
 #import "WebDelegateImplementationCaching.h"
 #import "WebDocumentInternal.h"
@@ -53,6 +55,7 @@
 #import <WebCore/FrameLoadRequest.h>
 #import <WebCore/FrameLoader.h>
 #import <WebCore/HTMLFormElement.h>
+#import <WebCore/HTMLFrameOwnerElement.h>
 #import <WebCore/KURL.h>
 #import <WebCore/KeyboardEvent.h>
 #import <WebCore/MouseEvent.h>
@@ -626,8 +629,23 @@ static BOOL _PDFSelectionsAreEqual(PDFSelection *selectionA, PDFSelection *selec
     return NO;
 }
 
-- (NSUInteger)countMatchesForText:(NSString *)string options:(WebFindOptions)options limit:(NSUInteger)limit markMatches:(BOOL)markMatches
+static BOOL isFrameInRange(WebFrame *frame, DOMRange *range)
 {
+    BOOL inRange = NO;
+    for (HTMLFrameOwnerElement* ownerElement = core(frame)->ownerElement(); ownerElement; ownerElement = ownerElement->document()->frame()->ownerElement()) {
+        if (ownerElement->document() == core(range)->ownerDocument()) {
+            inRange = [range intersectsNode:kit(ownerElement)];
+            break;
+        }
+    }
+    return inRange;
+}
+
+- (NSUInteger)countMatchesForText:(NSString *)string inDOMRange:(DOMRange *)range options:(WebFindOptions)options limit:(NSUInteger)limit markMatches:(BOOL)markMatches
+{
+    if (range && !isFrameInRange([dataSource webFrame], range))
+        return 0;
+
     PDFSelection *previousMatch = nil;
     NSMutableArray *matches = [[NSMutableArray alloc] initWithCapacity:limit];
     
diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm
index c57bf38..e2ebe2b 100644
--- a/WebKit/mac/WebView/WebView.mm
+++ b/WebKit/mac/WebView/WebView.mm
@@ -4518,6 +4518,11 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValue jsValu
 
 - (NSUInteger)countMatchesForText:(NSString *)string options:(WebFindOptions)options highlight:(BOOL)highlight limit:(NSUInteger)limit markMatches:(BOOL)markMatches
 {
+    return [self countMatchesForText:string inDOMRange:nil options:options highlight:highlight limit:limit markMatches:markMatches];
+}
+
+- (NSUInteger)countMatchesForText:(NSString *)string inDOMRange:(DOMRange *)range options:(WebFindOptions)options highlight:(BOOL)highlight limit:(NSUInteger)limit markMatches:(BOOL)markMatches
+{
     if (_private->closed)
         return 0;
 
@@ -4530,7 +4535,7 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValue jsValu
                 [(NSView <WebMultipleTextMatches>*)view setMarkedTextMatchesAreHighlighted:highlight];
         
             ASSERT(limit == 0 || matchCount < limit);
-            matchCount += [(NSView <WebMultipleTextMatches>*)view countMatchesForText:string options:options limit:(limit == 0 ? 0 : limit - matchCount) markMatches:markMatches];
+            matchCount += [(NSView <WebMultipleTextMatches>*)view countMatchesForText:string inDOMRange:range options:options limit:(limit == 0 ? 0 : limit - matchCount) markMatches:markMatches];
 
             // Stop looking if we've reached the limit. A limit of 0 means no limit.
             if (limit > 0 && matchCount >= limit)
diff --git a/WebKit/mac/WebView/WebViewPrivate.h b/WebKit/mac/WebView/WebViewPrivate.h
index 5b995e9..340ac53 100644
--- a/WebKit/mac/WebView/WebViewPrivate.h
+++ b/WebKit/mac/WebView/WebViewPrivate.h
@@ -182,6 +182,7 @@ typedef NSUInteger WebFindOptions;
 // These methods are still in flux; don't rely on them yet.
 - (BOOL)canMarkAllTextMatches;
 - (WebNSUInteger)countMatchesForText:(NSString *)string options:(WebFindOptions)options highlight:(BOOL)highlight limit:(WebNSUInteger)limit markMatches:(BOOL)markMatches;
+- (WebNSUInteger)countMatchesForText:(NSString *)string inDOMRange:(DOMRange *)range options:(WebFindOptions)options highlight:(BOOL)highlight limit:(WebNSUInteger)limit markMatches:(BOOL)markMatches;
 - (void)unmarkAllTextMatches;
 - (NSArray *)rectsForTextMatches;
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list