Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Unified Diff: third_party/WebKit/Source/core/dom/DOMURL.cpp

Issue 1860623002: Add support for URL.searchParams getter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMURL.h ('k') | third_party/WebKit/Source/core/dom/DOMURLUtils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/DOMURL.cpp
diff --git a/third_party/WebKit/Source/core/dom/DOMURL.cpp b/third_party/WebKit/Source/core/dom/DOMURL.cpp
index e0679ba650f8e1e82540b1aaa50af0a9466605d9..1b1373b96f9ef4f977f6d0c17e8fd3e6b5227c86 100644
--- a/third_party/WebKit/Source/core/dom/DOMURL.cpp
+++ b/third_party/WebKit/Source/core/dom/DOMURL.cpp
@@ -30,24 +30,37 @@
#include "bindings/core/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContext.h"
+#include "core/dom/URLSearchParams.h"
#include "core/fetch/MemoryCache.h"
#include "core/fileapi/Blob.h"
#include "core/html/PublicURLManager.h"
#include "platform/blob/BlobURL.h"
#include "platform/weborigin/SecurityOrigin.h"
+#include "wtf/TemporaryChange.h"
namespace blink {
DOMURL::DOMURL(const String& url, const KURL& base, ExceptionState& exceptionState)
{
- if (!base.isValid())
+ if (!base.isValid()) {
exceptionState.throwTypeError("Invalid base URL");
+ return;
+ }
m_url = KURL(base, url);
if (!m_url.isValid())
exceptionState.throwTypeError("Invalid URL");
}
+DOMURL::~DOMURL()
+{
+}
+
+DEFINE_TRACE(DOMURL)
+{
+ visitor->trace(m_searchParams);
+}
+
void DOMURL::setInput(const String& value)
{
KURL url(blankURL(), value);
@@ -58,6 +71,16 @@ void DOMURL::setInput(const String& value)
m_url = KURL();
m_input = value;
}
+ update();
+}
+
+void DOMURL::setSearch(const String& value)
+{
+ DOMURLUtils::setSearch(value);
+ if (!value.isEmpty() && value[0] == '?')
+ updateSearchParams(value.substring(1));
+ else
+ updateSearchParams(value);
}
String DOMURL::createObjectURL(ExecutionContext* executionContext, Blob* blob, ExceptionState& exceptionState)
@@ -101,4 +124,27 @@ void DOMURL::revokeObjectUUID(ExecutionContext* executionContext, const String&
executionContext->publicURLManager().revoke(uuid);
}
+URLSearchParams* DOMURL::searchParams()
+{
+ if (!m_searchParams)
+ m_searchParams = URLSearchParams::create(url().query(), this);
+
+ return m_searchParams;
+}
+
+void DOMURL::update()
+{
+ updateSearchParams(url().query());
+}
+
+void DOMURL::updateSearchParams(const String& queryString)
+{
+ if (!m_searchParams)
+ return;
+
+ TemporaryChange<bool> scope(m_isInUpdate, true);
+ ASSERT(m_searchParams->urlObject() == this);
+ m_searchParams->setInput(queryString);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMURL.h ('k') | third_party/WebKit/Source/core/dom/DOMURLUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698