Chromium Code Reviews| 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..05f4ccf519a7e738bb2c1cb3dad32d67c1d81e90 |
| --- /dev/null |
| +++ b/Source/bindings/v8/custom/V8URLSearchParamsCustom.cpp |
| @@ -0,0 +1,76 @@ |
| +/* |
| + * 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/V8Binding.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::visitDOMWrapper(void* object, const v8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate) |
| +{ |
| + 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); |
|
arv (Not doing code reviews)
2014/01/21 14:40:33
Maybe extract to a template helper function so you
|
| + 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 |