Chromium Code Reviews| 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 ce37ba6da33ff0fa0d2078ada787ca4692aa8fa5..a9e6953f0ba4d0a0e634e4b0b5b83effe7fabe53 100644 |
| --- a/third_party/WebKit/Source/core/dom/DOMURL.cpp |
| +++ b/third_party/WebKit/Source/core/dom/DOMURL.cpp |
| @@ -30,6 +30,7 @@ |
| #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" |
| @@ -40,14 +41,21 @@ namespace blink { |
| DOMURL::DOMURL(const String& url, const KURL& base, ExceptionState& exceptionState) |
| { |
| - if (!base.isValid()) |
| + if (!base.isValid()) { |
| exceptionState.throwTypeError("Invalid base URL"); |
| + return; |
| + } |
|
Mike West
2016/04/05 12:43:51
Whoops! Nice catch. Is there a test for this?
sof
2016/04/05 15:23:18
The final test in url-constructor.html
|
| m_url = KURL(base, url); |
| if (!m_url.isValid()) |
| exceptionState.throwTypeError("Invalid URL"); |
| } |
| +DEFINE_TRACE(DOMURL) |
| +{ |
| + visitor->trace(m_searchParams); |
| +} |
| + |
| void DOMURL::setInput(const String& value) |
| { |
| KURL url(blankURL(), value); |
| @@ -58,6 +66,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] == '?') |
|
Mike West
2016/04/05 12:43:51
Nit: It might make sense to move this check into `
sof
2016/04/05 15:23:18
That won't quite work if you set url.href with som
|
| + updateSearchParams(value.substring(1)); |
| + else |
| + updateSearchParams(value); |
| } |
| String DOMURL::createObjectURL(ExecutionContext* executionContext, Blob* blob, ExceptionState& exceptionState) |
| @@ -101,4 +119,26 @@ 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; |
| + |
| + ASSERT(m_searchParams->urlObject() == this); |
| + m_searchParams->setInput(queryString); |
| +} |
| + |
| } // namespace blink |