1/* 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of Apple Inc. ("Apple") nor the names of 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29// This header contains the WebFrame SPI. 30 31#import <WebKitLegacy/WebFrame.h> 32#import <JavaScriptCore/JSBase.h> 33 34#if !TARGET_OS_IPHONE 35#if !defined(ENABLE_NETSCAPE_PLUGIN_API) 36#define ENABLE_NETSCAPE_PLUGIN_API 1 37#endif 38#endif 39 40#if TARGET_OS_IPHONE 41#include <CoreText/CoreText.h> 42#include <WebKitLegacy/WAKAppKitStubs.h> 43#endif 44 45@class DOMDocumentFragment; 46@class DOMNode; 47@class DOMRange; 48@class WebScriptObject; 49@class WebScriptWorld; 50 51#if TARGET_OS_IPHONE 52@class DOMElement; 53@class DOMRange; 54@class WebEvent; 55#endif 56 57// Keys for accessing the values in the page cache dictionary. 58extern NSString *WebPageCacheEntryDateKey; 59extern NSString *WebPageCacheDataSourceKey; 60extern NSString *WebPageCacheDocumentViewKey; 61 62extern NSString *WebFrameMainDocumentError; 63extern NSString *WebFrameHasPlugins; 64extern NSString *WebFrameHasUnloadListener; 65extern NSString *WebFrameUsesDatabases; 66extern NSString *WebFrameUsesGeolocation; 67extern NSString *WebFrameUsesApplicationCache; 68extern NSString *WebFrameCanSuspendActiveDOMObjects; 69 70typedef enum { 71 WebFrameLoadTypeStandard, 72 WebFrameLoadTypeBack, 73 WebFrameLoadTypeForward, 74 WebFrameLoadTypeIndexedBackForward, // a multi-item hop in the backforward list 75 WebFrameLoadTypeReload, 76 WebFrameLoadTypeReloadAllowingStaleData, 77 WebFrameLoadTypeSame, // user loads same URL again (but not reload button) 78 WebFrameLoadTypeInternal, // maps to WebCore::FrameLoadTypeRedirectWithLockedBackForwardList 79 WebFrameLoadTypeReplace, 80 WebFrameLoadTypeReloadFromOrigin, 81} WebFrameLoadType; 82 83@interface WebFrame (WebPrivate) 84 85- (BOOL)_isDescendantOfFrame:(WebFrame *)frame; 86- (void)_setShouldCreateRenderers:(BOOL)shouldCreateRenderers; 87#if !TARGET_OS_IPHONE 88- (NSColor *)_bodyBackgroundColor; 89#else 90- (CGColorRef)_bodyBackgroundColor; 91#endif 92- (BOOL)_isFrameSet; 93- (BOOL)_firstLayoutDone; 94- (BOOL)_isVisuallyNonEmpty; 95- (WebFrameLoadType)_loadType; 96#if TARGET_OS_IPHONE 97- (BOOL)needsLayout; // Needed for Mail <rdar://problem/6228038> 98- (void)_setLoadsSynchronously:(BOOL)flag; 99- (BOOL)_loadsSynchronously; 100- (unsigned)formElementsCharacterCount; 101- (void)setTimeoutsPaused:(BOOL)flag; 102 103/*! 104 @method setPluginsPaused 105 @abstract Stop/start all plugins based on the flag passed if we have a WebHTMLView 106 @param flag YES to stop plugins on the html view, NO to start them 107 */ 108- (void)setPluginsPaused:(BOOL)flag; 109- (void)prepareForPause; 110- (void)resumeFromPause; 111- (void)updateLayout; 112- (void)selectNSRange:(NSRange)range; 113- (void)selectWithoutClosingTypingNSRange:(NSRange)range; 114- (NSRange)selectedNSRange; 115- (void)forceLayoutAdjustingViewSize:(BOOL)adjust; 116- (void)_handleKeyEvent:(WebEvent *)event; 117- (void)_selectAll; 118- (void)_setSelectionFromNone; 119- (void)_saveViewState; 120- (void)_restoreViewState; 121 122- (void)deviceOrientationChanged; 123// FIXME: deprecated, to be removed after the call sites are updated. 124- (void)sendOrientationChangeEvent:(int)newOrientation; 125 126- (void)setNeedsLayout; 127- (CGSize)renderedSizeOfNode:(DOMNode *)node constrainedToWidth:(float)width; 128- (DOMNode *)deepestNodeAtViewportLocation:(CGPoint)aViewportLocation; 129- (DOMNode *)scrollableNodeAtViewportLocation:(CGPoint)aViewportLocation; 130- (DOMNode *)approximateNodeAtViewportLocation:(CGPoint *)aViewportLocation; 131- (CGRect)renderRectForPoint:(CGPoint)point isReplaced:(BOOL *)isReplaced fontSize:(float *)fontSize; 132 133- (void)_setProhibitsScrolling:(BOOL)flag; 134 135- (void)revealSelectionAtExtent:(BOOL)revealExtent; 136- (void)resetSelection; 137- (BOOL)hasEditableSelection; 138 139- (int)preferredHeight; 140// Returns the line height of the inner node of a text control. 141// For other nodes, the value is the same as lineHeight. 142- (int)innerLineHeight:(DOMNode *)node; 143- (void)setIsActive:(BOOL)flag; 144- (void)setSelectionChangeCallbacksDisabled:(BOOL)flag; 145- (NSRect)caretRect; 146- (NSRect)rectForScrollToVisible; // return caretRect if selection is caret, selectionRect otherwise 147- (void)setCaretColor:(CGColorRef)color; 148- (NSView *)documentView; 149- (int)layoutCount; 150- (BOOL)isTelephoneNumberParsingAllowed; 151- (BOOL)isTelephoneNumberParsingEnabled; 152- (BOOL)mediaDataLoadsAutomatically; 153- (void)setMediaDataLoadsAutomatically:(BOOL)flag; 154 155- (DOMRange *)selectedDOMRange; 156- (void)setSelectedDOMRange:(DOMRange *)range affinity:(NSSelectionAffinity)affinity closeTyping:(BOOL)closeTyping; 157- (NSSelectionAffinity)selectionAffinity; 158- (void)expandSelectionToElementContainingCaretSelection; 159- (DOMRange *)elementRangeContainingCaretSelection; 160- (void)expandSelectionToWordContainingCaretSelection; 161- (void)expandSelectionToStartOfWordContainingCaretSelection; 162- (unichar)characterInRelationToCaretSelection:(int)amount; 163- (unichar)characterBeforeCaretSelection; 164- (unichar)characterAfterCaretSelection; 165- (DOMRange *)wordRangeContainingCaretSelection; 166- (NSString *)wordInRange:(DOMRange *)range; 167- (int)wordOffsetInRange:(DOMRange *)range; 168- (BOOL)spaceFollowsWordInRange:(DOMRange *)range; 169- (NSArray *)wordsInCurrentParagraph; 170- (BOOL)selectionAtDocumentStart; 171- (BOOL)selectionAtSentenceStart; 172- (BOOL)selectionAtWordStart; 173- (DOMRange *)rangeByMovingCurrentSelection:(int)amount; 174- (DOMRange *)rangeByExtendingCurrentSelection:(int)amount; 175- (void)selectNSRange:(NSRange)range onElement:(DOMElement *)element; 176- (DOMRange *)markedTextDOMRange; 177- (void)setMarkedText:(NSString *)text selectedRange:(NSRange)newSelRange; 178- (void)setMarkedText:(NSString *)text forCandidates:(BOOL)forCandidates; 179- (void)confirmMarkedText:(NSString *)text; 180- (void)setText:(NSString *)text asChildOfElement:(DOMElement *)element; 181- (void)setDictationPhrases:(NSArray *)dictationPhrases metadata:(id)metadata asChildOfElement:(DOMElement *)element; 182- (NSArray *)interpretationsForCurrentRoot; 183- (void)getDictationResultRanges:(NSArray **)ranges andMetadatas:(NSArray **)metadatas; 184- (id)dictationResultMetadataForRange:(DOMRange *)range; 185- (void)recursiveSetUpdateAppearanceEnabled:(BOOL)enabled; 186 187// WebCoreFrameBridge methods used by iOS applications and frameworks 188+ (NSString *)stringWithData:(NSData *)data textEncodingName:(NSString *)textEncodingName; 189 190- (NSRect)caretRectAtNode:(DOMNode *)node offset:(int)offset affinity:(NSSelectionAffinity)affinity; 191- (DOMRange *)characterRangeAtPoint:(NSPoint)point; 192- (NSRange)convertDOMRangeToNSRange:(DOMRange *)range; 193- (DOMRange *)convertNSRangeToDOMRange:(NSRange)nsrange; 194- (NSRect)firstRectForDOMRange:(DOMRange *)range; 195- (CTFontRef)fontForSelection:(BOOL *)hasMultipleFonts; 196- (void)sendScrollEvent; 197- (void)_userScrolled; 198- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)string forceUserGesture:(BOOL)forceUserGesture; 199- (NSString *)stringForRange:(DOMRange *)range; 200- (void)_replaceSelectionWithText:(NSString *)text selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace matchStyle:(BOOL)matchStyle; 201#endif // TARGET_OS_IPHONE 202 203// These methods take and return NSRanges based on the root editable element as the positional base. 204// This fits with AppKit's idea of an input context. These methods are slow compared to their DOMRange equivalents. 205// You should use WebView's selectedDOMRange and setSelectedDOMRange whenever possible. 206- (NSRange)_selectedNSRange; 207- (void)_selectNSRange:(NSRange)range; 208 209#if TARGET_OS_IPHONE 210// FIXME: selection 211- (NSArray *)_rectsForRange:(DOMRange *)domRange; 212- (DOMRange *)_selectionRangeForPoint:(CGPoint)point; 213- (DOMRange *)_selectionRangeForFirstPoint:(CGPoint)first secondPoint:(CGPoint)second; 214#endif 215 216- (BOOL)_isDisplayingStandaloneImage; 217 218- (unsigned)_pendingFrameUnloadEventCount; 219 220#if !TARGET_OS_IPHONE 221#if ENABLE_NETSCAPE_PLUGIN_API 222- (void)_recursive_resumeNullEventsForAllNetscapePlugins; 223- (void)_recursive_pauseNullEventsForAllNetscapePlugins; 224#endif 225#endif 226 227- (NSString *)_stringByEvaluatingJavaScriptFromString:(NSString *)string withGlobalObject:(JSObjectRef)globalObject inScriptWorld:(WebScriptWorld *)world; 228- (JSGlobalContextRef)_globalContextForScriptWorld:(WebScriptWorld *)world; 229 230#if JSC_OBJC_API_ENABLED 231- (JSContext *)_javaScriptContextForScriptWorld:(WebScriptWorld *)world; 232#endif 233 234- (void)resetTextAutosizingBeforeLayout; 235- (void)_setVisibleSize:(CGSize)size; 236- (void)_setTextAutosizingWidth:(CGFloat)width; 237 238#if TARGET_OS_IPHONE 239- (void)_replaceSelectionWithWebArchive:(WebArchive *)webArchive selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace; 240#endif 241 242- (void)_replaceSelectionWithFragment:(DOMDocumentFragment *)fragment selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace matchStyle:(BOOL)matchStyle; 243- (void)_replaceSelectionWithText:(NSString *)text selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace; 244- (void)_replaceSelectionWithMarkupString:(NSString *)markupString baseURLString:(NSString *)baseURLString selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace; 245 246#if !TARGET_OS_IPHONE 247- (void)_smartInsertForString:(NSString *)pasteString replacingRange:(DOMRange *)rangeToReplace beforeString:(NSString **)beforeString afterString:(NSString **)afterString; 248#endif 249 250- (NSMutableDictionary *)_cacheabilityDictionary; 251 252- (BOOL)_allowsFollowingLink:(NSURL *)URL; 253 254#if !TARGET_OS_IPHONE 255// Sets whether the scrollbars, if any, should be shown inside the document's border 256// (thus overlapping some content) or outside the webView's border (default behavior). 257// Changing this flag changes the size of the contentView and maintains the size of the frameView. 258- (void)setAllowsScrollersToOverlapContent:(BOOL)flag; 259 260// Sets if the scrollbar is always hidden, regardless of other scrollbar visibility settings. 261// This does not affect the scrollability of the document. 262- (void)setAlwaysHideHorizontalScroller:(BOOL)flag; 263- (void)setAlwaysHideVerticalScroller:(BOOL)flag; 264#endif 265 266// Sets the name presented to accessibility clients for the web area object. 267- (void)setAccessibleName:(NSString *)name; 268 269// Enhanced accessibility. 270- (BOOL)enhancedAccessibilityEnabled; 271- (void)setEnhancedAccessibility:(BOOL)enable; 272 273- (NSString*)_layerTreeAsText; 274 275// The top of the accessibility tree. 276- (id)accessibilityRoot; 277 278// Clears frame opener. This is executed between layout tests runs 279- (void)_clearOpener; 280 281// Printing. 282- (NSArray *)_computePageRectsWithPrintScaleFactor:(float)printWidthScaleFactor pageSize:(NSSize)pageSize; 283 284#if TARGET_OS_IPHONE 285- (DOMDocumentFragment *)_documentFragmentForText:(NSString *)text; 286// These have the side effect of adding subresources to our WebDataSource where appropriate. 287- (DOMDocumentFragment *)_documentFragmentForWebArchive:(WebArchive *)webArchive; 288- (DOMDocumentFragment *)_documentFragmentForImageData:(NSData *)data withRelativeURLPart:(NSString *)relativeURLPart andMIMEType:(NSString *)mimeType; 289 290- (BOOL)focusedNodeHasContent; 291 292- (void)_dispatchDidReceiveTitle:(NSString *)title; 293- (void)removeUnchangeableStyles; 294- (BOOL)hasRichlyEditableSelection; 295#endif 296 297- (JSValueRef)jsWrapperForNode:(DOMNode *)node inScriptWorld:(WebScriptWorld *)world; 298 299- (NSDictionary *)elementAtPoint:(NSPoint)point; 300 301- (NSURL *)_unreachableURL; 302@end 303