diff options
Diffstat (limited to 'WebCore/loader')
| -rw-r--r-- | WebCore/loader/CachedFont.cpp | 8 | ||||
| -rw-r--r-- | WebCore/loader/DocumentLoader.cpp | 8 | ||||
| -rw-r--r-- | WebCore/loader/DocumentLoader.h | 6 | ||||
| -rw-r--r-- | WebCore/loader/DocumentWriter.cpp | 20 | ||||
| -rw-r--r-- | WebCore/loader/EmptyClients.h | 1 | ||||
| -rw-r--r-- | WebCore/loader/FTPDirectoryDocument.cpp | 34 | ||||
| -rw-r--r-- | WebCore/loader/FTPDirectoryDocument.h | 2 | ||||
| -rw-r--r-- | WebCore/loader/FrameLoader.cpp | 293 | ||||
| -rw-r--r-- | WebCore/loader/FrameLoader.h | 13 | ||||
| -rw-r--r-- | WebCore/loader/ImageDocument.cpp | 6 | ||||
| -rw-r--r-- | WebCore/loader/ImageDocument.h | 2 | ||||
| -rw-r--r-- | WebCore/loader/MediaDocument.cpp | 28 | ||||
| -rw-r--r-- | WebCore/loader/MediaDocument.h | 2 | ||||
| -rw-r--r-- | WebCore/loader/PluginDocument.cpp | 32 | ||||
| -rw-r--r-- | WebCore/loader/PluginDocument.h | 2 | ||||
| -rw-r--r-- | WebCore/loader/SinkDocument.cpp | 18 | ||||
| -rw-r--r-- | WebCore/loader/SinkDocument.h | 2 | ||||
| -rw-r--r-- | WebCore/loader/TextDocument.cpp | 32 | ||||
| -rw-r--r-- | WebCore/loader/TextDocument.h | 4 | ||||
| -rw-r--r-- | WebCore/loader/TextResourceDecoder.cpp | 2 | ||||
| -rw-r--r-- | WebCore/loader/appcache/ApplicationCacheStorage.cpp | 12 |
21 files changed, 144 insertions, 383 deletions
diff --git a/WebCore/loader/CachedFont.cpp b/WebCore/loader/CachedFont.cpp index 92ac32e..af0c235 100644 --- a/WebCore/loader/CachedFont.cpp +++ b/WebCore/loader/CachedFont.cpp @@ -176,11 +176,9 @@ SVGFontElement* CachedFont::getSVGFontById(const String& fontName) const return static_cast<SVGFontElement*>(list->item(0)); for (unsigned i = 0; i < listLength; ++i) { - Node* node = list->item(i); - if (static_cast<Element*>(node)->getAttribute(static_cast<Element*>(node)->idAttributeName()) != fontName) - continue; - - return static_cast<SVGFontElement*>(node); + SVGFontElement* element = static_cast<SVGFontElement*>(list->item(i)); + if (element->getIdAttribute() == fontName) + return element; } return 0; diff --git a/WebCore/loader/DocumentLoader.cpp b/WebCore/loader/DocumentLoader.cpp index 21c2e27..990c48a 100644 --- a/WebCore/loader/DocumentLoader.cpp +++ b/WebCore/loader/DocumentLoader.cpp @@ -50,7 +50,7 @@ #include "PlatformString.h" #include "Settings.h" #include "SharedBuffer.h" -#include "XMLTokenizer.h" +#include "XMLDocumentParser.h" #include <wtf/Assertions.h> #include <wtf/unicode/Unicode.h> @@ -259,7 +259,7 @@ void DocumentLoader::commitIfReady() { if (m_gotFirstByte && !m_committed) { m_committed = true; - frameLoader()->commitProvisionalLoad(0); + frameLoader()->commitProvisionalLoad(); } } @@ -399,8 +399,8 @@ bool DocumentLoader::isLoadingInAPISense() const Document* doc = m_frame->document(); if (doc->docLoader()->requestCount()) return true; - if (Tokenizer* tok = doc->tokenizer()) - if (tok->processingData()) + if (DocumentParser* parser = doc->parser()) + if (parser->processingData()) return true; } return frameLoader()->subframeIsLoading(); diff --git a/WebCore/loader/DocumentLoader.h b/WebCore/loader/DocumentLoader.h index 1beed10..ea6f58b 100644 --- a/WebCore/loader/DocumentLoader.h +++ b/WebCore/loader/DocumentLoader.h @@ -200,7 +200,11 @@ namespace WebCore { void setDeferMainResourceDataLoad(bool defer) { m_deferMainResourceDataLoad = defer; } bool deferMainResourceDataLoad() const { return m_deferMainResourceDataLoad; } - void didTellClientAboutLoad(const String& url) { m_resourcesClientKnowsAbout.add(url); } + void didTellClientAboutLoad(const String& url) + { + if (!url.isEmpty()) + m_resourcesClientKnowsAbout.add(url); + } bool haveToldClientAboutLoad(const String& url) { return m_resourcesClientKnowsAbout.contains(url); } void recordMemoryCacheLoadForFutureClientNotification(const String& url); void takeMemoryCacheLoadsForClientNotification(Vector<String>& loads); diff --git a/WebCore/loader/DocumentWriter.cpp b/WebCore/loader/DocumentWriter.cpp index 0bed159..cc2632b 100644 --- a/WebCore/loader/DocumentWriter.cpp +++ b/WebCore/loader/DocumentWriter.cpp @@ -42,7 +42,7 @@ #include "Settings.h" #include "SinkDocument.h" #include "TextResourceDecoder.h" -#include "Tokenizer.h" +#include "DocumentParser.h" namespace WebCore { @@ -99,7 +99,7 @@ void DocumentWriter::begin(const KURL& url, bool dispatch, SecurityOrigin* origi RefPtr<Document> document = createDocument(); // If the new document is for a Plugin but we're supposed to be sandboxed from Plugins, - // then replace the document with one whose tokenizer will ignore the incoming data (bug 39323) + // then replace the document with one whose parser will ignore the incoming data (bug 39323) if (document->isPluginDocument() && m_frame->loader()->isSandboxed(SandboxPlugins)) document = SinkDocument::create(m_frame); @@ -136,10 +136,10 @@ void DocumentWriter::addData(const char* str, int len, bool flush) if (len == -1) len = strlen(str); - Tokenizer* tokenizer = m_frame->document()->tokenizer(); - if (tokenizer && tokenizer->wantsRawData()) { + DocumentParser* parser = m_frame->document()->parser(); + if (parser && parser->wantsRawData()) { if (len > 0) - tokenizer->writeRawData(str, len); + parser->writeRawData(str, len); return; } @@ -186,9 +186,9 @@ void DocumentWriter::addData(const char* str, int len, bool flush) m_frame->document()->recalcStyle(Node::Force); } - if (tokenizer) { - ASSERT(!tokenizer->wantsRawData()); - tokenizer->write(decoded, true); + if (parser) { + ASSERT(!parser->wantsRawData()); + parser->write(decoded, true); } } @@ -202,8 +202,8 @@ void DocumentWriter::addData(const String& str) m_frame->document()->setParseMode(Document::Strict); } - if (Tokenizer* tokenizer = m_frame->document()->tokenizer()) - tokenizer->write(str, true); + if (DocumentParser* parser = m_frame->document()->parser()) + parser->write(str, true); } void DocumentWriter::end() diff --git a/WebCore/loader/EmptyClients.h b/WebCore/loader/EmptyClients.h index 982324a..613c7f6 100644 --- a/WebCore/loader/EmptyClients.h +++ b/WebCore/loader/EmptyClients.h @@ -494,6 +494,7 @@ public: virtual void populateSetting(const String&, String*) { } virtual void storeSetting(const String&, const String&) { } + virtual bool sendMessageToFrontend(const String&) { return false; } }; } diff --git a/WebCore/loader/FTPDirectoryDocument.cpp b/WebCore/loader/FTPDirectoryDocument.cpp index 66136b5..5d1b2bf 100644 --- a/WebCore/loader/FTPDirectoryDocument.cpp +++ b/WebCore/loader/FTPDirectoryDocument.cpp @@ -29,7 +29,7 @@ #include "CharacterNames.h" #include "HTMLNames.h" #include "HTMLTableElement.h" -#include "HTMLTokenizer.h" +#include "HTMLDocumentParser.h" #include "LocalizedStrings.h" #include "Logging.h" #include "FTPDirectoryParser.h" @@ -48,9 +48,9 @@ namespace WebCore { using namespace HTMLNames; -class FTPDirectoryTokenizer : public HTMLTokenizer { +class FTPDirectoryDocumentParser : public HTMLDocumentParser { public: - FTPDirectoryTokenizer(HTMLDocument*); + FTPDirectoryDocumentParser(HTMLDocument*); virtual void write(const SegmentedString&, bool appendData); virtual void finish(); @@ -70,7 +70,7 @@ public: } private: - // The tokenizer will attempt to load the document template specified via the preference + // The parser will attempt to load the document template specified via the preference // Failing that, it will fall back and create the basic document which will have a minimal // table for presenting the FTP directory in a useful manner bool loadDocumentTemplate(); @@ -94,8 +94,8 @@ private: ListState m_listState; }; -FTPDirectoryTokenizer::FTPDirectoryTokenizer(HTMLDocument* doc) - : HTMLTokenizer(doc, false) +FTPDirectoryDocumentParser::FTPDirectoryDocumentParser(HTMLDocument* doc) + : HTMLDocumentParser(doc, false) , m_doc(doc) , m_skipLF(false) , m_parsedTemplate(false) @@ -105,7 +105,7 @@ FTPDirectoryTokenizer::FTPDirectoryTokenizer(HTMLDocument* doc) { } -void FTPDirectoryTokenizer::appendEntry(const String& filename, const String& size, const String& date, bool isDirectory) +void FTPDirectoryDocumentParser::appendEntry(const String& filename, const String& size, const String& date, bool isDirectory) { ExceptionCode ec; @@ -135,7 +135,7 @@ void FTPDirectoryTokenizer::appendEntry(const String& filename, const String& si rowElement->appendChild(element, ec); } -PassRefPtr<Element> FTPDirectoryTokenizer::createTDForFilename(const String& filename) +PassRefPtr<Element> FTPDirectoryDocumentParser::createTDForFilename(const String& filename) { ExceptionCode ec; @@ -257,7 +257,7 @@ static String processFileDateString(const FTPTime& fileTime) return dateString + timeOfDay; } -void FTPDirectoryTokenizer::parseAndAppendOneLine(const String& inputLine) +void FTPDirectoryDocumentParser::parseAndAppendOneLine(const String& inputLine) { ListResult result; CString latin1Input = inputLine.latin1(); @@ -292,7 +292,7 @@ static inline PassRefPtr<SharedBuffer> createTemplateDocumentData(Settings* sett return buffer.release(); } -bool FTPDirectoryTokenizer::loadDocumentTemplate() +bool FTPDirectoryDocumentParser::loadDocumentTemplate() { DEFINE_STATIC_LOCAL(RefPtr<SharedBuffer>, templateDocumentData, (createTemplateDocumentData(m_doc->settings()))); // FIXME: Instead of storing the data, we'd rather actually parse the template data into the template Document once, @@ -306,7 +306,7 @@ bool FTPDirectoryTokenizer::loadDocumentTemplate() // Tokenize the template as an HTML document synchronously setForceSynchronous(true); - HTMLTokenizer::write(String(templateDocumentData->data(), templateDocumentData->size()), true); + HTMLDocumentParser::write(String(templateDocumentData->data(), templateDocumentData->size()), true); setForceSynchronous(false); RefPtr<Element> tableElement = m_doc->getElementById("ftpDirectoryTable"); @@ -338,7 +338,7 @@ bool FTPDirectoryTokenizer::loadDocumentTemplate() return true; } -void FTPDirectoryTokenizer::createBasicDocument() +void FTPDirectoryDocumentParser::createBasicDocument() { LOG(FTP, "Creating a basic FTP document structure as no template was loaded"); @@ -357,7 +357,7 @@ void FTPDirectoryTokenizer::createBasicDocument() bodyElement->appendChild(m_tableElement, ec); } -void FTPDirectoryTokenizer::write(const SegmentedString& s, bool /*appendData*/) +void FTPDirectoryDocumentParser::write(const SegmentedString& s, bool /*appendData*/) { // Make sure we have the table element to append to by loading the template set in the pref, or // creating a very basic document with the appropriate table @@ -420,7 +420,7 @@ void FTPDirectoryTokenizer::write(const SegmentedString& s, bool /*appendData*/) m_carryOver.append(String(start, cursor - start - 1)); } -void FTPDirectoryTokenizer::finish() +void FTPDirectoryDocumentParser::finish() { // Possible the last line in the listing had no newline, so try to parse it now if (!m_carryOver.isEmpty()) { @@ -431,7 +431,7 @@ void FTPDirectoryTokenizer::finish() m_tableElement = 0; fastFree(m_buffer); - HTMLTokenizer::finish(); + HTMLDocumentParser::finish(); } FTPDirectoryDocument::FTPDirectoryDocument(Frame* frame) @@ -442,9 +442,9 @@ FTPDirectoryDocument::FTPDirectoryDocument(Frame* frame) #endif } -Tokenizer* FTPDirectoryDocument::createTokenizer() +DocumentParser* FTPDirectoryDocument::createParser() { - return new FTPDirectoryTokenizer(this); + return new FTPDirectoryDocumentParser(this); } } diff --git a/WebCore/loader/FTPDirectoryDocument.h b/WebCore/loader/FTPDirectoryDocument.h index b208c4e..f74508c 100644 --- a/WebCore/loader/FTPDirectoryDocument.h +++ b/WebCore/loader/FTPDirectoryDocument.h @@ -40,7 +40,7 @@ public: private: FTPDirectoryDocument(Frame*); - virtual Tokenizer* createTokenizer(); + virtual DocumentParser* createParser(); }; } // namespace WebCore diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp index 20a8142..7920e2e 100644 --- a/WebCore/loader/FrameLoader.cpp +++ b/WebCore/loader/FrameLoader.cpp @@ -114,7 +114,7 @@ #include "TextResourceDecoder.h" #include "WindowFeatures.h" #include "XMLHttpRequest.h" -#include "XMLTokenizer.h" +#include "XMLDocumentParser.h" #include "XSSAuditor.h" #include <wtf/text/CString.h> #include <wtf/CurrentTime.h> @@ -571,8 +571,8 @@ void FrameLoader::submitForm(const char* action, const String& url, PassRefPtr<F void FrameLoader::stopLoading(UnloadEventPolicy unloadEventPolicy, DatabasePolicy databasePolicy) { - if (m_frame->document() && m_frame->document()->tokenizer()) - m_frame->document()->tokenizer()->stopParsing(); + if (m_frame->document() && m_frame->document()->parser()) + m_frame->document()->parser()->stopParsing(); if (unloadEventPolicy != UnloadEventPolicyNone) { if (m_frame->document()) { @@ -648,8 +648,8 @@ void FrameLoader::stop() // The frame's last ref may be removed and it will be deleted by checkCompleted(). RefPtr<Frame> protector(m_frame); - if (m_frame->document()->tokenizer()) - m_frame->document()->tokenizer()->stopParsing(); + if (m_frame->document()->parser()) + m_frame->document()->parser()->stopParsing(); m_frame->document()->finishParsing(); if (m_iconLoader) @@ -1458,208 +1458,6 @@ static inline bool frameContainsWMLContent(Frame* frame) } #endif -bool FrameLoader::canCachePageContainingThisFrame() -{ - for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) { - if (!child->loader()->canCachePageContainingThisFrame()) - return false; - } - - return m_documentLoader - && m_documentLoader->mainDocumentError().isNull() - // FIXME: If we ever change this so that frames with plug-ins will be cached, - // we need to make sure that we don't cache frames that have outstanding NPObjects - // (objects created by the plug-in). Since there is no way to pause/resume a Netscape plug-in, - // they would need to be destroyed and then recreated, and there is no way that we can recreate - // the right NPObjects. See <rdar://problem/5197041> for more information. - && !m_containsPlugIns - && !m_URL.protocolIs("https") - && (!m_frame->domWindow() || !m_frame->domWindow()->hasEventListeners(eventNames().unloadEvent)) -#if ENABLE(DATABASE) - && !m_frame->document()->hasOpenDatabases() -#endif -#if ENABLE(SHARED_WORKERS) - && !SharedWorkerRepository::hasSharedWorkers(m_frame->document()) -#endif - && !m_frame->document()->usingGeolocation() - && history()->currentItem() - && !m_quickRedirectComing - && !m_documentLoader->isLoadingInAPISense() - && !m_documentLoader->isStopping() - && m_frame->document()->canSuspendActiveDOMObjects() -#if ENABLE(OFFLINE_WEB_APPLICATIONS) - // FIXME: We should investigating caching frames that have an associated - // application cache. <rdar://problem/5917899> tracks that work. - && m_documentLoader->applicationCacheHost()->canCacheInPageCache() -#endif -#if ENABLE(WML) - && !frameContainsWMLContent(m_frame) -#endif - && m_client->canCachePage() - ; -} - -bool FrameLoader::canCachePage() -{ -#ifndef NDEBUG - logCanCachePageDecision(); -#endif - - // Cache the page, if possible. - // Don't write to the cache if in the middle of a redirect, since we will want to - // store the final page we end up on. - // No point writing to the cache on a reload or loadSame, since we will just write - // over it again when we leave that page. - // FIXME: <rdar://problem/4886592> - We should work out the complexities of caching pages with frames as they - // are the most interesting pages on the web, and often those that would benefit the most from caching! - FrameLoadType loadType = this->loadType(); - - return !m_frame->tree()->parent() - && canCachePageContainingThisFrame() - && m_frame->page() - && m_frame->page()->backForwardList()->enabled() - && m_frame->page()->backForwardList()->capacity() > 0 - && m_frame->page()->settings()->usesPageCache() - && loadType != FrameLoadTypeReload - && loadType != FrameLoadTypeReloadFromOrigin - && loadType != FrameLoadTypeSame - ; -} - -#ifndef NDEBUG -static String& pageCacheLogPrefix(int indentLevel) -{ - static int previousIndent = -1; - DEFINE_STATIC_LOCAL(String, prefix, ()); - - if (indentLevel != previousIndent) { - previousIndent = indentLevel; - prefix.truncate(0); - for (int i = 0; i < previousIndent; ++i) - prefix += " "; - } - - return prefix; -} - -static void pageCacheLog(const String& prefix, const String& message) -{ - LOG(PageCache, "%s%s", prefix.utf8().data(), message.utf8().data()); -} - -#define PCLOG(...) pageCacheLog(pageCacheLogPrefix(indentLevel), String::format(__VA_ARGS__)) - -void FrameLoader::logCanCachePageDecision() -{ - // Only bother logging for main frames that have actually loaded and have content. - if (m_creatingInitialEmptyDocument) - return; - KURL currentURL = m_documentLoader ? m_documentLoader->url() : KURL(); - if (currentURL.isEmpty()) - return; - - int indentLevel = 0; - PCLOG("--------\n Determining if page can be cached:"); - - bool cannotCache = !logCanCacheFrameDecision(1); - - FrameLoadType loadType = this->loadType(); - do { - if (m_frame->tree()->parent()) - { PCLOG(" -Frame has a parent frame"); cannotCache = true; } - if (!m_frame->page()) { - PCLOG(" -There is no Page object"); - cannotCache = true; - break; - } - if (!m_frame->page()->backForwardList()->enabled()) - { PCLOG(" -The back/forward list is disabled"); cannotCache = true; } - if (!(m_frame->page()->backForwardList()->capacity() > 0)) - { PCLOG(" -The back/forward list has a 0 capacity"); cannotCache = true; } - if (!m_frame->page()->settings()->usesPageCache()) - { PCLOG(" -Page settings says b/f cache disabled"); cannotCache = true; } - if (loadType == FrameLoadTypeReload) - { PCLOG(" -Load type is: Reload"); cannotCache = true; } - if (loadType == FrameLoadTypeReloadFromOrigin) - { PCLOG(" -Load type is: Reload from origin"); cannotCache = true; } - if (loadType == FrameLoadTypeSame) - { PCLOG(" -Load type is: Same"); cannotCache = true; } - } while (false); - - PCLOG(cannotCache ? " Page CANNOT be cached\n--------" : " Page CAN be cached\n--------"); -} - -bool FrameLoader::logCanCacheFrameDecision(int indentLevel) -{ - // Only bother logging for frames that have actually loaded and have content. - if (m_creatingInitialEmptyDocument) - return false; - KURL currentURL = m_documentLoader ? m_documentLoader->url() : KURL(); - if (currentURL.isEmpty()) - return false; - - PCLOG("+---"); - KURL newURL = m_provisionalDocumentLoader ? m_provisionalDocumentLoader->url() : KURL(); - if (!newURL.isEmpty()) - PCLOG(" Determining if frame can be cached navigating from (%s) to (%s):", currentURL.string().utf8().data(), newURL.string().utf8().data()); - else - PCLOG(" Determining if subframe with URL (%s) can be cached:", currentURL.string().utf8().data()); - - bool cannotCache = false; - - do { - if (!m_documentLoader) { - PCLOG(" -There is no DocumentLoader object"); - cannotCache = true; - break; - } - if (!m_documentLoader->mainDocumentError().isNull()) - { PCLOG(" -Main document has an error"); cannotCache = true; } - if (m_containsPlugIns) - { PCLOG(" -Frame contains plugins"); cannotCache = true; } - if (m_URL.protocolIs("https")) - { PCLOG(" -Frame is HTTPS"); cannotCache = true; } - if (m_frame->domWindow() && m_frame->domWindow()->hasEventListeners(eventNames().unloadEvent)) - { PCLOG(" -Frame has an unload event listener"); cannotCache = true; } -#if ENABLE(DATABASE) - if (m_frame->document()->hasOpenDatabases()) - { PCLOG(" -Frame has open database handles"); cannotCache = true; } -#endif -#if ENABLE(SHARED_WORKERS) - if (SharedWorkerRepository::hasSharedWorkers(m_frame->document())) - { PCLOG(" -Frame has associated SharedWorkers"); cannotCache = true; } -#endif - if (m_frame->document()->usingGeolocation()) - { PCLOG(" -Frame uses Geolocation"); cannotCache = true; } - if (!history()->currentItem()) - { PCLOG(" -No current history item"); cannotCache = true; } - if (m_quickRedirectComing) - { PCLOG(" -Quick redirect is coming"); cannotCache = true; } - if (m_documentLoader->isLoadingInAPISense()) - { PCLOG(" -DocumentLoader is still loading in API sense"); cannotCache = true; } - if (m_documentLoader->isStopping()) - { PCLOG(" -DocumentLoader is in the middle of stopping"); cannotCache = true; } - if (!m_frame->document()->canSuspendActiveDOMObjects()) - { PCLOG(" -The document cannot suspect its active DOM Objects"); cannotCache = true; } -#if ENABLE(OFFLINE_WEB_APPLICATIONS) - if (!m_documentLoader->applicationCacheHost()->canCacheInPageCache()) - { PCLOG(" -The DocumentLoader uses an application cache"); cannotCache = true; } -#endif - if (!m_client->canCachePage()) - { PCLOG(" -The client says this frame cannot be cached"); cannotCache = true; } - } while (false); - - for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) - if (!child->loader()->logCanCacheFrameDecision(indentLevel + 1)) - cannotCache = true; - - PCLOG(cannotCache ? " Frame CANNOT be cached" : " Frame CAN be cached"); - PCLOG("+---"); - - return !cannotCache; -} -#endif - void FrameLoader::updateFirstPartyForCookies() { if (m_frame->tree()->parent()) @@ -1738,7 +1536,7 @@ void FrameLoader::loadInSameDocument(const KURL& url, SerializedScriptValue* sta } if (hashChange) { - m_frame->document()->enqueueHashchangeEvent(oldURL, m_URL); + m_frame->document()->enqueueHashchangeEvent(oldURL, url); m_client->dispatchDidChangeLocationWithinPage(); } @@ -2421,9 +2219,9 @@ void FrameLoader::markLoadComplete() setState(FrameStateComplete); } -void FrameLoader::commitProvisionalLoad(PassRefPtr<CachedPage> prpCachedPage) +void FrameLoader::commitProvisionalLoad() { - RefPtr<CachedPage> cachedPage = prpCachedPage; + RefPtr<CachedPage> cachedPage = m_loadingFromCachedPage ? pageCache()->get(history()->provisionalItem()) : 0; RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader; LOG(PageCache, "WebCoreLoading %s: About to commit provisional load from previous URL '%s' to new URL '%s'", m_frame->tree()->name().string().utf8().data(), m_URL.string().utf8().data(), @@ -2431,7 +2229,11 @@ void FrameLoader::commitProvisionalLoad(PassRefPtr<CachedPage> prpCachedPage) // Check to see if we need to cache the page we are navigating away from into the back/forward cache. // We are doing this here because we know for sure that a new page is about to be loaded. - cachePageForHistoryItem(history()->currentItem()); + HistoryItem* item = history()->currentItem(); + if (!m_frame->tree()->parent() && PageCache::canCache(m_frame->page()) && !item->isInPageCache()) { + pageHidden(); + pageCache()->add(item, m_frame->page()); + } if (m_loadType != FrameLoadTypeReplace) closeOldDataSources(); @@ -2448,9 +2250,11 @@ void FrameLoader::commitProvisionalLoad(PassRefPtr<CachedPage> prpCachedPage) if (m_sentRedirectNotification) clientRedirectCancelledOrFinished(false); - if (cachedPage && cachedPage->document()) - open(*cachedPage); - else { + if (cachedPage && cachedPage->document()) { + prepareForCachedPageRestore(); + cachedPage->restore(m_frame->page()); + checkCompleted(); + } else { KURL url = pdl->substituteData().responseURL(); if (url.isEmpty()) url = pdl->url(); @@ -2666,7 +2470,7 @@ void FrameLoader::closeOldDataSources() m_client->setMainFrameDocumentReady(false); // stop giving out the actual DOMDocument to observers } -void FrameLoader::open(CachedPage& cachedPage) +void FrameLoader::prepareForCachedPageRestore() { ASSERT(!m_frame->tree()->parent()); ASSERT(m_frame->page()); @@ -2682,10 +2486,6 @@ void FrameLoader::open(CachedPage& cachedPage) m_frame->setJSStatusBarText(String()); m_frame->setJSDefaultStatusBarText(String()); } - - cachedPage.restore(m_frame->page()); - - checkCompleted(); } void FrameLoader::open(CachedFrameBase& cachedFrame) @@ -3149,11 +2949,6 @@ String FrameLoader::userAgent(const KURL& url) const return m_client->userAgent(url); } -void FrameLoader::tokenizerProcessedData() -{ - checkCompleted(); -} - void FrameLoader::handledOnloadEvents() { m_client->dispatchDidHandleOnloadEvents(); @@ -3559,8 +3354,10 @@ void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest&, Pass setPolicyDocumentLoader(0); - if (isBackForwardLoadType(type) && loadProvisionalItemFromCachedPage()) + if (isBackForwardLoadType(type) && history()->provisionalItem()->isInPageCache()) { + loadProvisionalItemFromCachedPage(); return; + } if (formState) m_client->dispatchWillSubmitForm(&PolicyChecker::continueLoadAfterWillSubmitForm, formState); @@ -3673,36 +3470,17 @@ bool FrameLoader::shouldInterruptLoadForXFrameOptions(const String& content, con return false; } -bool FrameLoader::loadProvisionalItemFromCachedPage() +void FrameLoader::loadProvisionalItemFromCachedPage() { - RefPtr<CachedPage> cachedPage = pageCache()->get(history()->provisionalItem()); - if (!cachedPage || !cachedPage->document()) - return false; + DocumentLoader* provisionalLoader = provisionalDocumentLoader(); + LOG(PageCache, "WebCorePageCache: Loading provisional DocumentLoader %p with URL '%s' from CachedPage", provisionalDocumentLoader(), provisionalDocumentLoader()->url().string().utf8().data()); - DocumentLoader *provisionalLoader = provisionalDocumentLoader(); - LOG(PageCache, "WebCorePageCache: FrameLoader %p loading provisional DocumentLoader %p with URL '%s' from CachedPage %p", this, provisionalLoader, provisionalLoader->url().string().utf8().data(), cachedPage.get()); - provisionalLoader->prepareForLoadStart(); m_loadingFromCachedPage = true; provisionalLoader->setCommitted(true); - commitProvisionalLoad(cachedPage); - - return true; -} - -void FrameLoader::cachePageForHistoryItem(HistoryItem* item) -{ - if (!canCachePage() || item->isInPageCache()) - return; - - pageHidden(); - - if (Page* page = m_frame->page()) { - RefPtr<CachedPage> cachedPage = CachedPage::create(page); - pageCache()->add(item, cachedPage.release()); - } + commitProvisionalLoad(); } void FrameLoader::pageHidden() @@ -3770,21 +3548,10 @@ void FrameLoader::navigateToDifferentDocument(HistoryItem* item, FrameLoadType l { // Remember this item so we can traverse any child items as child frames load history()->setProvisionalItem(item); - - // Check if we'll be using the page cache. We only use the page cache - // if one exists and it is less than _backForwardCacheExpirationInterval - // seconds old. If the cache is expired it gets flushed here. - if (RefPtr<CachedPage> cachedPage = pageCache()->get(item)) { - // FIXME: 1800 should not be hardcoded, it should come from - // WebKitBackForwardCacheExpirationIntervalKey in WebKit. - // Or we should remove WebKitBackForwardCacheExpirationIntervalKey. - if (currentTime() - cachedPage->timeStamp() <= 1800) { - loadWithDocumentLoader(cachedPage->documentLoader(), loadType, 0); - return; - } - - LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", history()->provisionalItem()->url().string().ascii().data()); - pageCache()->remove(item); + + if (CachedPage* cachedPage = pageCache()->get(item)) { + loadWithDocumentLoader(cachedPage->documentLoader(), loadType, 0); + return; } KURL itemURL = item->url(); diff --git a/WebCore/loader/FrameLoader.h b/WebCore/loader/FrameLoader.h index 70e4b9f..a04937d 100644 --- a/WebCore/loader/FrameLoader.h +++ b/WebCore/loader/FrameLoader.h @@ -248,8 +248,6 @@ public: KURL baseURL() const; - void tokenizerProcessedData(); - void handledOnloadEvents(); String userAgent(const KURL&) const; @@ -311,7 +309,7 @@ public: void setTitle(const String&); void setIconURL(const String&); - void commitProvisionalLoad(PassRefPtr<CachedPage>); + void commitProvisionalLoad(); bool isLoadingFromCachedPage() const { return m_loadingFromCachedPage; } bool committingFirstRealLoad() const { return !m_creatingInitialEmptyDocument && !m_committedFirstRealDocumentLoad; } @@ -355,7 +353,9 @@ public: bool isDisplayingInitialEmptyDocument() const { return m_isDisplayingInitialEmptyDocument; } void clear(bool clearWindowProperties = true, bool clearScriptObjects = true, bool clearFrameView = true); - + + bool quickRedirectComing() const { return m_quickRedirectComing; } + bool shouldClose(); private: @@ -376,8 +376,7 @@ private: void navigateWithinDocument(HistoryItem*); void navigateToDifferentDocument(HistoryItem*, FrameLoadType); - bool loadProvisionalItemFromCachedPage(); - void cachePageForHistoryItem(HistoryItem*); + void loadProvisionalItemFromCachedPage(); void pageHidden(); void receivedFirstData(); @@ -418,7 +417,7 @@ private: void setState(FrameState); void closeOldDataSources(); - void open(CachedPage&); + void prepareForCachedPageRestore(); void updateHistoryAfterClientRedirect(); diff --git a/WebCore/loader/ImageDocument.cpp b/WebCore/loader/ImageDocument.cpp index 69aaed1..8ab412f 100644 --- a/WebCore/loader/ImageDocument.cpp +++ b/WebCore/loader/ImageDocument.cpp @@ -44,7 +44,7 @@ #include "SegmentedString.h" #include "Settings.h" #include "Text.h" -#include "XMLTokenizer.h" +#include "XMLDocumentParser.h" using std::min; @@ -76,7 +76,7 @@ private: ImageDocument* m_doc; }; -class ImageTokenizer : public Tokenizer { +class ImageTokenizer : public DocumentParser { public: ImageTokenizer(ImageDocument* doc) : m_doc(doc) {} @@ -192,7 +192,7 @@ ImageDocument::ImageDocument(Frame* frame) setParseMode(Compat); } -Tokenizer* ImageDocument::createTokenizer() +DocumentParser* ImageDocument::createParser() { return new ImageTokenizer(this); } diff --git a/WebCore/loader/ImageDocument.h b/WebCore/loader/ImageDocument.h index 080b250..bd627b4 100644 --- a/WebCore/loader/ImageDocument.h +++ b/WebCore/loader/ImageDocument.h @@ -49,7 +49,7 @@ public: private: ImageDocument(Frame*); - virtual Tokenizer* createTokenizer(); + virtual DocumentParser* createParser(); virtual bool isImageDocument() const { return true; } void createDocumentStructure(); diff --git a/WebCore/loader/MediaDocument.cpp b/WebCore/loader/MediaDocument.cpp index 27361fc..e505c2f 100644 --- a/WebCore/loader/MediaDocument.cpp +++ b/WebCore/loader/MediaDocument.cpp @@ -45,19 +45,18 @@ #include "SegmentedString.h" #include "Settings.h" #include "Text.h" -#include "XMLTokenizer.h" +#include "XMLDocumentParser.h" namespace WebCore { using namespace HTMLNames; -class MediaTokenizer : public Tokenizer { +class MediaDocumentParser : public DocumentParser { public: - MediaTokenizer(Document* doc) : m_doc(doc), m_mediaElement(0) {} + MediaDocumentParser(Document* doc) : m_doc(doc), m_mediaElement(0) {} private: virtual void write(const SegmentedString&, bool appendData); - virtual void stopParsing(); virtual void finish(); virtual bool isWaitingForScripts() const; @@ -70,12 +69,12 @@ private: HTMLMediaElement* m_mediaElement; }; -void MediaTokenizer::write(const SegmentedString&, bool) +void MediaDocumentParser::write(const SegmentedString&, bool) { ASSERT_NOT_REACHED(); } -void MediaTokenizer::createDocumentStructure() +void MediaDocumentParser::createDocumentStructure() { ExceptionCode ec; RefPtr<Element> rootElement = m_doc->createElement(htmlTag, false); @@ -105,7 +104,7 @@ void MediaTokenizer::createDocumentStructure() frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(false); } -bool MediaTokenizer::writeRawData(const char*, int) +bool MediaDocumentParser::writeRawData(const char*, int) { ASSERT(!m_mediaElement); if (m_mediaElement) @@ -115,19 +114,14 @@ bool MediaTokenizer::writeRawData(const char*, int) finish(); return false; } - -void MediaTokenizer::stopParsing() -{ - Tokenizer::stopParsing(); -} - -void MediaTokenizer::finish() + +void MediaDocumentParser::finish() { if (!m_parserStopped) m_doc->finishedParsing(); } -bool MediaTokenizer::isWaitingForScripts() const +bool MediaDocumentParser::isWaitingForScripts() const { // A media document is never waiting for scripts return false; @@ -145,9 +139,9 @@ MediaDocument::~MediaDocument() ASSERT(!m_replaceMediaElementTimer.isActive()); } -Tokenizer* MediaDocument::createTokenizer() +DocumentParser* MediaDocument::createParser() { - return new MediaTokenizer(this); + return new MediaDocumentParser(this); } void MediaDocument::defaultEventHandler(Event* event) diff --git a/WebCore/loader/MediaDocument.h b/WebCore/loader/MediaDocument.h index aa751ab..98eb02f 100644 --- a/WebCore/loader/MediaDocument.h +++ b/WebCore/loader/MediaDocument.h @@ -46,7 +46,7 @@ private: MediaDocument(Frame*); virtual bool isMediaDocument() const { return true; } - virtual Tokenizer* createTokenizer(); + virtual DocumentParser* createParser(); virtual void defaultEventHandler(Event*); diff --git a/WebCore/loader/PluginDocument.cpp b/WebCore/loader/PluginDocument.cpp index 7024333..7833d41 100644 --- a/WebCore/loader/PluginDocument.cpp +++ b/WebCore/loader/PluginDocument.cpp @@ -39,20 +39,19 @@ #include "SegmentedString.h" #include "Settings.h" #include "Text.h" -#include "XMLTokenizer.h" +#include "XMLDocumentParser.h" namespace WebCore { using namespace HTMLNames; -class PluginTokenizer : public Tokenizer { +class PluginDocumentParser : public DocumentParser { public: - PluginTokenizer(Document* doc) : m_doc(doc), m_embedElement(0) {} + PluginDocumentParser(Document* doc) : m_doc(doc), m_embedElement(0) {} static Widget* pluginWidgetFromDocument(Document* doc); private: virtual void write(const SegmentedString&, bool appendData); - virtual void stopParsing(); virtual void finish(); virtual bool isWaitingForScripts() const; @@ -65,7 +64,7 @@ private: HTMLEmbedElement* m_embedElement; }; -Widget* PluginTokenizer::pluginWidgetFromDocument(Document* doc) +Widget* PluginDocumentParser::pluginWidgetFromDocument(Document* doc) { ASSERT(doc); RefPtr<Element> body = doc->body(); @@ -79,12 +78,12 @@ Widget* PluginTokenizer::pluginWidgetFromDocument(Document* doc) return 0; } -void PluginTokenizer::write(const SegmentedString&, bool) +void PluginDocumentParser::write(const SegmentedString&, bool) { ASSERT_NOT_REACHED(); } -void PluginTokenizer::createDocumentStructure() +void PluginDocumentParser::createDocumentStructure() { ExceptionCode ec; RefPtr<Element> rootElement = m_doc->createElement(htmlTag, false); @@ -110,7 +109,7 @@ void PluginTokenizer::createDocumentStructure() body->appendChild(embedElement, ec); } -bool PluginTokenizer::writeRawData(const char*, int) +bool PluginDocumentParser::writeRawData(const char*, int) { ASSERT(!m_embedElement); if (m_embedElement) @@ -134,19 +133,14 @@ bool PluginTokenizer::writeRawData(const char*, int) return false; } - -void PluginTokenizer::stopParsing() -{ - Tokenizer::stopParsing(); -} - -void PluginTokenizer::finish() + +void PluginDocumentParser::finish() { if (!m_parserStopped) m_doc->finishedParsing(); } -bool PluginTokenizer::isWaitingForScripts() const +bool PluginDocumentParser::isWaitingForScripts() const { // A plugin document is never waiting for scripts return false; @@ -158,14 +152,14 @@ PluginDocument::PluginDocument(Frame* frame) setParseMode(Compat); } -Tokenizer* PluginDocument::createTokenizer() +DocumentParser* PluginDocument::createParser() { - return new PluginTokenizer(this); + return new PluginDocumentParser(this); } Widget* PluginDocument::pluginWidget() { - return PluginTokenizer::pluginWidgetFromDocument(this); + return PluginDocumentParser::pluginWidgetFromDocument(this); } Node* PluginDocument::pluginNode() diff --git a/WebCore/loader/PluginDocument.h b/WebCore/loader/PluginDocument.h index 7ff028a..e3f98a7 100644 --- a/WebCore/loader/PluginDocument.h +++ b/WebCore/loader/PluginDocument.h @@ -46,7 +46,7 @@ public: private: PluginDocument(Frame*); - virtual Tokenizer* createTokenizer(); + virtual DocumentParser* createParser(); }; } diff --git a/WebCore/loader/SinkDocument.cpp b/WebCore/loader/SinkDocument.cpp index b9c892e..d40e567 100644 --- a/WebCore/loader/SinkDocument.cpp +++ b/WebCore/loader/SinkDocument.cpp @@ -26,17 +26,16 @@ #include "config.h" #include "SinkDocument.h" -#include "Tokenizer.h" +#include "DocumentParser.h" namespace WebCore { -class SinkTokenizer : public Tokenizer { +class SinkDocumentParser : public DocumentParser { public: - SinkTokenizer(Document* document) : m_document(document) { } + SinkDocumentParser(Document* document) : m_document(document) { } private: virtual void write(const SegmentedString&, bool) { ASSERT_NOT_REACHED(); } - virtual void stopParsing(); virtual void finish(); virtual bool isWaitingForScripts() const { return false; } @@ -46,12 +45,7 @@ private: Document* m_document; }; -void SinkTokenizer::stopParsing() -{ - Tokenizer::stopParsing(); -} - -void SinkTokenizer::finish() +void SinkDocumentParser::finish() { if (!m_parserStopped) m_document->finishedParsing(); @@ -63,9 +57,9 @@ SinkDocument::SinkDocument(Frame* frame) setParseMode(Compat); } -Tokenizer* SinkDocument::createTokenizer() +DocumentParser* SinkDocument::createParser() { - return new SinkTokenizer(this); + return new SinkDocumentParser(this); } } // namespace WebCore diff --git a/WebCore/loader/SinkDocument.h b/WebCore/loader/SinkDocument.h index c79ffc3..386660c 100644 --- a/WebCore/loader/SinkDocument.h +++ b/WebCore/loader/SinkDocument.h @@ -40,7 +40,7 @@ public: private: SinkDocument(Frame*); - virtual Tokenizer* createTokenizer(); + virtual DocumentParser* createParser(); }; diff --git a/WebCore/loader/TextDocument.cpp b/WebCore/loader/TextDocument.cpp index a3d7061..68335a7 100644 --- a/WebCore/loader/TextDocument.cpp +++ b/WebCore/loader/TextDocument.cpp @@ -30,7 +30,7 @@ #include "HTMLViewSourceDocument.h" #include "SegmentedString.h" #include "Text.h" -#include "XMLTokenizer.h" +#include "XMLDocumentParser.h" using namespace std; @@ -38,11 +38,11 @@ namespace WebCore { using namespace HTMLNames; -class TextTokenizer : public Tokenizer { +class TextDocumentParser : public DocumentParser { public: - TextTokenizer(Document*); - virtual ~TextTokenizer(); - TextTokenizer(HTMLViewSourceDocument*); + TextDocumentParser(Document*); + virtual ~TextDocumentParser(); + TextDocumentParser(HTMLViewSourceDocument*); virtual void write(const SegmentedString&, bool appendData); virtual void finish(); @@ -71,7 +71,7 @@ private: UChar* m_dest; }; -TextTokenizer::TextTokenizer(Document* doc) +TextDocumentParser::TextDocumentParser(Document* doc) : m_doc(doc) , m_preElement(0) , m_skipLF(false) @@ -82,8 +82,8 @@ TextTokenizer::TextTokenizer(Document* doc) m_dest = m_buffer; } -TextTokenizer::TextTokenizer(HTMLViewSourceDocument* doc) - : Tokenizer(true) +TextDocumentParser::TextDocumentParser(HTMLViewSourceDocument* doc) + : DocumentParser(true) , m_doc(doc) , m_preElement(0) , m_skipLF(false) @@ -94,13 +94,13 @@ TextTokenizer::TextTokenizer(HTMLViewSourceDocument* doc) m_dest = m_buffer; } -TextTokenizer::~TextTokenizer() +TextDocumentParser::~TextDocumentParser() { // finish() should have been called to prevent any leaks ASSERT(!m_buffer); } -void TextTokenizer::write(const SegmentedString& s, bool) +void TextDocumentParser::write(const SegmentedString& s, bool) { ExceptionCode ec; @@ -160,7 +160,7 @@ void TextTokenizer::write(const SegmentedString& s, bool) } } -void TextTokenizer::finish() +void TextDocumentParser::finish() { if (!m_preElement) write(SegmentedString(), true); // Create document structure for an empty text document. @@ -172,7 +172,7 @@ void TextTokenizer::finish() m_doc->finishedParsing(); } -bool TextTokenizer::isWaitingForScripts() const +bool TextDocumentParser::isWaitingForScripts() const { // A text document is never waiting for scripts return false; @@ -183,14 +183,14 @@ TextDocument::TextDocument(Frame* frame) { } -Tokenizer* TextDocument::createTokenizer() +DocumentParser* TextDocument::createParser() { - return new TextTokenizer(this); + return new TextDocumentParser(this); } -Tokenizer* createTextTokenizer(HTMLViewSourceDocument* document) +DocumentParser* createTextDocumentParser(HTMLViewSourceDocument* document) { - return new TextTokenizer(document); + return new TextDocumentParser(document); } } diff --git a/WebCore/loader/TextDocument.h b/WebCore/loader/TextDocument.h index 53e3074..02c7af5 100644 --- a/WebCore/loader/TextDocument.h +++ b/WebCore/loader/TextDocument.h @@ -41,10 +41,10 @@ public: private: TextDocument(Frame*); - virtual Tokenizer* createTokenizer(); + virtual DocumentParser* createParser(); }; -Tokenizer* createTextTokenizer(HTMLViewSourceDocument*); +DocumentParser* createTextDocumentParser(HTMLViewSourceDocument*); } diff --git a/WebCore/loader/TextResourceDecoder.cpp b/WebCore/loader/TextResourceDecoder.cpp index 6ddd604..e4fd855 100644 --- a/WebCore/loader/TextResourceDecoder.cpp +++ b/WebCore/loader/TextResourceDecoder.cpp @@ -568,7 +568,7 @@ bool TextResourceDecoder::checkForHeadCharset(const char* data, size_t len, bool if (xmlDeclarationEnd == pEnd) return false; // No need for +1, because we have an extra "?" to lose at the end of XML declaration. - int len; + int len = 0; int pos = findXMLEncoding(ptr, xmlDeclarationEnd - ptr, len); if (pos != -1) setEncoding(findTextEncoding(ptr + pos, len), EncodingFromXMLHeader); diff --git a/WebCore/loader/appcache/ApplicationCacheStorage.cpp b/WebCore/loader/appcache/ApplicationCacheStorage.cpp index 36c9bda..59232a5 100644 --- a/WebCore/loader/appcache/ApplicationCacheStorage.cpp +++ b/WebCore/loader/appcache/ApplicationCacheStorage.cpp @@ -625,7 +625,11 @@ bool ApplicationCacheStorage::store(ApplicationCacheResource* resource, unsigned ASSERT(!resource->storageID()); openDatabase(true); - + + // openDatabase(true) could still fail, for example when cacheStorage is full or no longer available. + if (!m_database.isOpen()) + return false; + // First, insert the data SQLiteStatement dataStatement(m_database, "INSERT INTO CacheResourceData (data) VALUES (?)"); if (dataStatement.prepare() != SQLResultOk) @@ -711,6 +715,9 @@ bool ApplicationCacheStorage::store(ApplicationCacheResource* resource, Applicat ASSERT(cache->storageID()); openDatabase(true); + + if (!m_database.isOpen()) + return false; m_isMaximumSizeReached = false; m_database.setMaximumSize(m_maximumSize); @@ -742,6 +749,9 @@ bool ApplicationCacheStorage::storeNewestCache(ApplicationCacheGroup* group) { openDatabase(true); + if (!m_database.isOpen()) + return false; + m_isMaximumSizeReached = false; m_database.setMaximumSize(m_maximumSize); |
