diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/bindings/js/JSNodeCustom.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/bindings/js/JSNodeCustom.h')
-rw-r--r-- | Source/WebCore/bindings/js/JSNodeCustom.h | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/Source/WebCore/bindings/js/JSNodeCustom.h b/Source/WebCore/bindings/js/JSNodeCustom.h index 2880274ed..6779dad32 100644 --- a/Source/WebCore/bindings/js/JSNodeCustom.h +++ b/Source/WebCore/bindings/js/JSNodeCustom.h @@ -10,10 +10,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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 @@ -23,26 +23,26 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JSNodeCustom_h -#define JSNodeCustom_h +#pragma once #include "JSDOMBinding.h" #include "JSNode.h" -#include "ScriptState.h" #include "ShadowRoot.h" namespace WebCore { -JSC::JSValue createWrapper(JSC::ExecState*, JSDOMGlobalObject*, Node*); +WEBCORE_EXPORT JSC::JSValue createWrapper(JSC::ExecState*, JSDOMGlobalObject*, Ref<Node>&&); +WEBCORE_EXPORT JSC::JSObject* getOutOfLineCachedWrapper(JSDOMGlobalObject*, Node&); -inline JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Node* node) +inline JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Node& node) { - if (!node) - return JSC::jsNull(); - - JSNode* wrapper = JSC::jsCast<JSNode*>(getCachedWrapper(currentWorld(exec), node)); - if (wrapper) - return wrapper; + if (LIKELY(globalObject->worldIsNormal())) { + if (auto* wrapper = node.wrapper()) + return wrapper; + } else { + if (auto* wrapper = getOutOfLineCachedWrapper(globalObject, node)) + return wrapper; + } return createWrapper(exec, globalObject, node); } @@ -65,12 +65,7 @@ inline void willCreatePossiblyOrphanedTreeByRemoval(Node* root) inline void* root(Node* node) { - if (node->inDocument()) - return &node->document(); - - while (node->parentOrShadowHostNode()) - node = node->parentOrShadowHostNode(); - return node; + return node->opaqueRoot(); } inline void* root(Node& node) @@ -78,6 +73,15 @@ inline void* root(Node& node) return root(&node); } -} // namespace WebCore +template<typename From> +ALWAYS_INLINE JSDynamicCastResult<JSNode, From> jsNodeCast(From* value) +{ + return value->type() >= JSNodeType ? JSC::jsCast<JSDynamicCastResult<JSNode, From>>(value) : nullptr; +} -#endif // JSDOMNodeCustom_h +ALWAYS_INLINE JSC::JSValue JSNode::nodeType(JSC::ExecState&) const +{ + return JSC::jsNumber(static_cast<uint8_t>(type()) & JSNodeTypeMask); +} + +} // namespace WebCore |