summaryrefslogtreecommitdiffstats
path: root/WebKit/mac/WebView
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/mac/WebView')
-rw-r--r--WebKit/mac/WebView/WebDocumentInternal.h9
-rw-r--r--WebKit/mac/WebView/WebDynamicScrollBarsView.h6
-rw-r--r--WebKit/mac/WebView/WebDynamicScrollBarsView.mm73
-rw-r--r--WebKit/mac/WebView/WebFrame.mm7
-rw-r--r--WebKit/mac/WebView/WebFrameView.mm4
-rw-r--r--WebKit/mac/WebView/WebHTMLView.mm38
-rw-r--r--WebKit/mac/WebView/WebPDFView.mm10
-rw-r--r--WebKit/mac/WebView/WebRenderLayer.mm1
-rw-r--r--WebKit/mac/WebView/WebView.mm82
-rw-r--r--WebKit/mac/WebView/WebViewPrivate.h46
10 files changed, 197 insertions, 79 deletions
diff --git a/WebKit/mac/WebView/WebDocumentInternal.h b/WebKit/mac/WebView/WebDocumentInternal.h
index 0f63d75..0b86ba8 100644
--- a/WebKit/mac/WebView/WebDocumentInternal.h
+++ b/WebKit/mac/WebView/WebDocumentInternal.h
@@ -28,6 +28,7 @@
#import <WebKit/WebDocumentPrivate.h>
#import <WebKit/WebHTMLView.h>
+#import <WebKit/WebViewPrivate.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
#define WebNSUInteger unsigned int
@@ -61,12 +62,14 @@
@protocol WebMultipleTextMatches <NSObject>
- (void)setMarkedTextMatchesAreHighlighted:(BOOL)newValue;
- (BOOL)markedTextMatchesAreHighlighted;
-- (WebNSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(WebNSUInteger)limit;
-- (WebNSUInteger)countMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(WebNSUInteger)limit markMatches:(BOOL)markMatches;
+- (WebNSUInteger)countMatchesForText:(NSString *)string options:(WebFindOptions)options limit:(WebNSUInteger)limit markMatches:(BOOL)markMatches;
- (void)unmarkAllTextMatches;
- (NSArray *)rectsForTextMatches;
@end
+@protocol WebDocumentOptionsSearching <NSObject>
+- (BOOL)findString:(NSString *)string options:(WebFindOptions)options;
+@end
/* Used to save and restore state in the view, typically when going back/forward */
@protocol _WebDocumentViewState <NSObject>
@@ -76,7 +79,7 @@
- (void)setViewState:(id)statePList;
@end
-@interface WebHTMLView (WebDocumentInternalProtocols) <WebDocumentElement, WebMultipleTextMatches>
+@interface WebHTMLView (WebDocumentInternalProtocols) <WebDocumentElement, WebMultipleTextMatches, WebDocumentOptionsSearching>
@end
#undef WebNSUInteger
diff --git a/WebKit/mac/WebView/WebDynamicScrollBarsView.h b/WebKit/mac/WebView/WebDynamicScrollBarsView.h
index c289a04..b89462d 100644
--- a/WebKit/mac/WebView/WebDynamicScrollBarsView.h
+++ b/WebKit/mac/WebView/WebDynamicScrollBarsView.h
@@ -58,4 +58,10 @@ struct WebDynamicScrollBarsViewPrivate;
// visible is that they have been suppressed by setAlwaysHideHorizontal/VerticalScroller:.
- (BOOL)horizontalScrollingAllowed;
- (BOOL)verticalScrollingAllowed;
+
+// Returns YES if we're currently in the middle of programmatically moving the
+// scrollbar.
+// NOTE: As opposed to other places in the code, programmatically moving the
+// scrollers from inside this class should not fire JS events.
+- (BOOL)inProgramaticScroll;
@end
diff --git a/WebKit/mac/WebView/WebDynamicScrollBarsView.mm b/WebKit/mac/WebView/WebDynamicScrollBarsView.mm
index 74439dd..1c6980f 100644
--- a/WebKit/mac/WebView/WebDynamicScrollBarsView.mm
+++ b/WebKit/mac/WebView/WebDynamicScrollBarsView.mm
@@ -62,6 +62,17 @@ struct WebDynamicScrollBarsViewPrivate {
bool alwaysHideVerticalScroller;
bool horizontalScrollingAllowedButScrollerHidden;
bool verticalScrollingAllowedButScrollerHidden;
+
+ // scrollOrigin is set for various combinations of writing mode and direction.
+ // See the comment next to the corresponding member in ScrollView.h.
+ NSPoint scrollOrigin;
+
+ // Flag to indicate that the scrollbar thumb's initial position needs to
+ // be manually set.
+ bool scrollOriginChanged;
+ NSPoint scrollPositionExcludingOrigin;
+
+ bool inProgrammaticScroll;
};
@implementation WebDynamicScrollBarsView
@@ -149,6 +160,11 @@ struct WebDynamicScrollBarsViewPrivate {
return _private->verticalScrollingAllowedButScrollerHidden || [self hasVerticalScroller];
}
+- (BOOL)inProgramaticScroll
+{
+ return _private->inProgrammaticScroll;
+}
+
@end
@implementation WebDynamicScrollBarsView (WebInternal)
@@ -201,6 +217,24 @@ struct WebDynamicScrollBarsViewPrivate {
#endif
}
+- (void)adjustForScrollOriginChange
+{
+ if (!_private->scrollOriginChanged)
+ return;
+
+ _private->scrollOriginChanged = false;
+
+ NSView *documentView = [self documentView];
+ NSRect documentRect = [documentView bounds];
+
+ // The call to [NSView scrollPoint:] fires off notification the handler for which needs to know that
+ // we're setting the initial scroll position so it doesn't interpret this as a user action and
+ // fire off a JS event.
+ _private->inProgrammaticScroll = true;
+ [documentView scrollPoint:NSMakePoint(_private->scrollPositionExcludingOrigin.x + documentRect.origin.x, _private->scrollPositionExcludingOrigin.y + documentRect.origin.y)];
+ _private->inProgrammaticScroll = false;
+}
+
static const unsigned cMaxUpdateScrollbarsPass = 2;
- (void)updateScrollers
@@ -304,6 +338,10 @@ static const unsigned cMaxUpdateScrollbarsPass = 2;
[self setHasHorizontalScroller:newHasHorizontalScroller];
_private->inUpdateScrollers = NO;
needsLayout = YES;
+ NSView *documentView = [self documentView];
+ NSRect documentRect = [documentView bounds];
+ if (documentRect.origin.y < 0 && !newHasHorizontalScroller)
+ [documentView setBoundsOrigin:NSMakePoint(documentRect.origin.x, documentRect.origin.y + 15)];
}
if (hasVerticalScroller != newHasVerticalScroller) {
@@ -311,6 +349,10 @@ static const unsigned cMaxUpdateScrollbarsPass = 2;
[self setHasVerticalScroller:newHasVerticalScroller];
_private->inUpdateScrollers = NO;
needsLayout = YES;
+ NSView *documentView = [self documentView];
+ NSRect documentRect = [documentView bounds];
+ if (documentRect.origin.x < 0 && !newHasVerticalScroller)
+ [documentView setBoundsOrigin:NSMakePoint(documentRect.origin.x + 15, documentRect.origin.y)];
}
if (needsLayout && _private->inUpdateScrollersLayoutPass < cMaxUpdateScrollbarsPass &&
@@ -364,6 +406,11 @@ static const unsigned cMaxUpdateScrollbarsPass = 2;
}
#endif
+ // The call to [NSView reflectScrolledClipView] sets the scrollbar thumb
+ // position to 0 (the left) when the view is initially displayed.
+ // This call updates the initial position correctly.
+ [self adjustForScrollOriginChange];
+
#if USE(ACCELERATED_COMPOSITING) && defined(BUILDING_ON_LEOPARD)
NSView *documentView = [self documentView];
if ([documentView isKindOfClass:[WebHTMLView class]]) {
@@ -525,4 +572,30 @@ static const unsigned cMaxUpdateScrollbarsPass = 2;
return [super accessibilityIsIgnored];
}
+- (void)setScrollOrigin:(NSPoint)scrollOrigin updatePosition:(BOOL)updatePosition
+{
+ // The cross-platform ScrollView call already checked to see if the old/new scroll origins were the same or not
+ // so we don't have to check for equivalence here.
+ _private->scrollOrigin = scrollOrigin;
+ id docView = [self documentView];
+ NSPoint docOrigin = [docView bounds].origin;
+
+ NSRect visibleRect = [self documentVisibleRect];
+
+ [docView setBoundsOrigin:NSMakePoint(-scrollOrigin.x, -scrollOrigin.y)];
+
+ _private->scrollOriginChanged = true;
+
+ // Maintain our original position in the presence of the new scroll origin.
+ _private->scrollPositionExcludingOrigin = NSMakePoint(visibleRect.origin.x + scrollOrigin.x, visibleRect.origin.y + scrollOrigin.y);
+
+ if (updatePosition) // Otherwise we'll just let the snap happen when we update for the resize.
+ [self adjustForScrollOriginChange];
+}
+
+- (NSPoint)scrollOrigin
+{
+ return _private->scrollOrigin;
+}
+
@end
diff --git a/WebKit/mac/WebView/WebFrame.mm b/WebKit/mac/WebView/WebFrame.mm
index fb6d69c..d1d4953 100644
--- a/WebKit/mac/WebView/WebFrame.mm
+++ b/WebKit/mac/WebView/WebFrame.mm
@@ -901,9 +901,12 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
- (DOMCSSStyleDeclaration *)_typingStyle
{
- if (!_private->coreFrame || !_private->coreFrame->selection()->typingStyle())
+ if (!_private->coreFrame)
+ return nil;
+ RefPtr<CSSMutableStyleDeclaration> typingStyle = _private->coreFrame->selection()->copyTypingStyle();
+ if (!typingStyle)
return nil;
- return kit(_private->coreFrame->selection()->typingStyle()->copy().get());
+ return kit(typingStyle.get());
}
- (void)_setTypingStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(EditAction)undoAction
diff --git a/WebKit/mac/WebView/WebFrameView.mm b/WebKit/mac/WebView/WebFrameView.mm
index 0db12c0..20905d0 100644
--- a/WebKit/mac/WebView/WebFrameView.mm
+++ b/WebKit/mac/WebView/WebFrameView.mm
@@ -536,6 +536,8 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
if (![self _isScrollable])
return NO;
NSPoint point = [[[self _scrollView] documentView] frame].origin;
+ point.x += [[self _scrollView] scrollOrigin].x;
+ point.y += [[self _scrollView] scrollOrigin].y;
return [[self _contentView] _scrollTo:&point animate:YES];
}
@@ -547,6 +549,8 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
return NO;
NSRect frame = [[[self _scrollView] documentView] frame];
NSPoint point = NSMakePoint(frame.origin.x, NSMaxY(frame));
+ point.x += [[self _scrollView] scrollOrigin].x;
+ point.y += [[self _scrollView] scrollOrigin].y;
return [[self _contentView] _scrollTo:&point animate:YES];
}
diff --git a/WebKit/mac/WebView/WebHTMLView.mm b/WebKit/mac/WebView/WebHTMLView.mm
index ec2473f..db78c37 100644
--- a/WebKit/mac/WebView/WebHTMLView.mm
+++ b/WebKit/mac/WebView/WebHTMLView.mm
@@ -525,6 +525,16 @@ static NSCellStateValue kit(TriState state)
return NSOffState;
}
+static FindOptions coreOptions(WebFindOptions options)
+{
+ return (options & WebFindOptionsCaseInsensitive ? CaseInsensitive : 0)
+ | (options & WebFindOptionsAtWordStarts ? AtWordStarts : 0)
+ | (options & WebFindOptionsTreatMedialCapitalAsWordStart ? TreatMedialCapitalAsWordStart : 0)
+ | (options & WebFindOptionsBackwards ? Backwards : 0)
+ | (options & WebFindOptionsWrapAround ? WrapAround : 0)
+ | (options & WebFindOptionsStartInSelection ? StartInSelection : 0);
+}
+
@implementation WebHTMLViewPrivate
+ (void)initialize
@@ -1198,8 +1208,11 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info)
- (void)_frameOrBoundsChanged
{
+ WebView *webView = [self _webView];
+ WebDynamicScrollBarsView *scrollView = [[[webView mainFrame] frameView] _scrollView];
+
NSPoint origin = [[self superview] bounds].origin;
- if (!NSEqualPoints(_private->lastScrollPosition, origin)) {
+ if (!NSEqualPoints(_private->lastScrollPosition, origin) && ![scrollView inProgramaticScroll]) {
if (Frame* coreFrame = core([self _frame])) {
if (FrameView* coreView = coreFrame->view()) {
#ifndef BUILDING_ON_TIGER
@@ -1214,7 +1227,6 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info)
[_private->completionController endRevertingChange:NO moveLeft:NO];
- WebView *webView = [self _webView];
[[webView _UIDelegateForwarder] webView:webView didScrollDocumentInFrameView:[self _frameView]];
}
_private->lastScrollPosition = origin;
@@ -6196,10 +6208,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag startInSelection:(BOOL)startInSelection
{
- if (![string length])
- return NO;
- Frame* coreFrame = core([self _frame]);
- return coreFrame && coreFrame->editor()->findString(string, forward, caseFlag, wrapFlag, startInSelection);
+ return [self findString:string options:(forward ? 0 : WebFindOptionsBackwards) | (caseFlag ? 0 : WebFindOptionsCaseInsensitive) | (startInSelection ? WebFindOptionsStartInSelection : 0)];
}
@end
@@ -6219,17 +6228,12 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
return [[[WebElementDictionary alloc] initWithHitTestResult:coreFrame->eventHandler()->hitTestResultAtPoint(IntPoint(point), allow)] autorelease];
}
-- (NSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(NSUInteger)limit
-{
- return [self countMatchesForText:string caseSensitive:caseFlag limit:limit markMatches:YES];
-}
-
-- (NSUInteger)countMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(NSUInteger)limit markMatches:(BOOL)markMatches
+- (NSUInteger)countMatchesForText:(NSString *)string options:(WebFindOptions)options limit:(NSUInteger)limit markMatches:(BOOL)markMatches
{
Frame* coreFrame = core([self _frame]);
if (!coreFrame)
return 0;
- return coreFrame->editor()->countMatchesForText(string, caseFlag, limit, markMatches);
+ return coreFrame->editor()->countMatchesForText(string, coreOptions(options), limit, markMatches);
}
- (void)setMarkedTextMatchesAreHighlighted:(BOOL)newValue
@@ -6274,6 +6278,14 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
return result;
}
+- (BOOL)findString:(NSString *)string options:(WebFindOptions)options
+{
+ if (![string length])
+ return NO;
+ Frame* coreFrame = core([self _frame]);
+ return coreFrame && coreFrame->editor()->findString(string, coreOptions(options));
+}
+
@end
// This is used by AppKit and is included here so that WebDataProtocolScheme is only defined once.
diff --git a/WebKit/mac/WebView/WebPDFView.mm b/WebKit/mac/WebView/WebPDFView.mm
index 70fceb6..35d44f7 100644
--- a/WebKit/mac/WebView/WebPDFView.mm
+++ b/WebKit/mac/WebView/WebPDFView.mm
@@ -626,19 +626,13 @@ static BOOL _PDFSelectionsAreEqual(PDFSelection *selectionA, PDFSelection *selec
return NO;
}
-- (NSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(NSUInteger)limit
-{
- return [self countMatchesForText:string caseSensitive:caseFlag limit:limit markMatches:YES];
-}
-
-- (NSUInteger)countMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(NSUInteger)limit markMatches:(BOOL)markMatches
+- (NSUInteger)countMatchesForText:(NSString *)string options:(WebFindOptions)options limit:(NSUInteger)limit markMatches:(BOOL)markMatches
{
PDFSelection *previousMatch = nil;
- PDFSelection *nextMatch = nil;
NSMutableArray *matches = [[NSMutableArray alloc] initWithCapacity:limit];
for (;;) {
- nextMatch = [self _nextMatchFor:string direction:YES caseSensitive:caseFlag wrap:NO fromSelection:previousMatch startInSelection:NO];
+ PDFSelection *nextMatch = [self _nextMatchFor:string direction:YES caseSensitive:!(options & WebFindOptionsCaseInsensitive) wrap:NO fromSelection:previousMatch startInSelection:NO];
if (!nextMatch)
break;
diff --git a/WebKit/mac/WebView/WebRenderLayer.mm b/WebKit/mac/WebView/WebRenderLayer.mm
index edffac2..c282643 100644
--- a/WebKit/mac/WebView/WebRenderLayer.mm
+++ b/WebKit/mac/WebView/WebRenderLayer.mm
@@ -32,6 +32,7 @@
#import <WebCore/RenderLayer.h>
#import <WebCore/RenderLayerBacking.h>
#import <WebCore/RenderView.h>
+#import <WebCore/StyledElement.h>
using namespace WebCore;
diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm
index 0498554..c57bf38 100644
--- a/WebKit/mac/WebView/WebView.mm
+++ b/WebKit/mac/WebView/WebView.mm
@@ -2645,6 +2645,21 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
return coreFrame->pageScaleFactor();
}
+- (NSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(NSUInteger)limit
+{
+ return [self countMatchesForText:string options:(caseFlag ? 0 : WebFindOptionsCaseInsensitive) highlight:highlight limit:limit markMatches:YES];
+}
+
+- (NSUInteger)countMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(NSUInteger)limit markMatches:(BOOL)markMatches
+{
+ return [self countMatchesForText:string options:(caseFlag ? 0 : WebFindOptionsCaseInsensitive) highlight:highlight limit:limit markMatches:markMatches];
+}
+
+- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag startInSelection:(BOOL)startInSelection
+{
+ return [self findString:string options:((forward ? 0 : WebFindOptionsBackwards) | (caseFlag ? 0 : WebFindOptionsCaseInsensitive) | (wrapFlag ? WebFindOptionsWrapAround : 0) | (startInSelection ? WebFindOptionsStartInSelection : 0))];
+}
+
@end
@implementation _WebSafeForwarder
@@ -3824,12 +3839,12 @@ static bool needsWebViewInitThreadWorkaround()
[super setNextKeyView:view];
}
-static WebFrame *incrementFrame(WebFrame *frame, BOOL forward, BOOL wrapFlag)
+static WebFrame *incrementFrame(WebFrame *frame, WebFindOptions options = 0)
{
Frame* coreFrame = core(frame);
- return kit(forward
- ? coreFrame->tree()->traverseNextWithWrap(wrapFlag)
- : coreFrame->tree()->traversePreviousWithWrap(wrapFlag));
+ return kit((options & WebFindOptionsBackwards)
+ ? coreFrame->tree()->traversePreviousWithWrap(options & WebFindOptionsWrapAround)
+ : coreFrame->tree()->traverseNextWithWrap(options & WebFindOptionsWrapAround));
}
- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag
@@ -4255,7 +4270,16 @@ static WebFrame *incrementFrame(WebFrame *frame, BOOL forward, BOOL wrapFlag)
core(self)->removeSchedulePair(SchedulePair::create(runLoop, (CFStringRef)mode));
}
-- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag startInSelection:(BOOL)startInSelection
+static BOOL findString(NSView <WebDocumentSearching> *searchView, NSString *string, WebFindOptions options)
+{
+ if ([searchView conformsToProtocol:@protocol(WebDocumentOptionsSearching)])
+ return [(NSView <WebDocumentOptionsSearching> *)searchView findString:string options:options];
+ if ([searchView conformsToProtocol:@protocol(WebDocumentIncrementalSearching)])
+ return [(NSView <WebDocumentIncrementalSearching> *)searchView searchFor:string direction:!(options & WebFindOptionsBackwards) caseSensitive:!(options & WebFindOptionsCaseInsensitive) wrap:!!(options & WebFindOptionsWrapAround) startInSelection:!!(options & WebFindOptionsStartInSelection)];
+ return [searchView searchFor:string direction:!(options & WebFindOptionsBackwards) caseSensitive:!(options & WebFindOptionsCaseInsensitive) wrap:!!(options & WebFindOptionsWrapAround)];
+}
+
+- (BOOL)findString:(NSString *)string options:(WebFindOptions)options
{
if (_private->closed)
return NO;
@@ -4267,7 +4291,7 @@ static WebFrame *incrementFrame(WebFrame *frame, BOOL forward, BOOL wrapFlag)
NSView <WebDocumentSearching> *startSearchView = nil;
WebFrame *frame = startFrame;
do {
- WebFrame *nextFrame = incrementFrame(frame, forward, wrapFlag);
+ WebFrame *nextFrame = incrementFrame(frame, options);
BOOL onlyOneFrame = (frame == nextFrame);
ASSERT(!onlyOneFrame || frame == startFrame);
@@ -4279,18 +4303,13 @@ static WebFrame *incrementFrame(WebFrame *frame, BOOL forward, BOOL wrapFlag)
if (frame == startFrame)
startSearchView = searchView;
- BOOL foundString;
// In some cases we have to search some content twice; see comment later in this method.
- // We can avoid ever doing this in the common one-frame case by passing YES for wrapFlag
+ // We can avoid ever doing this in the common one-frame case by passing the wrap option through
// here, and then bailing out before we get to the code that would search again in the
// same content.
- BOOL wrapOnThisPass = wrapFlag && onlyOneFrame;
- if ([searchView conformsToProtocol:@protocol(WebDocumentIncrementalSearching)])
- foundString = [(NSView <WebDocumentIncrementalSearching> *)searchView searchFor:string direction:forward caseSensitive:caseFlag wrap:wrapOnThisPass startInSelection:startInSelection];
- else
- foundString = [searchView searchFor:string direction:forward caseSensitive:caseFlag wrap:wrapOnThisPass];
-
- if (foundString) {
+ WebFindOptions optionsForThisPass = onlyOneFrame ? options : (options & ~WebFindOptionsWrapAround);
+
+ if (findString(searchView, string, optionsForThisPass)) {
if (frame != startFrame)
[startFrame _clearSelection];
[[self window] makeFirstResponder:searchView];
@@ -4303,18 +4322,13 @@ static WebFrame *incrementFrame(WebFrame *frame, BOOL forward, BOOL wrapFlag)
frame = nextFrame;
} while (frame && frame != startFrame);
- // If there are multiple frames and wrapFlag is true and we've visited each one without finding a result, we still need to search in the
+ // If there are multiple frames and WebFindOptionsWrapAround is set and we've visited each one without finding a result, we still need to search in the
// first-searched frame up to the selection. However, the API doesn't provide a way to search only up to a particular point. The only
- // way to make sure the entire frame is searched is to pass YES for the wrapFlag. When there are no matches, this will search again
+ // way to make sure the entire frame is searched is to pass WebFindOptionsWrapAround. When there are no matches, this will search
// some content that we already searched on the first pass. In the worst case, we could search the entire contents of this frame twice.
// To fix this, we'd need to add a mechanism to specify a range in which to search.
- if (wrapFlag && startSearchView) {
- BOOL foundString;
- if ([startSearchView conformsToProtocol:@protocol(WebDocumentIncrementalSearching)])
- foundString = [(NSView <WebDocumentIncrementalSearching> *)startSearchView searchFor:string direction:forward caseSensitive:caseFlag wrap:YES startInSelection:startInSelection];
- else
- foundString = [startSearchView searchFor:string direction:forward caseSensitive:caseFlag wrap:YES];
- if (foundString) {
+ if ((options & WebFindOptionsWrapAround) && startSearchView) {
+ if (findString(startSearchView, string, options)) {
[[self window] makeFirstResponder:startSearchView];
return YES;
}
@@ -4496,21 +4510,13 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValue jsValu
if (view && ![view conformsToProtocol:@protocol(WebMultipleTextMatches)])
return NO;
- frame = incrementFrame(frame, YES, NO);
+ frame = incrementFrame(frame);
} while (frame);
return YES;
}
-- (NSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(NSUInteger)limit
-{
- if (_private->closed)
- return 0;
-
- return [self countMatchesForText:string caseSensitive:caseFlag highlight:highlight limit:limit markMatches:YES];
-}
-
-- (NSUInteger)countMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(NSUInteger)limit markMatches:(BOOL)markMatches
+- (NSUInteger)countMatchesForText:(NSString *)string options:(WebFindOptions)options highlight:(BOOL)highlight limit:(NSUInteger)limit markMatches:(BOOL)markMatches
{
if (_private->closed)
return 0;
@@ -4524,14 +4530,14 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValue jsValu
[(NSView <WebMultipleTextMatches>*)view setMarkedTextMatchesAreHighlighted:highlight];
ASSERT(limit == 0 || matchCount < limit);
- matchCount += [(NSView <WebMultipleTextMatches>*)view countMatchesForText:string caseSensitive:caseFlag limit:limit == 0 ? 0 : limit - matchCount markMatches:markMatches];
+ matchCount += [(NSView <WebMultipleTextMatches>*)view countMatchesForText:string 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)
break;
}
- frame = incrementFrame(frame, YES, NO);
+ frame = incrementFrame(frame);
} while (frame);
return matchCount;
@@ -4548,7 +4554,7 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValue jsValu
if ([view conformsToProtocol:@protocol(WebMultipleTextMatches)])
[(NSView <WebMultipleTextMatches>*)view unmarkAllTextMatches];
- frame = incrementFrame(frame, YES, NO);
+ frame = incrementFrame(frame);
} while (frame);
}
@@ -4586,7 +4592,7 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValue jsValu
[pool drain];
}
- frame = incrementFrame(frame, YES, NO);
+ frame = incrementFrame(frame);
} while (frame);
return result;
diff --git a/WebKit/mac/WebView/WebViewPrivate.h b/WebKit/mac/WebView/WebViewPrivate.h
index af594d9..5b995e9 100644
--- a/WebKit/mac/WebView/WebViewPrivate.h
+++ b/WebKit/mac/WebView/WebViewPrivate.h
@@ -70,7 +70,7 @@ extern NSString *WebElementIsContentEditableKey; // NSNumber indicating whether
extern NSString *WebElementMediaURLKey; // NSURL of the media element
// other WebElementDictionary keys
-extern NSString *WebElementLinkIsLiveKey; // NSNumber of BOOL indictating whether the link is live or not
+extern NSString *WebElementLinkIsLiveKey; // NSNumber of BOOL indicating whether the link is live or not
extern NSString *WebElementIsInScrollBarKey;
// One of the subviews of the WebView entered compositing mode.
@@ -96,6 +96,16 @@ typedef enum {
WebInjectInTopFrameOnly
} WebUserContentInjectedFrames;
+enum {
+ WebFindOptionsCaseInsensitive = 1 << 0,
+ WebFindOptionsAtWordStarts = 1 << 1,
+ WebFindOptionsTreatMedialCapitalAsWordStart = 1 << 2,
+ WebFindOptionsBackwards = 1 << 3,
+ WebFindOptionsWrapAround = 1 << 4,
+ WebFindOptionsStartInSelection = 1 << 5
+};
+typedef NSUInteger WebFindOptions;
+
@interface WebController : NSTreeController {
IBOutlet WebView *webView;
}
@@ -114,18 +124,7 @@ typedef enum {
- (void)scheduleInRunLoop:(NSRunLoop *)runLoop forMode:(NSString *)mode;
- (void)unscheduleFromRunLoop:(NSRunLoop *)runLoop forMode:(NSString *)mode;
-/*!
-@method searchFor:direction:caseSensitive:wrap:startInSelection:
- @abstract Searches a document view for a string and highlights the string if it is found.
- Starts the search from the current selection. Will search across all frames.
- @param string The string to search for.
- @param forward YES to search forward, NO to seach backwards.
- @param caseFlag YES to for case-sensitive search, NO for case-insensitive search.
- @param wrapFlag YES to wrap around, NO to avoid wrapping.
- @param startInSelection YES to begin search in the selected text (useful for incremental searching), NO to begin search after the selected text.
- @result YES if found, NO if not found.
- */
-- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag startInSelection:(BOOL)startInSelection;
+- (BOOL)findString:(NSString *)string options:(WebFindOptions)options;
- (void)setMainFrameDocumentReady:(BOOL)mainFrameDocumentReady;
@@ -182,8 +181,7 @@ typedef enum {
// 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;
-- (WebNSUInteger)countMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(WebNSUInteger)limit markMatches:(BOOL)markMatches;
+- (WebNSUInteger)countMatchesForText:(NSString *)string options:(WebFindOptions)options highlight:(BOOL)highlight limit:(WebNSUInteger)limit markMatches:(BOOL)markMatches;
- (void)unmarkAllTextMatches;
- (NSArray *)rectsForTextMatches;
@@ -545,6 +543,24 @@ Could be worth adding to the API.
- (void)_scaleWebView:(float)scale atOrigin:(NSPoint)origin;
- (float)_viewScaleFactor;
+// Deprecated. Use the methods in pending public above instead.
+- (WebNSUInteger)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(WebNSUInteger)limit;
+- (WebNSUInteger)countMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(WebNSUInteger)limit markMatches:(BOOL)markMatches;
+
+/*!
+ @method searchFor:direction:caseSensitive:wrap:startInSelection:
+ @abstract Searches a document view for a string and highlights the string if it is found.
+ Starts the search from the current selection. Will search across all frames.
+ @param string The string to search for.
+ @param forward YES to search forward, NO to seach backwards.
+ @param caseFlag YES to for case-sensitive search, NO for case-insensitive search.
+ @param wrapFlag YES to wrap around, NO to avoid wrapping.
+ @param startInSelection YES to begin search in the selected text (useful for incremental searching), NO to begin search after the selected text.
+ @result YES if found, NO if not found.
+ */
+// Deprecated. Use findString.
+- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag startInSelection:(BOOL)startInSelection;
+
@end
@interface WebView (WebViewPrintingPrivate)