diff options
Diffstat (limited to 'WebCore/loader')
29 files changed, 266 insertions, 169 deletions
diff --git a/WebCore/loader/Cache.h b/WebCore/loader/Cache.h index 0a5b74d..23aad1e 100644 --- a/WebCore/loader/Cache.h +++ b/WebCore/loader/Cache.h @@ -28,12 +28,12 @@ #include "CachePolicy.h" #include "CachedResource.h" #include "PlatformString.h" -#include "StringHash.h" #include "loader.h" #include <wtf/HashMap.h> #include <wtf/HashSet.h> #include <wtf/Noncopyable.h> #include <wtf/Vector.h> +#include <wtf/text/StringHash.h> namespace WebCore { diff --git a/WebCore/loader/CrossOriginAccessControl.cpp b/WebCore/loader/CrossOriginAccessControl.cpp index f019f28..630f2b7 100644 --- a/WebCore/loader/CrossOriginAccessControl.cpp +++ b/WebCore/loader/CrossOriginAccessControl.cpp @@ -27,11 +27,11 @@ #include "config.h" #include "CrossOriginAccessControl.h" -#include "AtomicString.h" #include "HTTPParsers.h" #include "ResourceResponse.h" #include "SecurityOrigin.h" #include <wtf/Threading.h> +#include <wtf/text/AtomicString.h> namespace WebCore { diff --git a/WebCore/loader/CrossOriginPreflightResultCache.cpp b/WebCore/loader/CrossOriginPreflightResultCache.cpp index 51874d1..18e4be2 100644 --- a/WebCore/loader/CrossOriginPreflightResultCache.cpp +++ b/WebCore/loader/CrossOriginPreflightResultCache.cpp @@ -74,16 +74,16 @@ static void addToAccessControlAllowList(const String& string, unsigned start, un template<class HashType> static bool parseAccessControlAllowList(const String& string, HashSet<String, HashType>& set) { - int start = 0; - int end; - while ((end = string.find(',', start)) != -1) { + unsigned start = 0; + size_t end; + while ((end = string.find(',', start)) != notFound) { if (start == end) return false; addToAccessControlAllowList(string, start, end - 1, set); start = end + 1; } - if (start != static_cast<int>(string.length())) + if (start != string.length()) addToAccessControlAllowList(string, start, string.length() - 1, set); return true; diff --git a/WebCore/loader/CrossOriginPreflightResultCache.h b/WebCore/loader/CrossOriginPreflightResultCache.h index 0f3e356..1016aed 100644 --- a/WebCore/loader/CrossOriginPreflightResultCache.h +++ b/WebCore/loader/CrossOriginPreflightResultCache.h @@ -28,10 +28,10 @@ #define CrossOriginPreflightResultCache_h #include "KURLHash.h" -#include "StringHash.h" #include <wtf/HashMap.h> #include <wtf/HashSet.h> #include <wtf/PassOwnPtr.h> +#include <wtf/text/StringHash.h> namespace WebCore { diff --git a/WebCore/loader/DocLoader.h b/WebCore/loader/DocLoader.h index 2b43bb3..06b02c9 100644 --- a/WebCore/loader/DocLoader.h +++ b/WebCore/loader/DocLoader.h @@ -29,10 +29,10 @@ #include "CachedResource.h" #include "CachedResourceHandle.h" #include "CachePolicy.h" -#include "StringHash.h" #include <wtf/HashMap.h> #include <wtf/HashSet.h> #include <wtf/ListHashSet.h> +#include <wtf/text/StringHash.h> namespace WebCore { diff --git a/WebCore/loader/DocumentLoader.cpp b/WebCore/loader/DocumentLoader.cpp index fcc1826..26d66e8 100644 --- a/WebCore/loader/DocumentLoader.cpp +++ b/WebCore/loader/DocumentLoader.cpp @@ -86,6 +86,7 @@ DocumentLoader::DocumentLoader(const ResourceRequest& req, const SubstituteData& , m_gotFirstByte(false) , m_primaryLoadComplete(false) , m_isClientRedirect(false) + , m_wasOnloadHandled(false) , m_stopRecordingResponses(false) , m_substituteResourceDeliveryTimer(this, &DocumentLoader::substituteResourceDeliveryTimerFired) , m_didCreateGlobalHistoryEntry(false) diff --git a/WebCore/loader/DocumentLoader.h b/WebCore/loader/DocumentLoader.h index d9e7581..bc81350 100644 --- a/WebCore/loader/DocumentLoader.h +++ b/WebCore/loader/DocumentLoader.h @@ -109,6 +109,8 @@ namespace WebCore { void prepareForLoadStart(); bool isClientRedirect() const { return m_isClientRedirect; } void setIsClientRedirect(bool isClientRedirect) { m_isClientRedirect = isClientRedirect; } + void handledOnloadEvents() { m_wasOnloadHandled = true; } + bool wasOnloadHandled() { return m_wasOnloadHandled; } bool isLoadingInAPISense() const; void setPrimaryLoadComplete(bool); void setTitle(const String&); @@ -269,6 +271,7 @@ namespace WebCore { bool m_gotFirstByte; bool m_primaryLoadComplete; bool m_isClientRedirect; + bool m_wasOnloadHandled; String m_pageTitle; String m_pageIconURL; diff --git a/WebCore/loader/FTPDirectoryDocument.cpp b/WebCore/loader/FTPDirectoryDocument.cpp index 9315e45..5c7102c 100644 --- a/WebCore/loader/FTPDirectoryDocument.cpp +++ b/WebCore/loader/FTPDirectoryDocument.cpp @@ -27,9 +27,9 @@ #include "FTPDirectoryDocument.h" #include "CharacterNames.h" +#include "HTMLDocumentParser.h" #include "HTMLNames.h" #include "HTMLTableElement.h" -#include "LegacyHTMLDocumentParser.h" #include "LocalizedStrings.h" #include "Logging.h" #include "FTPDirectoryParser.h" @@ -48,13 +48,13 @@ namespace WebCore { using namespace HTMLNames; -class FTPDirectoryDocumentParser : public LegacyHTMLDocumentParser { +class FTPDirectoryDocumentParser : public HTMLDocumentParser { public: FTPDirectoryDocumentParser(HTMLDocument*); virtual void append(const SegmentedString&); virtual void finish(); - + virtual bool isWaitingForScripts() const { return false; } inline void checkBuffer(int len = 10) @@ -79,7 +79,7 @@ private: void parseAndAppendOneLine(const String&); void appendEntry(const String& name, const String& size, const String& date, bool isDirectory); PassRefPtr<Element> createTDForFilename(const String&); - + RefPtr<HTMLTableElement> m_tableElement; bool m_skipLF; @@ -94,14 +94,14 @@ private: }; FTPDirectoryDocumentParser::FTPDirectoryDocumentParser(HTMLDocument* document) - : LegacyHTMLDocumentParser(document, false) + : HTMLDocumentParser(document, false) , m_skipLF(false) , m_parsedTemplate(false) , m_size(254) , m_buffer(static_cast<UChar*>(fastMalloc(sizeof(UChar) * m_size))) , m_dest(m_buffer) { -} +} void FTPDirectoryDocumentParser::appendEntry(const String& filename, const String& size, const String& date, bool isDirectory) { @@ -109,7 +109,7 @@ void FTPDirectoryDocumentParser::appendEntry(const String& filename, const Strin RefPtr<Element> rowElement = m_tableElement->insertRow(-1, ec); rowElement->setAttribute("class", "ftpDirectoryEntryRow", ec); - + RefPtr<Element> element = document()->createElement(tdTag, false); element->appendChild(Text::create(document(), String(&noBreakSpace, 1)), ec); if (isDirectory) @@ -117,16 +117,16 @@ void FTPDirectoryDocumentParser::appendEntry(const String& filename, const Strin else element->setAttribute("class", "ftpDirectoryIcon ftpDirectoryTypeFile", ec); rowElement->appendChild(element, ec); - + element = createTDForFilename(filename); element->setAttribute("class", "ftpDirectoryFileName", ec); rowElement->appendChild(element, ec); - + element = document()->createElement(tdTag, false); element->appendChild(Text::create(document(), date), ec); element->setAttribute("class", "ftpDirectoryFileDate", ec); rowElement->appendChild(element, ec); - + element = document()->createElement(tdTag, false); element->appendChild(Text::create(document(), size), ec); element->setAttribute("class", "ftpDirectoryFileSize", ec); @@ -136,7 +136,7 @@ void FTPDirectoryDocumentParser::appendEntry(const String& filename, const Strin PassRefPtr<Element> FTPDirectoryDocumentParser::createTDForFilename(const String& filename) { ExceptionCode ec; - + String fullURL = document()->baseURL().string(); if (fullURL[fullURL.length() - 1] == '/') fullURL.append(filename); @@ -146,10 +146,10 @@ PassRefPtr<Element> FTPDirectoryDocumentParser::createTDForFilename(const String RefPtr<Element> anchorElement = document()->createElement(aTag, false); anchorElement->setAttribute("href", fullURL, ec); anchorElement->appendChild(Text::create(document(), filename), ec); - + RefPtr<Element> tdElement = document()->createElement(tdTag, false); tdElement->appendChild(anchorElement, ec); - + return tdElement.release(); } @@ -157,18 +157,18 @@ static String processFilesizeString(const String& size, bool isDirectory) { if (isDirectory) return "--"; - + bool valid; int64_t bytes = size.toUInt64(&valid); if (!valid) return unknownFileSizeText(); - + if (bytes < 1000000) return String::format("%.2f KB", static_cast<float>(bytes)/1000); if (bytes < 1000000000) return String::format("%.2f MB", static_cast<float>(bytes)/1000000); - + return String::format("%.2f GB", static_cast<float>(bytes)/1000000000); } @@ -177,19 +177,19 @@ static bool wasLastDayOfMonth(int year, int month, int day) static int lastDays[] = { 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; if (month < 0 || month > 11) return false; - + if (month == 2) { if (year % 4 == 0 && (year % 100 || year % 400 == 0)) { if (day == 29) return true; return false; } - + if (day == 28) return true; return false; } - + return lastDays[month] == day; } @@ -198,11 +198,11 @@ static String processFileDateString(const FTPTime& fileTime) // FIXME: Need to localize this string? String timeOfDay; - + if (!(fileTime.tm_hour == 0 && fileTime.tm_min == 0 && fileTime.tm_sec == 0)) { int hour = fileTime.tm_hour; ASSERT(hour >= 0 && hour < 24); - + if (hour < 12) { if (hour == 0) hour = 12; @@ -214,15 +214,15 @@ static String processFileDateString(const FTPTime& fileTime) timeOfDay = String::format(", %i:%02i PM", hour, fileTime.tm_min); } } - + // If it was today or yesterday, lets just do that - but we have to compare to the current time struct tm now; time_t now_t = time(NULL); getLocalTime(&now_t, &now); - + // localtime does "year = current year - 1900", compensate for that for readability and comparison purposes now.tm_year += 1900; - + if (fileTime.tm_year == now.tm_year) { if (fileTime.tm_mon == now.tm_mon) { if (fileTime.tm_mday == now.tm_mday) @@ -235,23 +235,23 @@ static String processFileDateString(const FTPTime& fileTime) wasLastDayOfMonth(fileTime.tm_year, fileTime.tm_mon, fileTime.tm_mday)) return "Yesterday" + timeOfDay; } - + if (fileTime.tm_year == now.tm_year - 1 && fileTime.tm_mon == 12 && fileTime.tm_mday == 31 && now.tm_mon == 1 && now.tm_mday == 1) return "Yesterday" + timeOfDay; static const char* months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "???" }; - + int month = fileTime.tm_mon; if (month < 0 || month > 11) month = 12; - + String dateString; - + if (fileTime.tm_year > -1) dateString = String::format("%s %i, %i", months[month], fileTime.tm_mday, fileTime.tm_year); else dateString = String::format("%s %i, %i", months[month], fileTime.tm_mday, now.tm_year); - + return dateString + timeOfDay; } @@ -261,22 +261,22 @@ void FTPDirectoryDocumentParser::parseAndAppendOneLine(const String& inputLine) CString latin1Input = inputLine.latin1(); FTPEntryType typeResult = parseOneFTPLine(latin1Input.data(), m_listState, result); - + // FTPMiscEntry is a comment or usage statistic which we don't care about, and junk is invalid data - bail in these 2 cases if (typeResult == FTPMiscEntry || typeResult == FTPJunkEntry) return; - + String filename(result.filename, result.filenameLength); if (result.type == FTPDirectoryEntry) { filename.append("/"); - + // We have no interest in linking to "current directory" if (filename == "./") return; } LOG(FTP, "Appending entry - %s, %s", filename.ascii().data(), result.fileSize.ascii().data()); - + appendEntry(filename, processFilesizeString(result.fileSize, result.type == FTPDirectoryEntry), processFileDateString(result.modifiedTime), result.type == FTPDirectoryEntry); } @@ -302,8 +302,8 @@ bool FTPDirectoryDocumentParser::loadDocumentTemplate() return false; } - LegacyHTMLDocumentParser::insert(String(templateDocumentData->data(), templateDocumentData->size())); - + HTMLDocumentParser::insert(String(templateDocumentData->data(), templateDocumentData->size())); + RefPtr<Element> tableElement = document()->getElementById("ftpDirectoryTable"); if (!tableElement) LOG_ERROR("Unable to find element by id \"ftpDirectoryTable\" in the template document."); @@ -329,7 +329,7 @@ bool FTPDirectoryDocumentParser::loadDocumentTemplate() body->appendChild(m_tableElement, ec); else document()->appendChild(m_tableElement, ec); - + return true; } @@ -340,10 +340,10 @@ void FTPDirectoryDocumentParser::createBasicDocument() // FIXME: Make this "basic document" more acceptable RefPtr<Element> bodyElement = document()->createElement(bodyTag, false); - + ExceptionCode ec; document()->appendChild(bodyElement, ec); - + RefPtr<Element> tableElement = document()->createElement(tableTag, false); m_tableElement = static_cast<HTMLTableElement*>(tableElement.get()); m_tableElement->setAttribute("id", "ftpDirectoryTable", ec); @@ -360,14 +360,14 @@ void FTPDirectoryDocumentParser::append(const SegmentedString& source) createBasicDocument(); ASSERT(m_tableElement); } - + bool foundNewLine = false; - + m_dest = m_buffer; SegmentedString str = source; while (!str.isEmpty()) { UChar c = *str; - + if (c == '\r') { *m_dest++ = '\n'; foundNewLine = true; @@ -382,13 +382,13 @@ void FTPDirectoryDocumentParser::append(const SegmentedString& source) *m_dest++ = c; m_skipLF = false; } - + str.advance(); - + // Maybe enlarge the buffer checkBuffer(); } - + if (!foundNewLine) { m_dest = m_buffer; return; @@ -396,7 +396,7 @@ void FTPDirectoryDocumentParser::append(const SegmentedString& source) UChar* start = m_buffer; UChar* cursor = start; - + while (cursor < m_dest) { if (*cursor == '\n') { m_carryOver.append(String(start, cursor - start)); @@ -408,7 +408,7 @@ void FTPDirectoryDocumentParser::append(const SegmentedString& source) } else cursor++; } - + // Copy the partial line we have left to the carryover buffer if (cursor - start > 1) m_carryOver.append(String(start, cursor - start - 1)); @@ -421,11 +421,11 @@ void FTPDirectoryDocumentParser::finish() parseAndAppendOneLine(m_carryOver); m_carryOver = String(); } - + m_tableElement = 0; fastFree(m_buffer); - - LegacyHTMLDocumentParser::finish(); + + HTMLDocumentParser::finish(); } FTPDirectoryDocument::FTPDirectoryDocument(Frame* frame, const KURL& url) diff --git a/WebCore/loader/FTPDirectoryParser.cpp b/WebCore/loader/FTPDirectoryParser.cpp index 142f2a3..f6a74de 100644 --- a/WebCore/loader/FTPDirectoryParser.cpp +++ b/WebCore/loader/FTPDirectoryParser.cpp @@ -188,9 +188,13 @@ FTPEntryType parseOneFTPLine(const char* line, ListState& state, ListResult& res if (pos < linelen && line[pos] == ',') { unsigned long long seconds = 0; +#if OS(WINDOWS) + sscanf(p + 1, "%I64u", &seconds); +#else sscanf(p + 1, "%llu", &seconds); +#endif time_t t = static_cast<time_t>(seconds); - + // FIXME: This code has the year 2038 bug gmtime_r(&t, &result.modifiedTime); result.modifiedTime.tm_year += 1900; diff --git a/WebCore/loader/FormSubmission.cpp b/WebCore/loader/FormSubmission.cpp index f661273..22e89d7 100644 --- a/WebCore/loader/FormSubmission.cpp +++ b/WebCore/loader/FormSubmission.cpp @@ -179,6 +179,16 @@ PassRefPtr<FormSubmission> FormSubmission::create(HTMLFormElement* form, const A return adoptRef(new FormSubmission(attributes.method(), actionURL, targetOrBaseTarget, encodingType, formState.release(), formData.release(), boundary, lockHistory, event)); } +KURL FormSubmission::requestURL() const +{ + if (m_method == FormSubmission::PostMethod) + return m_action; + + KURL requestURL(m_action); + requestURL.setQuery(m_formData->flattenToString()); + return requestURL; +} + void FormSubmission::populateFrameLoadRequest(FrameLoadRequest& frameRequest) { if (!m_target.isEmpty()) @@ -187,9 +197,7 @@ void FormSubmission::populateFrameLoadRequest(FrameLoadRequest& frameRequest) if (!m_referrer.isEmpty()) frameRequest.resourceRequest().setHTTPReferrer(m_referrer); - if (m_method == FormSubmission::GetMethod) - m_action.setQuery(m_formData->flattenToString()); - else { + if (m_method == FormSubmission::PostMethod) { frameRequest.resourceRequest().setHTTPMethod("POST"); frameRequest.resourceRequest().setHTTPBody(m_formData); @@ -200,7 +208,7 @@ void FormSubmission::populateFrameLoadRequest(FrameLoadRequest& frameRequest) frameRequest.resourceRequest().setHTTPContentType(m_contentType + "; boundary=" + m_boundary); } - frameRequest.resourceRequest().setURL(m_action); + frameRequest.resourceRequest().setURL(requestURL()); FrameLoader::addHTTPOriginIfNeeded(frameRequest.resourceRequest(), m_origin); } diff --git a/WebCore/loader/FormSubmission.h b/WebCore/loader/FormSubmission.h index bee4e71..b935882 100644 --- a/WebCore/loader/FormSubmission.h +++ b/WebCore/loader/FormSubmission.h @@ -85,6 +85,8 @@ public: static PassRefPtr<FormSubmission> create(HTMLFormElement*, const Attributes&, PassRefPtr<Event> event, bool lockHistory, FormSubmissionTrigger); void populateFrameLoadRequest(FrameLoadRequest&); + + KURL requestURL() const; Method method() const { return m_method; } const KURL& action() const { return m_action; } diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp index 8307c15..a4bc865 100644 --- a/WebCore/loader/FrameLoader.cpp +++ b/WebCore/loader/FrameLoader.cpp @@ -271,71 +271,6 @@ void FrameLoader::setDefersLoading(bool defers) } } -Frame* FrameLoader::createWindow(FrameLoader* frameLoaderForFrameLookup, const FrameLoadRequest& request, const WindowFeatures& features, bool& created) -{ - ASSERT(!features.dialog || request.frameName().isEmpty()); - - if (!request.frameName().isEmpty() && request.frameName() != "_blank") { - Frame* frame = frameLoaderForFrameLookup->frame()->tree()->find(request.frameName()); - if (frame && shouldAllowNavigation(frame)) { - if (!request.resourceRequest().url().isEmpty()) - frame->loader()->loadFrameRequest(request, false, false, 0, 0, SendReferrer); - if (Page* page = frame->page()) - page->chrome()->focus(); - created = false; - return frame; - } - } - - // Sandboxed frames cannot open new auxiliary browsing contexts. - if (isDocumentSandboxed(m_frame, SandboxNavigation)) - return 0; - - // FIXME: Setting the referrer should be the caller's responsibility. - FrameLoadRequest requestWithReferrer = request; - requestWithReferrer.resourceRequest().setHTTPReferrer(m_outgoingReferrer); - addHTTPOriginIfNeeded(requestWithReferrer.resourceRequest(), outgoingOrigin()); - - Page* oldPage = m_frame->page(); - if (!oldPage) - return 0; - - Page* page = oldPage->chrome()->createWindow(m_frame, requestWithReferrer, features); - if (!page) - return 0; - - Frame* frame = page->mainFrame(); - if (request.frameName() != "_blank") - frame->tree()->setName(request.frameName()); - - page->chrome()->setToolbarsVisible(features.toolBarVisible || features.locationBarVisible); - page->chrome()->setStatusbarVisible(features.statusBarVisible); - page->chrome()->setScrollbarsVisible(features.scrollbarsVisible); - page->chrome()->setMenubarVisible(features.menuBarVisible); - page->chrome()->setResizable(features.resizable); - - // 'x' and 'y' specify the location of the window, while 'width' and 'height' - // specify the size of the page. We can only resize the window, so - // adjust for the difference between the window size and the page size. - - FloatRect windowRect = page->chrome()->windowRect(); - FloatSize pageSize = page->chrome()->pageRect().size(); - if (features.xSet) - windowRect.setX(features.x); - if (features.ySet) - windowRect.setY(features.y); - if (features.widthSet) - windowRect.setWidth(features.width + (windowRect.width() - pageSize.width())); - if (features.heightSet) - windowRect.setHeight(features.height + (windowRect.height() - pageSize.height())); - page->chrome()->setWindowRect(windowRect); - - page->chrome()->show(); - - created = true; - return frame; -} - bool FrameLoader::canHandleRequest(const ResourceRequest& request) { return m_client->canHandleRequest(request); @@ -1160,7 +1095,7 @@ bool FrameLoader::isProcessingUserGesture() Frame* frame = m_frame->tree()->top(); if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript)) return true; // If JavaScript is disabled, a user gesture must have initiated the navigation. - return frame->script()->processingUserGesture(mainThreadNormalWorld()); // FIXME: Use pageIsProcessingUserGesture. + return ScriptController::processingUserGesture(); // FIXME: Use pageIsProcessingUserGesture. } void FrameLoader::resetMultipleFormSubmissionProtection() @@ -2660,10 +2595,12 @@ void FrameLoader::handledOnloadEvents() { m_client->dispatchDidHandleOnloadEvents(); + if (documentLoader()) { + documentLoader()->handledOnloadEvents(); #if ENABLE(OFFLINE_WEB_APPLICATIONS) - if (documentLoader()) documentLoader()->applicationCacheHost()->stopDeferringEvents(); #endif + } } void FrameLoader::frameDetached() @@ -3553,4 +3490,69 @@ bool FrameLoaderClient::hasHTMLView() const return true; } +Frame* createWindow(Frame* openerFrame, Frame* lookupFrame, const FrameLoadRequest& request, const WindowFeatures& features, bool& created) +{ + ASSERT(!features.dialog || request.frameName().isEmpty()); + + if (!request.frameName().isEmpty() && request.frameName() != "_blank") { + Frame* frame = lookupFrame->tree()->find(request.frameName()); + if (frame && openerFrame->loader()->shouldAllowNavigation(frame)) { + if (!request.resourceRequest().url().isEmpty()) + frame->loader()->loadFrameRequest(request, false, false, 0, 0, SendReferrer); + if (Page* page = frame->page()) + page->chrome()->focus(); + created = false; + return frame; + } + } + + // Sandboxed frames cannot open new auxiliary browsing contexts. + if (isDocumentSandboxed(openerFrame, SandboxNavigation)) + return 0; + + // FIXME: Setting the referrer should be the caller's responsibility. + FrameLoadRequest requestWithReferrer = request; + requestWithReferrer.resourceRequest().setHTTPReferrer(openerFrame->loader()->outgoingReferrer()); + FrameLoader::addHTTPOriginIfNeeded(requestWithReferrer.resourceRequest(), openerFrame->loader()->outgoingOrigin()); + + Page* oldPage = openerFrame->page(); + if (!oldPage) + return 0; + + Page* page = oldPage->chrome()->createWindow(openerFrame, requestWithReferrer, features); + if (!page) + return 0; + + Frame* frame = page->mainFrame(); + if (request.frameName() != "_blank") + frame->tree()->setName(request.frameName()); + + page->chrome()->setToolbarsVisible(features.toolBarVisible || features.locationBarVisible); + page->chrome()->setStatusbarVisible(features.statusBarVisible); + page->chrome()->setScrollbarsVisible(features.scrollbarsVisible); + page->chrome()->setMenubarVisible(features.menuBarVisible); + page->chrome()->setResizable(features.resizable); + + // 'x' and 'y' specify the location of the window, while 'width' and 'height' + // specify the size of the page. We can only resize the window, so + // adjust for the difference between the window size and the page size. + + FloatRect windowRect = page->chrome()->windowRect(); + FloatSize pageSize = page->chrome()->pageRect().size(); + if (features.xSet) + windowRect.setX(features.x); + if (features.ySet) + windowRect.setY(features.y); + if (features.widthSet) + windowRect.setWidth(features.width + (windowRect.width() - pageSize.width())); + if (features.heightSet) + windowRect.setHeight(features.height + (windowRect.height() - pageSize.height())); + page->chrome()->setWindowRect(windowRect); + + page->chrome()->show(); + + created = true; + return frame; +} + } // namespace WebCore diff --git a/WebCore/loader/FrameLoader.h b/WebCore/loader/FrameLoader.h index de043d2..639b6cc 100644 --- a/WebCore/loader/FrameLoader.h +++ b/WebCore/loader/FrameLoader.h @@ -124,10 +124,6 @@ public: static void reportLocalLoadFailed(Frame*, const String& url); - // Called by createWindow in JSDOMWindowBase.cpp, e.g. to fulfill a modal dialog creation - // FIXME: Move this method outside of the FrameLoader class. - Frame* createWindow(FrameLoader* frameLoaderForFrameLookup, const FrameLoadRequest&, const WindowFeatures&, bool& created); - unsigned long loadResourceSynchronously(const ResourceRequest&, StoredCredentials, ResourceError&, ResourceResponse&, Vector<char>& data); bool canHandleRequest(const ResourceRequest&); @@ -505,6 +501,15 @@ private: #endif }; +// This function is called by createWindow() in JSDOMWindowBase.cpp, for example, for +// modal dialog creation. The lookupFrame is for looking up the frame name in case +// the frame name references a frame different from the openerFrame, e.g. when it is +// "_self" or "_parent". +// +// FIXME: Consider making this function part of an appropriate class (not FrameLoader) +// and moving it to a more appropriate location. +Frame* createWindow(Frame* openerFrame, Frame* lookupFrame, const FrameLoadRequest&, const WindowFeatures&, bool& created); + } // namespace WebCore #endif // FrameLoader_h diff --git a/WebCore/loader/FrameNetworkingContext.h b/WebCore/loader/FrameNetworkingContext.h new file mode 100644 index 0000000..dff1144 --- /dev/null +++ b/WebCore/loader/FrameNetworkingContext.h @@ -0,0 +1,51 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + 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. +*/ + +#ifndef FrameNetworkingContext_h +#define FrameNetworkingContext_h + +#include "Frame.h" +#include "NetworkingContext.h" + +namespace WebCore { + +class FrameNetworkingContext : public NetworkingContext { +public: + void invalidate() + { + m_frame = 0; + } + +protected: + FrameNetworkingContext(Frame* frame) + : m_frame(frame) + { + } + + Frame* frame() const { return m_frame; } + +private: + virtual bool isValid() const { return m_frame; } + + Frame* m_frame; +}; + +} + +#endif // FrameNetworkingContext_h diff --git a/WebCore/loader/ImageLoader.h b/WebCore/loader/ImageLoader.h index a585354..02ddce8 100644 --- a/WebCore/loader/ImageLoader.h +++ b/WebCore/loader/ImageLoader.h @@ -23,9 +23,9 @@ #ifndef ImageLoader_h #define ImageLoader_h -#include "AtomicString.h" #include "CachedResourceClient.h" #include "CachedResourceHandle.h" +#include <wtf/text/AtomicString.h> namespace WebCore { diff --git a/WebCore/loader/MainResourceLoader.cpp b/WebCore/loader/MainResourceLoader.cpp index c03f9ca..a7a5968 100644 --- a/WebCore/loader/MainResourceLoader.cpp +++ b/WebCore/loader/MainResourceLoader.cpp @@ -305,8 +305,8 @@ void MainResourceLoader::substituteMIMETypeFromPluginDatabase(const ResourceResp if (filename.endsWith("/")) return; - int extensionPos = filename.reverseFind('.'); - if (extensionPos == -1) + size_t extensionPos = filename.reverseFind('.'); + if (extensionPos == notFound) return; String extension = filename.substring(extensionPos + 1); diff --git a/WebCore/loader/RedirectScheduler.cpp b/WebCore/loader/RedirectScheduler.cpp index 3cfe61a..d969f30 100644 --- a/WebCore/loader/RedirectScheduler.cpp +++ b/WebCore/loader/RedirectScheduler.cpp @@ -175,15 +175,13 @@ public: ScheduledFormSubmission(PassRefPtr<FormSubmission> submission, bool lockBackForwardList, bool duringLoad) : ScheduledNavigation(0, submission->lockHistory(), lockBackForwardList, duringLoad, true) , m_submission(submission) - , m_wasProcessingUserGesture(UserGestureIndicator::processingUserGesture()) + , m_haveToldClient(false) { ASSERT(m_submission->state()); } virtual void fire(Frame* frame) { - UserGestureIndicator gestureIndicator(m_wasProcessingUserGesture ? DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture); - // The submitForm function will find a target frame before using the redirection timer. // Now that the timer has fired, we need to repeat the security check which normally is done when // selecting a target, in case conditions have changed. Other code paths avoid this by targeting @@ -194,15 +192,25 @@ public: m_submission->populateFrameLoadRequest(frameRequest); frame->loader()->loadFrameRequest(frameRequest, lockHistory(), lockBackForwardList(), m_submission->event(), m_submission->state(), SendReferrer); } + + virtual void didStartTimer(Frame* frame, Timer<RedirectScheduler>* timer) + { + if (m_haveToldClient) + return; + m_haveToldClient = true; + frame->loader()->clientRedirected(m_submission->requestURL(), delay(), currentTime() + timer->nextFireInterval(), lockBackForwardList()); + } - // FIXME: Implement didStartTimer? It would make sense to report form - // submissions as client redirects too. But we didn't do that in the past - // when form submission used a separate delay mechanism, so doing it will - // be a behavior change. + virtual void didStopTimer(Frame* frame, bool newLoadInProgress) + { + if (!m_haveToldClient) + return; + frame->loader()->clientRedirectCancelledOrFinished(newLoadInProgress); + } private: RefPtr<FormSubmission> m_submission; - bool m_wasProcessingUserGesture; + bool m_haveToldClient; }; RedirectScheduler::RedirectScheduler(Frame* frame) @@ -240,17 +248,21 @@ void RedirectScheduler::scheduleRedirect(double delay, const String& url) if (url.isEmpty()) return; - // We want a new history item if the refresh timeout is > 1 second. + // We want a new back/forward list item if the refresh timeout is > 1 second. if (!m_redirect || delay <= m_redirect->delay()) schedule(new ScheduledRedirect(delay, url, true, delay <= 1, false)); } -bool RedirectScheduler::mustLockBackForwardList(Frame* targetFrame) +bool RedirectScheduler::mustLockBackForwardList(Frame* targetFrame, bool wasUserGesture) { + // Non-user navigation before the page has finished firing onload should not create a new back/forward item. + // See https://webkit.org/b/42861 for the original motivation for this. + if (!wasUserGesture && targetFrame->loader()->documentLoader() && !targetFrame->loader()->documentLoader()->wasOnloadHandled()) + return true; + // Navigation of a subframe during loading of an ancestor frame does not create a new back/forward item. // The definition of "during load" is any time before all handlers for the load event have been run. // See https://bugs.webkit.org/show_bug.cgi?id=14957 for the original motivation for this. - for (Frame* ancestor = targetFrame->tree()->parent(); ancestor; ancestor = ancestor->tree()->parent()) { Document* document = ancestor->document(); if (!ancestor->loader()->isComplete() || (document && document->processingLoadEvent())) @@ -266,7 +278,7 @@ void RedirectScheduler::scheduleLocationChange(const String& url, const String& if (url.isEmpty()) return; - lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame); + lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame, wasUserGesture); FrameLoader* loader = m_frame->loader(); @@ -300,7 +312,7 @@ void RedirectScheduler::scheduleFormSubmission(PassRefPtr<FormSubmission> submis // to match IE and Opera. // See https://bugs.webkit.org/show_bug.cgi?id=32383 for the original motivation for this. - bool lockBackForwardList = mustLockBackForwardList(m_frame) || (submission->state()->formSubmissionTrigger() == SubmittedByJavaScript && m_frame->tree()->parent()); + bool lockBackForwardList = mustLockBackForwardList(m_frame, UserGestureIndicator::processingUserGesture()) || (submission->state()->formSubmissionTrigger() == SubmittedByJavaScript && m_frame->tree()->parent()); schedule(new ScheduledFormSubmission(submission, lockBackForwardList, duringLoad)); } diff --git a/WebCore/loader/RedirectScheduler.h b/WebCore/loader/RedirectScheduler.h index 0203e08..70b0202 100644 --- a/WebCore/loader/RedirectScheduler.h +++ b/WebCore/loader/RedirectScheduler.h @@ -70,7 +70,7 @@ private: void timerFired(Timer<RedirectScheduler>*); void schedule(PassOwnPtr<ScheduledNavigation>); - static bool mustLockBackForwardList(Frame* targetFrame); + static bool mustLockBackForwardList(Frame* targetFrame, bool mustLockIfDuringLoad); Frame* m_frame; Timer<RedirectScheduler> m_timer; @@ -79,4 +79,4 @@ private: } // namespace WebCore -#endif // FrameLoader_h +#endif // RedirectScheduler_h diff --git a/WebCore/loader/appcache/ApplicationCache.cpp b/WebCore/loader/appcache/ApplicationCache.cpp index 2ad4a4b..2a93765 100644 --- a/WebCore/loader/appcache/ApplicationCache.cpp +++ b/WebCore/loader/appcache/ApplicationCache.cpp @@ -32,6 +32,7 @@ #include "ApplicationCacheResource.h" #include "ApplicationCacheStorage.h" #include "ResourceRequest.h" +#include <wtf/text/CString.h> #include <stdio.h> namespace WebCore { diff --git a/WebCore/loader/appcache/ApplicationCache.h b/WebCore/loader/appcache/ApplicationCache.h index d6e15ed..f073499 100644 --- a/WebCore/loader/appcache/ApplicationCache.h +++ b/WebCore/loader/appcache/ApplicationCache.h @@ -29,11 +29,11 @@ #if ENABLE(OFFLINE_WEB_APPLICATIONS) #include "PlatformString.h" -#include "StringHash.h" #include <wtf/HashMap.h> #include <wtf/HashSet.h> #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> +#include <wtf/text/StringHash.h> namespace WebCore { diff --git a/WebCore/loader/appcache/ApplicationCacheStorage.cpp b/WebCore/loader/appcache/ApplicationCacheStorage.cpp index 5624809..5a82d6e 100644 --- a/WebCore/loader/appcache/ApplicationCacheStorage.cpp +++ b/WebCore/loader/appcache/ApplicationCacheStorage.cpp @@ -968,8 +968,8 @@ bool ApplicationCacheStorage::storeNewestCache(ApplicationCacheGroup* group) static inline void parseHeader(const UChar* header, size_t headerLength, ResourceResponse& response) { - int pos = find(header, headerLength, ':'); - ASSERT(pos != -1); + size_t pos = find(header, headerLength, ':'); + ASSERT(pos != notFound); AtomicString headerName = AtomicString(header, pos); String headerValue = String(header + pos + 1, headerLength - pos - 1); @@ -979,9 +979,9 @@ static inline void parseHeader(const UChar* header, size_t headerLength, Resourc static inline void parseHeaders(const String& headers, ResourceResponse& response) { - int startPos = 0; - int endPos; - while ((endPos = headers.find('\n', startPos)) != -1) { + unsigned startPos = 0; + size_t endPos; + while ((endPos = headers.find('\n', startPos)) != notFound) { ASSERT(startPos != endPos); parseHeader(headers.characters() + startPos, endPos - startPos, response); @@ -989,7 +989,7 @@ static inline void parseHeaders(const String& headers, ResourceResponse& respons startPos = endPos + 1; } - if (startPos != static_cast<int>(headers.length())) + if (startPos != headers.length()) parseHeader(headers.characters(), headers.length(), response); } diff --git a/WebCore/loader/appcache/ApplicationCacheStorage.h b/WebCore/loader/appcache/ApplicationCacheStorage.h index c990fa7..7db34e6 100644 --- a/WebCore/loader/appcache/ApplicationCacheStorage.h +++ b/WebCore/loader/appcache/ApplicationCacheStorage.h @@ -30,9 +30,8 @@ #include "PlatformString.h" #include "SQLiteDatabase.h" -#include "StringHash.h" - #include <wtf/HashCountedSet.h> +#include <wtf/text/StringHash.h> namespace WebCore { diff --git a/WebCore/loader/appcache/DOMApplicationCache.h b/WebCore/loader/appcache/DOMApplicationCache.h index de0614a..2a806fa 100644 --- a/WebCore/loader/appcache/DOMApplicationCache.h +++ b/WebCore/loader/appcache/DOMApplicationCache.h @@ -29,7 +29,6 @@ #if ENABLE(OFFLINE_WEB_APPLICATIONS) #include "ApplicationCacheHost.h" -#include "AtomicStringHash.h" #include "EventListener.h" #include "EventNames.h" #include "EventTarget.h" @@ -38,6 +37,7 @@ #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> #include <wtf/Vector.h> +#include <wtf/text/AtomicStringHash.h> namespace WebCore { diff --git a/WebCore/loader/icon/IconDatabase.cpp b/WebCore/loader/icon/IconDatabase.cpp index b8149d2..63b9c64 100644 --- a/WebCore/loader/icon/IconDatabase.cpp +++ b/WebCore/loader/icon/IconDatabase.cpp @@ -1315,7 +1315,7 @@ void IconDatabase::performURLImport() } } - LOG(IconDatabase, "Notifying %zu interested page URLs that their icon URL is known due to the import", urlsToNotify.size()); + LOG(IconDatabase, "Notifying %lu interested page URLs that their icon URL is known due to the import", static_cast<unsigned long>(urlsToNotify.size())); // Now that we don't hold any locks, perform the actual notifications for (unsigned i = 0; i < urlsToNotify.size(); ++i) { LOG(IconDatabase, "Notifying icon info known for pageURL %s", urlsToNotify[i].ascii().data()); @@ -1639,11 +1639,19 @@ void IconDatabase::pruneUnretainedIcons() SQLiteStatement pageDeleteSQL(m_syncDB, "DELETE FROM PageURL WHERE rowid = (?);"); pageDeleteSQL.prepare(); for (size_t i = 0; i < numToDelete; ++i) { +#if OS(WINDOWS) + LOG(IconDatabase, "Pruning page with rowid %I64i from disk", static_cast<long long>(pageIDsToDelete[i])); +#else LOG(IconDatabase, "Pruning page with rowid %lli from disk", static_cast<long long>(pageIDsToDelete[i])); +#endif pageDeleteSQL.bindInt64(1, pageIDsToDelete[i]); int result = pageDeleteSQL.step(); if (result != SQLResultDone) +#if OS(WINDOWS) + LOG_ERROR("Unabled to delete page with id %I64i from disk", static_cast<long long>(pageIDsToDelete[i])); +#else LOG_ERROR("Unabled to delete page with id %lli from disk", static_cast<long long>(pageIDsToDelete[i])); +#endif pageDeleteSQL.reset(); // If the thread was asked to terminate, we should commit what pruning we've done so far, figuring we can diff --git a/WebCore/loader/icon/IconDatabase.h b/WebCore/loader/icon/IconDatabase.h index 44ef22a..9793d21 100644 --- a/WebCore/loader/icon/IconDatabase.h +++ b/WebCore/loader/icon/IconDatabase.h @@ -27,12 +27,12 @@ #ifndef IconDatabase_h #define IconDatabase_h -#include "StringHash.h" #include "Timer.h" #include <wtf/HashMap.h> #include <wtf/HashSet.h> #include <wtf/Noncopyable.h> #include <wtf/OwnPtr.h> +#include <wtf/text/StringHash.h> #if ENABLE(ICONDATABASE) #include "SQLiteDatabase.h" diff --git a/WebCore/loader/icon/IconFetcher.cpp b/WebCore/loader/icon/IconFetcher.cpp index 3d3df39..1107d7b 100644 --- a/WebCore/loader/icon/IconFetcher.cpp +++ b/WebCore/loader/icon/IconFetcher.cpp @@ -87,8 +87,8 @@ static void parseIconLink(HTMLLinkElement* link, Vector<IconLinkEntry>& entries) // Try to determine the file type. String path = url.path(); - int pos = path.reverseFind('.'); - if (pos >= 0) { + size_t pos = path.reverseFind('.'); + if (pos != notFound) { String extension = path.substring(pos + 1); if (equalIgnoringCase(extension, "icns")) type = IconLinkEntry::ICNS; diff --git a/WebCore/loader/icon/IconRecord.cpp b/WebCore/loader/icon/IconRecord.cpp index ffea318..7e90d8e 100644 --- a/WebCore/loader/icon/IconRecord.cpp +++ b/WebCore/loader/icon/IconRecord.cpp @@ -34,6 +34,7 @@ #include "Logging.h" #include "SQLiteStatement.h" #include "SQLiteTransaction.h" +#include <wtf/text/CString.h> #include <limits.h> diff --git a/WebCore/loader/icon/IconRecord.h b/WebCore/loader/icon/IconRecord.h index aaea787..f1fe12f 100644 --- a/WebCore/loader/icon/IconRecord.h +++ b/WebCore/loader/icon/IconRecord.h @@ -33,10 +33,10 @@ #include <wtf/RefCounted.h> #include "SharedBuffer.h" +#include "PlatformString.h" #include <wtf/HashSet.h> #include <wtf/OwnPtr.h> -#include "PlatformString.h" -#include "StringHash.h" +#include <wtf/text/StringHash.h> namespace WebCore { diff --git a/WebCore/loader/loader.h b/WebCore/loader/loader.h index 1fdb9cf..52c61aa 100644 --- a/WebCore/loader/loader.h +++ b/WebCore/loader/loader.h @@ -22,8 +22,6 @@ #ifndef loader_h #define loader_h -#include "AtomicString.h" -#include "AtomicStringImpl.h" #include "FrameLoaderTypes.h" #include "PlatformString.h" #include "SubresourceLoaderClient.h" @@ -31,6 +29,8 @@ #include <wtf/Deque.h> #include <wtf/HashMap.h> #include <wtf/Noncopyable.h> +#include <wtf/text/AtomicString.h> +#include <wtf/text/AtomicStringImpl.h> namespace WebCore { |