diff options
Diffstat (limited to 'WebKit/mac/WebView/WebView.mm')
-rw-r--r-- | WebKit/mac/WebView/WebView.mm | 94 |
1 files changed, 59 insertions, 35 deletions
diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm index 0498554..bd13ff0 100644 --- a/WebKit/mac/WebView/WebView.mm +++ b/WebKit/mac/WebView/WebView.mm @@ -1390,8 +1390,12 @@ static bool fastDocumentTeardownEnabled() // <https://bugs.webkit.org/show_bug.cgi?id=46334>. static bool isApplicationNeedingParserQuirks = !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_HTML5_PARSER) && (applicationIsAOLInstantMessenger() || applicationIsMicrosoftMyDay()); + + // Mail.app must continue to display HTML email that contains quirky markup. + static bool isAppleMail = applicationIsAppleMail(); return isApplicationNeedingParserQuirks + || isAppleMail #if ENABLE(DASHBOARD_SUPPORT) // Pre-HTML5 parser quirks are required to remain compatible with many // Dashboard widgets. See <rdar://problem/8175982>. @@ -1501,6 +1505,10 @@ static bool fastDocumentTeardownEnabled() #if ENABLE(FULLSCREEN_API) settings->setFullScreenEnabled([preferences fullScreenEnabled]); #endif +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + // Asynchronous spell checking API is available for 10.6 or later. + settings->setAsynchronousSpellCheckingEnabled([preferences asynchronousSpellCheckingEnabled]); +#endif settings->setMemoryInfoEnabled([preferences memoryInfoEnabled]); settings->setHyperlinkAuditingEnabled([preferences hyperlinkAuditingEnabled]); settings->setUsePreHTML5ParserQuirks([self _needsPreHTML5ParserQuirks]); @@ -2645,6 +2653,26 @@ 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))]; +} + ++ (void)_setLoadResourcesSerially:(BOOL)serialize +{ + resourceLoadScheduler()->setSerialLoadingEnabled(serialize); +} + @end @implementation _WebSafeForwarder @@ -3824,12 +3852,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 +4283,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 +4304,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 +4316,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 +4335,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 +4523,18 @@ 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 +- (NSUInteger)countMatchesForText:(NSString *)string options:(WebFindOptions)options highlight:(BOOL)highlight limit:(NSUInteger)limit markMatches:(BOOL)markMatches { - if (_private->closed) - return 0; - - return [self countMatchesForText:string caseSensitive:caseFlag highlight:highlight limit:limit markMatches:YES]; + return [self countMatchesForText:string inDOMRange:nil options:options highlight:highlight limit:limit markMatches:markMatches]; } -- (NSUInteger)countMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(NSUInteger)limit markMatches:(BOOL)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; @@ -4524,14 +4548,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 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) break; } - frame = incrementFrame(frame, YES, NO); + frame = incrementFrame(frame); } while (frame); return matchCount; @@ -4548,7 +4572,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 +4610,7 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValue jsValu [pool drain]; } - frame = incrementFrame(frame, YES, NO); + frame = incrementFrame(frame); } while (frame); return result; |