1/* 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2014 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 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#ifndef WAKWindow_h 27#define WAKWindow_h 28 29#if TARGET_OS_IPHONE 30 31#import "WAKAppKitStubs.h" 32#import "WAKResponder.h" 33#import "WAKView.h" 34#import "WKContentObservation.h" 35#import <CoreGraphics/CoreGraphics.h> 36#import <Foundation/Foundation.h> 37 38@class CALayer; 39@class WebEvent; 40 41#ifdef __cplusplus 42namespace WebCore { 43 class LegacyTileCache; 44} 45typedef WebCore::LegacyTileCache LegacyTileCache; 46#else 47typedef struct LegacyTileCache LegacyTileCache; 48#endif 49 50typedef enum { 51 kWAKWindowTilingModeNormal, 52 kWAKWindowTilingModeMinimal, 53 kWAKWindowTilingModePanning, 54 kWAKWindowTilingModeZooming, 55 kWAKWindowTilingModeDisabled, 56 kWAKWindowTilingModeScrollToTop, 57} WAKWindowTilingMode; 58 59typedef enum { 60 kWAKTilingDirectionUp, 61 kWAKTilingDirectionDown, 62 kWAKTilingDirectionLeft, 63 kWAKTilingDirectionRight, 64} WAKTilingDirection; 65 66extern NSString * const WAKWindowScreenScaleDidChangeNotification; 67extern NSString * const WAKWindowVisibilityDidChangeNotification; 68 69@interface WAKWindow : WAKResponder 70{ 71 CALayer* _hostLayer; 72 LegacyTileCache* _tileCache; 73 CGRect _frozenVisibleRect; 74 CALayer *_rootLayer; 75 76 CGSize _screenSize; 77 CGSize _availableScreenSize; 78 CGFloat _screenScale; 79 80 CGRect _frame; 81 82 WAKView *_contentView; 83 WAKView *_responderView; 84 WAKView *_nextResponder; 85 86 BOOL _visible; 87 BOOL _useOrientationDependentFontAntialiasing; 88} 89 90@property (nonatomic, assign) BOOL useOrientationDependentFontAntialiasing; 91 92// If non-NULL, contentReplacementImage will draw into tiles instead of web content. 93@property (nonatomic) CGImageRef contentReplacementImage; 94 95// Create layer hosted window 96- (id)initWithLayer:(CALayer *)hostLayer; 97// Create unhosted window for manual painting 98- (id)initWithFrame:(CGRect)frame; 99 100- (CALayer*)hostLayer; 101 102- (void)setContentView:(WAKView *)aView; 103- (WAKView *)contentView; 104- (void)close; 105- (WAKView *)firstResponder; 106 107- (NSPoint)convertBaseToScreen:(NSPoint)aPoint; 108- (NSPoint)convertScreenToBase:(NSPoint)aPoint; 109- (BOOL)isKeyWindow; 110- (void)makeKeyWindow; 111- (BOOL)isVisible; 112- (void)setVisible:(BOOL)visible; 113- (NSSelectionDirection)keyViewSelectionDirection; 114- (BOOL)makeFirstResponder:(NSResponder *)aResponder; 115- (WAKView *)_newFirstResponderAfterResigning; 116- (void)setFrame:(NSRect)frameRect display:(BOOL)flag; 117- (CGRect)frame; 118- (void)setContentRect:(CGRect)rect; 119- (void)setScreenSize:(CGSize)size; 120- (CGSize)screenSize; 121- (void)setAvailableScreenSize:(CGSize)size; 122- (CGSize)availableScreenSize; 123- (void)setScreenScale:(CGFloat)scale; 124- (CGFloat)screenScale; 125- (void)setRootLayer:(CALayer *)layer; 126- (CALayer *)rootLayer; 127- (void)sendEvent:(WebEvent *)anEvent; 128- (void)sendEventSynchronously:(WebEvent *)anEvent; 129- (void)sendMouseMoveEvent:(WebEvent *)anEvent contentChange:(WKContentChange *)aContentChange; 130 131// Thread safe way of providing the "usable" rect of the WAKWindow in the viewport/scrollview. 132- (CGRect)exposedScrollViewRect; 133// setExposedScrollViewRect should only ever be called from UIKit. 134- (void)setExposedScrollViewRect:(CGRect)exposedScrollViewRect; 135 136// Tiling support 137- (void)layoutTiles; 138- (void)layoutTilesNow; 139- (void)layoutTilesNowForRect:(CGRect)rect; 140- (void)setNeedsDisplay; 141- (void)setNeedsDisplayInRect:(CGRect)rect; 142- (BOOL)tilesOpaque; 143- (void)setTilesOpaque:(BOOL)opaque; 144- (CGRect)visibleRect; 145// The extended visible rect includes the area outside superviews with 146// masksToBounds set to NO. 147- (CGRect)extendedVisibleRect; 148- (void)removeAllNonVisibleTiles; 149- (void)removeAllTiles; 150- (void)removeForegroundTiles; 151- (void)setTilingMode:(WAKWindowTilingMode)mode; 152- (WAKWindowTilingMode)tilingMode; 153- (void)setTilingDirection:(WAKTilingDirection)tilingDirection; 154- (WAKTilingDirection)tilingDirection; 155- (BOOL)hasPendingDraw; 156- (void)displayRect:(NSRect)rect; 157- (void)setZoomedOutTileScale:(float)scale; 158- (float)zoomedOutTileScale; 159- (void)setCurrentTileScale:(float)scale; 160- (float)currentTileScale; 161- (void)setKeepsZoomedOutTiles:(BOOL)keepsZoomedOutTiles; 162- (BOOL)keepsZoomedOutTiles; 163- (LegacyTileCache *)tileCache; 164 165- (void)setTileControllerShouldUseLowScaleTiles:(BOOL)lowScaleTiles; 166 167- (void)dumpTiles; 168 169- (void)setTileBordersVisible:(BOOL)visible; 170- (void)setTilePaintCountsVisible:(BOOL)visible; 171- (void)setAcceleratedDrawingEnabled:(BOOL)enabled; 172 173- (void)freezeVisibleRect; 174- (void)unfreezeVisibleRect; 175- (void)willRotate; 176- (void)didRotate; 177 178- (BOOL)useOrientationDependentFontAntialiasing; 179- (void)setUseOrientationDependentFontAntialiasing:(BOOL)aa; 180+ (BOOL)hasLandscapeOrientation; 181+ (void)setOrientationProvider:(id)provider; 182 183+ (WebEvent *)currentEvent; 184 185- (NSString *)recursiveDescription; 186@end 187 188#endif // TARGET_OS_IPHONE 189 190#endif // WAKWindow_h 191