diff options
Diffstat (limited to 'WebKit/mac')
-rw-r--r-- | WebKit/mac/ChangeLog | 166 | ||||
-rw-r--r-- | WebKit/mac/Configurations/Version.xcconfig | 2 | ||||
-rw-r--r-- | WebKit/mac/Configurations/WebKit.xcconfig | 3 | ||||
-rw-r--r-- | WebKit/mac/MigrateHeaders.make | 1 | ||||
-rw-r--r-- | WebKit/mac/WebCoreSupport/WebEditorClient.h | 4 | ||||
-rw-r--r-- | WebKit/mac/WebCoreSupport/WebEditorClient.mm | 71 | ||||
-rw-r--r-- | WebKit/mac/WebView/WebDocumentInternal.h | 9 | ||||
-rw-r--r-- | WebKit/mac/WebView/WebDynamicScrollBarsView.h | 6 | ||||
-rw-r--r-- | WebKit/mac/WebView/WebDynamicScrollBarsView.mm | 73 | ||||
-rw-r--r-- | WebKit/mac/WebView/WebFrame.mm | 7 | ||||
-rw-r--r-- | WebKit/mac/WebView/WebFrameView.mm | 4 | ||||
-rw-r--r-- | WebKit/mac/WebView/WebHTMLView.mm | 38 | ||||
-rw-r--r-- | WebKit/mac/WebView/WebPDFView.mm | 10 | ||||
-rw-r--r-- | WebKit/mac/WebView/WebRenderLayer.mm | 1 | ||||
-rw-r--r-- | WebKit/mac/WebView/WebView.mm | 82 | ||||
-rw-r--r-- | WebKit/mac/WebView/WebViewPrivate.h | 46 |
16 files changed, 427 insertions, 96 deletions
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog index 4acd7e5..76428a4 100644 --- a/WebKit/mac/ChangeLog +++ b/WebKit/mac/ChangeLog @@ -1,3 +1,169 @@ +2010-12-01 Jia Pu <jpu@apple.com> + + Reviewed by Darin Adler. + + Support multiple correction candidates panel for misspelled word on Mac OS X. + https://bugs.webkit.org/show_bug.cgi?id=50137 + <rdar://problem/8568059> + + This patch is for supporting multiple correction suggestion panel on Mac OS X. + The behavior and implementation is similar to that of reversion candiate panel. + + * WebCoreSupport/WebEditorClient.h: Adopted new signatures defined in base class. + + * WebCoreSupport/WebEditorClient.mm: Adopted new signatures defined in base class. + Added code to handle new multiple suggestion canidate panel type. + (WebEditorClient::showCorrectionPanel): + (WebEditorClient::getGuessesForWord): + +2010-12-01 David Hyatt <hyatt@apple.com> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=46645 + + Part 1 of making scrolling work with vertical text. This patch generalizes the scrollOriginX concept + recently added for horizontal RTL documents and applies it to writing modes as well. Now the + scrollOrigin is a point, since you can start off locked to the bottom or locked to the right. + + This patch also fixes numerous bugs with the scrollOrigin code using native Mac NSScrollViews and + makes them behave the same as the cross-platform code (allowing for cross-platform results to be + landed). + + * WebView/WebDynamicScrollBarsView.mm: + (-[WebDynamicScrollBarsView adjustForScrollOriginChange]): + (-[WebDynamicScrollBarsView updateScrollers]): + (-[WebDynamicScrollBarsView reflectScrolledClipView:]): + (-[WebDynamicScrollBarsView setScrollOrigin:updatePosition:]): + (-[WebDynamicScrollBarsView scrollOrigin]): + * WebView/WebFrameView.mm: + (-[WebFrameView _scrollToBeginningOfDocument]): + (-[WebFrameView _scrollToEndOfDocument]): + +2010-11-29 Dan Bernstein <mitz@apple.com> + + Reviewed by Darin Adler. + + WebKit Mac part of <rdar://problem/8650085> adding word-prefix search options to the text search API. + https://bugs.webkit.org/show_bug.cgi?id=50038 + Based on a patch from Darin Adler. + + * WebView/WebDocumentInternal.h: Removed -markAllMatchesForText:caseSensitive:limit: and + replaced -countMatchesForText:caseSensitive:limit:markMatches: with a WebFindOptions-based + method. Declared a WebDocumentOptionsSearching protocol with a new -findString:options: + method. Made WebHTMLView conform to the new protocol. + * WebView/WebHTMLView.mm: + (coreOptions): Added. Converts WebFindOptions to WebCore FindOptions. + (-[WebHTMLView searchFor:direction:caseSensitive:wrap:startInSelection:]): Changed to use + -findString:options:. + (-[WebHTMLView countMatchesForText:options:limit:markMatches:]): Changed to use WebFindOptions. + (-[WebHTMLView findString:options:]): Added. Calls through to WebCore::Editor::findString(). + * WebView/WebPDFView.mm: + (-[WebPDFView countMatchesForText:options:limit:markMatches:]): Changed to use WebFindOptions. + * WebView/WebView.mm: + (-[WebView markAllMatchesForText:caseSensitive:highlight:limit:]): Now calls through to + -countMatchesForText:options:highlight:limit:markMatches. + (-[WebView countMatchesForText:caseSensitive:highlight:limit:markMatches:]): Ditto. + (-[WebView searchFor:direction:caseSensitive:wrap:startInSelection:]): Now calls through to + -findString:options:. + (incrementFrame): Changed to use WebFindOptions. + (findString): Added this helper method that performs the search using the best supported + method for the document view. + (-[WebView findString:options:]): Changed -searchFor::::: into this. + (-[WebView canMarkAllTextMatches]): + (-[WebView countMatchesForText:options:highlight:limit:markMatches:]): Updated to use + WebFindOptions. + (-[WebView unmarkAllTextMatches]): Updated for change to incrementFrame. + (-[WebView rectsForTextMatches]): Ditto. + * WebView/WebViewPrivate.h: Added WebFindOptions, -findString:options:, and WebFindOptions version + of countMatchesForText:. + +2010-11-29 Jeremy Moskovich <jeremy@chromium.org> + + Reviewed by David Hyatt. + + Right-to-left pages should be scrollable to reveal left overflow. + https://bugs.webkit.org/show_bug.cgi?id=23556 + + Set and get the original x-axis scroll position and reset scroll position on HOME/END key press. + Modify WebFrameView to support setting the initial horizontal scroller's thumb position to the right for + pages with a left overflow. + + * WebView/WebDynamicScrollBarsView.h: + * WebView/WebDynamicScrollBarsView.mm: + (-[WebDynamicScrollBarsView inProgramaticScroll]): + (-[WebDynamicScrollBarsView refreshInitialScrollbarPosition]): + (-[WebDynamicScrollBarsView updateScrollers]): + (-[WebDynamicScrollBarsView reflectScrolledClipView:]): + (-[WebDynamicScrollBarsView setScrollOriginX:]): + (-[WebDynamicScrollBarsView scrollOriginX]): + * WebView/WebFrameView.mm: + (-[WebFrameView _scrollToBeginningOfDocument]): + (-[WebFrameView _scrollToEndOfDocument]): + * WebView/WebHTMLView.mm: + (-[WebHTMLView _frameOrBoundsChanged]): + +2010-11-22 Ryosuke Niwa <rniwa@webkit.org> + + Reviewed by Tony Chang. + + SelectionController::typingStyle() should return EditingStyle* + https://bugs.webkit.org/show_bug.cgi?id=49813 + + Changed the return value of SelectionController::typingStyle() to EditingStyle*. + Also added SelectionController::copyTypingStyle() to copy the typing style + as an instance of CSSMutableStyleDeclaration. + + No tests are added since this is no behavioral change. + + * WebView/WebFrame.mm: + (-[WebFrame _typingStyle]): Calls SelectionController::copyTypingStyle() + +2010-11-19 Michael Saboff <msaboff@apple.com> + + Reviewed by Sam Weinig + + Remove DOMSVGAnimatedPathData.h from all: target to fix build. + + * MigrateHeaders.make: + +2010-11-19 Nikolas Zimmermann <nzimmermann@rim.com> + + Reviewed by Dirk Schulze. + + Convert SVGPathSeg/SVGPathSegList to the new SVGPropertyTearOff concept + https://bugs.webkit.org/show_bug.cgi?id=49580 + + * WebView/WebRenderLayer.mm: Add missing StyledElement.h include. + +2010-11-18 Mark Rowe <mrowe@apple.com> + + Rubber-stamped by Adam Roben. + + <rdar://problem/8602509&8602717&8602724> Enable compaction support. + + * Configurations/WebKit.xcconfig: + +2010-11-18 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r72288. + http://trac.webkit.org/changeset/72288 + https://bugs.webkit.org/show_bug.cgi?id=49730 + + 'krit attempted to do that, but revert got stuck' (Requested + by antonm on #webkit). + + * WebView/WebRenderLayer.mm: + +2010-11-17 Nikolas Zimmermann <nzimmermann@rim.com> + + Reviewed by Dirk Schulze. + + Convert SVGPathSeg/SVGPathSegList to the new SVGPropertyTearOff concept + https://bugs.webkit.org/show_bug.cgi?id=49580 + + * WebView/WebRenderLayer.mm: Add missing StyledElement.h include. + 2010-11-16 Stephanie Lewis <slewis@apple.com> Reviewed by Geoff Garen. diff --git a/WebKit/mac/Configurations/Version.xcconfig b/WebKit/mac/Configurations/Version.xcconfig index e0ce9cb..b60f899 100644 --- a/WebKit/mac/Configurations/Version.xcconfig +++ b/WebKit/mac/Configurations/Version.xcconfig @@ -22,7 +22,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. MAJOR_VERSION = 534; -MINOR_VERSION = 13; +MINOR_VERSION = 14; TINY_VERSION = 0; FULL_VERSION = $(MAJOR_VERSION).$(MINOR_VERSION); diff --git a/WebKit/mac/Configurations/WebKit.xcconfig b/WebKit/mac/Configurations/WebKit.xcconfig index 6b8ae6f..594b3a7 100644 --- a/WebKit/mac/Configurations/WebKit.xcconfig +++ b/WebKit/mac/Configurations/WebKit.xcconfig @@ -60,7 +60,8 @@ UMBRELLA_FRAMEWORKS_DIR = $(PRODUCTION_FRAMEWORKS_DIR)/WebKit.framework/Versions OTHER_LDFLAGS = $(OTHER_LDFLAGS_$(REAL_PLATFORM_NAME)); OTHER_LDFLAGS_iphoneos = -lobjc -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework Foundation -framework GraphicsServices -framework ImageIO -framework WebCore; OTHER_LDFLAGS_iphonesimulator = $(OTHER_LDFLAGS_iphoneos); -OTHER_LDFLAGS_macosx = -sub_umbrella WebCore $(OTHER_LDFLAGS); +OTHER_LDFLAGS_macosx = -sub_umbrella WebCore $(OTHER_LDFLAGS) $(OTHER_LDFLAGS_macosx_$(TARGET_MAC_OS_X_VERSION_MAJOR)); +OTHER_LDFLAGS_macosx_1070 = -Xlinker -objc_gc_compaction; PRODUCTION_FRAMEWORKS_DIR = $(PRODUCTION_FRAMEWORKS_DIR_$(REAL_PLATFORM_NAME)); PRODUCTION_FRAMEWORKS_DIR_iphoneos = $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks; diff --git a/WebKit/mac/MigrateHeaders.make b/WebKit/mac/MigrateHeaders.make index d674d4d..7b09b05 100644 --- a/WebKit/mac/MigrateHeaders.make +++ b/WebKit/mac/MigrateHeaders.make @@ -221,7 +221,6 @@ all : \ $(INTERNAL_HEADERS_DIR)/DOMSVGAnimatedNumberInternal.h \ $(PRIVATE_HEADERS_DIR)/DOMSVGAnimatedNumberList.h \ $(INTERNAL_HEADERS_DIR)/DOMSVGAnimatedNumberListInternal.h \ - $(PRIVATE_HEADERS_DIR)/DOMSVGAnimatedPathData.h \ $(PRIVATE_HEADERS_DIR)/DOMSVGAnimatedPreserveAspectRatio.h \ $(INTERNAL_HEADERS_DIR)/DOMSVGAnimatedPreserveAspectRatioInternal.h \ $(PRIVATE_HEADERS_DIR)/DOMSVGAnimatedRect.h \ diff --git a/WebKit/mac/WebCoreSupport/WebEditorClient.h b/WebKit/mac/WebCoreSupport/WebEditorClient.h index 23cf312..a7ffe3a 100644 --- a/WebKit/mac/WebCoreSupport/WebEditorClient.h +++ b/WebKit/mac/WebCoreSupport/WebEditorClient.h @@ -129,11 +129,11 @@ public: virtual void updateSpellingUIWithMisspelledWord(const WTF::String&); virtual void showSpellingUI(bool show); virtual bool spellingUIIsShowing(); - virtual void getGuessesForWord(const WTF::String&, WTF::Vector<WTF::String>& guesses); + virtual void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses); virtual void willSetInputMethodState(); virtual void setInputMethodState(bool enabled); #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) - virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const WTF::String& replacedString, const WTF::String& replacementString, WebCore::Editor*); + virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const WTF::String& replacedString, const WTF::String& replacementString, const WTF::Vector<WTF::String>& alternativeReplacementStrings, WebCore::Editor*); virtual void dismissCorrectionPanel(WebCore::CorrectionWasRejectedOrNot); virtual bool isShowingCorrectionPanel(); #endif diff --git a/WebKit/mac/WebCoreSupport/WebEditorClient.mm b/WebKit/mac/WebCoreSupport/WebEditorClient.mm index 9efa766..0376122 100644 --- a/WebKit/mac/WebCoreSupport/WebEditorClient.mm +++ b/WebKit/mac/WebCoreSupport/WebEditorClient.mm @@ -77,6 +77,22 @@ using namespace WTF; using namespace HTMLNames; +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +static inline NSCorrectionBubbleType correctionBubbleType(CorrectionPanelInfo::PanelType panelType) +{ + switch (panelType) { + case CorrectionPanelInfo::PanelTypeCorrection: + return NSCorrectionBubbleTypeCorrection; + case CorrectionPanelInfo::PanelTypeReversion: + return NSCorrectionBubbleTypeReversion; + case CorrectionPanelInfo::PanelTypeSpellingSuggestions: + return NSCorrectionBubbleTypeGuesses; + } + ASSERT_NOT_REACHED(); + return NSCorrectionBubbleTypeCorrection; +} +#endif + @interface NSAttributedString (WebNSAttributedStringDetails) - (id)_initWithDOMRange:(DOMRange*)range; - (DOMDocumentFragment*)_documentFromRange:(NSRange)range document:(DOMDocument*)document documentAttributes:(NSDictionary *)dict subresources:(NSArray **)subresources; @@ -856,7 +872,7 @@ void WebEditorClient::updateSpellingUIWithGrammarString(const String& badGrammar } #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) -void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType panelType, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, Editor* editor) { +void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType panelType, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings, Editor* editor) { dismissCorrectionPanel(WebCore::CorrectionWasNotRejected); NSRect boundingBoxAsNSRect = boundingBoxOfReplacedString; @@ -868,14 +884,34 @@ void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelTyp NSString *replacementStringAsNSString = replacementString; m_correctionPanelIsShown = YES; - NSCorrectionBubbleType bubbleType = panelType == WebCore::CorrectionPanelInfo::PanelTypeCorrection ? NSCorrectionBubbleTypeCorrection : NSCorrectionBubbleTypeReversion; - [[NSSpellChecker sharedSpellChecker] showCorrectionBubbleOfType:bubbleType primaryString:replacementStringAsNSString alternativeStrings:nil forStringInRect:boundingBoxAsNSRect view:m_webView completionHandler:^(NSString *acceptedString) { - if (!acceptedString && bubbleType == NSCorrectionBubbleTypeCorrection) { - [[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseRejected toCorrection:replacementStringAsNSString forWord:replacedStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]]; - editor->handleRejectedCorrection(); - } else if (acceptedString && bubbleType == NSCorrectionBubbleTypeReversion) { - [[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseReverted toCorrection:replacedStringAsNSString forWord:replacementStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]]; - editor->handleRejectedCorrection(); + NSCorrectionBubbleType bubbleType = correctionBubbleType(panelType); + NSMutableArray *alternativeStrings = nil; + if (!alternativeReplacementStrings.isEmpty()) { + size_t size = alternativeReplacementStrings.size(); + alternativeStrings = [NSMutableArray arrayWithCapacity:size]; + for (size_t i = 0; i < size; ++i) + [alternativeStrings addObject:(NSString*)alternativeReplacementStrings[i]]; + } + + [[NSSpellChecker sharedSpellChecker] showCorrectionBubbleOfType:bubbleType primaryString:replacementStringAsNSString alternativeStrings:alternativeStrings forStringInRect:boundingBoxAsNSRect view:m_webView completionHandler:^(NSString *acceptedString) { + switch (bubbleType) { + case NSCorrectionBubbleTypeCorrection: + if (!acceptedString) { + [[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseRejected toCorrection:replacementStringAsNSString forWord:replacedStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]]; + editor->handleCorrectionPanelResult(String()); + } + break; + case NSCorrectionBubbleTypeReversion: + if (acceptedString) { + [[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseReverted toCorrection:replacedStringAsNSString forWord:replacementStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]]; + editor->handleCorrectionPanelResult(String()); + } + break; + case NSCorrectionBubbleTypeGuesses: + if (acceptedString) + [[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseAccepted toCorrection:acceptedString forWord:replacedStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]]; + editor->handleCorrectionPanelResult(String(acceptedString)); + break; } }]; } @@ -916,11 +952,22 @@ bool WebEditorClient::spellingUIIsShowing() return [[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible]; } -void WebEditorClient::getGuessesForWord(const String& word, WTF::Vector<String>& guesses) -{ +void WebEditorClient::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses) { + guesses.clear(); +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) + NSString* language = nil; + NSOrthography* orthography = nil; + NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker]; + if (context.length()) { + [checker checkString:context range:NSMakeRange(0, context.length()) types:NSTextCheckingTypeOrthography options:0 inSpellDocumentWithTag:spellCheckerDocumentTag() orthography:&orthography wordCount:0]; + language = [checker languageForWordRange:NSMakeRange(0, context.length()) inString:context orthography:orthography]; + } + NSArray* stringsArray = [checker guessesForWordRange:NSMakeRange(0, word.length()) inString:word language:language inSpellDocumentWithTag:spellCheckerDocumentTag()]; +#else NSArray* stringsArray = [[NSSpellChecker sharedSpellChecker] guessesForWord:word]; +#endif unsigned count = [stringsArray count]; - guesses.clear(); + if (count > 0) { NSEnumerator* enumerator = [stringsArray objectEnumerator]; NSString* string; 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) |