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

📄 frameloader.cpp

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        submitFormAgain();        Document::updateDocumentsRendering();    }    return result;}void FrameLoader::cancelAndClear(){    cancelRedirection();    if (!m_isComplete)        closeURL();    clear(false);    m_frame->script()->updatePlatformScriptObjects();}void FrameLoader::clear(bool clearWindowProperties, bool clearScriptObjects){    m_frame->editor()->clear();    if (!m_needsClear)        return;    m_needsClear = false;        if (!m_frame->document()->inPageCache()) {        m_frame->document()->cancelParsing();        m_frame->document()->stopActiveDOMObjects();        if (m_frame->document()->attached()) {            m_frame->document()->willRemove();            m_frame->document()->detach();                        m_frame->document()->removeFocusedNodeOfSubtree(m_frame->document());        }    }    // Do this after detaching the document so that the unload event works.    if (clearWindowProperties) {        m_frame->clearDOMWindow();        m_frame->script()->clearWindowShell();    }    m_frame->selection()->clear();    m_frame->eventHandler()->clear();    if (m_frame->view())        m_frame->view()->clear();    m_frame->setSelectionGranularity(CharacterGranularity);    // Do not drop the document before the ScriptController and view are cleared    // as some destructors might still try to access the document.    m_frame->setDocument(0);    m_decoder = 0;    m_containsPlugIns = false;    if (clearScriptObjects)        m_frame->script()->clearScriptObjects();    m_redirectionTimer.stop();    m_scheduledRedirection.clear();    m_checkCompletedTimer.stop();    m_checkLoadCompleteTimer.stop();    m_receivedData = false;    m_isDisplayingInitialEmptyDocument = false;    if (!m_encodingWasChosenByUser)        m_encoding = String();}void FrameLoader::receivedFirstData(){    begin(m_workingURL, false);    dispatchDidCommitLoad();    dispatchWindowObjectAvailable();        String ptitle = m_documentLoader->title();    // If we have a title let the WebView know about it.    if (!ptitle.isNull())        m_client->dispatchDidReceiveTitle(ptitle);    m_workingURL = KURL();    double delay;    String url;    if (!m_documentLoader)        return;    if (!parseHTTPRefresh(m_documentLoader->response().httpHeaderField("Refresh"), false, delay, url))        return;    if (url.isEmpty())        url = m_URL.string();    else        url = m_frame->document()->completeURL(url).string();    scheduleHTTPRedirection(delay, url);}const String& FrameLoader::responseMIMEType() const{    return m_responseMIMEType;}void FrameLoader::setResponseMIMEType(const String& type){    m_responseMIMEType = type;}    void FrameLoader::begin(){    begin(KURL());}void FrameLoader::begin(const KURL& url, bool dispatch, SecurityOrigin* origin){    // We need to take a reference to the security origin because |clear|    // might destroy the document that owns it.    RefPtr<SecurityOrigin> forcedSecurityOrigin = origin;    RefPtr<Document> document;    // Create a new document before clearing the frame, because it may need to inherit an aliased security context.    if (!m_isDisplayingInitialEmptyDocument && m_client->shouldUsePluginDocument(m_responseMIMEType))        document = PluginDocument::create(m_frame);    else        document = DOMImplementation::createDocument(m_responseMIMEType, m_frame, m_frame->inViewSourceMode());    bool resetScripting = !(m_isDisplayingInitialEmptyDocument && m_frame->document()->securityOrigin()->isSecureTransitionTo(url));    clear(resetScripting, resetScripting);    if (resetScripting)        m_frame->script()->updatePlatformScriptObjects();    m_needsClear = true;    m_isComplete = false;    m_didCallImplicitClose = false;    m_isLoadingMainResource = true;    m_isDisplayingInitialEmptyDocument = m_creatingInitialEmptyDocument;    KURL ref(url);    ref.setUser(String());    ref.setPass(String());    ref.setRef(String());    m_outgoingReferrer = ref.string();    m_URL = url;    m_frame->setDocument(document);    if (dispatch)        dispatchWindowObjectAvailable();    document->setURL(m_URL);    if (m_decoder)        document->setDecoder(m_decoder.get());    if (forcedSecurityOrigin)        document->setSecurityOrigin(forcedSecurityOrigin.get());    m_frame->domWindow()->setURL(document->url());    m_frame->domWindow()->setSecurityOrigin(document->securityOrigin());    updatePolicyBaseURL();    Settings* settings = document->settings();    document->docLoader()->setAutoLoadImages(settings && settings->loadsImagesAutomatically());    if (m_documentLoader) {        String dnsPrefetchControl = m_documentLoader->response().httpHeaderField("X-DNS-Prefetch-Control");        if (!dnsPrefetchControl.isEmpty())            document->parseDNSPrefetchControlHeader(dnsPrefetchControl);    }#if FRAME_LOADS_USER_STYLESHEET    KURL userStyleSheet = settings ? settings->userStyleSheetLocation() : KURL();    if (!userStyleSheet.isEmpty())        m_frame->setUserStyleSheetLocation(userStyleSheet);#endif    restoreDocumentState();    document->implicitOpen();    if (m_frame->view())        m_frame->view()->setContentsSize(IntSize());}void FrameLoader::write(const char* str, int len, bool flush){    if (len == 0 && !flush)        return;        if (len == -1)        len = strlen(str);    Tokenizer* tokenizer = m_frame->document()->tokenizer();    if (tokenizer && tokenizer->wantsRawData()) {        if (len > 0)            tokenizer->writeRawData(str, len);        return;    }        if (!m_decoder) {        Settings* settings = m_frame->settings();        m_decoder = TextResourceDecoder::create(m_responseMIMEType, settings ? settings->defaultTextEncodingName() : String());        if (m_encoding.isEmpty()) {            Frame* parentFrame = m_frame->tree()->parent();            if (parentFrame && parentFrame->document()->securityOrigin()->canAccess(m_frame->document()->securityOrigin()))                m_decoder->setEncoding(parentFrame->document()->inputEncoding(), TextResourceDecoder::DefaultEncoding);        } else {            m_decoder->setEncoding(m_encoding,                m_encodingWasChosenByUser ? TextResourceDecoder::UserChosenEncoding : TextResourceDecoder::EncodingFromHTTPHeader);        }        m_frame->document()->setDecoder(m_decoder.get());    }    String decoded = m_decoder->decode(str, len);    if (flush)        decoded += m_decoder->flush();    if (decoded.isEmpty())        return;    if (!m_receivedData) {        m_receivedData = true;        if (m_decoder->encoding().usesVisualOrdering())            m_frame->document()->setVisuallyOrdered();        m_frame->document()->recalcStyle(Node::Force);    }    if (tokenizer) {        ASSERT(!tokenizer->wantsRawData());        tokenizer->write(decoded, true);    }}void FrameLoader::write(const String& str){    if (str.isNull())        return;    if (!m_receivedData) {        m_receivedData = true;        m_frame->document()->setParseMode(Document::Strict);    }    if (Tokenizer* tokenizer = m_frame->document()->tokenizer())        tokenizer->write(str, true);}void FrameLoader::end(){    m_isLoadingMainResource = false;    endIfNotLoadingMainResource();}void FrameLoader::endIfNotLoadingMainResource(){    if (m_isLoadingMainResource || !m_frame->page() || !m_frame->document())        return;    // http://bugs.webkit.org/show_bug.cgi?id=10854    // The frame's last ref may be removed and it can be deleted by checkCompleted(),     // so we'll add a protective refcount    RefPtr<Frame> protector(m_frame);    // make sure nothing's left in there    write(0, 0, true);    m_frame->document()->finishParsing();}void FrameLoader::iconLoadDecisionAvailable(){    if (!m_mayLoadIconLater)        return;    LOG(IconDatabase, "FrameLoader %p was told a load decision is available for its icon", this);    startIconLoader();    m_mayLoadIconLater = false;}void FrameLoader::startIconLoader(){    // FIXME: We kick off the icon loader when the frame is done receiving its main resource.    // But we should instead do it when we're done parsing the head element.    if (!isLoadingMainFrame())        return;    if (!iconDatabase() || !iconDatabase()->isEnabled())        return;        KURL url(iconURL());    String urlString(url.string());    if (urlString.isEmpty())        return;    // If we're not reloading and the icon database doesn't say to load now then bail before we actually start the load    if (loadType() != FrameLoadTypeReload && loadType() != FrameLoadTypeReloadFromOrigin) {        IconLoadDecision decision = iconDatabase()->loadDecisionForIconURL(urlString, m_documentLoader.get());        if (decision == IconLoadNo) {            LOG(IconDatabase, "FrameLoader::startIconLoader() - Told not to load this icon, committing iconURL %s to database for pageURL mapping", urlString.ascii().data());            commitIconURLToIconDatabase(url);                        // We were told not to load this icon - that means this icon is already known by the database            // If the icon data hasn't been read in from disk yet, kick off the read of the icon from the database to make sure someone            // has done it.  This is after registering for the notification so the WebView can call the appropriate delegate method.            // Otherwise if the icon data *is* available, notify the delegate            if (!iconDatabase()->iconDataKnownForIconURL(urlString)) {                LOG(IconDatabase, "Told not to load icon %s but icon data is not yet available - registering for notification and requesting load from disk", urlString.ascii().data());                m_client->registerForIconNotification();                iconDatabase()->iconForPageURL(m_URL.string(), IntSize(0, 0));                iconDatabase()->iconForPageURL(originalRequestURL().string(), IntSize(0, 0));            } else                m_client->dispatchDidReceiveIcon();                            return;        }                 if (decision == IconLoadUnknown) {            // In this case, we may end up loading the icon later, but we still want to commit the icon url mapping to the database            // just in case we don't end up loading later - if we commit the mapping a second time after the load, that's no big deal            // We also tell the client to register for the notification that the icon is received now so it isn't missed in case the             // icon is later read in from disk            LOG(IconDatabase, "FrameLoader %p might load icon %s later", this, urlString.ascii().data());            m_mayLoadIconLater = true;                m_client->registerForIconNotification();            commitIconURLToIconDatabase(url);            return;        }    }    // This is either a reload or the icon database said "yes, load the icon", so kick off the load!    if (!m_iconLoader)        m_iconLoader.set(IconLoader::create(m_frame).release());            m_iconLoader->startLoading();}void FrameLoader::setLocalLoadPolicy(LocalLoadPolicy policy){    localLoadPolicy = policy;}bool FrameLoader::restrictAccessToLocal(){    return localLoadPolicy != FrameLoader::AllowLocalLoadsForAll;}bool FrameLoader::allowSubstituteDataAccessToLocal(){    return localLoadPolicy != FrameLoader::AllowLocalLoadsForLocalOnly;}static LocalSchemesMap& localSchemes(){    DEFINE_STATIC_LOCAL(LocalSchemesMap, localSchemes, ());    if (localSchemes.isEmpty()) {        localSchemes.add("file");#if PLATFORM(MAC)        localSchemes.add("applewebdata");#endif#if PLATFORM(QT)        localSchemes.add("qrc");#endif    }    return localSchemes;}void FrameLoader::commitIconURLToIconDatabase(const KURL& icon){    ASSERT(iconDatabase());    LOG(IconDatabase, "Committing iconURL %s to database for pageURLs %s and %s", icon.string().ascii().data(), m_URL.string().ascii().data(), originalRequestURL().string().ascii().data());    iconDatabase()->setIconURLForPageURL(icon.string(), m_URL.string());    iconDatabase()->setIconURLForPageURL(icon.string(), originalRequestURL().string());}void FrameLoader::restoreDocumentState(){    Document* doc = m_frame->document();            HistoryItem* itemToRestore = 0;    

⌨️ 快捷键说明

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