Index: Source/bindings/v8/custom/V8URLSearchParamsCustom.cpp |
diff --git a/Source/bindings/v8/custom/V8URLSearchParamsCustom.cpp b/Source/bindings/v8/custom/V8URLSearchParamsCustom.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ca866d933ba11c097cee8942faadd2fedc3b3b64 |
--- /dev/null |
+++ b/Source/bindings/v8/custom/V8URLSearchParamsCustom.cpp |
@@ -0,0 +1,103 @@ |
+/* |
+ * Copyright (c) 2014, Opera Software ASA. All rights reserved. |
+ * |
+ * Redistribution and use in source and binary forms, with or without |
+ * modification, are permitted provided that the following conditions |
+ * are met: |
+ * 1. Redistributions of source code must retain the above copyright |
+ * notice, this list of conditions and the following disclaimer. |
+ * 2. Redistributions in binary form must reproduce the above copyright |
+ * notice, this list of conditions and the following disclaimer in the |
+ * documentation and/or other materials provided with the distribution. |
+ * 3. Neither the name of Opera Software ASA nor the names of its |
+ * contributors may be used to endorse or promote products derived |
+ * from this software without specific prior written permission. |
+ * |
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
+ * OF THE POSSIBILITY OF SUCH DAMAGE. |
+ */ |
+ |
+#include "config.h" |
+#include "V8URLSearchParams.h" |
+ |
+#include "V8HTMLAnchorElement.h" |
+#include "V8URL.h" |
+#include "bindings/v8/ExceptionState.h" |
+#include "bindings/v8/V8Binding.h" |
+#include "bindings/v8/V8BindingMacros.h" |
+#include "bindings/v8/V8DOMWrapper.h" |
+#include "bindings/v8/V8GCController.h" |
+#include "bindings/v8/V8Utilities.h" |
+#include "core/dom/DOMURL.h" |
+#include "core/dom/DOMURLSearchParams.h" |
+#include "core/dom/DOMURLUtils.h" |
+ |
+namespace WebCore { |
+ |
+void V8URLSearchParams::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
arv (Not doing code reviews)
2014/01/22 16:12:05
It is not clear to me why this needs a custom cons
sof
2014/01/22 17:15:47
Ah, it is possible to do without -- I overlooked s
|
+{ |
+ ExceptionState exceptionState(ExceptionState::ConstructionContext, "URLSearchParams", info.Holder(), info.GetIsolate()); |
+ if (!info.Length()) { |
+ RefPtr<DOMURLSearchParams> searchParams = DOMURLSearchParams::create(); |
+ v8SetReturnValue(info, searchParams.release()); |
+ return; |
+ } |
+ |
+ v8::Handle<v8::Object> wrapper = info.Holder(); |
+ RefPtr<DOMURLSearchParams> searchParams; |
+ if (V8URLSearchParams::hasInstance(info[0], info.GetIsolate(), worldType(info.GetIsolate()))) { |
arv (Not doing code reviews)
2014/01/22 16:12:05
I thought hasInstance was updated. Did you sync re
|
+ V8TRYCATCH_EXCEPTION_VOID(DOMURLSearchParams*, initial, V8URLSearchParams::toNative(v8::Handle<v8::Object>::Cast(info[0])), exceptionState); |
+ searchParams = DOMURLSearchParams::create(initial); |
+ } else if (info[0]->IsString()) { |
+ searchParams = DOMURLSearchParams::create(toCoreString(info[0].As<v8::String>())); |
+ } else { |
+ exceptionState.throwTypeError("Argument not a string nor a URLSearchParams object."); |
+ exceptionState.throwIfNeeded(); |
+ return; |
+ } |
+ V8DOMWrapper::associateObjectWithWrapper<V8URLSearchParams>(searchParams.release(), &V8URLSearchParams::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent); |
+ v8SetReturnValue(info, wrapper); |
+} |
+ |
+void V8URLSearchParams::visitDOMWrapper(void* object, const v8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate) |
arv (Not doing code reviews)
2014/01/22 16:12:05
Could this be done with GenerateVisitDOMWrapper=ow
sof
2014/01/22 17:15:47
Definitely agree with that. The complexity enters
|
+{ |
+ DOMURLSearchParams* impl = fromInternalPointer(object); |
+ v8::Local<v8::Object> creationContext = v8::Local<v8::Object>::New(isolate, wrapper); |
+ V8WrapperInstantiationScope scope(creationContext, isolate); |
+ if (DOMURLUtils* urlObject = impl->urlObject()) { |
+ switch (urlObject->implementedBy()) { |
+ case DOMURLUtils::Anchor: { |
+ HTMLAnchorElement* anchor = static_cast<HTMLAnchorElement*>(urlObject); |
+ if (!DOMDataStore::containsWrapper<V8HTMLAnchorElement>(anchor, isolate)) |
+ wrap(anchor, creationContext, isolate); |
+ DOMDataStore::setWrapperReference<V8HTMLAnchorElement>(wrapper, anchor, isolate); |
+ break; |
+ } |
+ case DOMURLUtils::DomURL: { |
+ DOMURL* domURL = static_cast<DOMURL*>(urlObject); |
+ if (!DOMDataStore::containsWrapper<V8URL>(domURL, isolate)) |
+ wrap(domURL, creationContext, isolate); |
+ DOMDataStore::setWrapperReference<V8URL>(wrapper, domURL, isolate); |
+ break; |
+ } |
+ default: |
+ // Either an entirely unexpected condition or you've forgotten to |
+ // extend this switch to include handling for a new type. |
+ ASSERT_NOT_REACHED(); |
+ break; |
+ } |
+ } |
+ setObjectGroup(object, wrapper, isolate); |
+} |
+ |
+} // namespace WebCore |