summaryrefslogtreecommitdiff
path: root/Source/WebCore/bindings/js/JSNodeCustom.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/bindings/js/JSNodeCustom.h')
-rw-r--r--Source/WebCore/bindings/js/JSNodeCustom.h46
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