Commit aa6e9031 authored by thatcher's avatar thatcher
Browse files

Reviewed by Darin.

        Bug 9814: Move new WebView API that has been through API review to public headers
        http://bugzilla.opendarwin.org/show_bug.cgi?id=9814

        * WebView/WebView.h:
        * WebView/WebView.m:
        (-[WebView close]):
        (-[WebView setShouldCloseWithWindow:]):
        (-[WebView shouldCloseWithWindow]):
        (-[WebView selectedFrame]):
        (-[WebView setMainFrameURL:]):
        (-[WebView mainFrameURL]):
        (-[WebView isLoading]):
        (-[WebView mainFrameTitle]):
        (-[WebView mainFrameIcon]):
        (-[WebView mainFrameDocument]):
        (-[WebView setDrawsBackground:]):
        (-[WebView drawsBackground]):
        (-[WebView toggleSmartInsertDelete:]):
        (-[WebView toggleContinuousSpellChecking:]):
        (-[WebView canMakeTextStandardSize]):
        (-[WebView makeTextStandardSize:]):
        (-[WebView maintainsInactiveSelection]):
        * WebView/WebViewPrivate.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@15272 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent def2e8db
2006-07-09 Timothy Hatcher <timothy@apple.com>
Reviewed by Darin.
Bug 9814: Move new WebView API that has been through API review to public headers
http://bugzilla.opendarwin.org/show_bug.cgi?id=9814
* WebView/WebView.h:
* WebView/WebView.m:
(-[WebView close]):
(-[WebView setShouldCloseWithWindow:]):
(-[WebView shouldCloseWithWindow]):
(-[WebView selectedFrame]):
(-[WebView setMainFrameURL:]):
(-[WebView mainFrameURL]):
(-[WebView isLoading]):
(-[WebView mainFrameTitle]):
(-[WebView mainFrameIcon]):
(-[WebView mainFrameDocument]):
(-[WebView setDrawsBackground:]):
(-[WebView drawsBackground]):
(-[WebView toggleSmartInsertDelete:]):
(-[WebView toggleContinuousSpellChecking:]):
(-[WebView canMakeTextStandardSize]):
(-[WebView makeTextStandardSize:]):
(-[WebView maintainsInactiveSelection]):
* WebView/WebViewPrivate.h:
2006-07-09 Timothy Hatcher <timothy@apple.com>
Reviewed by Maciej.
......
......@@ -184,6 +184,32 @@ extern NSString *WebViewProgressFinishedNotification;
*/
- (id)initWithFrame:(NSRect)frame frameName:(NSString *)frameName groupName:(NSString *)groupName;
/*!
@method close
@abstract Cancels any pending load operations. Once the receiver is closed it will no longer
respond to new requests or fire any more delegate methods.
@discussion A garbage collected application is required to call close when the receiver is no longer needed.
The close method will be called automatically when the window or hostWindow closes and shouldCloseWithWindow returns YES.
A non-garbage collected application can still call close, providing a convenient way to prevent receiver
from doing any more loading and firing any future delegate methods.
*/
- (void)close;
/*!
@method setShouldCloseWithWindow:
@abstract Set whether the receiver closes when either it's window or hostWindow closes.
@param close YES if the receiver should close when either it's window or hostWindow closes, otherwise NO.
*/
- (void)setShouldCloseWithWindow:(BOOL)close;
/*!
@method shouldCloseWithWindow
@abstract Returns whether the receiver closes when either it's window or hostWindow closes.
@discussion Defaults to YES in garbage collected applications, otherwise NO to maintain backwards compatibility.
@result YES if the receiver closes when either it's window or hostWindow closes, otherwise NO.
*/
- (BOOL)shouldCloseWithWindow;
/*!
@method setUIDelegate:
@abstract Set the WebView's WebUIDelegate.
......@@ -263,6 +289,15 @@ extern NSString *WebViewProgressFinishedNotification;
*/
- (WebFrame *)mainFrame;
/*!
@method selectedFrame
@abstract Return the frame that has the active selection.
@discussion Returns the frame that contains the first responder, if any. Otherwise returns the
frame that contains a non-zero-length selection, if any. Returns nil if no frame meets these criteria.
@result The selected frame.
*/
- (WebFrame *)selectedFrame;
/*!
@method backForwardList
@result The backforward list for this webView.
......@@ -491,7 +526,6 @@ extern NSString *WebViewProgressFinishedNotification;
*/
- (NSString *)groupName;
/*!
@method estimatedProgress
@discussion An estimate of the percent complete for a document load. This
......@@ -504,6 +538,12 @@ extern NSString *WebViewProgressFinishedNotification;
*/
- (double)estimatedProgress;
/*!
@method isLoading
@discussion Returns YES if there are any pending loads.
*/
- (BOOL)isLoading;
/*!
@method elementAtPoint:
@param point A point in the coordinates of the WebView
......@@ -555,6 +595,50 @@ extern NSString *WebViewProgressFinishedNotification;
*/
- (void)removeDragCaret;
/*!
@method setDrawsBackground:
@param drawsBackround YES to cause the receiver to draw a default white background, NO otherwise.
@abstract Sets whether the receiver draws a default white background when the loaded page has no background specified.
*/
- (void)setDrawsBackground:(BOOL)drawsBackround;
/*!
@method drawsBackground
@result Returns YES if the receiver draws a default white background, NO otherwise.
*/
- (BOOL)drawsBackground;
/*!
@method setMainFrameURL:
@param URLString The URL to load in the mainFrame.
*/
- (void)setMainFrameURL:(NSString *)URLString;
/*!
@method mainFrameURL
@result Returns the main frame's current URL.
*/
- (NSString *)mainFrameURL;
/*!
@method mainFrameDocument
@result Returns the main frame's DOMDocument.
*/
- (DOMDocument *)mainFrameDocument;
/*!
@method mainFrameTitle
@result Returns the main frame's title if any, otherwise an empty string.
*/
- (NSString *)mainFrameTitle;
/*!
@method mainFrameIcon
@discussion The methods returns the site icon for the current page loaded in the mainFrame.
@result Returns the main frame's icon if any, otherwise nil.
*/
- (NSImage *)mainFrameIcon;
@end
......@@ -570,6 +654,10 @@ extern NSString *WebViewProgressFinishedNotification;
- (IBAction)makeTextLarger:(id)sender;
- (BOOL)canMakeTextSmaller;
- (IBAction)makeTextSmaller:(id)sender;
- (BOOL)canMakeTextStandardSize;
- (IBAction)makeTextStandardSize:(id)sender;
- (IBAction)toggleContinuousSpellChecking:(id)sender;
- (IBAction)toggleSmartInsertDelete:(id)sender;
@end
......@@ -590,6 +678,7 @@ extern NSString * const WebViewDidChangeSelectionNotification;
- (void)setSelectedDOMRange:(DOMRange *)range affinity:(NSSelectionAffinity)selectionAffinity;
- (DOMRange *)selectedDOMRange;
- (NSSelectionAffinity)selectionAffinity;
- (BOOL)maintainsInactiveSelection;
- (void)setEditable:(BOOL)flag;
- (BOOL)isEditable;
- (void)setTypingStyle:(DOMCSSStyleDeclaration *)style;
......@@ -642,6 +731,12 @@ extern NSString * const WebViewDidChangeSelectionNotification;
- (void)startSpeaking:(id)sender;
- (void)stopSpeaking:(id)sender;
- (void)moveToBeginningOfSentence:(id)sender;
- (void)moveToBeginningOfSentenceAndModifySelection:(id)sender;
- (void)moveToEndOfSentence:(id)sender;
- (void)moveToEndOfSentenceAndModifySelection:(id)sender;
- (void)selectSentence:(id)sender;
/*
The following methods are declared in NSResponder.h.
WebView overrides each method in this list, providing
......
......@@ -1874,6 +1874,21 @@ - (void)finalize
[super finalize];
}
- (void)close
{
[self _close];
}
- (void)setShouldCloseWithWindow:(BOOL)close
{
_private->shouldCloseWithWindow = close;
}
- (BOOL)shouldCloseWithWindow
{
return _private->shouldCloseWithWindow;
}
- (void)viewWillMoveToWindow:(NSWindow *)window
{
// Don't do anything if we aren't initialized. This happens
......@@ -1996,6 +2011,22 @@ - (WebFrame *)mainFrame
return [(WebFrameBridge *)[_private->_pageBridge mainFrame] webFrame];
}
- (WebFrame *)selectedFrame
{
// If the first responder is a view in our tree, we get the frame containing the first responder.
// This is faster than searching the frame hierarchy, and will give us a result even in the case
// where the focused frame doesn't actually contain a selection.
WebFrame *focusedFrame = [self _focusedFrame];
if (focusedFrame)
return focusedFrame;
// If the first responder is outside of our view tree, we search for a frame containing a selection.
// There should be at most only one of these.
return [[self mainFrame] _findFrameWithSelection];
return nil;
}
- (WebBackForwardList *)backForwardList
{
if (_private->useBackForwardList)
......@@ -2510,6 +2541,59 @@ - (void)removeDragCaret
[[[self mainFrame] _bridge] removeDragCaret];
}
- (void)setMainFrameURL:(NSString *)URLString
{
[[self mainFrame] loadRequest: [NSURLRequest requestWithURL: [NSURL _web_URLWithDataAsString: URLString]]];
}
- (NSString *)mainFrameURL
{
WebDataSource *ds;
ds = [[self mainFrame] provisionalDataSource];
if (!ds)
ds = [[self mainFrame] dataSource];
return [[[ds request] URL] _web_originalDataAsString];
}
- (BOOL)isLoading
{
LOG (Bindings, "isLoading = %d", (int)[self _isLoading]);
return [self _isLoading];
}
- (NSString *)mainFrameTitle
{
NSString *mainFrameTitle = [[[self mainFrame] dataSource] pageTitle];
return (mainFrameTitle != nil) ? mainFrameTitle : (NSString *)@"";
}
- (NSImage *)mainFrameIcon
{
return [[WebIconDatabase sharedIconDatabase] iconForURL:[[[[self mainFrame] dataSource] _URL] _web_originalDataAsString] withSize:WebIconSmallSize];
}
- (DOMDocument *)mainFrameDocument
{
// only return the actual value if the state we're in gives NSTreeController
// enough time to release its observers on the old model
if (_private->mainFrameDocumentReady)
return [[self mainFrame] DOMDocument];
return nil;
}
- (void)setDrawsBackground:(BOOL)drawsBackground
{
if (_private->drawsBackground == drawsBackground)
return;
_private->drawsBackground = drawsBackground;
[[self mainFrame] _updateDrawsBackground];
}
- (BOOL)drawsBackground
{
return _private->drawsBackground;
}
- (void)_inspectElement:(id)sender
{
NSDictionary *element = [sender representedObject];
......@@ -2603,6 +2687,16 @@ - (IBAction)makeTextLarger:(id)sender
[self _performTextSizingSelector:@selector(_makeTextLarger:) withObject:sender onTrackingDocs:canGrowMore selForNonTrackingDocs:@selector(_canMakeTextLarger) newScaleFactor:newScale];
}
- (IBAction)toggleSmartInsertDelete:(id)sender
{
[self setSmartInsertDeleteEnabled:![self smartInsertDeleteEnabled]];
}
- (IBAction)toggleContinuousSpellChecking:(id)sender
{
[self setContinuousSpellCheckingEnabled:![self isContinuousSpellCheckingEnabled]];
}
- (BOOL)_responderValidateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
{
id responder = [self _responderForResponderOperations];
......@@ -2615,6 +2709,18 @@ - (BOOL)_responderValidateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)i
return NO;
}
- (BOOL)canMakeTextStandardSize
{
BOOL notAlreadyStandard = _private->textSizeMultiplier != 1.0;
return [self _performTextSizingSelector:(SEL)0 withObject:nil onTrackingDocs:notAlreadyStandard selForNonTrackingDocs:@selector(_canMakeTextStandardSize) newScaleFactor:0];
}
- (IBAction)makeTextStandardSize:(id)sender
{
BOOL notAlreadyStandard = _private->textSizeMultiplier != 1.0;
[self _performTextSizingSelector:@selector(_makeTextStandardSize:) withObject:sender onTrackingDocs:notAlreadyStandard selForNonTrackingDocs:@selector(_canMakeTextStandardSize) newScaleFactor:1.0];
}
#define VALIDATE(name) \
else if (action == @selector(name:)) { return [self _responderValidateUserInterfaceItem:item]; }
......@@ -2658,37 +2764,6 @@ - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
@implementation WebView (WebPendingPublic)
- (void)setMainFrameURL:(NSString *)URLString
{
[[self mainFrame] loadRequest: [NSURLRequest requestWithURL: [NSURL _web_URLWithDataAsString: URLString]]];
}
- (NSString *)mainFrameURL
{
WebDataSource *ds;
ds = [[self mainFrame] provisionalDataSource];
if (!ds)
ds = [[self mainFrame] dataSource];
return [[[ds request] URL] _web_originalDataAsString];
}
- (BOOL)isLoading
{
LOG (Bindings, "isLoading = %d", (int)[self _isLoading]);
return [self _isLoading];
}
- (NSString *)mainFrameTitle
{
NSString *mainFrameTitle = [[[self mainFrame] dataSource] pageTitle];
return (mainFrameTitle != nil) ? mainFrameTitle : (NSString *)@"";
}
- (NSImage *)mainFrameIcon
{
return [[WebIconDatabase sharedIconDatabase] iconForURL:[[[[self mainFrame] dataSource] _URL] _web_originalDataAsString] withSize:WebIconSmallSize];
}
- (void)setMainFrameDocumentReady:(BOOL)mainFrameDocumentReady
{
// by setting this to NO, calls to mainFrameDocument are forced to return nil
......@@ -2702,43 +2777,6 @@ - (void)setMainFrameDocumentReady:(BOOL)mainFrameDocumentReady
// this will cause observers to call mainFrameDocument where this flag will be checked
}
- (DOMDocument *)mainFrameDocument
{
// only return the actual value if the state we're in gives NSTreeController
// enough time to release its observers on the old model
if (_private->mainFrameDocumentReady)
return [[self mainFrame] DOMDocument];
return nil;
}
- (void)setDrawsBackground:(BOOL)drawsBackground
{
if (_private->drawsBackground == drawsBackground)
return;
_private->drawsBackground = drawsBackground;
[[self mainFrame] _updateDrawsBackground];
}
- (BOOL)drawsBackground
{
return _private->drawsBackground;
}
- (void)toggleSmartInsertDelete:(id)sender
{
[self setSmartInsertDeleteEnabled:![self smartInsertDeleteEnabled]];
}
- (IBAction)toggleContinuousSpellChecking:(id)sender
{
[self setContinuousSpellCheckingEnabled:![self isContinuousSpellCheckingEnabled]];
}
- (BOOL)maintainsInactiveSelection
{
return [self isEditable];
}
// This method name is used by Mail on Tiger (but not post-Tiger), so we shouldn't delete it
// until the day comes when we're no longer supporting Mail on Tiger.
- (WebFrame *)_frameForCurrentSelection
......@@ -2746,34 +2784,6 @@ - (WebFrame *)_frameForCurrentSelection
return [self _selectedOrMainFrame];
}
- (WebFrame *)selectedFrame
{
// If the first responder is a view in our tree, we get the frame containing the first responder.
// This is faster than searching the frame hierarchy, and will give us a result even in the case
// where the focused frame doesn't actually contain a selection.
WebFrame *focusedFrame = [self _focusedFrame];
if (focusedFrame)
return focusedFrame;
// If the first responder is outside of our view tree, we search for a frame containing a selection.
// There should be at most only one of these.
return [[self mainFrame] _findFrameWithSelection];
return nil;
}
- (BOOL)canMakeTextStandardSize
{
BOOL notAlreadyStandard = _private->textSizeMultiplier != 1.0;
return [self _performTextSizingSelector:(SEL)0 withObject:nil onTrackingDocs:notAlreadyStandard selForNonTrackingDocs:@selector(_canMakeTextStandardSize) newScaleFactor:0];
}
- (IBAction)makeTextStandardSize:(id)sender
{
BOOL notAlreadyStandard = _private->textSizeMultiplier != 1.0;
[self _performTextSizingSelector:@selector(_makeTextStandardSize:) withObject:sender onTrackingDocs:notAlreadyStandard selForNonTrackingDocs:@selector(_canMakeTextStandardSize) newScaleFactor:1.0];
}
- (void)setTabKeyCyclesThroughElements:(BOOL)cyclesElements
{
_private->tabKeyCyclesThroughElements = cyclesElements;
......@@ -2876,21 +2886,6 @@ - (NSArray *)rectsForTextMatches
return result;
}
- (void)close
{
[self _close];
}
- (void)setShouldCloseWithWindow:(BOOL)close
{
_private->shouldCloseWithWindow = close;
}
- (BOOL)shouldCloseWithWindow
{
return _private->shouldCloseWithWindow;
}
@end
@implementation WebView (WebViewPrintingPrivate)
......@@ -3049,6 +3044,11 @@ - (BOOL)_canPaste
return [documentView respondsToSelector:@selector(_canPaste)] && [documentView _canPaste];
}
- (BOOL)maintainsInactiveSelection
{
return [self isEditable];
}
- (void)setSelectedDOMRange:(DOMRange *)range affinity:(NSSelectionAffinity)selectionAffinity
{
if (range == nil) {
......
......@@ -73,38 +73,11 @@ typedef enum {
@interface WebView (WebPendingPublic)
- (void)setMainFrameURL:(NSString *)URLString;
- (NSString *)mainFrameURL;
- (BOOL)isLoading;
- (NSString *)mainFrameTitle;
- (NSImage *)mainFrameIcon;
- (void)setMainFrameDocumentReady:(BOOL)mainFrameDocumentReady;
- (DOMDocument *)mainFrameDocument;
- (void)setDrawsBackground:(BOOL)drawsBackround;
- (BOOL)drawsBackground;
- (IBAction)toggleContinuousSpellChecking:(id)sender;
- (IBAction)toggleSmartInsertDelete:(id)sender;
- (BOOL)canMakeTextStandardSize;
- (IBAction)makeTextStandardSize:(id)sender;
- (void)setTabKeyCyclesThroughElements:(BOOL)cyclesElements;
- (BOOL)tabKeyCyclesThroughElements;
// If true, the selection will be maintained even when the first responder is outside
// of the webview. Returns true only if self is editable at this level. Subclasses can
// override to enforce additional criteria.
- (BOOL)maintainsInactiveSelection;
// Returns the frame that contains the first responder, if any. Otherwise returns the
// frame that contains a non-zero-length selection, if any. Returns nil if no frame
// meets these criteria.
- (WebFrame *)selectedFrame;
/*!
@method setScriptDebugDelegate:
@abstract Set the WebView's WebScriptDebugDelegate delegate.
......@@ -121,11 +94,6 @@ typedef enum {
- (BOOL)shouldClose;
- (void)close;
- (void)setShouldCloseWithWindow:(BOOL)close;
- (BOOL)shouldCloseWithWindow;
/*!
@method aeDescByEvaluatingJavaScriptFromString:
@param script The text of the JavaScript.
......@@ -143,16 +111,6 @@ typedef enum {
@end
@interface WebView (WebViewEditingPendingPublic)
- (IBAction)moveToBeginningOfSentence:(id)sender;
- (IBAction)moveToBeginningOfSentenceAndModifySelection:(id)sender;
- (IBAction)moveToEndOfSentence:(id)sender;
- (IBAction)moveToEndOfSentenceAndModifySelection:(id)sender;
- (IBAction)selectSentence:(id)sender;
@end
@interface WebView (WebPrivate)
+ (BOOL)_developerExtrasEnabled;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment