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

📄 webframe.mm

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 MM
📖 第 1 页 / 共 4 页
字号:
/* * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1.  Redistributions of source code must retain the above copyright *     notice, this list of conditions and the following disclaimer.  * 2.  Redistributions in binary form must reproduce the above copyright *     notice, this list of conditions and the following disclaimer in the *     documentation and/or other materials provided with the distribution.  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of *     its contributors may be used to endorse or promote products derived *     from this software without specific prior written permission.  * * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */#import "WebFrameInternal.h"#import "DOMCSSStyleDeclarationInternal.h"#import "DOMDocumentFragmentInternal.h"#import "DOMDocumentInternal.h"#import "DOMElementInternal.h"#import "DOMHTMLElementInternal.h"#import "DOMNodeInternal.h"#import "DOMRangeInternal.h"#import "WebArchiveInternal.h"#import "WebChromeClient.h"#import "WebDataSourceInternal.h"#import "WebDocumentLoaderMac.h"#import "WebFrameLoaderClient.h"#import "WebFrameViewInternal.h"#import "WebHTMLView.h"#import "WebHTMLViewInternal.h"#import "WebIconFetcherInternal.h"#import "WebKitStatisticsPrivate.h"#import "WebKitVersionChecks.h"#import "WebNSURLExtras.h"#import "WebScriptDebugger.h"#import "WebViewInternal.h"#import <JavaScriptCore/APICast.h>#import <WebCore/AccessibilityObject.h>#import <WebCore/AnimationController.h>#import <WebCore/AXObjectCache.h>#import <WebCore/ColorMac.h>#import <WebCore/DOMImplementation.h>#import <WebCore/DocLoader.h>#import <WebCore/DocumentFragment.h>#import <WebCore/EventHandler.h>#import <WebCore/Frame.h>#import <WebCore/FrameLoader.h>#import <WebCore/FrameTree.h>#import <WebCore/GraphicsContext.h>#import <WebCore/HTMLFrameOwnerElement.h>#import <WebCore/HistoryItem.h>#import <WebCore/HitTestResult.h>#import <WebCore/LegacyWebArchive.h>#import <WebCore/Page.h>#import <WebCore/PluginData.h>#import <WebCore/RenderPart.h>#import <WebCore/RenderView.h>#import <WebCore/RenderLayer.h>#import <WebCore/ReplaceSelectionCommand.h>#import <WebCore/SmartReplace.h>#import <WebCore/TextIterator.h>#import <WebCore/TypingCommand.h>#import <WebCore/htmlediting.h>#import <WebCore/ScriptController.h>#import <WebCore/ScriptValue.h>#import <WebCore/markup.h>#import <WebCore/visible_units.h>#import <runtime/JSLock.h>#import <runtime/JSValue.h>#include <wtf/CurrentTime.h>using namespace std;using namespace WebCore;using namespace HTMLNames;using JSC::JSGlobalObject;using JSC::JSLock;using JSC::JSValuePtr;/*Here is the current behavior matrix for four types of navigations:Standard Nav: Restore form state:   YES Restore scroll and focus state:  YES Cache policy: NSURLRequestUseProtocolCachePolicy Add to back/forward list: YES Back/Forward: Restore form state:   YES Restore scroll and focus state:  YES Cache policy: NSURLRequestReturnCacheDataElseLoad Add to back/forward list: NOReload (meaning only the reload button): Restore form state:   NO Restore scroll and focus state:  YES Cache policy: NSURLRequestReloadIgnoringCacheData Add to back/forward list: NORepeat load of the same URL (by any other means of navigation other than the reload button, including hitting return in the location field): Restore form state:   NO Restore scroll and focus state:  NO, reset to initial conditions Cache policy: NSURLRequestReloadIgnoringCacheData Add to back/forward list: NO*/NSString *WebPageCacheEntryDateKey = @"WebPageCacheEntryDateKey";NSString *WebPageCacheDataSourceKey = @"WebPageCacheDataSourceKey";NSString *WebPageCacheDocumentViewKey = @"WebPageCacheDocumentViewKey";// FIXME: Remove when this key becomes publicly definedNSString *NSAccessibilityEnhancedUserInterfaceAttribute = @"AXEnhancedUserInterface";@implementation WebFramePrivate- (void)dealloc{    [webFrameView release];    delete scriptDebugger;    [super dealloc];}- (void)finalize{    delete scriptDebugger;    [super finalize];}- (void)setWebFrameView:(WebFrameView *)v {     [v retain];    [webFrameView release];    webFrameView = v;}@endCSSStyleDeclaration* core(DOMCSSStyleDeclaration *declaration){    return [declaration _CSSStyleDeclaration];}DOMCSSStyleDeclaration *kit(WebCore::CSSStyleDeclaration* declaration){    return [DOMCSSStyleDeclaration _wrapCSSStyleDeclaration:declaration];}Element* core(DOMElement *element){    return [element _element];}DOMElement *kit(Element* element){    return [DOMElement _wrapElement:element];}Node* core(DOMNode *node){    return [node _node];}DOMNode *kit(Node* node){    return [DOMNode _wrapNode:node];}Document* core(DOMDocument *document){    return [document _document];}DOMDocument *kit(Document* document){    return [DOMDocument _wrapDocument:document];}DocumentFragment* core(DOMDocumentFragment *fragment){    return [fragment _documentFragment];}DOMDocumentFragment *kit(DocumentFragment* fragment){    return [DOMDocumentFragment _wrapDocumentFragment:fragment];}HTMLElement* core(DOMHTMLElement *element){    return [element _HTMLElement];}DOMHTMLElement *kit(HTMLElement *element){    return [DOMHTMLElement _wrapHTMLElement:element];}Range* core(DOMRange *range){    return [range _range];}DOMRange *kit(Range* range){    return [DOMRange _wrapRange:range];}EditableLinkBehavior core(WebKitEditableLinkBehavior editableLinkBehavior){    switch (editableLinkBehavior) {        case WebKitEditableLinkDefaultBehavior:            return EditableLinkDefaultBehavior;        case WebKitEditableLinkAlwaysLive:            return EditableLinkAlwaysLive;        case WebKitEditableLinkOnlyLiveWithShiftKey:            return EditableLinkOnlyLiveWithShiftKey;        case WebKitEditableLinkLiveWhenNotFocused:            return EditableLinkLiveWhenNotFocused;        case WebKitEditableLinkNeverLive:            return EditableLinkNeverLive;    }    ASSERT_NOT_REACHED();    return EditableLinkDefaultBehavior;}TextDirectionSubmenuInclusionBehavior core(WebTextDirectionSubmenuInclusionBehavior behavior){    switch (behavior) {        case WebTextDirectionSubmenuNeverIncluded:            return TextDirectionSubmenuNeverIncluded;        case WebTextDirectionSubmenuAutomaticallyIncluded:            return TextDirectionSubmenuAutomaticallyIncluded;        case WebTextDirectionSubmenuAlwaysIncluded:            return TextDirectionSubmenuAlwaysIncluded;    }    ASSERT_NOT_REACHED();    return TextDirectionSubmenuNeverIncluded;}@implementation WebFrame (WebInternal)Frame* core(WebFrame *frame){    return frame ? frame->_private->coreFrame : 0;}WebFrame *kit(Frame* frame){    return frame ? static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame() : nil;}Page* core(WebView *webView){    return [webView page];}WebView *kit(Page* page){    return page ? static_cast<WebChromeClient*>(page->chrome()->client())->webView() : nil;}WebView *getWebView(WebFrame *webFrame){    Frame* coreFrame = core(webFrame);    if (!coreFrame)        return nil;    return kit(coreFrame->page());}+ (PassRefPtr<Frame>)_createFrameWithPage:(Page*)page frameName:(const String&)name frameView:(WebFrameView *)frameView ownerElement:(HTMLFrameOwnerElement*)ownerElement{    WebView *webView = kit(page);    WebFrame *frame = [[self alloc] _initWithWebFrameView:frameView webView:webView];    RefPtr<Frame> coreFrame = Frame::create(page, ownerElement, new WebFrameLoaderClient(frame));    [frame release];    frame->_private->coreFrame = coreFrame.get();    coreFrame->tree()->setName(name);    if (ownerElement) {        ASSERT(ownerElement->document()->frame());        ownerElement->document()->frame()->tree()->appendChild(coreFrame.get());    }    coreFrame->init();    [webView _setZoomMultiplier:[webView _realZoomMultiplier] isTextOnly:[webView _realZoomMultiplierIsTextOnly]];    return coreFrame.release();}+ (void)_createMainFrameWithPage:(Page*)page frameName:(const String&)name frameView:(WebFrameView *)frameView{    [self _createFrameWithPage:page frameName:name frameView:frameView ownerElement:0];}+ (PassRefPtr<WebCore::Frame>)_createSubframeWithOwnerElement:(HTMLFrameOwnerElement*)ownerElement frameName:(const String&)name frameView:(WebFrameView *)frameView{    return [self _createFrameWithPage:ownerElement->document()->frame()->page() frameName:name frameView:frameView ownerElement:ownerElement];}- (void)_attachScriptDebugger{    ScriptController* scriptController = _private->coreFrame->script();    // Calling ScriptController::globalObject() would create a window shell, and dispatch corresponding callbacks, which may be premature    //  if the script debugger is attached before a document is created.    if (!scriptController->haveWindowShell())        return;    JSGlobalObject* globalObject = scriptController->globalObject();    if (!globalObject)        return;    if (_private->scriptDebugger) {        ASSERT(_private->scriptDebugger == globalObject->debugger());        return;    }    _private->scriptDebugger = new WebScriptDebugger(globalObject);}- (void)_detachScriptDebugger{    if (!_private->scriptDebugger)        return;    delete _private->scriptDebugger;    _private->scriptDebugger = 0;}- (id)_initWithWebFrameView:(WebFrameView *)fv webView:(WebView *)v{    self = [super init];

⌨️ 快捷键说明

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