diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-07 11:21:11 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-07 11:21:11 +0200 |
commit | 2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 (patch) | |
tree | 988e8c5b116dd0466244ae2fe5af8ee9be926d76 /Source/WebCore/page/Location.cpp | |
parent | dd91e772430dc294e3bf478c119ef8d43c0a3358 (diff) | |
download | qtwebkit-2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47.tar.gz |
Imported WebKit commit 7e538425aa020340619e927792f3d895061fb54b (http://svn.webkit.org/repository/webkit/trunk@116286)
Diffstat (limited to 'Source/WebCore/page/Location.cpp')
-rw-r--r-- | Source/WebCore/page/Location.cpp | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/Source/WebCore/page/Location.cpp b/Source/WebCore/page/Location.cpp index 1a2d2db99..f6511d6a3 100644 --- a/Source/WebCore/page/Location.cpp +++ b/Source/WebCore/page/Location.cpp @@ -124,6 +124,16 @@ String Location::origin() const return SecurityOrigin::create(url())->toString(); } +PassRefPtr<DOMStringList> Location::ancestorOrigins() const +{ + RefPtr<DOMStringList> origins = DOMStringList::create(); + if (!m_frame) + return origins.release(); + for (Frame* frame = m_frame->tree()->parent(true); frame; frame = frame->tree()->parent(true)) + origins->append(frame->document()->securityOrigin()->toString()); + return origins.release(); +} + String Location::hash() const { if (!m_frame) @@ -133,11 +143,11 @@ String Location::hash() const return fragmentIdentifier.isEmpty() ? emptyString() : "#" + fragmentIdentifier; } -void Location::setHref(const String& urlString, DOMWindow* activeWindow, DOMWindow* firstWindow) +void Location::setHref(const String& url, DOMWindow* activeWindow, DOMWindow* firstWindow) { if (!m_frame) return; - m_frame->domWindow()->setLocation(urlString, activeWindow, firstWindow); + setLocation(url, activeWindow, firstWindow); } void Location::setProtocol(const String& protocol, DOMWindow* activeWindow, DOMWindow* firstWindow, ExceptionCode& ec) @@ -149,7 +159,7 @@ void Location::setProtocol(const String& protocol, DOMWindow* activeWindow, DOMW ec = SYNTAX_ERR; return; } - m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow); + setLocation(url.string(), activeWindow, firstWindow); } void Location::setHost(const String& host, DOMWindow* activeWindow, DOMWindow* firstWindow) @@ -158,7 +168,7 @@ void Location::setHost(const String& host, DOMWindow* activeWindow, DOMWindow* f return; KURL url = m_frame->document()->url(); url.setHostAndPort(host); - m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow); + setLocation(url.string(), activeWindow, firstWindow); } void Location::setHostname(const String& hostname, DOMWindow* activeWindow, DOMWindow* firstWindow) @@ -167,7 +177,7 @@ void Location::setHostname(const String& hostname, DOMWindow* activeWindow, DOMW return; KURL url = m_frame->document()->url(); url.setHost(hostname); - m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow); + setLocation(url.string(), activeWindow, firstWindow); } void Location::setPort(const String& portString, DOMWindow* activeWindow, DOMWindow* firstWindow) @@ -180,7 +190,7 @@ void Location::setPort(const String& portString, DOMWindow* activeWindow, DOMWin url.removePort(); else url.setPort(port); - m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow); + setLocation(url.string(), activeWindow, firstWindow); } void Location::setPathname(const String& pathname, DOMWindow* activeWindow, DOMWindow* firstWindow) @@ -189,7 +199,7 @@ void Location::setPathname(const String& pathname, DOMWindow* activeWindow, DOMW return; KURL url = m_frame->document()->url(); url.setPath(pathname); - m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow); + setLocation(url.string(), activeWindow, firstWindow); } void Location::setSearch(const String& search, DOMWindow* activeWindow, DOMWindow* firstWindow) @@ -198,7 +208,7 @@ void Location::setSearch(const String& search, DOMWindow* activeWindow, DOMWindo return; KURL url = m_frame->document()->url(); url.setQuery(search); - m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow); + setLocation(url.string(), activeWindow, firstWindow); } void Location::setHash(const String& hash, DOMWindow* activeWindow, DOMWindow* firstWindow) @@ -216,21 +226,22 @@ void Location::setHash(const String& hash, DOMWindow* activeWindow, DOMWindow* f // cases where fragment identifiers are ignored or invalid. if (equalIgnoringNullity(oldFragmentIdentifier, url.fragmentIdentifier())) return; - m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow); + setLocation(url.string(), activeWindow, firstWindow); } -void Location::assign(const String& urlString, DOMWindow* activeWindow, DOMWindow* firstWindow) +void Location::assign(const String& url, DOMWindow* activeWindow, DOMWindow* firstWindow) { if (!m_frame) return; - m_frame->domWindow()->setLocation(urlString, activeWindow, firstWindow); + setLocation(url, activeWindow, firstWindow); } -void Location::replace(const String& urlString, DOMWindow* activeWindow, DOMWindow* firstWindow) +void Location::replace(const String& url, DOMWindow* activeWindow, DOMWindow* firstWindow) { if (!m_frame) return; - m_frame->domWindow()->setLocation(urlString, activeWindow, firstWindow, LockHistoryAndBackForwardList); + // Note: We call DOMWindow::setLocation directly here because replace() always operates on the current frame. + m_frame->domWindow()->setLocation(url, activeWindow, firstWindow, LockHistoryAndBackForwardList); } void Location::reload(DOMWindow* activeWindow) @@ -250,4 +261,14 @@ void Location::reload(DOMWindow* activeWindow) m_frame->navigationScheduler()->scheduleRefresh(); } +void Location::setLocation(const String& url, DOMWindow* activeWindow, DOMWindow* firstWindow) +{ + ASSERT(m_frame); + // We call findFrameForNavigation to handle the case of a seamless iframe correctly. + Frame* frame = m_frame->loader()->findFrameForNavigation(String(), activeWindow->document()); + if (!frame) + return; + frame->domWindow()->setLocation(url, activeWindow, firstWindow); +} + } // namespace WebCore |