- WebKit part of <rdar://problem/5293820>, needed to support multiple matches in PDFs
* WebView/WebDocumentInternal.h:
Added WebMultipleTextMatches protocol, containing five methods that were formerly implemented in WebHTMLView
* WebView/WebHTMLViewPrivate.h:
Removed declarations for the methods that are now in WebMultipleTextMatches protocol
* WebView/WebHTMLView.mm:
(-[WebHTMLView markAllMatchesForText:caseSensitive:limit:]):
moved this method into the WebDocumentInternalProtocols portion of the file
(-[WebHTMLView setMarkedTextMatchesAreHighlighted:]):
ditto
(-[WebHTMLView markedTextMatchesAreHighlighted]):
ditto
(-[WebHTMLView unmarkAllTextMatches]):
ditto
(-[WebHTMLView rectsForTextMatches]):
ditto
* WebView/WebView.mm:
(-[WebView canMarkAllTextMatches]):
new method, returns YES only if the documentView of every frame implements WebMultipleTextMatches
(-[WebView markAllMatchesForText:caseSensitive:highlight:limit:]):
check for WebMultipleTextMatches protocol instead of checking for WebHTMLView class
(-[WebView unmarkAllTextMatches]):
ditto
(-[WebView rectsForTextMatches]):
ditto
* WebView/WebViewPrivate.h:
declared new method canMarkAllTextMatches
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@23774
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
Reviewed by Darin
+ - WebKit part of <rdar://problem/5293820>, needed to support multiple matches in PDFs
+
+ * WebView/WebDocumentInternal.h:
+ Added WebMultipleTextMatches protocol, containing five methods that were formerly implemented in WebHTMLView
+ * WebView/WebHTMLViewPrivate.h:
+ Removed declarations for the methods that are now in WebMultipleTextMatches protocol
+
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLView markAllMatchesForText:caseSensitive:limit:]):
+ moved this method into the WebDocumentInternalProtocols portion of the file
+ (-[WebHTMLView setMarkedTextMatchesAreHighlighted:]):
+ ditto
+ (-[WebHTMLView markedTextMatchesAreHighlighted]):
+ ditto
+ (-[WebHTMLView unmarkAllTextMatches]):
+ ditto
+ (-[WebHTMLView rectsForTextMatches]):
+ ditto
+
+ * WebView/WebView.mm:
+ (-[WebView canMarkAllTextMatches]):
+ new method, returns YES only if the documentView of every frame implements WebMultipleTextMatches
+ (-[WebView markAllMatchesForText:caseSensitive:highlight:limit:]):
+ check for WebMultipleTextMatches protocol instead of checking for WebHTMLView class
+ (-[WebView unmarkAllTextMatches]):
+ ditto
+ (-[WebView rectsForTextMatches]):
+ ditto
+
+ * WebView/WebViewPrivate.h:
+ declared new method canMarkAllTextMatches
+
+2007-06-25 John Sullivan <sullivan@apple.com>
+
+ Reviewed by Darin
+
Fixed <rdar://problem/5292259> Find on Page doesn't work (throws exception) on page that includes PDF in a subframe
* WebView/WebView.mm:
#import <WebKit/WebDocumentPrivate.h>
#import <WebKit/WebHTMLView.h>
+#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
+#define WebNSUInteger unsigned int
+#else
+#define WebNSUInteger NSUInteger
+#endif
+
/*!
@protocol _WebDocumentTextSizing
@discussion Optional protocol for making text larger and smaller.
- (NSDictionary *)elementAtPoint:(NSPoint)point allowShadowContent:(BOOL)allow;
@end
+@protocol WebMultipleTextMatches <NSObject>
+- (void)setMarkedTextMatchesAreHighlighted:(BOOL)newValue;
+- (BOOL)markedTextMatchesAreHighlighted;
+- (WebNSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(WebNSUInteger)limit;
+- (void)unmarkAllTextMatches;
+- (NSArray *)rectsForTextMatches;
+@end
+
+
/* Used to save and restore state in the view, typically when going back/forward */
@protocol _WebDocumentViewState <NSObject>
- (NSPoint)scrollPoint;
- (void)setViewState:(id)statePList;
@end
-@interface WebHTMLView (WebDocumentInternalProtocols) <WebDocumentElement>
+@interface WebHTMLView (WebDocumentInternalProtocols) <WebDocumentElement, WebMultipleTextMatches>
@end
frame->setWindowHasFocus(frame == focusedFrame && windowOrSheetIsKey);
}
-- (unsigned)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(unsigned)limit
-{
- return [[self _bridge] markAllMatchesForText:string caseSensitive:caseFlag limit:limit];
-}
-
-- (void)setMarkedTextMatchesAreHighlighted:(BOOL)newValue
-{
- [[self _bridge] setMarkedTextMatchesAreHighlighted:newValue];
-}
-
-- (BOOL)markedTextMatchesAreHighlighted
-{
- return [[self _bridge] markedTextMatchesAreHighlighted];
-}
-
-- (void)unmarkAllTextMatches
-{
- return [[self _bridge] unmarkAllTextMatches];
-}
-
-- (NSArray *)rectsForTextMatches
-{
- return [[self _bridge] rectsForTextMatches];
-}
-
- (void)_writeSelectionToPasteboard:(NSPasteboard *)pasteboard
{
ASSERT([self _hasSelection]);
return nil;
}
+- (unsigned)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(unsigned)limit
+{
+ return [[self _bridge] markAllMatchesForText:string caseSensitive:caseFlag limit:limit];
+}
+
+- (void)setMarkedTextMatchesAreHighlighted:(BOOL)newValue
+{
+ [[self _bridge] setMarkedTextMatchesAreHighlighted:newValue];
+}
+
+- (BOOL)markedTextMatchesAreHighlighted
+{
+ return [[self _bridge] markedTextMatchesAreHighlighted];
+}
+
+- (void)unmarkAllTextMatches
+{
+ return [[self _bridge] unmarkAllTextMatches];
+}
+
+- (NSArray *)rectsForTextMatches
+{
+ return [[self _bridge] rectsForTextMatches];
+}
+
@end
// This is used by AppKit and is included here so that WebDataProtocolScheme is only defined once.
// SPI for DumpRenderTree
- (void)_updateActiveState;
-// Support for displaying multiple text matches.
-// These methods might end up moving into a protocol, so different document types can specify
-// whether or not they implement the protocol.
-// These methods are still in flux; don't rely on them yet.
-- (unsigned)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(unsigned)limit;
-- (void)unmarkAllTextMatches;
-- (void)setMarkedTextMatchesAreHighlighted:(BOOL)newValue;
-- (BOOL)markedTextMatchesAreHighlighted;
-- (NSArray *)rectsForTextMatches;
@end
return [[[self mainFrame] _bridge] aeDescByEvaluatingJavaScriptFromString:script];
}
+- (BOOL)canMarkAllTextMatches
+{
+ WebFrame *frame = [self mainFrame];
+ do {
+ id <WebDocumentView> view = [[frame frameView] documentView];
+ if (view && ![view conformsToProtocol:@protocol(WebMultipleTextMatches)])
+ return NO;
+
+ frame = incrementFrame(frame, YES, NO);
+ } while (frame);
+
+ return YES;
+}
+
- (WebNSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(WebNSUInteger)limit
{
WebFrame *frame = [self mainFrame];
unsigned matchCount = 0;
do {
id <WebDocumentView> view = [[frame frameView] documentView];
- // FIXME: introduce a protocol, or otherwise make this work with other types
- if ([view isKindOfClass:[WebHTMLView class]]) {
- [(WebHTMLView *)view setMarkedTextMatchesAreHighlighted:highlight];
+ if ([view conformsToProtocol:@protocol(WebMultipleTextMatches)]) {
+ [(NSView <WebMultipleTextMatches>*)view setMarkedTextMatchesAreHighlighted:highlight];
ASSERT(limit == 0 || matchCount < limit);
- matchCount += [(WebHTMLView *)view markAllMatchesForText:string caseSensitive:caseFlag limit:limit == 0 ? 0 : limit - matchCount];
+ matchCount += [(NSView <WebMultipleTextMatches>*)view markAllMatchesForText:string caseSensitive:caseFlag limit:limit == 0 ? 0 : limit - matchCount];
// Stop looking if we've reached the limit. A limit of 0 means no limit.
if (limit > 0 && matchCount >= limit)
WebFrame *frame = [self mainFrame];
do {
id <WebDocumentView> view = [[frame frameView] documentView];
- // FIXME: introduce a protocol, or otherwise make this work with other types
- if ([view isKindOfClass:[WebHTMLView class]])
- [(WebHTMLView *)view unmarkAllTextMatches];
+ if ([view conformsToProtocol:@protocol(WebMultipleTextMatches)])
+ [(NSView <WebMultipleTextMatches>*)view unmarkAllTextMatches];
frame = incrementFrame(frame, YES, NO);
} while (frame);
WebFrame *frame = [self mainFrame];
do {
id <WebDocumentView> view = [[frame frameView] documentView];
- // FIXME: introduce a protocol, or otherwise make this work with other types
- if ([view isKindOfClass:[WebHTMLView class]]) {
- WebHTMLView *htmlView = (WebHTMLView *)view;
- NSRect htmlViewVisibleRect = [htmlView visibleRect];
- NSArray *originalRects = [htmlView rectsForTextMatches];
+ if ([view conformsToProtocol:@protocol(WebMultipleTextMatches)]) {
+ NSView <WebMultipleTextMatches> *documentView = (NSView <WebMultipleTextMatches> *)view;
+ NSRect documentViewVisibleRect = [documentView visibleRect];
+ NSArray *originalRects = [documentView rectsForTextMatches];
unsigned rectCount = [originalRects count];
unsigned rectIndex;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
for (rectIndex = 0; rectIndex < rectCount; ++rectIndex) {
NSRect r = [[originalRects objectAtIndex:rectIndex] rectValue];
- // Clip rect to HTMLView's visible rect so rect is confined to subframe
- r = NSIntersectionRect(r, htmlViewVisibleRect);
+ // Clip rect to document view's visible rect so rect is confined to subframe
+ r = NSIntersectionRect(r, documentViewVisibleRect);
if (NSIsEmptyRect(r))
continue;
// Convert rect to our coordinate system
- r = [htmlView convertRect:r toView:self];
+ r = [documentView convertRect:r toView:self];
[result addObject:[NSValue valueWithRect:r]];
if (rectIndex % 10 == 0) {
[pool drain];
// These methods might end up moving into a protocol, so different document types can specify
// whether or not they implement the protocol. For now we'll just deal with HTML.
// These methods are still in flux; don't rely on them yet.
+- (BOOL)canMarkAllTextMatches;
- (WebNSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(WebNSUInteger)limit;
- (void)unmarkAllTextMatches;
- (NSArray *)rectsForTextMatches;