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

📄 jsdocumentcustom.cpp

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 CPP
字号:
/* * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB.  If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */#include "config.h"#include "JSDocument.h"#include "ExceptionCode.h"#include "Frame.h"#include "FrameLoader.h"#include "HTMLDocument.h"#include "JSDOMWindowCustom.h"#include "JSHTMLDocument.h"#include "JSLocation.h"#include "ScriptController.h"#if ENABLE(SVG)#include "JSSVGDocument.h"#include "SVGDocument.h"#endifusing namespace JSC;namespace WebCore {void JSDocument::mark(){    JSNode::mark();    markDOMNodesForDocument(impl());    markActiveObjectsForContext(*Heap::heap(this)->globalData(), impl());}JSValuePtr JSDocument::location(ExecState* exec) const{    Frame* frame = static_cast<Document*>(impl())->frame();    if (!frame)        return jsNull();    return toJS(exec, frame->domWindow()->location());}void JSDocument::setLocation(ExecState* exec, JSValuePtr value){    Frame* frame = static_cast<Document*>(impl())->frame();    if (!frame)        return;    String str = value.toString(exec);    // IE and Mozilla both resolve the URL relative to the source frame,    // not the target frame.    Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame();    if (activeFrame)        str = activeFrame->document()->completeURL(str).string();    bool userGesture = activeFrame->script()->processingUserGesture();    frame->loader()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture);}JSValuePtr toJS(ExecState* exec, Document* document){    if (!document)        return jsNull();    DOMObject* wrapper = getCachedDOMObjectWrapper(exec->globalData(), document);    if (wrapper)        return wrapper;    if (document->isHTMLDocument())        wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, HTMLDocument, document);#if ENABLE(SVG)    else if (document->isSVGDocument())        wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, SVGDocument, document);#endif    else        wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, Document, document);    // Make sure the document is kept around by the window object, and works right with the    // back/forward cache.    if (!document->frame()) {        size_t nodeCount = 0;        for (Node* n = document; n; n = n->traverseNextNode())            nodeCount++;                exec->heap()->reportExtraMemoryCost(nodeCount * sizeof(Node));    }    return wrapper;}} // namespace WebCore

⌨️ 快捷键说明

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