⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webview.mm

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 MM
📖 第 1 页 / 共 5 页
字号:
    WebNodeHighlight *currentNodeHighlight;    BOOL allowsUndo;            float zoomMultiplier;    NSString *applicationNameForUserAgent;    String userAgent;    BOOL userAgentOverridden;        WebPreferences *preferences;    BOOL useSiteSpecificSpoofing;    NSWindow *hostWindow;    int programmaticFocusCount;        WebResourceDelegateImplementationCache resourceLoadDelegateImplementations;    WebFrameLoadDelegateImplementationCache frameLoadDelegateImplementations;    WebScriptDebugDelegateImplementationCache scriptDebugDelegateImplementations;    void *observationInfo;        BOOL closed;    BOOL shouldCloseWithWindow;    BOOL mainFrameDocumentReady;    BOOL drawsBackground;    BOOL editable;    BOOL tabKeyCyclesThroughElementsChanged;    BOOL becomingFirstResponder;    BOOL becomingFirstResponderFromOutside;    BOOL hoverFeedbackSuspended;    BOOL usesPageCache;    BOOL catchesDelegateExceptions;    NSColor *backgroundColor;    NSString *mediaStyle;        BOOL hasSpellCheckerDocumentTag;    NSInteger spellCheckerDocumentTag;    BOOL smartInsertDeleteEnabled;    BOOL selectTrailingWhitespaceEnabled;        #if ENABLE(DASHBOARD_SUPPORT)    BOOL dashboardBehaviorAlwaysSendMouseEventsToAllWindows;    BOOL dashboardBehaviorAlwaysSendActiveNullEventsToPlugIns;    BOOL dashboardBehaviorAlwaysAcceptsFirstMouse;    BOOL dashboardBehaviorAllowWheelScrolling;#endif        // WebKit has both a global plug-in database and a separate, per WebView plug-in database. Dashboard uses the per WebView database.    WebPluginDatabase *pluginDatabase;        HashMap<unsigned long, RetainPtr<id> > identifierMap;    BOOL _keyboardUIModeAccessed;    KeyboardUIMode _keyboardUIMode;    BOOL shouldUpdateWhileOffscreen;        // When this flag is set, we will not make any subviews underneath this WebView.  This means no WebFrameViews and no WebHTMLViews.    BOOL useDocumentViews;#if USE(ACCELERATED_COMPOSITING)    // When this flag is set, next time a WebHTMLView draws, it needs to temporarily disable screen updates    // so that the NSView drawing is visually synchronized with CALayer updates.    BOOL needsOneShotDrawingSynchronization;    // Number of WebHTMLViews using accelerated compositing. Used to implement _isUsingAcceleratedCompositing.    int acceleratedFramesCount;#endif    }@end@interface WebView (WebFileInternal)- (WebFrame *)_selectedOrMainFrame;- (BOOL)_isLoading;- (WebFrameView *)_frameViewAtWindowPoint:(NSPoint)point;- (WebFrame *)_focusedFrame;+ (void)_preflightSpellChecker;- (BOOL)_continuousCheckingAllowed;- (NSResponder *)_responderForResponderOperations;@end@interface WebView (WebCallDelegateFunctions)@endstatic void patchMailRemoveAttributesMethod();NSString *WebElementDOMNodeKey =            @"WebElementDOMNode";NSString *WebElementFrameKey =              @"WebElementFrame";NSString *WebElementImageKey =              @"WebElementImage";NSString *WebElementImageAltStringKey =     @"WebElementImageAltString";NSString *WebElementImageRectKey =          @"WebElementImageRect";NSString *WebElementImageURLKey =           @"WebElementImageURL";NSString *WebElementIsSelectedKey =         @"WebElementIsSelected";NSString *WebElementLinkLabelKey =          @"WebElementLinkLabel";NSString *WebElementLinkTargetFrameKey =    @"WebElementTargetFrame";NSString *WebElementLinkTitleKey =          @"WebElementLinkTitle";NSString *WebElementLinkURLKey =            @"WebElementLinkURL";NSString *WebElementSpellingToolTipKey =    @"WebElementSpellingToolTip";NSString *WebElementTitleKey =              @"WebElementTitle";NSString *WebElementLinkIsLiveKey =         @"WebElementLinkIsLive";NSString *WebElementIsContentEditableKey =  @"WebElementIsContentEditableKey";NSString *WebViewProgressStartedNotification =          @"WebProgressStartedNotification";NSString *WebViewProgressEstimateChangedNotification =  @"WebProgressEstimateChangedNotification";NSString *WebViewProgressFinishedNotification =         @"WebProgressFinishedNotification";NSString * const WebViewDidBeginEditingNotification =         @"WebViewDidBeginEditingNotification";NSString * const WebViewDidChangeNotification =               @"WebViewDidChangeNotification";NSString * const WebViewDidEndEditingNotification =           @"WebViewDidEndEditingNotification";NSString * const WebViewDidChangeTypingStyleNotification =    @"WebViewDidChangeTypingStyleNotification";NSString * const WebViewDidChangeSelectionNotification =      @"WebViewDidChangeSelectionNotification";enum { WebViewVersion = 4 };#define timedLayoutSize 4096static NSMutableSet *schemesWithRepresentationsSet;NSString *_WebCanGoBackKey =            @"canGoBack";NSString *_WebCanGoForwardKey =         @"canGoForward";NSString *_WebEstimatedProgressKey =    @"estimatedProgress";NSString *_WebIsLoadingKey =            @"isLoading";NSString *_WebMainFrameIconKey =        @"mainFrameIcon";NSString *_WebMainFrameTitleKey =       @"mainFrameTitle";NSString *_WebMainFrameURLKey =         @"mainFrameURL";NSString *_WebMainFrameDocumentKey =    @"mainFrameDocument";@interface WebProgressItem : NSObject{@public    long long bytesReceived;    long long estimatedLength;}@end@implementation WebProgressItem@endstatic BOOL continuousSpellCheckingEnabled;#ifndef BUILDING_ON_TIGERstatic BOOL grammarCheckingEnabled;#endif@implementation WebViewPrivate+ (void)initialize{    JSC::initializeThreading();#ifndef BUILDING_ON_TIGER    WebCoreObjCFinalizeOnMainThread(self);#endif}- init {    self = [super init];    if (!self)        return nil;    JSC::initializeThreading();    allowsUndo = YES;    zoomMultiplier = 1;#if ENABLE(DASHBOARD_SUPPORT)    dashboardBehaviorAllowWheelScrolling = YES;#endif    shouldCloseWithWindow = objc_collecting_enabled();    continuousSpellCheckingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebContinuousSpellCheckingEnabled];#ifndef BUILDING_ON_TIGER    grammarCheckingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebGrammarCheckingEnabled];#endif        usesPageCache = YES;        pluginDatabaseClientCount++;    shouldUpdateWhileOffscreen = YES;    return self;}- (void)dealloc{        ASSERT(applicationIsTerminating || !page);    ASSERT(applicationIsTerminating || !preferences);        [applicationNameForUserAgent release];    [backgroundColor release];        [inspector release];    [currentNodeHighlight release];    [hostWindow release];    [policyDelegateForwarder release];    [UIDelegateForwarder release];    [frameLoadDelegateForwarder release];    [editingDelegateForwarder release];        [mediaStyle release];        [super dealloc];}- (void)finalize{    ASSERT_MAIN_THREAD();    [super finalize];}@end@implementation WebView (AllWebViews)static CFSetCallBacks NonRetainingSetCallbacks = {    0,    NULL,    NULL,    CFCopyDescription,    CFEqual,    CFHash};static CFMutableSetRef allWebViewsSet;+ (void)_makeAllWebViewsPerformSelector:(SEL)selector{    if (!allWebViewsSet)        return;    [(NSMutableSet *)allWebViewsSet makeObjectsPerformSelector:selector];}- (void)_removeFromAllWebViewsSet{    if (allWebViewsSet)        CFSetRemoveValue(allWebViewsSet, self);}- (void)_addToAllWebViewsSet{    if (!allWebViewsSet)        allWebViewsSet = CFSetCreateMutable(NULL, 0, &NonRetainingSetCallbacks);    CFSetSetValue(allWebViewsSet, self);}@end@implementation WebView (WebPrivate)static inline int callGestalt(OSType selector){    SInt32 value = 0;    Gestalt(selector, &value);    return value;}// Uses underscores instead of dots because if "4." ever appears in a user agent string, old DHTML libraries treat it as Netscape 4.static NSString *createMacOSXVersionString(){    // Can't use -[NSProcessInfo operatingSystemVersionString] because it has too much stuff we don't want.    int major = callGestalt(gestaltSystemVersionMajor);    ASSERT(major);    int minor = callGestalt(gestaltSystemVersionMinor);    int bugFix = callGestalt(gestaltSystemVersionBugFix);    if (bugFix)        return [[NSString alloc] initWithFormat:@"%d_%d_%d", major, minor, bugFix];    if (minor)        return [[NSString alloc] initWithFormat:@"%d_%d", major, minor];    return [[NSString alloc] initWithFormat:@"%d", major];}static NSString *createUserVisibleWebKitVersionString(){    // If the version is 4 digits long or longer, then the first digit represents    // the version of the OS. Our user agent string should not include this first digit,    // so strip it off and report the rest as the version. <rdar://problem/4997547>    NSString *fullVersion = [[NSBundle bundleForClass:[WebView class]] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];    NSRange nonDigitRange = [fullVersion rangeOfCharacterFromSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]];    if (nonDigitRange.location == NSNotFound && [fullVersion length] >= 4)        return [[fullVersion substringFromIndex:1] copy];    if (nonDigitRange.location != NSNotFound && nonDigitRange.location >= 4)        return [[fullVersion substringFromIndex:1] copy];    return [fullVersion copy];}+ (NSString *)_standardUserAgentWithApplicationName:(NSString *)applicationName{    // Note: Do *not* move the initialization of osVersion nor webKitVersion into the declaration.    // Garbage collection won't correctly mark the global variable in that case <rdar://problem/5733674>.    static NSString *osVersion;    static NSString *webKitVersion;    if (!osVersion)        osVersion = createMacOSXVersionString();    if (!webKitVersion)        webKitVersion = createUserVisibleWebKitVersionString();    NSString *language = [NSUserDefaults _webkit_preferredLanguageCode];    if ([applicationName length])        return [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; " PROCESSOR " Mac OS X %@; %@) AppleWebKit/%@ (KHTML, like Gecko) %@", osVersion, language, webKitVersion, applicationName];    return [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; " PROCESSOR " Mac OS X %@; %@) AppleWebKit/%@ (KHTML, like Gecko)", osVersion, language, webKitVersion];}static void WebKitInitializeApplicationCachePathIfNecessary(){    static BOOL initialized = NO;    if (initialized)        return;    NSString *appName = [[NSBundle mainBundle] bundleIdentifier];    if (!appName)        appName = [[NSProcessInfo processInfo] processName];        ASSERT(appName);    NSString* cacheDir = [NSString _webkit_localCacheDirectoryWithBundleIdentifier:appName];    cacheStorage().setCacheDirectory(cacheDir);    initialized = YES;}- (void)_registerDraggedTypes{    NSArray *editableTypes = [WebHTMLView _insertablePasteboardTypes];    NSArray *URLTypes = [NSPasteboard _web_dragTypesForURL];    NSMutableSet *types = [[NSMutableSet alloc] initWithArray:editableTypes];    [types addObjectsFromArray:URLTypes];    [self registerForDraggedTypes:[types allObjects]];    [types release];}- (BOOL)_usesDocumentViews{    return _private->useDocumentViews;}- (void)_commonInitializationWithFrameName:(NSString *)frameName groupName:(NSString *)groupName usesDocumentViews:(BOOL)usesDocumentViews{    WebCoreThreadViolationCheck();#ifndef NDEBUG    WTF::RefCountedLeakCounter::suppressMessages(webViewIsOpen);#endif        WebPreferences *standardPreferences = [WebPreferences standardPreferences];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -