Diff
Modified: trunk/Source/WTF/ChangeLog (174124 => 174125)
--- trunk/Source/WTF/ChangeLog 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WTF/ChangeLog 2014-09-30 21:32:55 UTC (rev 174125)
@@ -1,3 +1,17 @@
+2014-09-30 Christophe Dumez <[email protected]>
+
+ Generalize is<>() / downcast<>() support to all types
+ https://bugs.webkit.org/show_bug.cgi?id=137243
+
+ Reviewed by Benjamin Poulain.
+
+ Generalize is<>() / downcast<>() support to all types, not just Nodes.
+
+ * wtf/Assertions.h:
+ * wtf/TypeCasts.h: Added.
+ (WTF::is):
+ (WTF::downcast):
+
2014-09-30 Anders Carlsson <[email protected]>
Get the STRING_STATS codepath compiling again, and add calls to ref/deref
Modified: trunk/Source/WTF/wtf/Assertions.h (174124 => 174125)
--- trunk/Source/WTF/wtf/Assertions.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WTF/wtf/Assertions.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -384,6 +384,8 @@
/* TYPE CAST */
+// FIXME: This macro should be removed once the code base is ported to using
+// the new SPECIALIZE_TYPE_TRAITS_*() macro.
#define TYPE_CASTS_BASE(ToClassName, argumentType, argumentName, pointerPredicate, referencePredicate) \
inline ToClassName* to##ToClassName(argumentType* argumentName) \
{ \
Added: trunk/Source/WTF/wtf/TypeCasts.h (0 => 174125)
--- trunk/Source/WTF/wtf/TypeCasts.h (rev 0)
+++ trunk/Source/WTF/wtf/TypeCasts.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2014 Apple Inc. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+#ifndef TypeCasts_h
+#define TypeCasts_h
+
+namespace WTF {
+
+template <typename ExpectedType, typename ArgType>
+struct TypeCastTraits {
+ static bool isOfType(ArgType&);
+};
+
+template <typename ExpectedType>
+struct TypeCastTraits<ExpectedType, ExpectedType> {
+ static bool isOfType(ExpectedType&) { return true; }
+};
+
+// Type checking function, to use before casting with downcast<>().
+template <typename ExpectedType, typename ArgType>
+inline bool is(ArgType& source)
+{
+ static_assert(!std::is_base_of<ExpectedType, ArgType>::value, "Unnecessary type check");
+ return TypeCastTraits<const ExpectedType, const ArgType>::isOfType(source);
+}
+
+template <typename ExpectedType, typename ArgType>
+inline bool is(ArgType* source)
+{
+ ASSERT(source);
+ static_assert(!std::is_base_of<ExpectedType, ArgType>::value, "Unnecessary type check");
+ return TypeCastTraits<const ExpectedType, const ArgType>::isOfType(*source);
+}
+
+// Safe downcasting functions.
+template<typename Target, typename Source>
+inline typename std::conditional<std::is_const<Source>::value, const Target&, Target&>::type downcast(Source& source)
+{
+ static_assert(!std::is_base_of<Target, Source>::value, "Unnecessary cast");
+ ASSERT_WITH_SECURITY_IMPLICATION(is<Target>(source));
+ return static_cast<typename std::conditional<std::is_const<Source>::value, const Target&, Target&>::type>(source);
+}
+template<typename Target, typename Source> inline typename std::conditional<std::is_const<Source>::value, const Target*, Target*>::type downcast(Source* source)
+{
+ static_assert(!std::is_base_of<Target, Source>::value, "Unnecessary cast");
+ ASSERT_WITH_SECURITY_IMPLICATION(!source || is<Target>(*source));
+ return static_cast<typename std::conditional<std::is_const<Source>::value, const Target*, Target*>::type>(source);
+}
+
+// Add support for type checking / casting using is<>() / downcast<>() helpers for a specific class.
+#define SPECIALIZE_TYPE_TRAITS_BEGIN(ClassName) \
+namespace WTF { \
+template <typename ArgType> \
+class TypeCastTraits<const ClassName, ArgType> { \
+public: \
+ static bool isOfType(ArgType& source) { return isType(source); } \
+private:
+
+#define SPECIALIZE_TYPE_TRAITS_END() \
+}; \
+}
+
+} // namespace WTF
+
+using WTF::is;
+using WTF::downcast;
+
+#endif // TypeCasts_h
Modified: trunk/Source/WebCore/ChangeLog (174124 => 174125)
--- trunk/Source/WebCore/ChangeLog 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/ChangeLog 2014-09-30 21:32:55 UTC (rev 174125)
@@ -1,3 +1,199 @@
+2014-09-30 Christophe Dumez <[email protected]>
+
+ Generalize is<>() / downcast<>() support to all types
+ https://bugs.webkit.org/show_bug.cgi?id=137243
+
+ Reviewed by Benjamin Poulain.
+
+ Generalize is<>() / downcast<>() support to all types, not just Nodes.
+ To achieve this, the following changes were made:
+ - Move is<> / downcast<>() and NodeTypeCastTraits from Node.h to a new
+ wtf/TypeCasts.h header. Also move them to WTF namespace instead of
+ WebCore namespace as they can be used for classes in other namespaces
+ (e.g. WebKit namespace).
+ - Rename NodeTypeCastsTraits to TypeCastTraits as it can be specialized
+ for non-Nodes.
+ - Since C++ does not allow template specializations in different
+ namespaces, I had to move all the SPECIALIZE_TYPE_TRAITS_*() uses to
+ the global scope and use the WebCore:: namespace explicitly in those.
+ This is a bit unfortunate but I couldn't find a better way.
+
+ This patch also takes care of supporting is<>() / downcast<>() for
+ the WorkerGlobalScope class, which does not derive from Node.
+
+ No new tests, no behavior change.
+
+ * Modules/indexeddb/IDBFactory.cpp:
+ * Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.cpp:
+ (WebCore::WorkerGlobalScopeIndexedDatabase::from):
+ * Modules/websockets/ThreadableWebSocketChannel.cpp:
+ (WebCore::ThreadableWebSocketChannel::create):
+ * bindings/js/JSDOMGlobalObject.cpp:
+ (WebCore::toJSDOMGlobalObject):
+ * bindings/js/JSEventListener.cpp:
+ (WebCore::JSEventListener::handleEvent):
+ * bindings/js/ScheduledAction.cpp:
+ (WebCore::ScheduledAction::execute):
+ * dom/Attr.h:
+ (isType):
+ (WebCore::isAttr): Deleted.
+ * dom/CDATASection.h:
+ (isType):
+ (WebCore::isCDATASection): Deleted.
+ * dom/CharacterData.h:
+ (isType):
+ (WebCore::isCharacterData): Deleted.
+ * dom/Comment.h:
+ (isType):
+ (WebCore::isComment): Deleted.
+ * dom/Document.h:
+ (isType):
+ (WebCore::isDocument): Deleted.
+ * dom/DocumentFragment.h:
+ (isType):
+ (WebCore::isDocumentFragment): Deleted.
+ * dom/DocumentType.h:
+ (isType):
+ (WebCore::isDocumentType): Deleted.
+ * dom/Element.h:
+ * dom/MessagePort.cpp:
+ (WebCore::MessagePort::dispatchMessages):
+ * dom/Node.h:
+ (WebCore::is): Deleted.
+ (WebCore::downcast): Deleted.
+ * dom/ProcessingInstruction.h:
+ (isType):
+ (WebCore::isProcessingInstruction): Deleted.
+ * dom/PseudoElement.h:
+ (isType):
+ (WebCore::isPseudoElement): Deleted.
+ * dom/ScriptExecutionContext.cpp:
+ (WebCore::ScriptExecutionContext::createdMessagePort):
+ (WebCore::ScriptExecutionContext::destroyedMessagePort):
+ (WebCore::ScriptExecutionContext::vm):
+ * dom/ScriptExecutionContext.h:
+ * dom/ShadowRoot.h:
+ (isType):
+ (WebCore::isShadowRoot): Deleted.
+ * dom/StyledElement.h:
+ (isType):
+ (WebCore::isStyledElement): Deleted.
+ * dom/Text.h:
+ (isType):
+ (WebCore::isText): Deleted.
+ * dom/make_names.pl:
+ (printTypeHelpers):
+ (printTypeHelpersHeaderFile):
+ * html/HTMLDocument.h:
+ (isType):
+ (WebCore::isHTMLDocument): Deleted.
+ * html/HTMLElement.h:
+ (isType):
+ (WebCore::isHTMLElement): Deleted.
+ * html/HTMLFormControlElement.h:
+ (isType):
+ (WebCore::isHTMLFormControlElement): Deleted.
+ * html/HTMLFrameElementBase.h:
+ (isType):
+ (WebCore::isHTMLFrameElementBase): Deleted.
+ * html/HTMLFrameOwnerElement.h:
+ (isType):
+ (WebCore::isHTMLFrameOwnerElement): Deleted.
+ * html/HTMLMediaElement.h:
+ (isType):
+ (WebCore::isHTMLMediaElement): Deleted.
+ * html/HTMLPlugInElement.h:
+ (isType):
+ (WebCore::isHTMLPlugInElement): Deleted.
+ * html/HTMLPlugInImageElement.h:
+ (isType):
+ (WebCore::isHTMLPlugInImageElement): Deleted.
+ * html/HTMLTableCellElement.h:
+ (isType):
+ (WebCore::isHTMLTableCellElement): Deleted.
+ * html/HTMLTableSectionElement.h:
+ (isType):
+ (WebCore::isHTMLTableSectionElement): Deleted.
+ * html/HTMLTextFormControlElement.h:
+ (isType):
+ (WebCore::isHTMLTextFormControlElement): Deleted.
+ * html/ImageDocument.h:
+ (isType):
+ (WebCore::isImageDocument): Deleted.
+ * html/LabelableElement.h:
+ (isType):
+ (WebCore::isLabelableElement): Deleted.
+ * html/MediaDocument.h:
+ (isType):
+ (WebCore::isMediaDocument): Deleted.
+ * html/PluginDocument.h:
+ (isType):
+ (WebCore::isPluginDocument): Deleted.
+ * html/shadow/InsertionPoint.h:
+ (isType):
+ (WebCore::isInsertionPoint): Deleted.
+ * html/shadow/TextControlInnerElements.h:
+ (isType):
+ (WebCore::isTextControlInnerTextElement): Deleted.
+ * html/track/WebVTTElement.h:
+ (isType):
+ (WebCore::isWebVTTElement): Deleted.
+ * inspector/InspectorInstrumentation.cpp:
+ (WebCore::InspectorInstrumentation::instrumentingAgentsForNonDocumentContext):
+ * loader/ThreadableLoader.cpp:
+ (WebCore::ThreadableLoader::create):
+ (WebCore::ThreadableLoader::loadResourceSynchronously):
+ * loader/cache/MemoryCache.cpp:
+ (WebCore::MemoryCache::removeRequestFromCache):
+ (WebCore::MemoryCache::removeRequestFromSessionCaches):
+ * mathml/MathMLElement.h:
+ (isType):
+ (WebCore::isMathMLElement): Deleted.
+ * svg/SVGAnimateElementBase.h:
+ (isType):
+ (WebCore::isSVGAnimateElementBase): Deleted.
+ * svg/SVGDocument.h:
+ (isType):
+ (WebCore::isSVGDocument): Deleted.
+ * svg/SVGElement.h:
+ (isType):
+ (WebCore::isSVGElement): Deleted.
+ * svg/SVGFilterPrimitiveStandardAttributes.h:
+ (isType):
+ (WebCore::isSVGFilterPrimitiveStandardAttributes): Deleted.
+ * svg/SVGGradientElement.h:
+ (isType):
+ (WebCore::isSVGGradientElement): Deleted.
+ * svg/SVGGraphicsElement.h:
+ (isType):
+ (WebCore::isSVGGraphicsElement): Deleted.
+ * svg/SVGPolyElement.h:
+ (isType):
+ (WebCore::isSVGPolyElement): Deleted.
+ * svg/SVGTextContentElement.h:
+ (isType):
+ (WebCore::isSVGTextContentElement): Deleted.
+ * svg/animation/SVGSMILElement.h:
+ (isType):
+ (WebCore::isSVGSMILElement): Deleted.
+ * workers/DefaultSharedWorkerRepository.cpp:
+ (WebCore::SharedWorkerConnectTask::SharedWorkerConnectTask):
+ * workers/WorkerGlobalScope.cpp:
+ (WebCore::WorkerGlobalScope::close):
+ * workers/WorkerGlobalScope.h:
+ (isType):
+ * workers/WorkerMessagingProxy.cpp:
+ (WebCore::WorkerMessagingProxy::WorkerMessagingProxy):
+ (WebCore::WorkerMessagingProxy::~WorkerMessagingProxy):
+ (WebCore::WorkerMessagingProxy::notifyNetworkStateChange):
+ (WebCore::WorkerMessagingProxy::connectToInspector):
+ (WebCore::WorkerMessagingProxy::disconnectFromInspector):
+ (WebCore::WorkerMessagingProxy::sendMessageToInspector):
+ * workers/WorkerScriptLoader.cpp:
+ (WebCore::WorkerScriptLoader::loadSynchronously):
+ * workers/WorkerThread.cpp:
+ (WebCore::WorkerThread::stop):
+
2014-09-30 Chris Dumez <[email protected]>
Use is<>() / downcast<>() for Element
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp (174124 => 174125)
--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp 2014-09-30 21:32:55 UTC (rev 174125)
@@ -83,7 +83,7 @@
Document& document = downcast<Document>(*context);
return document.page()->group().groupSettings().indexedDBDatabasePath();
}
- const GroupSettings* groupSettings = toWorkerGlobalScope(context)->groupSettings();
+ const GroupSettings* groupSettings = downcast<WorkerGlobalScope>(*context).groupSettings();
if (groupSettings)
return groupSettings->indexedDBDatabasePath();
return String();
Modified: trunk/Source/WebCore/Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.cpp (174124 => 174125)
--- trunk/Source/WebCore/Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.cpp 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.cpp 2014-09-30 21:32:55 UTC (rev 174125)
@@ -57,7 +57,7 @@
WorkerGlobalScopeIndexedDatabase* supplement = static_cast<WorkerGlobalScopeIndexedDatabase*>(Supplement<ScriptExecutionContext>::from(context, supplementName()));
if (!supplement) {
String databaseDirectoryIdentifier;
- const GroupSettings* groupSettings = toWorkerGlobalScope(context)->groupSettings();
+ const GroupSettings* groupSettings = downcast<WorkerGlobalScope>(*context).groupSettings();
if (groupSettings)
databaseDirectoryIdentifier = groupSettings->indexedDBDatabasePath();
Modified: trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp (174124 => 174125)
--- trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp 2014-09-30 21:32:55 UTC (rev 174125)
@@ -55,13 +55,13 @@
ASSERT(context);
ASSERT(client);
- if (context->isWorkerGlobalScope()) {
- WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
- WorkerRunLoop& runLoop = workerGlobalScope->thread().runLoop();
+ if (is<WorkerGlobalScope>(context)) {
+ WorkerGlobalScope& workerGlobalScope = downcast<WorkerGlobalScope>(*context);
+ WorkerRunLoop& runLoop = workerGlobalScope.thread().runLoop();
StringBuilder mode;
mode.appendLiteral(webSocketChannelMode);
mode.appendNumber(runLoop.createUniqueId());
- return WorkerThreadableWebSocketChannel::create(workerGlobalScope, client, mode.toString());
+ return WorkerThreadableWebSocketChannel::create(&workerGlobalScope, client, mode.toString());
}
return WebSocketChannel::create(downcast<Document>(context), client);
Modified: trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp (174124 => 174125)
--- trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp 2014-09-30 21:32:55 UTC (rev 174125)
@@ -108,8 +108,8 @@
if (is<Document>(scriptExecutionContext))
return toJSDOMGlobalObject(downcast<Document>(scriptExecutionContext), exec);
- if (scriptExecutionContext->isWorkerGlobalScope())
- return toWorkerGlobalScope(scriptExecutionContext)->script()->workerGlobalScopeWrapper();
+ if (is<WorkerGlobalScope>(scriptExecutionContext))
+ return downcast<WorkerGlobalScope>(*scriptExecutionContext).script()->workerGlobalScopeWrapper();
ASSERT_NOT_REACHED();
return nullptr;
@@ -125,8 +125,8 @@
if (is<Document>(scriptExecutionContext))
return toJSDOMGlobalObject(downcast<Document>(scriptExecutionContext), world);
- if (scriptExecutionContext->isWorkerGlobalScope())
- return toWorkerGlobalScope(scriptExecutionContext)->script()->workerGlobalScopeWrapper();
+ if (is<WorkerGlobalScope>(scriptExecutionContext))
+ return downcast<WorkerGlobalScope>(*scriptExecutionContext).script()->workerGlobalScopeWrapper();
ASSERT_NOT_REACHED();
return nullptr;
Modified: trunk/Source/WebCore/bindings/js/JSEventListener.cpp (174124 => 174125)
--- trunk/Source/WebCore/bindings/js/JSEventListener.cpp 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/bindings/js/JSEventListener.cpp 2014-09-30 21:32:55 UTC (rev 174125)
@@ -131,10 +131,10 @@
globalObject->setCurrentEvent(savedEvent);
- if (scriptExecutionContext->isWorkerGlobalScope()) {
+ if (is<WorkerGlobalScope>(scriptExecutionContext)) {
bool terminatorCausedException = (exec->hadException() && isTerminatedExecutionException(exec->exception()));
if (terminatorCausedException || (vm.watchdog && vm.watchdog->didFire()))
- toWorkerGlobalScope(scriptExecutionContext)->script()->forbidExecution();
+ downcast<WorkerGlobalScope>(*scriptExecutionContext).script()->forbidExecution();
}
if (exception) {
Modified: trunk/Source/WebCore/bindings/js/ScheduledAction.cpp (174124 => 174125)
--- trunk/Source/WebCore/bindings/js/ScheduledAction.cpp 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/bindings/js/ScheduledAction.cpp 2014-09-30 21:32:55 UTC (rev 174125)
@@ -77,7 +77,7 @@
if (is<Document>(context))
execute(downcast<Document>(context));
else
- execute(toWorkerGlobalScope(context));
+ execute(downcast<WorkerGlobalScope>(context));
}
void ScheduledAction::executeFunctionInContext(JSGlobalObject* globalObject, JSValue thisValue, ScriptExecutionContext* context)
Modified: trunk/Source/WebCore/dom/Attr.h (174124 => 174125)
--- trunk/Source/WebCore/dom/Attr.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/Attr.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -99,10 +99,10 @@
unsigned m_ignoreChildrenChanged;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(Attr)
- static bool isAttr(const Node& node) { return node.isAttributeNode(); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Attr)
+ static bool isType(const WebCore::Node& node) { return node.isAttributeNode(); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif // Attr_h
Modified: trunk/Source/WebCore/dom/CDATASection.h (174124 => 174125)
--- trunk/Source/WebCore/dom/CDATASection.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/CDATASection.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -41,10 +41,10 @@
virtual PassRefPtr<Text> virtualCreate(const String&) override;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(CDATASection)
- static bool isCDATASection(const Node& node) { return node.nodeType() == Node::CDATA_SECTION_NODE; }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::CDATASection)
+ static bool isType(const WebCore::Node& node) { return node.nodeType() == WebCore::Node::CDATA_SECTION_NODE; }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif // CDATASection_h
Modified: trunk/Source/WebCore/dom/CharacterData.h (174124 => 174125)
--- trunk/Source/WebCore/dom/CharacterData.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/CharacterData.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -76,10 +76,10 @@
String m_data;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(CharacterData)
- static bool isCharacterData(const Node& node) { return node.isCharacterDataNode(); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::CharacterData)
+ static bool isType(const WebCore::Node& node) { return node.isCharacterDataNode(); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif // CharacterData_h
Modified: trunk/Source/WebCore/dom/Comment.h (174124 => 174125)
--- trunk/Source/WebCore/dom/Comment.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/Comment.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -41,10 +41,10 @@
virtual bool childTypeAllowed(NodeType) const override;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(Comment)
- static bool isComment(const Node& node) { return node.nodeType() == Node::COMMENT_NODE; }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Comment)
+ static bool isType(const WebCore::Node& node) { return node.nodeType() == WebCore::Node::COMMENT_NODE; }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif // Comment_h
Modified: trunk/Source/WebCore/dom/Document.h (174124 => 174125)
--- trunk/Source/WebCore/dom/Document.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/Document.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -1740,13 +1740,13 @@
Element* eventTargetElementForDocument(Document*);
-SPECIALIZE_TYPE_TRAITS_BEGIN(Document)
- static bool isDocument(const ScriptExecutionContext& context) { return context.isDocument(); }
- static bool isDocument(const Node& node) { return node.isDocumentNode(); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Document)
+ static bool isType(const WebCore::ScriptExecutionContext& context) { return context.isDocument(); }
+ static bool isType(const WebCore::Node& node) { return node.isDocumentNode(); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
namespace WTF {
inline WebCore::Document* getPtr(WebCore::Document& p) { return &p; }
}
Modified: trunk/Source/WebCore/dom/DocumentFragment.h (174124 => 174125)
--- trunk/Source/WebCore/dom/DocumentFragment.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/DocumentFragment.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -52,10 +52,10 @@
virtual bool childTypeAllowed(NodeType) const override;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(DocumentFragment)
- static bool isDocumentFragment(const Node& node) { return node.isDocumentFragment(); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::DocumentFragment)
+ static bool isType(const WebCore::Node& node) { return node.isDocumentFragment(); }
SPECIALIZE_TYPE_TRAITS_END()
-} //namespace
-
#endif
Modified: trunk/Source/WebCore/dom/DocumentType.h (174124 => 174125)
--- trunk/Source/WebCore/dom/DocumentType.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/DocumentType.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -60,10 +60,10 @@
String m_subset;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(DocumentType)
- static bool isDocumentType(const Node& node) { return node.nodeType() == Node::DOCUMENT_TYPE_NODE; }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::DocumentType)
+ static bool isType(const WebCore::Node& node) { return node.nodeType() == WebCore::Node::DOCUMENT_TYPE_NODE; }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif
Modified: trunk/Source/WebCore/dom/Element.h (174124 => 174125)
--- trunk/Source/WebCore/dom/Element.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/Element.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -666,10 +666,6 @@
RefPtr<ElementData> m_elementData;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(Element)
- static bool isElement(const Node& node) { return node.isElementNode(); }
-SPECIALIZE_TYPE_TRAITS_END()
-
inline bool Node::hasAttributes() const
{
return is<Element>(*this) && downcast<Element>(*this).hasAttributes();
@@ -781,4 +777,8 @@
} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Element)
+ static bool isType(const WebCore::Node& node) { return node.isElementNode(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
#endif
Modified: trunk/Source/WebCore/dom/MessagePort.cpp (174124 => 174125)
--- trunk/Source/WebCore/dom/MessagePort.cpp 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/MessagePort.cpp 2014-09-30 21:32:55 UTC (rev 174125)
@@ -157,7 +157,7 @@
while (m_entangledChannel && m_entangledChannel->tryGetMessageFromRemote(message, channels)) {
// close() in Worker onmessage handler should prevent next message from dispatching.
- if (m_scriptExecutionContext->isWorkerGlobalScope() && toWorkerGlobalScope(m_scriptExecutionContext)->isClosing())
+ if (is<WorkerGlobalScope>(m_scriptExecutionContext) && downcast<WorkerGlobalScope>(*m_scriptExecutionContext).isClosing())
return;
std::unique_ptr<MessagePortArray> ports = MessagePort::entanglePorts(*m_scriptExecutionContext, WTF::move(channels));
Modified: trunk/Source/WebCore/dom/Node.h (174124 => 174125)
--- trunk/Source/WebCore/dom/Node.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/Node.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -36,6 +36,7 @@
#include "TreeShared.h"
#include <wtf/Forward.h>
#include <wtf/ListHashSet.h>
+#include <wtf/TypeCasts.h>
namespace JSC {
class VM;
@@ -739,58 +740,6 @@
return parentNode();
}
-template <typename ExpectedType, typename ArgType>
-struct NodeTypeCastTraits {
- static bool isType(ArgType&);
-};
-
-template <typename ExpectedType>
-struct NodeTypeCastTraits<ExpectedType, ExpectedType> {
- static bool isType(ExpectedType&) { return true; }
-};
-
-// Type checking function for Nodes, to use before casting with downcast<>().
-template <typename ExpectedType, typename ArgType>
-inline bool is(ArgType& node)
-{
- static_assert(!std::is_base_of<ExpectedType, ArgType>::value, "Unnecessary type check");
- return NodeTypeCastTraits<const ExpectedType, const ArgType>::isType(node);
-}
-
-template <typename ExpectedType, typename ArgType>
-inline bool is(ArgType* node)
-{
- ASSERT(node);
- static_assert(!std::is_base_of<ExpectedType, ArgType>::value, "Unnecessary type check");
- return NodeTypeCastTraits<const ExpectedType, const ArgType>::isType(*node);
-}
-
-// Downcasting functions for Node types.
-template<typename Target, typename Source>
-inline typename std::conditional<std::is_const<Source>::value, const Target&, Target&>::type downcast(Source& source)
-{
- static_assert(!std::is_base_of<Target, Source>::value, "Unnecessary cast");
- ASSERT_WITH_SECURITY_IMPLICATION(is<Target>(source));
- return static_cast<typename std::conditional<std::is_const<Source>::value, const Target&, Target&>::type>(source);
-}
-template<typename Target, typename Source> inline typename std::conditional<std::is_const<Source>::value, const Target*, Target*>::type downcast(Source* source)
-{
- static_assert(!std::is_base_of<Target, Source>::value, "Unnecessary cast");
- ASSERT_WITH_SECURITY_IMPLICATION(!source || is<Target>(*source));
- return static_cast<typename std::conditional<std::is_const<Source>::value, const Target*, Target*>::type>(source);
-}
-
-// Add support for type checking / casting using is<>() / downcast<>() helpers for a specific class.
-#define SPECIALIZE_TYPE_TRAITS_BEGIN(ClassName) \
- template <typename ArgType> \
- class NodeTypeCastTraits<const ClassName, ArgType> { \
- public: \
- static bool isType(ArgType& node) { return is##ClassName(node); } \
- private:
-
-#define SPECIALIZE_TYPE_TRAITS_END() \
- };
-
// FIXME: This should be removed and all uses should be replaced with SPECIALIZE_TYPE_TRAITS_*().
#define NODE_TYPE_CASTS(ToClassName) \
TYPE_CASTS_BASE(ToClassName, Node, node, WebCore::is##ToClassName(*node), WebCore::is##ToClassName(node))
Modified: trunk/Source/WebCore/dom/ProcessingInstruction.h (174124 => 174125)
--- trunk/Source/WebCore/dom/ProcessingInstruction.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/ProcessingInstruction.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -91,10 +91,10 @@
#endif
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(ProcessingInstruction)
- static bool isProcessingInstruction(const Node& node) { return node.nodeType() == Node::PROCESSING_INSTRUCTION_NODE; }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ProcessingInstruction)
+ static bool isType(const WebCore::Node& node) { return node.nodeType() == WebCore::Node::PROCESSING_INSTRUCTION_NODE; }
SPECIALIZE_TYPE_TRAITS_END()
-} //namespace
-
#endif
Modified: trunk/Source/WebCore/dom/PseudoElement.h (174124 => 174125)
--- trunk/Source/WebCore/dom/PseudoElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/PseudoElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -77,10 +77,10 @@
return style && style->display() != NONE && (style->contentData() || style->hasFlowFrom());
}
-SPECIALIZE_TYPE_TRAITS_BEGIN(PseudoElement)
- static bool isPseudoElement(const Node& node) { return node.isPseudoElement(); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::PseudoElement)
+ static bool isType(const WebCore::Node& node) { return node.isPseudoElement(); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace
-
#endif
Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.cpp (174124 => 174125)
--- trunk/Source/WebCore/dom/ScriptExecutionContext.cpp 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.cpp 2014-09-30 21:32:55 UTC (rev 174125)
@@ -30,6 +30,7 @@
#include "CachedScript.h"
#include "DOMTimer.h"
+#include "Document.h"
#include "ErrorEvent.h"
#include "MessagePort.h"
#include "PublicURLManager.h"
@@ -158,16 +159,16 @@
void ScriptExecutionContext::createdMessagePort(MessagePort& messagePort)
{
- ASSERT((isDocument() && isMainThread())
- || (isWorkerGlobalScope() && currentThread() == toWorkerGlobalScope(this)->thread().threadID()));
+ ASSERT((is<Document>(*this) && isMainThread())
+ || (is<WorkerGlobalScope>(*this) && currentThread() == downcast<WorkerGlobalScope>(*this).thread().threadID()));
m_messagePorts.add(&messagePort);
}
void ScriptExecutionContext::destroyedMessagePort(MessagePort& messagePort)
{
- ASSERT((isDocument() && isMainThread())
- || (isWorkerGlobalScope() && currentThread() == toWorkerGlobalScope(this)->thread().threadID()));
+ ASSERT((is<Document>(*this) && isMainThread())
+ || (is<WorkerGlobalScope>(*this) && currentThread() == downcast<WorkerGlobalScope>(*this).thread().threadID()));
m_messagePorts.remove(&messagePort);
}
@@ -445,10 +446,10 @@
JSC::VM& ScriptExecutionContext::vm()
{
- if (isDocument())
+ if (is<Document>(*this))
return JSDOMWindow::commonVM();
- return toWorkerGlobalScope(*this).script()->vm();
+ return downcast<WorkerGlobalScope>(*this).script()->vm();
}
#if ENABLE(SQL_DATABASE)
Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.h (174124 => 174125)
--- trunk/Source/WebCore/dom/ScriptExecutionContext.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -234,10 +234,6 @@
#endif
};
-#define SCRIPT_EXECUTION_CONTEXT_TYPE_CASTS(ToValueTypeName) \
- template<typename T> inline ToValueTypeName* to##ToValueTypeName(const RefPtr<T>& context) { return to##ToValueTypeName(context.get()); } \
- TYPE_CASTS_BASE(ToValueTypeName, ScriptExecutionContext, context, context->is##ToValueTypeName(), context.is##ToValueTypeName())
-
} // namespace WebCore
#endif // ScriptExecutionContext_h
Modified: trunk/Source/WebCore/dom/ShadowRoot.h (174124 => 174125)
--- trunk/Source/WebCore/dom/ShadowRoot.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/ShadowRoot.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -95,10 +95,6 @@
return treeScope().focusedElement();
}
-SPECIALIZE_TYPE_TRAITS_BEGIN(ShadowRoot)
- static bool isShadowRoot(const Node& node) { return node.isShadowRoot(); }
-SPECIALIZE_TYPE_TRAITS_END()
-
inline ShadowRoot* Node::shadowRoot() const
{
if (!is<Element>(*this))
@@ -119,6 +115,10 @@
return node.parentNode() && node.parentNode()->isShadowRoot();
}
-} // namespace
+} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ShadowRoot)
+ static bool isType(const WebCore::Node& node) { return node.isShadowRoot(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
#endif
Modified: trunk/Source/WebCore/dom/StyledElement.h (174124 => 174125)
--- trunk/Source/WebCore/dom/StyledElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/StyledElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -106,10 +106,10 @@
return elementData()->presentationAttributeStyle();
}
-SPECIALIZE_TYPE_TRAITS_BEGIN(StyledElement)
- static bool isStyledElement(const Node& node) { return node.isStyledElement(); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::StyledElement)
+ static bool isType(const WebCore::Node& node) { return node.isStyledElement(); }
SPECIALIZE_TYPE_TRAITS_END()
-} //namespace
-
#endif
Modified: trunk/Source/WebCore/dom/Text.h (174124 => 174125)
--- trunk/Source/WebCore/dom/Text.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/Text.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -74,10 +74,10 @@
#endif
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(Text)
- static bool isText(const Node& node) { return node.isTextNode(); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Text)
+ static bool isType(const WebCore::Node& node) { return node.isTextNode(); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif // Text_h
Modified: trunk/Source/WebCore/dom/make_names.pl (174124 => 174125)
--- trunk/Source/WebCore/dom/make_names.pl 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/dom/make_names.pl 2014-09-30 21:32:55 UTC (rev 174125)
@@ -639,29 +639,33 @@
next if $tagCount > 1;
my $name = $classToTags{$class}[0];
print F <<END
+namespace WebCore {
class $class;
+}
+namespace WTF {
template <typename ArgType>
-class NodeTypeCastTraits<const $class, ArgType> {
+class TypeCastTraits<const WebCore::$class, ArgType> {
public:
- static bool isType(ArgType& node) { return checkTagName(node); }
+ static bool isOfType(ArgType& node) { return checkTagName(node); }
private:
END
;
if ($parameters{namespace} eq "HTML" && $parsedTags{$name}{wrapperOnlyIfMediaIsAvailable}) {
print F <<END
- static bool checkTagName(const HTMLElement& element) { return !element.isHTMLUnknownElement() && element.hasTagName($parameters{namespace}Names::${name}Tag); }
- static bool checkTagName(const Node& node) { return is<HTMLElement>(node) && checkTagName(downcast<HTMLElement>(node)); }
+ static bool checkTagName(const WebCore::HTMLElement& element) { return !element.isHTMLUnknownElement() && element.hasTagName(WebCore::$parameters{namespace}Names::${name}Tag); }
+ static bool checkTagName(const WebCore::Node& node) { return is<WebCore::HTMLElement>(node) && checkTagName(downcast<WebCore::HTMLElement>(node)); }
END
;
} else {
print F <<END
- static bool checkTagName(const $parameters{namespace}Element& element) { return element.hasTagName($parameters{namespace}Names::${name}Tag); }
- static bool checkTagName(const Node& node) { return node.hasTagName($parameters{namespace}Names::${name}Tag); }
+ static bool checkTagName(const WebCore::$parameters{namespace}Element& element) { return element.hasTagName(WebCore::$parameters{namespace}Names::${name}Tag); }
+ static bool checkTagName(const WebCore::Node& node) { return node.hasTagName(WebCore::$parameters{namespace}Names::${name}Tag); }
END
;
}
print F <<END
};
+}
END
;
print F "\n";
@@ -678,11 +682,9 @@
print F "#ifndef ".$parameters{namespace}."ElementTypeHelpers_h\n";
print F "#define ".$parameters{namespace}."ElementTypeHelpers_h\n\n";
print F "#include \"".$parameters{namespace}."Names.h\"\n\n";
- print F "namespace WebCore {\n\n";
printTypeHelpers($F, \%allTags);
- print F "}\n\n";
print F "#endif\n";
close F;
Modified: trunk/Source/WebCore/html/HTMLDocument.h (174124 => 174125)
--- trunk/Source/WebCore/html/HTMLDocument.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/HTMLDocument.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -97,11 +97,11 @@
DocumentOrderedMap m_windowNamedItem;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLDocument)
- static bool isHTMLDocument(const Document& document) { return document.isHTMLDocument(); }
- static bool isHTMLDocument(const Node& node) { return is<Document>(node) && isHTMLDocument(downcast<Document>(node)); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLDocument)
+ static bool isType(const WebCore::Document& document) { return document.isHTMLDocument(); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::Document>(node) && isType(downcast<WebCore::Document>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif // HTMLDocument_h
Modified: trunk/Source/WebCore/html/HTMLElement.h (174124 => 174125)
--- trunk/Source/WebCore/html/HTMLElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/HTMLElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -146,10 +146,6 @@
ASSERT(tagName.localName().impl());
}
-SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLElement)
- static bool isHTMLElement(const Node& node) { return node.isHTMLElement(); }
-SPECIALIZE_TYPE_TRAITS_END()
-
inline bool Node::hasTagName(const HTMLQualifiedName& name) const
{
return is<HTMLElement>(*this) && downcast<HTMLElement>(*this).hasTagName(name);
@@ -157,6 +153,10 @@
} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLElement)
+ static bool isType(const WebCore::Node& node) { return node.isHTMLElement(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
#include "HTMLElementTypeHelpers.h"
#endif // HTMLElement_h
Modified: trunk/Source/WebCore/html/HTMLFormControlElement.h (174124 => 174125)
--- trunk/Source/WebCore/html/HTMLFormControlElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -190,12 +190,12 @@
bool m_hasAutofocused : 1;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLFormControlElement)
- static bool isHTMLFormControlElement(const Element& element) { return element.isFormControlElement(); }
- static bool isHTMLFormControlElement(const Node& node) { return is<Element>(node) && downcast<Element>(node).isFormControlElement(); }
- static bool isHTMLFormControlElement(const FormAssociatedElement& element) { return element.isFormControlElement(); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLFormControlElement)
+ static bool isType(const WebCore::Element& element) { return element.isFormControlElement(); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::Element>(node) && isType(downcast<WebCore::Element>(node)); }
+ static bool isType(const WebCore::FormAssociatedElement& element) { return element.isFormControlElement(); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace
-
#endif
Modified: trunk/Source/WebCore/html/HTMLFrameElementBase.h (174124 => 174125)
--- trunk/Source/WebCore/html/HTMLFrameElementBase.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/HTMLFrameElementBase.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -76,11 +76,11 @@
int m_marginHeight;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLFrameElementBase)
- static bool isHTMLFrameElementBase(const HTMLElement& element) { return is<HTMLFrameElement>(element) || is<HTMLIFrameElement>(element); }
- static bool isHTMLFrameElementBase(const Node& node) { return is<HTMLElement>(node) && isHTMLFrameElementBase(downcast<HTMLElement>(node)); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLFrameElementBase)
+ static bool isType(const WebCore::HTMLElement& element) { return is<WebCore::HTMLFrameElement>(element) || is<WebCore::HTMLIFrameElement>(element); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::HTMLElement>(node) && isType(downcast<WebCore::HTMLElement>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif // HTMLFrameElementBase_h
Modified: trunk/Source/WebCore/html/HTMLFrameOwnerElement.h (174124 => 174125)
--- trunk/Source/WebCore/html/HTMLFrameOwnerElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/HTMLFrameOwnerElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -69,11 +69,6 @@
SandboxFlags m_sandboxFlags;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLFrameOwnerElement)
- static bool isHTMLFrameOwnerElement(const Node& node) { return node.isFrameOwnerElement(); }
-SPECIALIZE_TYPE_TRAITS_END()
-
-
class SubframeLoadingDisabler {
public:
explicit SubframeLoadingDisabler(ContainerNode& root)
@@ -101,4 +96,8 @@
} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLFrameOwnerElement)
+ static bool isType(const WebCore::Node& node) { return node.isFrameOwnerElement(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
#endif // HTMLFrameOwnerElement_h
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (174124 => 174125)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -909,11 +909,6 @@
#endif
#endif
-SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLMediaElement)
- static bool isHTMLMediaElement(const Element& element) { return element.isMediaElement(); }
- static bool isHTMLMediaElement(const Node& node) { return is<Element>(node) && isHTMLMediaElement(downcast<Element>(node)); }
-SPECIALIZE_TYPE_TRAITS_END()
-
#ifndef NDEBUG
template<>
struct ValueToString<MediaTime> {
@@ -924,7 +919,12 @@
};
#endif
-} //namespace
+} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLMediaElement)
+ static bool isType(const WebCore::Element& element) { return element.isMediaElement(); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::Element>(node) && isType(downcast<WebCore::Element>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
+
#endif
#endif
Modified: trunk/Source/WebCore/html/HTMLPlugInElement.h (174124 => 174125)
--- trunk/Source/WebCore/html/HTMLPlugInElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/HTMLPlugInElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -136,10 +136,10 @@
DisplayState m_displayState;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLPlugInElement)
- static bool isHTMLPlugInElement(const Node& node) { return node.isPluginElement(); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLPlugInElement)
+ static bool isType(const WebCore::Node& node) { return node.isPluginElement(); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif // HTMLPlugInElement_h
Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.h (174124 => 174125)
--- trunk/Source/WebCore/html/HTMLPlugInImageElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -157,11 +157,11 @@
bool m_plugInDimensionsSpecified;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLPlugInImageElement)
- static bool isHTMLPlugInImageElement(const HTMLPlugInElement& element) { return element.isPlugInImageElement(); }
- static bool isHTMLPlugInImageElement(const Node& node) { return is<HTMLPlugInElement>(node) && isHTMLPlugInImageElement(downcast<HTMLPlugInElement>(node)); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLPlugInImageElement)
+ static bool isType(const WebCore::HTMLPlugInElement& element) { return element.isPlugInImageElement(); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::HTMLPlugInElement>(node) && isType(downcast<WebCore::HTMLPlugInElement>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif // HTMLPlugInImageElement_h
Modified: trunk/Source/WebCore/html/HTMLTableCellElement.h (174124 => 174125)
--- trunk/Source/WebCore/html/HTMLTableCellElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/HTMLTableCellElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -62,11 +62,11 @@
virtual void addSubresourceAttributeURLs(ListHashSet<URL>&) const override;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLTableCellElement)
- static bool isHTMLTableCellElement(const HTMLElement& element) { return element.hasTagName(HTMLNames::tdTag) || element.hasTagName(HTMLNames::thTag); }
- static bool isHTMLTableCellElement(const Node& node) { return is<HTMLElement>(node) && isHTMLTableCellElement(downcast<HTMLElement>(node)); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLTableCellElement)
+ static bool isType(const WebCore::HTMLElement& element) { return element.hasTagName(WebCore::HTMLNames::tdTag) || element.hasTagName(WebCore::HTMLNames::thTag); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::HTMLElement>(node) && isType(downcast<WebCore::HTMLElement>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace
-
#endif
Modified: trunk/Source/WebCore/html/HTMLTableSectionElement.h (174124 => 174125)
--- trunk/Source/WebCore/html/HTMLTableSectionElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/HTMLTableSectionElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -61,11 +61,11 @@
virtual const StyleProperties* additionalPresentationAttributeStyle() override;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLTableSectionElement)
- static bool isHTMLTableSectionElement(const HTMLElement& element) { return element.hasTagName(HTMLNames::theadTag) || element.hasTagName(HTMLNames::tfootTag) || element.hasTagName(HTMLNames::tbodyTag); }
- static bool isHTMLTableSectionElement(const Node& node) { return is<HTMLElement>(node) && isHTMLTableSectionElement(downcast<HTMLElement>(node)); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLTableSectionElement)
+ static bool isType(const WebCore::HTMLElement& element) { return element.hasTagName(WebCore::HTMLNames::theadTag) || element.hasTagName(WebCore::HTMLNames::tfootTag) || element.hasTagName(WebCore::HTMLNames::tbodyTag); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::HTMLElement>(node) && isType(downcast<WebCore::HTMLElement>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
-} //namespace
-
#endif
Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.h (174124 => 174125)
--- trunk/Source/WebCore/html/HTMLTextFormControlElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -151,13 +151,13 @@
unsigned char m_isPlaceholderVisible : 1;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLTextFormControlElement)
- static bool isHTMLTextFormControlElement(const Element& element) { return element.isTextFormControl(); }
- static bool isHTMLTextFormControlElement(const Node& node) { return is<Element>(node) && isHTMLTextFormControlElement(downcast<Element>(node)); }
-SPECIALIZE_TYPE_TRAITS_END()
-
HTMLTextFormControlElement* enclosingTextFormControl(const Position&);
-} // namespace
+} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLTextFormControlElement)
+ static bool isType(const WebCore::Element& element) { return element.isTextFormControl(); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::Element>(node) && isType(downcast<WebCore::Element>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
+
#endif
Modified: trunk/Source/WebCore/html/ImageDocument.h (174124 => 174125)
--- trunk/Source/WebCore/html/ImageDocument.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/ImageDocument.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -82,11 +82,11 @@
bool m_shouldShrinkImage;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(ImageDocument)
- static bool isImageDocument(const Document& document) { return document.isImageDocument(); }
- static bool isImageDocument(const Node& node) { return is<Document>(node) && isImageDocument(downcast<Document>(node)); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ImageDocument)
+ static bool isType(const WebCore::Document& document) { return document.isImageDocument(); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::Document>(node) && isType(downcast<WebCore::Document>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
-}
-
#endif // ImageDocument_h
Modified: trunk/Source/WebCore/html/LabelableElement.h (174124 => 174125)
--- trunk/Source/WebCore/html/LabelableElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/LabelableElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -50,11 +50,11 @@
virtual bool isLabelable() const override final { return true; }
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(LabelableElement)
- static bool isLabelableElement(const HTMLElement& element) { return element.isLabelable(); }
- static bool isLabelableElement(const Node& node) { return is<HTMLElement>(node) && isLabelableElement(downcast<HTMLElement>(node)); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::LabelableElement)
+ static bool isType(const WebCore::HTMLElement& element) { return element.isLabelable(); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::HTMLElement>(node) && isType(downcast<WebCore::HTMLElement>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif
Modified: trunk/Source/WebCore/html/MediaDocument.h (174124 => 174125)
--- trunk/Source/WebCore/html/MediaDocument.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/MediaDocument.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -56,12 +56,12 @@
String m_outgoingReferrer;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(MediaDocument)
- static bool isMediaDocument(const Document& document) { return document.isMediaDocument(); }
- static bool isMediaDocument(const Node& node) { return is<Document>(node) && isMediaDocument(downcast<Document>(node)); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::MediaDocument)
+ static bool isType(const WebCore::Document& document) { return document.isMediaDocument(); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::Document>(node) && isType(downcast<WebCore::Document>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
-}
-
#endif
#endif
Modified: trunk/Source/WebCore/html/PluginDocument.h (174124 => 174125)
--- trunk/Source/WebCore/html/PluginDocument.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/PluginDocument.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -61,11 +61,11 @@
RefPtr<HTMLPlugInElement> m_pluginElement;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(PluginDocument)
- static bool isPluginDocument(const Document& document) { return document.isPluginDocument(); }
- static bool isPluginDocument(const Node& node) { return is<Document>(node) && isPluginDocument(downcast<Document>(node)); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::PluginDocument)
+ static bool isType(const WebCore::Document& document) { return document.isPluginDocument(); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::Document>(node) && isType(downcast<WebCore::Document>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
-}
-
#endif // PluginDocument_h
Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.h (174124 => 174125)
--- trunk/Source/WebCore/html/shadow/InsertionPoint.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -75,10 +75,6 @@
bool m_hasDistribution;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(InsertionPoint)
- static bool isInsertionPoint(const Node& node) { return node.isInsertionPoint(); }
-SPECIALIZE_TYPE_TRAITS_END()
-
inline bool isActiveInsertionPoint(const Node* node)
{
return node && is<InsertionPoint>(node) && downcast<InsertionPoint>(*node).isActive();
@@ -127,4 +123,8 @@
} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::InsertionPoint)
+ static bool isType(const WebCore::Node& node) { return node.isInsertionPoint(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
#endif // InsertionPoint_h
Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.h (174124 => 174125)
--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -70,11 +70,6 @@
virtual bool isTextControlInnerTextElement() const override { return true; }
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(TextControlInnerTextElement)
- static bool isTextControlInnerTextElement(const HTMLElement& element) { return element.isTextControlInnerTextElement(); }
- static bool isTextControlInnerTextElement(const Node& node) { return is<HTMLElement>(node) && isTextControlInnerTextElement(downcast<HTMLElement>(node)); }
-SPECIALIZE_TYPE_TRAITS_END()
-
class SearchFieldResultsButtonElement final : public HTMLDivElement {
public:
static PassRefPtr<SearchFieldResultsButtonElement> create(Document&);
@@ -107,6 +102,11 @@
bool m_capturing;
};
-} // namespace
+} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::TextControlInnerTextElement)
+ static bool isType(const WebCore::HTMLElement& element) { return element.isTextControlInnerTextElement(); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::HTMLElement>(node) && isType(downcast<WebCore::HTMLElement>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
+
#endif
Modified: trunk/Source/WebCore/html/track/WebVTTElement.h (174124 => 174125)
--- trunk/Source/WebCore/html/track/WebVTTElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/html/track/WebVTTElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -80,10 +80,10 @@
AtomicString m_language;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(WebVTTElement)
- static bool isWebVTTElement(const Node& node) { return node.isWebVTTElement(); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::WebVTTElement)
+ static bool isType(const WebCore::Node& node) { return node.isWebVTTElement(); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (174124 => 174125)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2014-09-30 21:32:55 UTC (rev 174125)
@@ -1262,8 +1262,8 @@
InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForNonDocumentContext(ScriptExecutionContext* context)
{
- if (context->isWorkerGlobalScope())
- return instrumentationForWorkerGlobalScope(toWorkerGlobalScope(context));
+ if (is<WorkerGlobalScope>(context))
+ return instrumentationForWorkerGlobalScope(downcast<WorkerGlobalScope>(context));
return nullptr;
}
Modified: trunk/Source/WebCore/loader/ThreadableLoader.cpp (174124 => 174125)
--- trunk/Source/WebCore/loader/ThreadableLoader.cpp 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/loader/ThreadableLoader.cpp 2014-09-30 21:32:55 UTC (rev 174125)
@@ -56,8 +56,8 @@
ASSERT(client);
ASSERT(context);
- if (context->isWorkerGlobalScope())
- return WorkerThreadableLoader::create(toWorkerGlobalScope(context), client, WorkerRunLoop::defaultMode(), request, options);
+ if (is<WorkerGlobalScope>(context))
+ return WorkerThreadableLoader::create(downcast<WorkerGlobalScope>(context), client, WorkerRunLoop::defaultMode(), request, options);
return DocumentThreadableLoader::create(downcast<Document>(*context), *client, request, options);
}
@@ -66,8 +66,8 @@
{
ASSERT(context);
- if (context->isWorkerGlobalScope()) {
- WorkerThreadableLoader::loadResourceSynchronously(toWorkerGlobalScope(context), request, client, options);
+ if (is<WorkerGlobalScope>(context)) {
+ WorkerThreadableLoader::loadResourceSynchronously(downcast<WorkerGlobalScope>(context), request, client, options);
return;
}
Modified: trunk/Source/WebCore/loader/cache/MemoryCache.cpp (174124 => 174125)
--- trunk/Source/WebCore/loader/cache/MemoryCache.cpp 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/loader/cache/MemoryCache.cpp 2014-09-30 21:32:55 UTC (rev 174125)
@@ -752,8 +752,8 @@
void MemoryCache::removeRequestFromCache(ScriptExecutionContext* context, const ResourceRequest& request, SessionID sessionID)
{
- if (context->isWorkerGlobalScope()) {
- toWorkerGlobalScope(context)->thread().workerLoaderProxy().postTaskToLoader(CrossThreadTask(&crossThreadRemoveRequestFromCache, request, sessionID));
+ if (is<WorkerGlobalScope>(context)) {
+ downcast<WorkerGlobalScope>(*context).thread().workerLoaderProxy().postTaskToLoader(CrossThreadTask(&crossThreadRemoveRequestFromCache, request, sessionID));
return;
}
@@ -768,8 +768,8 @@
void MemoryCache::removeRequestFromSessionCaches(ScriptExecutionContext* context, const ResourceRequest& request)
{
- if (context->isWorkerGlobalScope()) {
- toWorkerGlobalScope(context)->thread().workerLoaderProxy().postTaskToLoader(CrossThreadTask(&crossThreadRemoveRequestFromSessionCaches, request));
+ if (is<WorkerGlobalScope>(context)) {
+ downcast<WorkerGlobalScope>(*context).thread().workerLoaderProxy().postTaskToLoader(CrossThreadTask(&crossThreadRemoveRequestFromSessionCaches, request));
return;
}
removeRequestFromSessionCachesImpl(context, request);
Modified: trunk/Source/WebCore/mathml/MathMLElement.h (174124 => 174125)
--- trunk/Source/WebCore/mathml/MathMLElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/mathml/MathMLElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -73,10 +73,6 @@
virtual void updateSelectedChild() { }
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(MathMLElement)
- static bool isMathMLElement(const Node& node) { return node.isMathMLElement(); }
-SPECIALIZE_TYPE_TRAITS_END()
-
inline bool Node::hasTagName(const MathMLQualifiedName& name) const
{
return isMathMLElement() && downcast<MathMLElement>(*this).hasTagName(name);
@@ -84,6 +80,10 @@
} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::MathMLElement)
+ static bool isType(const WebCore::Node& node) { return node.isMathMLElement(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
#include "MathMLElementTypeHelpers.h"
#endif // ENABLE(MATHML)
Modified: trunk/Source/WebCore/svg/SVGAnimateElementBase.h (174124 => 174125)
--- trunk/Source/WebCore/svg/SVGAnimateElementBase.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/svg/SVGAnimateElementBase.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -72,15 +72,15 @@
std::unique_ptr<SVGAnimatedTypeAnimator> m_animator;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(SVGAnimateElementBase)
- static bool isSVGAnimateElementBase(const SVGElement& element)
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SVGAnimateElementBase)
+ static bool isType(const WebCore::SVGElement& element)
{
- return element.hasTagName(SVGNames::animateTag) || element.hasTagName(SVGNames::animateColorTag)
- || element.hasTagName(SVGNames::animateTransformTag) || element.hasTagName(SVGNames::setTag);
+ return element.hasTagName(WebCore::SVGNames::animateTag) || element.hasTagName(WebCore::SVGNames::animateColorTag)
+ || element.hasTagName(WebCore::SVGNames::animateTransformTag) || element.hasTagName(WebCore::SVGNames::setTag);
}
- static bool isSVGAnimateElementBase(const Node& node) { return is<SVGElement>(node) && isSVGAnimateElementBase(downcast<SVGElement>(node)); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::SVGElement>(node) && isType(downcast<WebCore::SVGElement>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif // SVGAnimateElementBase_h
Modified: trunk/Source/WebCore/svg/SVGDocument.h (174124 => 174125)
--- trunk/Source/WebCore/svg/SVGDocument.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/svg/SVGDocument.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -52,11 +52,11 @@
FloatPoint m_translate;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(SVGDocument)
- static bool isSVGDocument(const Document& document) { return document.isSVGDocument(); }
- static bool isSVGDocument(const Node& node) { return is<Document>(node) && isSVGDocument(downcast<Document>(node)); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SVGDocument)
+ static bool isType(const WebCore::Document& document) { return document.isSVGDocument(); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::Document>(node) && isType(downcast<WebCore::Document>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif // SVGDocument_h
Modified: trunk/Source/WebCore/svg/SVGElement.h (174124 => 174125)
--- trunk/Source/WebCore/svg/SVGElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/svg/SVGElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -221,10 +221,6 @@
static bool equal(const QualifiedName& a, const QualifiedName& b) { return a.matches(b); }
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(SVGElement)
- static bool isSVGElement(const Node& node) { return node.isSVGElement(); }
-SPECIALIZE_TYPE_TRAITS_END()
-
inline bool Node::hasTagName(const SVGQualifiedName& name) const
{
return isSVGElement() && downcast<SVGElement>(*this).hasTagName(name);
@@ -232,6 +228,10 @@
} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SVGElement)
+ static bool isType(const WebCore::Node& node) { return node.isSVGElement(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
#include "SVGElementTypeHelpers.h"
#endif
Modified: trunk/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h (174124 => 174125)
--- trunk/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -82,11 +82,11 @@
void invalidateFilterPrimitiveParent(SVGElement*);
-SPECIALIZE_TYPE_TRAITS_BEGIN(SVGFilterPrimitiveStandardAttributes)
- static bool isSVGFilterPrimitiveStandardAttributes(const SVGElement& element) { return element.isFilterEffect(); }
- static bool isSVGFilterPrimitiveStandardAttributes(const Node& node) { return is<SVGElement>(node) && isSVGFilterPrimitiveStandardAttributes(downcast<SVGElement>(node)); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SVGFilterPrimitiveStandardAttributes)
+ static bool isType(const WebCore::SVGElement& element) { return element.isFilterEffect(); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::SVGElement>(node) && isType(downcast<WebCore::SVGElement>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif
Modified: trunk/Source/WebCore/svg/SVGGradientElement.h (174124 => 174125)
--- trunk/Source/WebCore/svg/SVGGradientElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/svg/SVGGradientElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -107,17 +107,17 @@
END_DECLARE_ANIMATED_PROPERTIES
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(SVGGradientElement)
-static bool isSVGGradientElement(const SVGElement& element)
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SVGGradientElement)
+static bool isType(const WebCore::SVGElement& element)
{
- return element.hasTagName(SVGNames::radialGradientTag) || element.hasTagName(SVGNames::linearGradientTag);
+ return element.hasTagName(WebCore::SVGNames::radialGradientTag) || element.hasTagName(WebCore::SVGNames::linearGradientTag);
}
-static bool isSVGGradientElement(const Node& node)
+static bool isType(const WebCore::Node& node)
{
- return is<SVGElement>(node) && isSVGGradientElement(downcast<SVGElement>(node));
+ return is<WebCore::SVGElement>(node) && isType(downcast<WebCore::SVGElement>(node));
}
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif
Modified: trunk/Source/WebCore/svg/SVGGraphicsElement.h (174124 => 174125)
--- trunk/Source/WebCore/svg/SVGGraphicsElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/svg/SVGGraphicsElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -82,11 +82,11 @@
bool m_shouldIsolateBlending;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(SVGGraphicsElement)
- static bool isSVGGraphicsElement(const SVGElement& element) { return element.isSVGGraphicsElement(); }
- static bool isSVGGraphicsElement(const Node& node) { return is<SVGElement>(node) && isSVGGraphicsElement(downcast<SVGElement>(node)); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SVGGraphicsElement)
+ static bool isType(const WebCore::SVGElement& element) { return element.isSVGGraphicsElement(); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::SVGElement>(node) && isType(downcast<WebCore::SVGElement>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif // SVGGraphicsElement_h
Modified: trunk/Source/WebCore/svg/SVGPolyElement.h (174124 => 174125)
--- trunk/Source/WebCore/svg/SVGPolyElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/svg/SVGPolyElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -62,11 +62,11 @@
mutable SVGSynchronizableAnimatedProperty<SVGPointList> m_points;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(SVGPolyElement)
- static bool isSVGPolyElement(const SVGElement& element) { return element.hasTagName(SVGNames::polygonTag) || element.hasTagName(SVGNames::polylineTag); }
- static bool isSVGPolyElement(const Node& node) { return is<SVGElement>(node) && isSVGPolyElement(downcast<SVGElement>(node)); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SVGPolyElement)
+ static bool isType(const WebCore::SVGElement& element) { return element.hasTagName(WebCore::SVGNames::polygonTag) || element.hasTagName(WebCore::SVGNames::polylineTag); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::SVGElement>(node) && isType(downcast<WebCore::SVGElement>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif
Modified: trunk/Source/WebCore/svg/SVGTextContentElement.h (174124 => 174125)
--- trunk/Source/WebCore/svg/SVGTextContentElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/svg/SVGTextContentElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -119,11 +119,11 @@
END_DECLARE_ANIMATED_PROPERTIES
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(SVGTextContentElement)
- static bool isSVGTextContentElement(const SVGElement& element) { return element.isTextContent(); }
- static bool isSVGTextContentElement(const Node& node) { return is<SVGElement>(node) && isSVGTextContentElement(downcast<SVGElement>(node)); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SVGTextContentElement)
+ static bool isType(const WebCore::SVGElement& element) { return element.isTextContent(); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::SVGElement>(node) && isType(downcast<WebCore::SVGElement>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
-
#endif
Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.h (174124 => 174125)
--- trunk/Source/WebCore/svg/animation/SVGSMILElement.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -237,11 +237,11 @@
friend class ConditionEventListener;
};
-SPECIALIZE_TYPE_TRAITS_BEGIN(SVGSMILElement)
- static bool isSVGSMILElement(const SVGElement& element) { return element.isSMILElement(); }
- static bool isSVGSMILElement(const Node& node) { return is<SVGElement>(node) && isSVGSMILElement(downcast<SVGElement>(node)); }
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SVGSMILElement)
+ static bool isType(const WebCore::SVGElement& element) { return element.isSMILElement(); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::SVGElement>(node) && isType(downcast<WebCore::SVGElement>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
-}
-
#endif // SVGSMILElement_h
Modified: trunk/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp (174124 => 174125)
--- trunk/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp 2014-09-30 21:32:55 UTC (rev 174125)
@@ -257,12 +257,12 @@
: ScriptExecutionContext::Task([=] (ScriptExecutionContext& context) {
RefPtr<MessagePort> port = MessagePort::create(context);
port->entangle(std::unique_ptr<MessagePortChannel>(channel));
- ASSERT_WITH_SECURITY_IMPLICATION(context.isWorkerGlobalScope());
- WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(&context);
+ ASSERT_WITH_SECURITY_IMPLICATION(is<WorkerGlobalScope>(context));
+ WorkerGlobalScope& workerGlobalScope = downcast<WorkerGlobalScope>(context);
// Since close() stops the thread event loop, this should not ever get called while closing.
- ASSERT(!workerGlobalScope->isClosing());
- ASSERT_WITH_SECURITY_IMPLICATION(workerGlobalScope->isSharedWorkerGlobalScope());
- workerGlobalScope->dispatchEvent(createConnectEvent(port));
+ ASSERT(!workerGlobalScope.isClosing());
+ ASSERT_WITH_SECURITY_IMPLICATION(workerGlobalScope.isSharedWorkerGlobalScope());
+ workerGlobalScope.dispatchEvent(createConnectEvent(port));
})
{
}
Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.cpp (174124 => 174125)
--- trunk/Source/WebCore/workers/WorkerGlobalScope.cpp 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.cpp 2014-09-30 21:32:55 UTC (rev 174125)
@@ -133,10 +133,10 @@
// tasks with isCleanupTask()==true will be executed.
m_closing = true;
postTask({ ScriptExecutionContext::Task::CleanupTask, [] (ScriptExecutionContext& context) {
- ASSERT_WITH_SECURITY_IMPLICATION(context.isWorkerGlobalScope());
- WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(&context);
+ ASSERT_WITH_SECURITY_IMPLICATION(is<WorkerGlobalScope>(context));
+ WorkerGlobalScope& workerGlobalScope = downcast<WorkerGlobalScope>(context);
// Notify parent that this context is closed. Parent is responsible for calling WorkerThread::stop().
- workerGlobalScope->thread().workerReportingProxy().workerGlobalScopeClosed();
+ workerGlobalScope.thread().workerReportingProxy().workerGlobalScopeClosed();
} });
}
Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.h (174124 => 174125)
--- trunk/Source/WebCore/workers/WorkerGlobalScope.h 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.h 2014-09-30 21:32:55 UTC (rev 174125)
@@ -40,6 +40,7 @@
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
+#include <wtf/TypeCasts.h>
#include <wtf/text/AtomicStringHash.h>
namespace WebCore {
@@ -181,8 +182,10 @@
RefPtr<SecurityOrigin> m_topOrigin;
};
-SCRIPT_EXECUTION_CONTEXT_TYPE_CASTS(WorkerGlobalScope)
-
} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::WorkerGlobalScope)
+ static bool isType(const WebCore::ScriptExecutionContext& context) { return context.isWorkerGlobalScope(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
#endif // WorkerGlobalScope_h
Modified: trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp (174124 => 174125)
--- trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp 2014-09-30 21:32:55 UTC (rev 174125)
@@ -68,15 +68,15 @@
#endif
{
ASSERT(m_workerObject);
- ASSERT((m_scriptExecutionContext->isDocument() && isMainThread())
- || (m_scriptExecutionContext->isWorkerGlobalScope() && currentThread() == toWorkerGlobalScope(*m_scriptExecutionContext).thread().threadID()));
+ ASSERT((is<Document>(*m_scriptExecutionContext) && isMainThread())
+ || (is<WorkerGlobalScope>(*m_scriptExecutionContext) && currentThread() == downcast<WorkerGlobalScope>(*m_scriptExecutionContext).thread().threadID()));
}
WorkerMessagingProxy::~WorkerMessagingProxy()
{
ASSERT(!m_workerObject);
- ASSERT((m_scriptExecutionContext->isDocument() && isMainThread())
- || (m_scriptExecutionContext->isWorkerGlobalScope() && currentThread() == toWorkerGlobalScope(*m_scriptExecutionContext).thread().threadID()));
+ ASSERT((is<Document>(*m_scriptExecutionContext) && isMainThread())
+ || (is<WorkerGlobalScope>(*m_scriptExecutionContext) && currentThread() == downcast<WorkerGlobalScope>(*m_scriptExecutionContext).thread().threadID()));
}
void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode)
@@ -212,7 +212,7 @@
return;
m_workerThread->runLoop().postTask([=] (ScriptExecutionContext& context) {
- toWorkerGlobalScope(&context)->dispatchEvent(Event::create(isOnline ? eventNames().onlineEvent : eventNames().offlineEvent, false, false));
+ downcast<WorkerGlobalScope>(context).dispatchEvent(Event::create(isOnline ? eventNames().onlineEvent : eventNames().offlineEvent, false, false));
});
}
@@ -224,17 +224,17 @@
ASSERT(!m_pageInspector);
m_pageInspector = pageInspector;
m_workerThread->runLoop().postTaskForMode([] (ScriptExecutionContext& context) {
- toWorkerGlobalScope(&context)->workerInspectorController().connectFrontend();
+ downcast<WorkerGlobalScope>(context).workerInspectorController().connectFrontend();
}, WorkerDebuggerAgent::debuggerTaskMode);
}
void WorkerMessagingProxy::disconnectFromInspector()
{
- m_pageInspector = 0;
+ m_pageInspector = nullptr;
if (m_askedToTerminate)
return;
m_workerThread->runLoop().postTaskForMode([] (ScriptExecutionContext& context) {
- toWorkerGlobalScope(&context)->workerInspectorController().disconnectFrontend(Inspector::InspectorDisconnectReason::InspectorDestroyed);
+ downcast<WorkerGlobalScope>(context).workerInspectorController().disconnectFrontend(Inspector::InspectorDisconnectReason::InspectorDestroyed);
}, WorkerDebuggerAgent::debuggerTaskMode);
}
@@ -244,7 +244,7 @@
return;
String messageCopy = message.isolatedCopy();
m_workerThread->runLoop().postTaskForMode([messageCopy] (ScriptExecutionContext& context) {
- toWorkerGlobalScope(&context)->workerInspectorController().dispatchMessageFromFrontend(messageCopy);
+ downcast<WorkerGlobalScope>(context).workerInspectorController().dispatchMessageFromFrontend(messageCopy);
}, WorkerDebuggerAgent::debuggerTaskMode);
WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(m_workerThread.get());
}
Modified: trunk/Source/WebCore/workers/WorkerScriptLoader.cpp (174124 => 174125)
--- trunk/Source/WebCore/workers/WorkerScriptLoader.cpp 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/workers/WorkerScriptLoader.cpp 2014-09-30 21:32:55 UTC (rev 174125)
@@ -61,14 +61,14 @@
if (!request)
return;
- ASSERT_WITH_SECURITY_IMPLICATION(scriptExecutionContext->isWorkerGlobalScope());
+ ASSERT_WITH_SECURITY_IMPLICATION(is<WorkerGlobalScope>(scriptExecutionContext));
ThreadableLoaderOptions options;
options.setAllowCredentials(AllowStoredCredentials);
options.crossOriginRequestPolicy = crossOriginRequestPolicy;
options.setSendLoadCallbacks(SendCallbacks);
- WorkerThreadableLoader::loadResourceSynchronously(toWorkerGlobalScope(scriptExecutionContext), *request, *this, options);
+ WorkerThreadableLoader::loadResourceSynchronously(downcast<WorkerGlobalScope>(scriptExecutionContext), *request, *this, options);
}
void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext* scriptExecutionContext, const URL& url, CrossOriginRequestPolicy crossOriginRequestPolicy, WorkerScriptLoaderClient* client)
Modified: trunk/Source/WebCore/workers/WorkerThread.cpp (174124 => 174125)
--- trunk/Source/WebCore/workers/WorkerThread.cpp 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebCore/workers/WorkerThread.cpp 2014-09-30 21:32:55 UTC (rev 174125)
@@ -214,21 +214,21 @@
DatabaseManager::manager().interruptAllDatabasesForContext(m_workerGlobalScope.get());
#endif
m_runLoop.postTaskAndTerminate({ ScriptExecutionContext::Task::CleanupTask, [] (ScriptExecutionContext& context ) {
- WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(&context);
+ WorkerGlobalScope& workerGlobalScope = downcast<WorkerGlobalScope>(context);
#if ENABLE(SQL_DATABASE)
// FIXME: Should we stop the databases as part of stopActiveDOMObjects() below?
DatabaseTaskSynchronizer cleanupSync;
- DatabaseManager::manager().stopDatabases(workerGlobalScope, &cleanupSync);
+ DatabaseManager::manager().stopDatabases(&workerGlobalScope, &cleanupSync);
#endif
- workerGlobalScope->stopActiveDOMObjects();
+ workerGlobalScope.stopActiveDOMObjects();
- workerGlobalScope->notifyObserversOfStop();
+ workerGlobalScope.notifyObserversOfStop();
// Event listeners would keep DOMWrapperWorld objects alive for too long. Also, they have references to JS objects,
// which become dangling once Heap is destroyed.
- workerGlobalScope->removeAllEventListeners();
+ workerGlobalScope.removeAllEventListeners();
#if ENABLE(SQL_DATABASE)
// We wait for the database thread to clean up all its stuff so that we
@@ -238,10 +238,10 @@
// Stick a shutdown command at the end of the queue, so that we deal
// with all the cleanup tasks the databases post first.
- workerGlobalScope->postTask({ ScriptExecutionContext::Task::CleanupTask, [] (ScriptExecutionContext& context) {
- WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(&context);
+ workerGlobalScope.postTask({ ScriptExecutionContext::Task::CleanupTask, [] (ScriptExecutionContext& context) {
+ WorkerGlobalScope& workerGlobalScope = downcast<WorkerGlobalScope>(context);
// It's not safe to call clearScript until all the cleanup tasks posted by functions initiated by WorkerThreadShutdownStartTask have completed.
- workerGlobalScope->clearScript();
+ workerGlobalScope.clearScript();
} });
} });
Modified: trunk/Source/WebKit/win/ChangeLog (174124 => 174125)
--- trunk/Source/WebKit/win/ChangeLog 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebKit/win/ChangeLog 2014-09-30 21:32:55 UTC (rev 174125)
@@ -1,3 +1,15 @@
+2014-09-30 Christophe Dumez <[email protected]>
+
+ Generalize is<>() / downcast<>() support to all types
+ https://bugs.webkit.org/show_bug.cgi?id=137243
+
+ Reviewed by Benjamin Poulain.
+
+ Generalize is<>() / downcast<>() support to all types, not just Nodes.
+
+ * DOMCoreClasses.cpp:
+ (DOMElement::createInstance):
+
2014-09-30 Chris Dumez <[email protected]>
Use is<>() / downcast<>() for Element
Modified: trunk/Source/WebKit/win/DOMCoreClasses.cpp (174124 => 174125)
--- trunk/Source/WebKit/win/DOMCoreClasses.cpp 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebKit/win/DOMCoreClasses.cpp 2014-09-30 21:32:55 UTC (rev 174125)
@@ -1500,22 +1500,22 @@
HRESULT hr;
IDOMElement* domElement = 0;
- if (WebCore::is<WebCore::HTMLFormElement>(e)) {
+ if (is<WebCore::HTMLFormElement>(e)) {
DOMHTMLFormElement* newElement = new DOMHTMLFormElement(e);
hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement);
} else if (e->hasTagName(iframeTag)) {
DOMHTMLIFrameElement* newElement = new DOMHTMLIFrameElement(e);
hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement);
- } else if (WebCore::is<WebCore::HTMLInputElement>(e)) {
+ } else if (is<WebCore::HTMLInputElement>(e)) {
DOMHTMLInputElement* newElement = new DOMHTMLInputElement(e);
hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement);
- } else if (WebCore::is<WebCore::HTMLOptionElement>(e)) {
+ } else if (is<WebCore::HTMLOptionElement>(e)) {
DOMHTMLOptionElement* newElement = new DOMHTMLOptionElement(e);
hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement);
} else if (e->hasTagName(selectTag)) {
DOMHTMLSelectElement* newElement = new DOMHTMLSelectElement(e);
hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement);
- } else if (WebCore::is<WebCore::HTMLTextAreaElement>(e)) {
+ } else if (is<WebCore::HTMLTextAreaElement>(e)) {
DOMHTMLTextAreaElement* newElement = new DOMHTMLTextAreaElement(e);
hr = newElement->QueryInterface(IID_IDOMElement, (void**)&domElement);
} else if (e->isHTMLElement()) {
Modified: trunk/Source/WebKit2/ChangeLog (174124 => 174125)
--- trunk/Source/WebKit2/ChangeLog 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebKit2/ChangeLog 2014-09-30 21:32:55 UTC (rev 174125)
@@ -1,3 +1,20 @@
+2014-09-30 Christophe Dumez <[email protected]>
+
+ Generalize is<>() / downcast<>() support to all types
+ https://bugs.webkit.org/show_bug.cgi?id=137243
+
+ Reviewed by Benjamin Poulain.
+
+ Generalize is<>() / downcast<>() support to all types, not just Nodes.
+
+ * WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm:
+ (-[WKDOMDocument createElement:]):
+ (-[WKDOMDocument createTextNode:]):
+ (-[WKDOMDocument body]):
+ * WebProcess/InjectedBundle/API/mac/WKDOMText.mm:
+ (-[WKDOMText data]):
+ (-[WKDOMText setData:]):
+
2014-09-30 Chris Dumez <[email protected]>
Use is<>() / downcast<>() for Element
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm (174124 => 174125)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm 2014-09-30 21:32:55 UTC (rev 174125)
@@ -39,17 +39,17 @@
{
// FIXME: Do something about the exception.
WebCore::ExceptionCode ec = 0;
- return WebKit::toWKDOMElement(WebCore::downcast<WebCore::Document>(*_impl).createElement(tagName, ec).get());
+ return WebKit::toWKDOMElement(downcast<WebCore::Document>(*_impl).createElement(tagName, ec).get());
}
- (WKDOMText *)createTextNode:(NSString *)data
{
- return WebKit::toWKDOMText(WebCore::downcast<WebCore::Document>(*_impl).createTextNode(data).get());
+ return WebKit::toWKDOMText(downcast<WebCore::Document>(*_impl).createTextNode(data).get());
}
- (WKDOMElement *)body
{
- return WebKit::toWKDOMElement(WebCore::downcast<WebCore::Document>(*_impl).body());
+ return WebKit::toWKDOMElement(downcast<WebCore::Document>(*_impl).body());
}
@end
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.mm (174124 => 174125)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.mm 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMElement.mm 2014-09-30 21:32:55 UTC (rev 174125)
@@ -35,24 +35,24 @@
- (BOOL)hasAttribute:(NSString *)attribute
{
- return WebCore::downcast<WebCore::Element>(*_impl).hasAttribute(attribute);
+ return downcast<WebCore::Element>(*_impl).hasAttribute(attribute);
}
- (NSString *)getAttribute:(NSString *)attribute
{
- return WebCore::downcast<WebCore::Element>(*_impl).getAttribute(attribute);
+ return downcast<WebCore::Element>(*_impl).getAttribute(attribute);
}
- (void)setAttribute:(NSString *)name value:(NSString *)value
{
// FIXME: Do something about the exception.
WebCore::ExceptionCode ec;
- WebCore::downcast<WebCore::Element>(*_impl).setAttribute(name, value, ec);
+ downcast<WebCore::Element>(*_impl).setAttribute(name, value, ec);
}
- (NSString *)tagName
{
- return WebCore::downcast<WebCore::Element>(*_impl).tagName();
+ return downcast<WebCore::Element>(*_impl).tagName();
}
@end
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMText.mm (174124 => 174125)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMText.mm 2014-09-30 21:30:22 UTC (rev 174124)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMText.mm 2014-09-30 21:32:55 UTC (rev 174125)
@@ -35,14 +35,14 @@
- (NSString *)data
{
- return WebCore::downcast<WebCore::Text>(*_impl).data();
+ return downcast<WebCore::Text>(*_impl).data();
}
- (void)setData:(NSString *)data
{
// FIXME: Do something about the exception.
WebCore::ExceptionCode ec;
- WebCore::downcast<WebCore::Text>(*_impl).setData(data, ec);
+ downcast<WebCore::Text>(*_impl).setData(data, ec);
}
@end