void PageLoadState::commitChanges() { if (!m_mayHaveUncommittedChanges) return; m_mayHaveUncommittedChanges = false; bool canGoBackChanged = m_committedState.canGoBack != m_uncommittedState.canGoBack; bool canGoForwardChanged = m_committedState.canGoForward != m_uncommittedState.canGoForward; bool titleChanged = m_committedState.title != m_uncommittedState.title; bool isLoadingChanged = isLoading(m_committedState) != isLoading(m_uncommittedState); bool activeURLChanged = activeURL(m_committedState) != activeURL(m_uncommittedState); bool hasOnlySecureContentChanged = hasOnlySecureContent(m_committedState) != hasOnlySecureContent(m_uncommittedState); bool estimatedProgressChanged = estimatedProgress(m_committedState) != estimatedProgress(m_uncommittedState); bool networkRequestsInProgressChanged = m_committedState.networkRequestsInProgress != m_uncommittedState.networkRequestsInProgress; bool certificateInfoChanged = m_committedState.certificateInfo != m_uncommittedState.certificateInfo; if (canGoBackChanged) callObserverCallback(&Observer::willChangeCanGoBack); if (canGoForwardChanged) callObserverCallback(&Observer::willChangeCanGoForward); if (titleChanged) callObserverCallback(&Observer::willChangeTitle); if (isLoadingChanged) callObserverCallback(&Observer::willChangeIsLoading); if (activeURLChanged) callObserverCallback(&Observer::willChangeActiveURL); if (hasOnlySecureContentChanged) callObserverCallback(&Observer::willChangeHasOnlySecureContent); if (estimatedProgressChanged) callObserverCallback(&Observer::willChangeEstimatedProgress); if (networkRequestsInProgressChanged) callObserverCallback(&Observer::willChangeNetworkRequestsInProgress); if (certificateInfoChanged) callObserverCallback(&Observer::willChangeCertificateInfo); m_committedState = m_uncommittedState; // The "did" ordering is the reverse of the "will". This is a requirement of Cocoa Key-Value Observing. if (certificateInfoChanged) callObserverCallback(&Observer::didChangeCertificateInfo); if (networkRequestsInProgressChanged) callObserverCallback(&Observer::didChangeNetworkRequestsInProgress); if (estimatedProgressChanged) callObserverCallback(&Observer::didChangeEstimatedProgress); if (hasOnlySecureContentChanged) callObserverCallback(&Observer::didChangeHasOnlySecureContent); if (activeURLChanged) callObserverCallback(&Observer::didChangeActiveURL); if (isLoadingChanged) callObserverCallback(&Observer::didChangeIsLoading); if (titleChanged) callObserverCallback(&Observer::didChangeTitle); if (canGoForwardChanged) callObserverCallback(&Observer::didChangeCanGoForward); if (canGoBackChanged) callObserverCallback(&Observer::didChangeCanGoBack); }
// Cancels the data source's pending loads. Conceptually, a data source only loads // one document at a time, but one document may have many related resources. // stopLoading will stop all loads initiated by the data source, // but not loads initiated by child frames' data sources -- that's the WebFrame's job. void DocumentLoader::stopLoading() { RefPtr<Frame> protectFrame(m_frame); RefPtr<DocumentLoader> protectLoader(this); // In some rare cases, calling FrameLoader::stopLoading could cause isLoading() to return false. // (This can happen when there's a single XMLHttpRequest currently loading and stopLoading causes it // to stop loading. Because of this, we need to save it so we don't return early. bool loading = isLoading(); if (m_committed) { // Attempt to stop the frame if the document loader is loading, or if it is done loading but // still parsing. Failure to do so can cause a world leak. Document* doc = m_frame->document(); if (loading || doc->parsing()) m_frame->loader()->stopLoading(UnloadEventPolicyNone); } // Always cancel multipart loaders cancelAll(m_multipartResourceLoaders); clearArchiveResources(); if (!loading) { // If something above restarted loading we might run into mysterious crashes like // https://bugs.webkit.org/show_bug.cgi?id=62764 and <rdar://problem/9328684> ASSERT(!isLoading()); return; } // We might run in to infinite recursion if we're stopping loading as the result of // detaching from the frame, so break out of that recursion here. // See <rdar://problem/9673866> for more details. if (m_isStopping) return; m_isStopping = true; FrameLoader* frameLoader = DocumentLoader::frameLoader(); if (isLoadingMainResource()) // Stop the main resource loader and let it send the cancelled message. cancelMainResourceLoad(frameLoader->cancelledError(m_request)); else if (!m_resourceLoaders.isEmpty()) // The main resource loader already finished loading. Set the cancelled error on the // document and let the resourceLoaders send individual cancelled messages below. setMainDocumentError(frameLoader->cancelledError(m_request)); else // If there are no resource loaders, we need to manufacture a cancelled message. // (A back/forward navigation has no resource loaders because its resources are cached.) mainReceivedError(frameLoader->cancelledError(m_request)); stopLoadingSubresources(); m_isStopping = false; }
void Sound::unload() throw() { if (isLoading()) { abortLoad(); if (isLoading()) waitLoad(); } if (isLoaded()) { unloadImpl(); flags.loaded = false; } }
void ResourceSerializer::syncAsResourceReference(ResourceReference &reference) { if (isLoading()) { reference.loadFromStream(_loadStream); } else { reference.saveToStream(_saveStream); } }
void SVGStyleElement::childrenChanged() { SVGElement::childrenChanged(); if(m_sheet) m_sheet = 0; m_loading = false; MediaQueryEvaluator screenEval("screen", true); MediaQueryEvaluator printEval("print", true); RefPtr<MediaList> mediaList = new MediaList((CSSStyleSheet*)0, media()); if ((type().isEmpty() || type() == "text/css") && (screenEval.eval(mediaList.get()) || printEval.eval(mediaList.get()))) { ownerDocument()->addPendingSheet(); m_loading = true; m_sheet = new CSSStyleSheet(this); m_sheet->parseString(textContent()); // SVG css is always parsed in strict mode m_sheet->setMedia(mediaList.get()); m_loading = false; } if(!isLoading() && m_sheet) document()->stylesheetLoaded(); }
bool CachedFont::ensureCustomFontData() { if (!m_fontData && !errorOccurred() && !isLoading() && m_data) { SharedBuffer* buffer = m_data.get()->sharedBuffer(); ASSERT(buffer); RefPtr<SharedBuffer> sfntBuffer; bool fontIsWOFF = isWOFF(buffer); if (fontIsWOFF) { Vector<char> sfnt; if (convertWOFFToSfnt(buffer, sfnt)) { sfntBuffer = SharedBuffer::adoptVector(sfnt); buffer = sfntBuffer.get(); } else buffer = nullptr; } m_fontData = buffer ? createFontCustomPlatformData(*buffer) : nullptr; if (m_fontData) m_hasCreatedFontDataWrappingResource = !fontIsWOFF; else setStatus(DecodeError); } return m_fontData.get(); }
void Serializer::validate(int v, Common::Serializer::Version minVersion, Common::Serializer::Version maxVersion) { int tempVal = v; syncAsUint32LE(tempVal, minVersion, maxVersion); if (isLoading() && (tempVal != v)) error("Savegame is corrupt"); }
DocumentLoader::~DocumentLoader() { ASSERT(!m_frame || !isLoading()); m_fetcher->clearDocumentLoader(); clearMainResourceHandle(); m_applicationCacheHost->dispose(); }
void DocumentLoader::checkLoadComplete() { if (!m_frame || isLoading()) return; ASSERT(this == frameLoader()->activeDocumentLoader()); m_frame->document()->domWindow()->finishedLoading(); }
void FontResource::didAddClient(ResourceClient* c) { ASSERT(c->resourceClientType() == FontResourceClient::expectedType()); Resource::didAddClient(c); if (!isLoading()) static_cast<FontResourceClient*>(c)->fontLoaded(this); }
void ResourceSerializer::syncAsFloat(float &value) { if (isLoading()) { value = _loadStream->readFloatLE(); } else { _saveStream->writeFloatLE(value); } }
void XSLStyleSheetResource::didAddClient(ResourceClient* c) { ASSERT(StyleSheetResourceClient::isExpectedType(c)); Resource::didAddClient(c); if (!isLoading()) static_cast<StyleSheetResourceClient*>(c)->setXSLStyleSheet(m_resourceRequest.url(), m_response.url(), m_sheet); }
bool CachedSVGFont::ensureCustomFontData(bool externalSVG, const AtomicString& remoteURI) { if (!externalSVG) return CachedFont::ensureCustomFontData(externalSVG, remoteURI); if (!m_externalSVGDocument && !errorOccurred() && !isLoading() && m_data) { m_externalSVGDocument = SVGDocument::create(nullptr, URL()); RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("application/xml"); m_externalSVGDocument->setContent(decoder->decodeAndFlush(m_data->data(), m_data->size())); #if !ENABLE(SVG_OTF_CONVERTER) if (decoder->sawError()) m_externalSVGDocument = nullptr; #else if (decoder->sawError()) m_externalSVGDocument = nullptr; else maybeInitializeExternalSVGFontElement(remoteURI); if (!m_externalSVGFontElement) return false; Vector<char> convertedFont = convertSVGToOTFFont(*m_externalSVGFontElement); m_convertedFont = SharedBuffer::adoptVector(convertedFont); #endif } #if !ENABLE(SVG_OTF_CONVERTER) return m_externalSVGDocument; #else return m_externalSVGDocument && CachedFont::ensureCustomFontData(m_convertedFont.get()); #endif }
void WebWidget::updateNavigationActions() { if (m_actions.contains(ActionsManager::GoBackAction)) { m_actions[ActionsManager::GoBackAction]->setEnabled(canGoBack()); } if (m_actions.contains(ActionsManager::GoForwardAction)) { m_actions[ActionsManager::GoForwardAction]->setEnabled(canGoForward()); } if (m_actions.contains(ActionsManager::RewindAction)) { m_actions[ActionsManager::RewindAction]->setEnabled(canGoBack()); } if (m_actions.contains(ActionsManager::FastForwardAction)) { m_actions[ActionsManager::FastForwardAction]->setEnabled(canGoForward()); } if (m_actions.contains(ActionsManager::StopAction)) { m_actions[ActionsManager::StopAction]->setEnabled(isLoading()); } if (m_actions.contains(ActionsManager::ReloadAction)) { m_actions[ActionsManager::ReloadAction]->setEnabled(!isLoading()); } if (m_actions.contains(ActionsManager::ReloadOrStopAction)) { m_actions[ActionsManager::ReloadOrStopAction]->setup(isLoading() ? getAction(ActionsManager::StopAction) : getAction(ActionsManager::ReloadAction)); } if (m_actions.contains(ActionsManager::LoadPluginsAction)) { m_actions[ActionsManager::LoadPluginsAction]->setEnabled(getAmountOfNotLoadedPlugins() > 0); } if (m_actions.contains(ActionsManager::ViewSourceAction)) { m_actions[ActionsManager::ViewSourceAction]->setEnabled(canViewSource()); } }
void Serializer::validate(const Common::String &s, Common::Serializer::Version minVersion, Common::Serializer::Version maxVersion) { Common::String tempStr = s; syncString(tempStr, minVersion, maxVersion); if (isLoading() && (tempStr != s)) error("Savegame is corrupt"); }
bool StyleElement::sheetLoaded(Document& document) { if (isLoading()) return false; document.styleEngine().removePendingSheet(m_sheet->ownerNode(), m_styleEngineContext); return true; }
bool InlineStyleSheetOwner::sheetLoaded(Element& element) { if (isLoading()) return false; authorStyleSheetsForElement(element).removePendingSheet(); return true; }
bool ProcessingInstruction::sheetLoaded() { if (!isLoading()) { if (!DocumentXSLT::sheetLoaded(document(), this)) document().styleEngine().removePendingSheet(*this, m_styleEngineContext); return true; } return false; }
int SlotAssetsMgr::getLoadPercent(AssetsType type, int machineId) { // 如果没有正在下载压缩包,则按初始化的值 if(type == AssetsType_Machine_Zip && !isLoading(getUrl(type, machineId))) { MachineState state = getMachineState(machineId); return state.loadPercent; } return AssetsMgr::getLoadPercent(getUrl(type, machineId)); }
void CSSStyleSheet::checkLoaded() { if (isLoading()) return; if (parent()) parent()->checkLoaded(); m_loadCompleted = m_parentNode ? m_parentNode->sheetLoaded() : true; }
void CachedCSSStyleSheet::didAddClient(CachedResourceClient* c) { ASSERT(c->resourceClientType() == CachedStyleSheetClient::expectedType()); if (!isLoading()) static_cast<CachedStyleSheetClient*>(c)->setCSSStyleSheet(m_resourceRequest.url(), m_response.url(), m_decoder->encoding().name(), this); CachedResource::didAddClient(c); }
bool ProcessingInstruction::sheetLoaded() { if (!isLoading()) { document()->removePendingSheet(); return true; } return false; }
void FontResource::fontLoadLongLimitCallback(Timer<FontResource>*) { if (!isLoading()) return; ResourceClientWalker<FontResourceClient> walker(m_clients); while (FontResourceClient* client = walker.next()) client->fontLoadLongLimitExceeded(this); }
void XSLStyleSheet::checkLoaded() { if (isLoading()) return; if (XSLStyleSheet* styleSheet = parentStyleSheet()) styleSheet->checkLoaded(); if (ownerNode()) ownerNode()->sheetLoaded(); }
void ImageResource::destroyDecodedDataIfPossible() { if (!hasClients() && !isLoading() && (!m_image || (m_image->hasOneRef() && m_image->isBitmapImage()))) { m_image = nullptr; setDecodedSize(0); } else if (m_image && !errorOccurred()) { m_image->destroyDecodedData(true); } }
DocumentLoader::~DocumentLoader() { ASSERT(!m_frame || frameLoader()->activeDocumentLoader() != this || !isLoading()); if (m_iconLoadDecisionCallback) m_iconLoadDecisionCallback->invalidate(); if (m_iconDataCallback) m_iconDataCallback->invalidate(); m_cachedResourceLoader->clearDocumentLoader(); }
void Resource::checkNotify() { if (isLoading()) return; ResourceClientWalker<ResourceClient> w(m_clients); while (ResourceClient* c = w.next()) c->notifyFinished(this); }
void CachedFont::checkNotify() { if (isLoading()) return; CachedResourceClientWalker w(m_clients); while (CachedResourceClient *c = w.next()) c->fontLoaded(this); }
void CachedCSSStyleSheet::checkNotify() { if (isLoading()) return; CachedResourceClientWalker<CachedStyleSheetClient> w(m_clients); while (CachedStyleSheetClient* c = w.next()) c->setCSSStyleSheet(m_resourceRequest.url(), m_response.url(), m_decoder->encoding().name(), this); }
void CachedResource::cancelLoad() { if (!isLoading()) return; setStatus(LoadError); setLoading(false); checkNotify(); }