Diff
Modified: trunk/Source/WebCore/ChangeLog (174088 => 174089)
--- trunk/Source/WebCore/ChangeLog 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/ChangeLog 2014-09-29 22:23:20 UTC (rev 174089)
@@ -1,3 +1,176 @@
+2014-09-29 Christophe Dumez <cdu...@apple.com>
+
+ Use is<>() / downcast<>() for Document
+ https://bugs.webkit.org/show_bug.cgi?id=137221
+
+ Reviewed by Andreas Kling.
+
+ Use is<>() / downcast<>() for Document instead of isDocumentNode() /
+ toDocument().
+
+ No new tests, no behavior change.
+
+ * Modules/geolocation/Geolocation.cpp:
+ (WebCore::Geolocation::document):
+ (WebCore::Geolocation::frame):
+ (WebCore::Geolocation::page):
+ * Modules/indexeddb/IDBFactory.cpp:
+ * Modules/mediasource/SourceBuffer.cpp:
+ (WebCore::SourceBuffer::document):
+ * Modules/mediastream/RTCPeerConnection.cpp:
+ (WebCore::RTCPeerConnection::RTCPeerConnection):
+ * Modules/notifications/Notification.cpp:
+ (WebCore::Notification::Notification):
+ (WebCore::Notification::show):
+ (WebCore::Notification::permission):
+ (WebCore::Notification::requestPermission):
+ * Modules/webaudio/AudioContext.cpp:
+ (WebCore::AudioContext::document):
+ * Modules/webaudio/OfflineAudioContext.cpp:
+ (WebCore::OfflineAudioContext::create):
+ * Modules/webdatabase/DatabaseContext.cpp:
+ (WebCore::DatabaseContext::allowDatabaseAccess):
+ (WebCore::DatabaseContext::databaseExceededQuota):
+ * Modules/websockets/ThreadableWebSocketChannel.cpp:
+ (WebCore::ThreadableWebSocketChannel::create):
+ * Modules/websockets/WebSocket.cpp:
+ (WebCore::WebSocket::connect):
+ * Modules/websockets/WebSocketHandshake.cpp:
+ (WebCore::WebSocketHandshake::clientHandshakeMessage):
+ (WebCore::WebSocketHandshake::clientHandshakeRequest):
+ * Modules/websockets/WorkerThreadableWebSocketChannel.cpp:
+ (WebCore::WorkerThreadableWebSocketChannel::Peer::Peer):
+ * bindings/gobject/WebKitDOMPrivate.cpp:
+ (WebKit::wrap):
+ * bindings/js/DOMConstructorWithDocument.h:
+ (WebCore::DOMConstructorWithDocument::document):
+ * bindings/js/DOMRequestState.h:
+ (WebCore::DOMRequestState::DOMRequestState):
+ (WebCore::DOMRequestState::clear):
+ * bindings/js/JSAudioContextCustom.cpp:
+ (WebCore::constructJSAudioContext):
+ * bindings/js/JSDOMGlobalObject.cpp:
+ (WebCore::toJSDOMGlobalObject):
+ * bindings/js/JSLazyEventListener.cpp:
+ (WebCore::JSLazyEventListener::initializeJSFunction):
+ * bindings/js/JSNodeCustom.cpp:
+ (WebCore::createWrapperInline):
+ * bindings/js/ScheduledAction.cpp:
+ (WebCore::ScheduledAction::execute):
+ * bindings/js/ScriptState.cpp:
+ (WebCore::frameFromExecState):
+ * crypto/SubtleCrypto.cpp:
+ (WebCore::SubtleCrypto::document):
+ * dom/Comment.cpp:
+ (WebCore::Comment::create):
+ * dom/ContainerNode.cpp:
+ (WebCore::checkAcceptChild):
+ * dom/ContainerNodeAlgorithms.cpp:
+ (WebCore::ChildNodeInsertionNotifier::notifyDescendantInsertedIntoDocument):
+ * dom/Document.h:
+ (WebCore::isDocument):
+ * dom/DocumentFragment.cpp:
+ (WebCore::DocumentFragment::create):
+ * dom/Element.cpp:
+ (WebCore::Element::computeInheritedLanguage):
+ * dom/EventDispatcher.cpp:
+ (WebCore::WindowEventContext::WindowEventContext):
+ * dom/EventTarget.cpp:
+ (WebCore::EventTarget::fireEventListeners):
+ * dom/NamedFlowCollection.cpp:
+ (WebCore::NamedFlowCollection::document):
+ * dom/Node.cpp:
+ (WebCore::Node::isDefaultNamespace):
+ (WebCore::Node::lookupPrefix):
+ (WebCore::Node::lookupNamespaceURI):
+ (WebCore::Node::removedLastRef):
+ * dom/Range.cpp:
+ (WebCore::Range::create):
+ * dom/ScriptExecutionContext.cpp:
+ (WebCore::ScriptExecutionContext::dispatchErrorEvent):
+ * dom/Text.cpp:
+ (WebCore::Text::create):
+ * editing/MarkupAccumulator.cpp:
+ (WebCore::MarkupAccumulator::appendStartMarkup):
+ * html/HTMLDocument.h:
+ (WebCore::isHTMLDocument):
+ * html/HTMLNameCollection.h:
+ (WebCore::HTMLNameCollection::document):
+ * html/HTMLStyleElement.cpp:
+ (WebCore::HTMLStyleElement::insertedInto):
+ * html/ImageDocument.h:
+ (WebCore::isImageDocument):
+ * html/MediaDocument.h:
+ (WebCore::isMediaDocument):
+ * html/PluginDocument.h:
+ (WebCore::isPluginDocument):
+ * html/track/TextTrackCue.h:
+ (WebCore::TextTrackCue::ownerDocument):
+ * html/track/VTTCue.cpp:
+ (WebCore::VTTCue::initialize):
+ * html/track/VTTRegion.h:
+ (WebCore::VTTRegion::ownerDocument):
+ * inspector/InspectorDOMAgent.cpp:
+ (WebCore::InspectorDOMAgent::assertDocument):
+ (WebCore::InspectorDOMAgent::buildObjectForNode):
+ (WebCore::InspectorDOMAgent::innerParentNode):
+ * inspector/InspectorInstrumentation.cpp:
+ (WebCore::frameForScriptExecutionContext):
+ * inspector/InspectorInstrumentation.h:
+ (WebCore::InspectorInstrumentation::instrumentingAgentsForContext):
+ * loader/TextTrackLoader.cpp:
+ (WebCore::TextTrackLoader::corsPolicyPreventedLoad):
+ (WebCore::TextTrackLoader::notifyFinished):
+ (WebCore::TextTrackLoader::load):
+ * loader/ThreadableLoader.cpp:
+ (WebCore::ThreadableLoader::create):
+ (WebCore::ThreadableLoader::loadResourceSynchronously):
+ * loader/WorkerThreadableLoader.cpp:
+ (WebCore::WorkerThreadableLoader::MainThreadBridge::mainThreadCreateLoader):
+ * page/ContentSecurityPolicy.cpp:
+ (WebCore::ContentSecurityPolicy::reportViolation):
+ * page/Crypto.cpp:
+ (WebCore::Crypto::document):
+ * page/DOMTimer.cpp:
+ (WebCore::DOMTimer::install):
+ (WebCore::DOMTimer::fired):
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::focus):
+ (WebCore::DOMWindow::close):
+ (WebCore::DOMWindow::document):
+ (WebCore::DOMWindow::styleMedia):
+ (WebCore::DOMWindow::getComputedStyle):
+ * page/DragController.cpp:
+ (WebCore::DragController::dragExited):
+ (WebCore::DragController::dragEnteredOrUpdated):
+ * page/EventSource.cpp:
+ (WebCore::EventSource::create):
+ * page/FocusController.cpp:
+ (WebCore::FocusController::advanceFocusDirectionally):
+ * page/History.cpp:
+ (WebCore::History::go):
+ * page/SpatialNavigation.cpp:
+ (WebCore::scrollInDirection):
+ (WebCore::scrollableEnclosingBoxOrParentFrameForNodeInDirection):
+ (WebCore::canScrollInDirection):
+ (WebCore::nodeRectInAbsoluteCoordinates):
+ * svg/SVGDocument.h:
+ (WebCore::isSVGDocument):
+ * testing/Internals.cpp:
+ (WebCore::Internals::contextDocument):
+ (WebCore::Internals::frame):
+ (WebCore::Internals::updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks):
+ * testing/js/WebCoreTestSupport.cpp:
+ (WebCoreTestSupport::injectInternalsObject):
+ (WebCoreTestSupport::resetInternalsObject):
+ * workers/DefaultSharedWorkerRepository.cpp:
+ (WebCore::SharedWorkerProxy::addToWorkerDocuments):
+ * workers/WorkerMessagingProxy.cpp:
+ (WebCore::WorkerMessagingProxy::startWorkerGlobalScope):
+ * xml/XMLHttpRequest.cpp:
+ (WebCore::XMLHttpRequest::document):
+ (WebCore::XMLHttpRequest::open):
+
2014-09-29 David Hyatt <hy...@apple.com>
REGRESSION (r168046): Confused column spans when combined with dynamic animations
Modified: trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp (174088 => 174089)
--- trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -250,17 +250,17 @@
Document* Geolocation::document() const
{
- return toDocument(scriptExecutionContext());
+ return downcast<Document>(scriptExecutionContext());
}
Frame* Geolocation::frame() const
{
- return document() ? document()->frame() : 0;
+ return document() ? document()->frame() : nullptr;
}
Page* Geolocation::page() const
{
- return document() ? document()->page() : 0;
+ return document() ? document()->page() : nullptr;
}
#if PLATFORM(IOS)
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp (174088 => 174089)
--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -68,10 +68,10 @@
namespace {
static bool isContextValid(ScriptExecutionContext* context)
{
- ASSERT(context->isDocument() || context->isWorkerGlobalScope());
- if (context->isDocument()) {
- Document* document = toDocument(context);
- return document->frame() && document->page() && (!document->page()->usesEphemeralSession() || SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing(document->securityOrigin()->protocol()));
+ ASSERT(is<Document>(context) || context->isWorkerGlobalScope());
+ if (is<Document>(context)) {
+ Document& document = downcast<Document>(*context);
+ return document.frame() && document.page() && (!document.page()->usesEphemeralSession() || SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing(document.securityOrigin()->protocol()));
}
return true;
}
@@ -79,9 +79,9 @@
static String getIndexedDBDatabasePath(ScriptExecutionContext* context)
{
ASSERT(isContextValid(context));
- if (context->isDocument()) {
- Document* document = toDocument(context);
- return document->page()->group().groupSettings().indexedDBDatabasePath();
+ if (is<Document>(context)) {
+ Document& document = downcast<Document>(*context);
+ return document.page()->group().groupSettings().indexedDBDatabasePath();
}
const GroupSettings* groupSettings = toWorkerGlobalScope(context)->groupSettings();
if (groupSettings)
Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp (174088 => 174089)
--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -1796,7 +1796,7 @@
Document& SourceBuffer::document() const
{
ASSERT(scriptExecutionContext());
- return *toDocument(scriptExecutionContext());
+ return downcast<Document>(*scriptExecutionContext());
}
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (174088 => 174089)
--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -178,7 +178,7 @@
, m_configuration(configuration)
, m_stopped(false)
{
- Document& document = toDocument(context);
+ Document& document = downcast<Document>(context);
if (!document.frame()) {
ec = NOT_SUPPORTED_ERR;
Modified: trunk/Source/WebCore/Modules/notifications/Notification.cpp (174088 => 174089)
--- trunk/Source/WebCore/Modules/notifications/Notification.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/Modules/notifications/Notification.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -86,7 +86,7 @@
, m_state(Idle)
, m_taskTimer(std::make_unique<Timer<Notification>>(this, &Notification::taskTimerFired))
{
- m_notificationCenter = DOMWindowNotifications::webkitNotifications(toDocument(context).domWindow());
+ m_notificationCenter = DOMWindowNotifications::webkitNotifications(downcast<Document>(context).domWindow());
ASSERT(m_notificationCenter->client());
m_taskTimer->startOneShot(0);
@@ -135,9 +135,9 @@
// prevent double-showing
if (m_state == Idle && m_notificationCenter->client()) {
#if ENABLE(NOTIFICATIONS)
- if (!toDocument(scriptExecutionContext())->page())
+ if (!downcast<Document>(*scriptExecutionContext()).page())
return;
- if (NotificationController::from(toDocument(scriptExecutionContext())->page())->client()->checkPermission(scriptExecutionContext()) != NotificationClient::PermissionAllowed) {
+ if (NotificationController::from(downcast<Document>(*scriptExecutionContext()).page())->client()->checkPermission(scriptExecutionContext()) != NotificationClient::PermissionAllowed) {
dispatchErrorEvent();
return;
}
@@ -213,8 +213,8 @@
#if ENABLE(NOTIFICATIONS)
const String Notification::permission(ScriptExecutionContext* context)
{
- ASSERT(toDocument(context)->page());
- return permissionString(NotificationController::from(toDocument(context)->page())->client()->checkPermission(context));
+ ASSERT(downcast<Document>(*context).page());
+ return permissionString(NotificationController::from(downcast<Document>(*context).page())->client()->checkPermission(context));
}
const String Notification::permissionString(NotificationClient::Permission permission)
@@ -234,8 +234,8 @@
void Notification::requestPermission(ScriptExecutionContext* context, PassRefPtr<NotificationPermissionCallback> callback)
{
- ASSERT(toDocument(context)->page());
- NotificationController::from(toDocument(context)->page())->client()->requestPermission(context, callback);
+ ASSERT(downcast<Document>(*context).page());
+ NotificationController::from(downcast<Document>(*context).page())->client()->requestPermission(context, callback);
}
#endif
Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp (174088 => 174089)
--- trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -325,7 +325,7 @@
Document* AudioContext::document() const
{
ASSERT(m_scriptExecutionContext);
- return toDocument(m_scriptExecutionContext);
+ return downcast<Document>(m_scriptExecutionContext);
}
PassRefPtr<AudioBuffer> AudioContext::createBuffer(unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionCode& ec)
Modified: trunk/Source/WebCore/Modules/webaudio/OfflineAudioContext.cpp (174088 => 174089)
--- trunk/Source/WebCore/Modules/webaudio/OfflineAudioContext.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/Modules/webaudio/OfflineAudioContext.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -37,12 +37,12 @@
PassRefPtr<OfflineAudioContext> OfflineAudioContext::create(ScriptExecutionContext& context, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionCode& ec)
{
// FIXME: add support for workers.
- if (!context.isDocument()) {
+ if (!is<Document>(context)) {
ec = NOT_SUPPORTED_ERR;
return nullptr;
}
- Document& document = toDocument(context);
+ Document& document = downcast<Document>(context);
if (numberOfChannels > 10 || !isSampleRateRangeGood(sampleRate)) {
ec = SYNTAX_ERR;
Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseContext.cpp (174088 => 174089)
--- trunk/Source/WebCore/Modules/webdatabase/DatabaseContext.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseContext.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -218,9 +218,9 @@
bool DatabaseContext::allowDatabaseAccess() const
{
- if (m_scriptExecutionContext->isDocument()) {
- Document* document = toDocument(m_scriptExecutionContext);
- if (!document->page() || (document->page()->usesEphemeralSession() && !SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing(document->securityOrigin()->protocol())))
+ if (is<Document>(*m_scriptExecutionContext)) {
+ Document& document = downcast<Document>(*m_scriptExecutionContext);
+ if (!document.page() || (document.page()->usesEphemeralSession() && !SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing(document.securityOrigin()->protocol())))
return false;
return true;
}
@@ -231,10 +231,10 @@
void DatabaseContext::databaseExceededQuota(const String& name, DatabaseDetails details)
{
- if (m_scriptExecutionContext->isDocument()) {
- Document* document = toDocument(m_scriptExecutionContext);
- if (Page* page = document->page())
- page->chrome().client().exceededDatabaseQuota(document->frame(), name, details);
+ if (is<Document>(*m_scriptExecutionContext)) {
+ Document& document = downcast<Document>(*m_scriptExecutionContext);
+ if (Page* page = document.page())
+ page->chrome().client().exceededDatabaseQuota(document.frame(), name, details);
return;
}
ASSERT(m_scriptExecutionContext->isWorkerGlobalScope());
Modified: trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp (174088 => 174089)
--- trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -64,7 +64,7 @@
return WorkerThreadableWebSocketChannel::create(workerGlobalScope, client, mode.toString());
}
- return WebSocketChannel::create(toDocument(context), client);
+ return WebSocketChannel::create(downcast<Document>(context), client);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.cpp (174088 => 174089)
--- trunk/Source/WebCore/Modules/websockets/WebSocket.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -239,9 +239,9 @@
// FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved.
bool shouldBypassMainWorldContentSecurityPolicy = false;
- if (scriptExecutionContext()->isDocument()) {
- Document* document = toDocument(scriptExecutionContext());
- shouldBypassMainWorldContentSecurityPolicy = document->frame()->script().shouldBypassMainWorldContentSecurityPolicy();
+ if (is<Document>(scriptExecutionContext())) {
+ Document& document = downcast<Document>(*scriptExecutionContext());
+ shouldBypassMainWorldContentSecurityPolicy = document.frame()->script().shouldBypassMainWorldContentSecurityPolicy();
}
if (!shouldBypassMainWorldContentSecurityPolicy && !scriptExecutionContext()->contentSecurityPolicy()->allowConnectToSource(m_url)) {
m_state = CLOSED;
Modified: trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp (174088 => 174089)
--- trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -196,9 +196,9 @@
fields.append("Sec-WebSocket-Protocol: " + m_clientProtocol);
URL url = ""
- if (m_context->isDocument()) {
- Document* document = toDocument(m_context);
- String cookie = cookieRequestHeaderFieldValue(document, url);
+ if (is<Document>(m_context)) {
+ Document& document = downcast<Document>(*m_context);
+ String cookie = cookieRequestHeaderFieldValue(&document, url);
if (!cookie.isEmpty())
fields.append("Cookie: " + cookie);
// Set "Cookie2: <cookie>" if cookies 2 exists for url?
@@ -247,9 +247,9 @@
request.setHTTPHeaderField(HTTPHeaderName::SecWebSocketProtocol, m_clientProtocol);
URL url = ""
- if (m_context->isDocument()) {
- Document* document = toDocument(m_context);
- String cookie = cookieRequestHeaderFieldValue(document, url);
+ if (is<Document>(*m_context)) {
+ Document& document = downcast<Document>(*m_context);
+ String cookie = cookieRequestHeaderFieldValue(&document, url);
if (!cookie.isEmpty())
request.setHTTPHeaderField(HTTPHeaderName::Cookie, cookie);
// Set "Cookie2: <cookie>" if cookies 2 exists for url?
Modified: trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp (174088 => 174089)
--- trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -147,7 +147,7 @@
WorkerThreadableWebSocketChannel::Peer::Peer(PassRefPtr<ThreadableWebSocketChannelClientWrapper> clientWrapper, WorkerLoaderProxy& loaderProxy, ScriptExecutionContext* context, const String& taskMode)
: m_workerClientWrapper(clientWrapper)
, m_loaderProxy(loaderProxy)
- , m_mainWebSocketChannel(WebSocketChannel::create(toDocument(context), this))
+ , m_mainWebSocketChannel(WebSocketChannel::create(downcast<Document>(context), this))
, m_taskMode(taskMode)
{
ASSERT(isMainThread());
Modified: trunk/Source/WebCore/bindings/gobject/WebKitDOMPrivate.cpp (174088 => 174089)
--- trunk/Source/WebCore/bindings/gobject/WebKitDOMPrivate.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/bindings/gobject/WebKitDOMPrivate.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -100,9 +100,9 @@
case Node::COMMENT_NODE:
return WEBKIT_DOM_NODE(wrapComment(static_cast<Comment*>(node)));
case Node::DOCUMENT_NODE:
- if (toDocument(node)->isHTMLDocument())
- return WEBKIT_DOM_NODE(wrapHTMLDocument(static_cast<HTMLDocument*>(node)));
- return WEBKIT_DOM_NODE(wrapDocument(toDocument(node)));
+ if (is<HTMLDocument>(node))
+ return WEBKIT_DOM_NODE(wrapHTMLDocument(downcast<HTMLDocument>(node)));
+ return WEBKIT_DOM_NODE(wrapDocument(downcast<Document>(node)));
case Node::DOCUMENT_TYPE_NODE:
return WEBKIT_DOM_NODE(wrapDocumentType(static_cast<DocumentType*>(node)));
case Node::DOCUMENT_FRAGMENT_NODE:
Modified: trunk/Source/WebCore/bindings/js/DOMConstructorWithDocument.h (174088 => 174089)
--- trunk/Source/WebCore/bindings/js/DOMConstructorWithDocument.h 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/bindings/js/DOMConstructorWithDocument.h 2014-09-29 22:23:20 UTC (rev 174089)
@@ -32,7 +32,7 @@
public:
Document* document() const
{
- return toDocument(scriptExecutionContext());
+ return downcast<Document>(scriptExecutionContext());
}
protected:
Modified: trunk/Source/WebCore/bindings/js/DOMRequestState.h (174088 => 174089)
--- trunk/Source/WebCore/bindings/js/DOMRequestState.h 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/bindings/js/DOMRequestState.h 2014-09-29 22:23:20 UTC (rev 174089)
@@ -41,11 +41,11 @@
public:
explicit DOMRequestState(ScriptExecutionContext* scriptExecutionContext)
: m_scriptExecutionContext(scriptExecutionContext)
- , m_exec(0)
+ , m_exec(nullptr)
{
- if (m_scriptExecutionContext->isDocument()) {
- Document* document = toDocument(m_scriptExecutionContext);
- m_exec = execStateFromPage(mainThreadNormalWorld(), document->page());
+ if (is<Document>(*m_scriptExecutionContext)) {
+ Document& document = downcast<Document>(*m_scriptExecutionContext);
+ m_exec = execStateFromPage(mainThreadNormalWorld(), document.page());
} else {
WorkerGlobalScope* workerGlobalScope = static_cast<WorkerGlobalScope*>(m_scriptExecutionContext);
m_exec = execStateFromWorkerGlobalScope(workerGlobalScope);
@@ -54,8 +54,8 @@
void clear()
{
- m_scriptExecutionContext = 0;
- m_exec = 0;
+ m_scriptExecutionContext = nullptr;
+ m_exec = nullptr;
}
class Scope {
Modified: trunk/Source/WebCore/bindings/js/JSAudioContextCustom.cpp (174088 => 174089)
--- trunk/Source/WebCore/bindings/js/JSAudioContextCustom.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/bindings/js/JSAudioContextCustom.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -53,10 +53,10 @@
if (!scriptExecutionContext)
return throwVMError(exec, createReferenceError(exec, "AudioContext constructor script execution context is unavailable"));
- if (!scriptExecutionContext->isDocument())
+ if (!is<Document>(scriptExecutionContext))
return throwVMError(exec, createReferenceError(exec, "AudioContext constructor called in a script execution context which is not a document"));
- Document& document = toDocument(*scriptExecutionContext);
+ Document& document = downcast<Document>(*scriptExecutionContext);
RefPtr<AudioContext> audioContext;
Modified: trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp (174088 => 174089)
--- trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -105,14 +105,14 @@
JSDOMGlobalObject* toJSDOMGlobalObject(ScriptExecutionContext* scriptExecutionContext, JSC::ExecState* exec)
{
- if (scriptExecutionContext->isDocument())
- return toJSDOMGlobalObject(toDocument(scriptExecutionContext), exec);
+ if (is<Document>(scriptExecutionContext))
+ return toJSDOMGlobalObject(downcast<Document>(scriptExecutionContext), exec);
if (scriptExecutionContext->isWorkerGlobalScope())
return toWorkerGlobalScope(scriptExecutionContext)->script()->workerGlobalScopeWrapper();
ASSERT_NOT_REACHED();
- return 0;
+ return nullptr;
}
JSDOMGlobalObject* toJSDOMGlobalObject(Document* document, DOMWrapperWorld& world)
@@ -122,14 +122,14 @@
JSDOMGlobalObject* toJSDOMGlobalObject(ScriptExecutionContext* scriptExecutionContext, DOMWrapperWorld& world)
{
- if (scriptExecutionContext->isDocument())
- return toJSDOMGlobalObject(toDocument(scriptExecutionContext), world);
+ if (is<Document>(scriptExecutionContext))
+ return toJSDOMGlobalObject(downcast<Document>(scriptExecutionContext), world);
if (scriptExecutionContext->isWorkerGlobalScope())
return toWorkerGlobalScope(scriptExecutionContext)->script()->workerGlobalScopeWrapper();
ASSERT_NOT_REACHED();
- return 0;
+ return nullptr;
}
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp (174088 => 174089)
--- trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -73,30 +73,30 @@
JSObject* JSLazyEventListener::initializeJSFunction(ScriptExecutionContext* executionContext) const
{
ASSERT(executionContext);
- ASSERT(executionContext->isDocument());
+ ASSERT(is<Document>(executionContext));
if (!executionContext)
- return 0;
+ return nullptr;
ASSERT(!m_code.isNull());
ASSERT(!m_eventParameterName.isNull());
if (m_code.isNull() || m_eventParameterName.isNull())
- return 0;
+ return nullptr;
- Document* document = toDocument(executionContext);
+ Document& document = downcast<Document>(*executionContext);
- if (!document->frame())
- return 0;
+ if (!document.frame())
+ return nullptr;
- if (!document->contentSecurityPolicy()->allowInlineEventHandlers(m_sourceURL, m_position.m_line))
- return 0;
+ if (!document.contentSecurityPolicy()->allowInlineEventHandlers(m_sourceURL, m_position.m_line))
+ return nullptr;
- ScriptController& script = document->frame()->script();
+ ScriptController& script = document.frame()->script();
if (!script.canExecuteScripts(AboutToExecuteScript) || script.isPaused())
- return 0;
+ return nullptr;
JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(executionContext, isolatedWorld());
if (!globalObject)
- return 0;
+ return nullptr;
ExecState* exec = globalObject->globalExec();
@@ -108,7 +108,7 @@
if (exec->hadException()) {
reportCurrentException(exec);
exec->clearException();
- return 0;
+ return nullptr;
}
JSFunction* listenerAsFunction = jsCast<JSFunction*>(jsFunction);
Modified: trunk/Source/WebCore/bindings/js/JSNodeCustom.cpp (174088 => 174089)
--- trunk/Source/WebCore/bindings/js/JSNodeCustom.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/bindings/js/JSNodeCustom.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -219,7 +219,7 @@
break;
case Node::DOCUMENT_NODE:
// we don't want to cache the document itself in the per-document dictionary
- return toJS(exec, globalObject, toDocument(node));
+ return toJS(exec, globalObject, downcast<Document>(node));
case Node::DOCUMENT_TYPE_NODE:
wrapper = CREATE_DOM_WRAPPER(globalObject, DocumentType, node);
break;
Modified: trunk/Source/WebCore/bindings/js/ScheduledAction.cpp (174088 => 174089)
--- trunk/Source/WebCore/bindings/js/ScheduledAction.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/bindings/js/ScheduledAction.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -74,8 +74,8 @@
void ScheduledAction::execute(ScriptExecutionContext* context)
{
- if (context->isDocument())
- execute(toDocument(context));
+ if (is<Document>(context))
+ execute(downcast<Document>(context));
else
execute(toWorkerGlobalScope(context));
}
Modified: trunk/Source/WebCore/bindings/js/ScriptState.cpp (174088 => 174089)
--- trunk/Source/WebCore/bindings/js/ScriptState.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/bindings/js/ScriptState.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -58,7 +58,7 @@
Frame* frameFromExecState(JSC::ExecState* scriptState)
{
ScriptExecutionContext* context = scriptExecutionContextFromExecState(scriptState);
- Document* document = context && context->isDocument() ? toDocument(context) : nullptr;
+ Document* document = context && is<Document>(context) ? downcast<Document>(context) : nullptr;
return document ? document->frame() : nullptr;
}
Modified: trunk/Source/WebCore/crypto/SubtleCrypto.cpp (174088 => 174089)
--- trunk/Source/WebCore/crypto/SubtleCrypto.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/crypto/SubtleCrypto.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -39,7 +39,7 @@
Document* SubtleCrypto::document() const
{
- return toDocument(scriptExecutionContext());
+ return downcast<Document>(scriptExecutionContext());
}
}
Modified: trunk/Source/WebCore/dom/Comment.cpp (174088 => 174089)
--- trunk/Source/WebCore/dom/Comment.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/dom/Comment.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -38,7 +38,7 @@
PassRefPtr<Comment> Comment::create(ScriptExecutionContext& context, const String& text)
{
- return adoptRef(new Comment(toDocument(context), text));
+ return adoptRef(new Comment(downcast<Document>(context), text));
}
String Comment::nodeName() const
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (174088 => 174089)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -202,8 +202,8 @@
if (containsConsideringHostElements(newChild, newParent))
return HIERARCHY_REQUEST_ERR;
- if (oldChild && newParent->isDocumentNode()) {
- if (!toDocument(newParent)->canReplaceChild(newChild, oldChild))
+ if (oldChild && is<Document>(newParent)) {
+ if (!downcast<Document>(*newParent).canReplaceChild(newChild, oldChild))
return HIERARCHY_REQUEST_ERR;
} else if (!isChildTypeAllowed(newParent, newChild))
return HIERARCHY_REQUEST_ERR;
Modified: trunk/Source/WebCore/dom/ContainerNodeAlgorithms.cpp (174088 => 174089)
--- trunk/Source/WebCore/dom/ContainerNodeAlgorithms.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/dom/ContainerNodeAlgorithms.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -37,7 +37,7 @@
// we don't want to tell the rest of our children that they've been
// inserted into the document because they haven't.
if (node.inDocument() && child->parentNode() == &node)
- notifyNodeInsertedIntoDocument(*child.get());
+ notifyNodeInsertedIntoDocument(*child);
}
if (!node.isElementNode())
@@ -45,7 +45,7 @@
if (RefPtr<ShadowRoot> root = toElement(node).shadowRoot()) {
if (node.inDocument() && root->hostElement() == &node)
- notifyNodeInsertedIntoDocument(*root.get());
+ notifyNodeInsertedIntoDocument(*root);
}
}
Modified: trunk/Source/WebCore/dom/Document.h (174088 => 174089)
--- trunk/Source/WebCore/dom/Document.h 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/dom/Document.h 2014-09-29 22:23:20 UTC (rev 174089)
@@ -1740,13 +1740,11 @@
Element* eventTargetElementForDocument(Document*);
-SCRIPT_EXECUTION_CONTEXT_TYPE_CASTS(Document)
+SPECIALIZE_TYPE_TRAITS_BEGIN(Document)
+ static bool isDocument(const ScriptExecutionContext& context) { return context.isDocument(); }
+ static bool isDocument(const Node& node) { return node.isDocumentNode(); }
+SPECIALIZE_TYPE_TRAITS_END()
-inline bool isDocument(const Node& node) { return node.isDocumentNode(); }
-void isDocument(const Document&); // Catch unnecessary runtime check of type known at compile time.
-
-NODE_TYPE_CASTS(Document)
-
} // namespace WebCore
namespace WTF {
Modified: trunk/Source/WebCore/dom/DocumentFragment.cpp (174088 => 174089)
--- trunk/Source/WebCore/dom/DocumentFragment.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/dom/DocumentFragment.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -43,7 +43,7 @@
PassRefPtr<DocumentFragment> DocumentFragment::create(ScriptExecutionContext& context)
{
- return adoptRef(new DocumentFragment(toDocument(context), Node::CreateDocumentFragment));
+ return adoptRef(new DocumentFragment(downcast<Document>(context), Node::CreateDocumentFragment));
}
String DocumentFragment::nodeName() const
Modified: trunk/Source/WebCore/dom/Element.cpp (174088 => 174089)
--- trunk/Source/WebCore/dom/Element.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/dom/Element.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -2200,9 +2200,9 @@
if (const Attribute* attribute = elementData->findLanguageAttribute())
return attribute->value();
}
- } else if (currentNode->isDocumentNode()) {
+ } else if (is<Document>(currentNode)) {
// checking the MIME content-language
- return toDocument(currentNode)->contentLanguage();
+ return downcast<Document>(*currentNode).contentLanguage();
}
}
Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (174088 => 174089)
--- trunk/Source/WebCore/dom/EventDispatcher.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -60,10 +60,10 @@
WindowEventContext::WindowEventContext(PassRefPtr<Node> node, const EventContext* topEventContext)
{
Node* topLevelContainer = topEventContext ? topEventContext->node() : node.get();
- if (!topLevelContainer->isDocumentNode())
+ if (!is<Document>(topLevelContainer))
return;
- m_window = toDocument(topLevelContainer)->domWindow();
+ m_window = downcast<Document>(*topLevelContainer).domWindow();
m_target = topEventContext ? topEventContext->target() : node.get();
}
Modified: trunk/Source/WebCore/dom/EventTarget.cpp (174088 => 174089)
--- trunk/Source/WebCore/dom/EventTarget.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/dom/EventTarget.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -223,8 +223,8 @@
ScriptExecutionContext* context = scriptExecutionContext();
Document* document = nullptr;
InspectorInstrumentationCookie willDispatchEventCookie;
- if (context && context->isDocument()) {
- document = toDocument(context);
+ if (context && is<Document>(context)) {
+ document = downcast<Document>(context);
willDispatchEventCookie = InspectorInstrumentation::willDispatchEvent(document, *event, size > 0);
}
Modified: trunk/Source/WebCore/dom/NamedFlowCollection.cpp (174088 => 174089)
--- trunk/Source/WebCore/dom/NamedFlowCollection.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/dom/NamedFlowCollection.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -101,7 +101,7 @@
Document* NamedFlowCollection::document() const
{
ScriptExecutionContext* context = ContextDestructionObserver::scriptExecutionContext();
- return toDocument(context);
+ return downcast<Document>(context);
}
PassRefPtr<DOMNamedFlowCollection> NamedFlowCollection::createCSSOMSnapshot()
Modified: trunk/Source/WebCore/dom/Node.cpp (174088 => 174089)
--- trunk/Source/WebCore/dom/Node.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/dom/Node.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -1162,8 +1162,8 @@
return false;
}
case DOCUMENT_NODE:
- if (Element* de = toDocument(this)->documentElement())
- return de->isDefaultNamespace(namespaceURI);
+ if (Element* documentElement = downcast<Document>(*this).documentElement())
+ return documentElement->isDefaultNamespace(namespaceURI);
return false;
case ENTITY_NODE:
case NOTATION_NODE:
@@ -1195,8 +1195,8 @@
case ELEMENT_NODE:
return lookupNamespacePrefix(namespaceURI, static_cast<const Element *>(this));
case DOCUMENT_NODE:
- if (Element* de = toDocument(this)->documentElement())
- return de->lookupPrefix(namespaceURI);
+ if (Element* documentElement = downcast<Document>(*this).documentElement())
+ return documentElement->lookupPrefix(namespaceURI);
return String();
case ENTITY_NODE:
case NOTATION_NODE:
@@ -1253,8 +1253,8 @@
return String();
}
case DOCUMENT_NODE:
- if (Element* de = toDocument(this)->documentElement())
- return de->lookupNamespaceURI(prefix);
+ if (Element* documentElement = downcast<Document>(*this).documentElement())
+ return documentElement->lookupNamespaceURI(prefix);
return String();
case ENTITY_NODE:
case NOTATION_NODE:
@@ -2198,8 +2198,8 @@
// An explicit check for Document here is better than a virtual function since it is
// faster for non-Document nodes, and because the call to removedLastRef that is inlined
// at all deref call sites is smaller if it's a non-virtual function.
- if (isDocumentNode()) {
- toDocument(*this).removedLastRef();
+ if (is<Document>(*this)) {
+ downcast<Document>(*this).removedLastRef();
return;
}
Modified: trunk/Source/WebCore/dom/Range.cpp (174088 => 174089)
--- trunk/Source/WebCore/dom/Range.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/dom/Range.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -106,7 +106,7 @@
PassRefPtr<Range> Range::create(ScriptExecutionContext& context)
{
- return adoptRef(new Range(toDocument(context)));
+ return adoptRef(new Range(downcast<Document>(context)));
}
PassRefPtr<Range> Range::create(Document& ownerDocument, const VisiblePosition& visibleStart, const VisiblePosition& visibleEnd)
Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.cpp (174088 => 174089)
--- trunk/Source/WebCore/dom/ScriptExecutionContext.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -378,8 +378,8 @@
return false;
#if PLATFORM(IOS)
- if (target == target->toDOMWindow() && isDocument()) {
- Settings* settings = toDocument(this)->settings();
+ if (target == target->toDOMWindow() && is<Document>(*this)) {
+ Settings* settings = downcast<Document>(*this).settings();
if (settings && !settings->shouldDispatchJavaScriptWindowOnErrorEvents())
return false;
}
Modified: trunk/Source/WebCore/dom/Text.cpp (174088 => 174089)
--- trunk/Source/WebCore/dom/Text.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/dom/Text.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -45,7 +45,7 @@
PassRefPtr<Text> Text::create(ScriptExecutionContext& context, const String& data)
{
- return adoptRef(new Text(toDocument(context), data, CreateText));
+ return adoptRef(new Text(downcast<Document>(context), data, CreateText));
}
PassRefPtr<Text> Text::createEditingText(Document& document, const String& data)
Modified: trunk/Source/WebCore/editing/MarkupAccumulator.cpp (174088 => 174089)
--- trunk/Source/WebCore/editing/MarkupAccumulator.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/editing/MarkupAccumulator.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -559,7 +559,7 @@
appendComment(result, downcast<Comment>(node).data());
break;
case Node::DOCUMENT_NODE:
- appendXMLDeclaration(result, toDocument(node));
+ appendXMLDeclaration(result, downcast<Document>(node));
break;
case Node::DOCUMENT_FRAGMENT_NODE:
break;
Modified: trunk/Source/WebCore/html/HTMLDocument.h (174088 => 174089)
--- trunk/Source/WebCore/html/HTMLDocument.h 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/html/HTMLDocument.h 2014-09-29 22:23:20 UTC (rev 174089)
@@ -99,7 +99,7 @@
SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLDocument)
static bool isHTMLDocument(const Document& document) { return document.isHTMLDocument(); }
- static bool isHTMLDocument(const Node& node) { return node.isDocumentNode() && isHTMLDocument(toDocument(node)); }
+ static bool isHTMLDocument(const Node& node) { return is<Document>(node) && isHTMLDocument(downcast<Document>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
} // namespace WebCore
Modified: trunk/Source/WebCore/html/HTMLNameCollection.h (174088 => 174089)
--- trunk/Source/WebCore/html/HTMLNameCollection.h 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/html/HTMLNameCollection.h 2014-09-29 22:23:20 UTC (rev 174089)
@@ -35,7 +35,7 @@
public:
~HTMLNameCollection();
- Document& document() { return toDocument(ownerNode()); }
+ Document& document() { return downcast<Document>(ownerNode()); }
protected:
HTMLNameCollection(Document&, CollectionType, const AtomicString& name);
Modified: trunk/Source/WebCore/html/ImageDocument.h (174088 => 174089)
--- trunk/Source/WebCore/html/ImageDocument.h 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/html/ImageDocument.h 2014-09-29 22:23:20 UTC (rev 174089)
@@ -84,7 +84,7 @@
SPECIALIZE_TYPE_TRAITS_BEGIN(ImageDocument)
static bool isImageDocument(const Document& document) { return document.isImageDocument(); }
- static bool isImageDocument(const Node& node) { return node.isDocumentNode() && isImageDocument(toDocument(node)); }
+ static bool isImageDocument(const Node& node) { return is<Document>(node) && isImageDocument(downcast<Document>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
}
Modified: trunk/Source/WebCore/html/MediaDocument.h (174088 => 174089)
--- trunk/Source/WebCore/html/MediaDocument.h 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/html/MediaDocument.h 2014-09-29 22:23:20 UTC (rev 174089)
@@ -58,7 +58,7 @@
SPECIALIZE_TYPE_TRAITS_BEGIN(MediaDocument)
static bool isMediaDocument(const Document& document) { return document.isMediaDocument(); }
- static bool isMediaDocument(const Node& node) { return node.isDocumentNode() && isMediaDocument(toDocument(node)); }
+ static bool isMediaDocument(const Node& node) { return is<Document>(node) && isMediaDocument(downcast<Document>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
}
Modified: trunk/Source/WebCore/html/PluginDocument.h (174088 => 174089)
--- trunk/Source/WebCore/html/PluginDocument.h 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/html/PluginDocument.h 2014-09-29 22:23:20 UTC (rev 174089)
@@ -63,7 +63,7 @@
SPECIALIZE_TYPE_TRAITS_BEGIN(PluginDocument)
static bool isPluginDocument(const Document& document) { return document.isPluginDocument(); }
- static bool isPluginDocument(const Node& node) { return node.isDocumentNode() && isPluginDocument(toDocument(node)); }
+ static bool isPluginDocument(const Node& node) { return is<Document>(node) && isPluginDocument(downcast<Document>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
}
Modified: trunk/Source/WebCore/html/track/TextTrackCue.h (174088 => 174089)
--- trunk/Source/WebCore/html/track/TextTrackCue.h 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/html/track/TextTrackCue.h 2014-09-29 22:23:20 UTC (rev 174089)
@@ -120,7 +120,7 @@
protected:
TextTrackCue(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end);
- Document& ownerDocument() { return toDocument(m_scriptExecutionContext); }
+ Document& ownerDocument() { return downcast<Document>(m_scriptExecutionContext); }
private:
Modified: trunk/Source/WebCore/html/track/VTTCue.cpp (174088 => 174089)
--- trunk/Source/WebCore/html/track/VTTCue.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/html/track/VTTCue.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -288,8 +288,8 @@
m_writingDirection = Horizontal;
m_cueAlignment = Middle;
m_webVTTNodeTree = nullptr;
- m_cueBackdropBox = HTMLDivElement::create(toDocument(context));
- m_cueHighlightBox = HTMLSpanElement::create(spanTag, toDocument(context));
+ m_cueBackdropBox = HTMLDivElement::create(downcast<Document>(context));
+ m_cueHighlightBox = HTMLSpanElement::create(spanTag, downcast<Document>(context));
m_displayDirection = CSSValueLtr;
m_displaySize = 0;
m_snapToLines = true;
Modified: trunk/Source/WebCore/html/track/VTTRegion.h (174088 => 174089)
--- trunk/Source/WebCore/html/track/VTTRegion.h 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/html/track/VTTRegion.h 2014-09-29 22:23:20 UTC (rev 174089)
@@ -98,7 +98,7 @@
private:
VTTRegion(ScriptExecutionContext&);
- Document* ownerDocument() { return toDocument(m_scriptExecutionContext); }
+ Document* ownerDocument() { return downcast<Document>(m_scriptExecutionContext); }
void prepareRegionDisplayTree();
Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (174088 => 174089)
--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -379,11 +379,11 @@
Node* node = assertNode(errorString, nodeId);
if (!node)
return nullptr;
- if (!node->isDocumentNode()) {
+ if (!is<Document>(node)) {
*errorString = "Document is not available";
return nullptr;
}
- return toDocument(node);
+ return downcast<Document>(node);
}
Element* InspectorDOMAgent::assertElement(ErrorString* errorString, int nodeId)
@@ -1301,11 +1301,11 @@
value->setTemplateContent(buildObjectForNode(downcast<HTMLTemplateElement>(*element).content(), 0, nodesMap));
#endif
- } else if (node->isDocumentNode()) {
- Document* document = toDocument(node);
- value->setDocumentURL(documentURLString(document));
- value->setBaseURL(documentBaseURLString(document));
- value->setXmlVersion(document->xmlVersion());
+ } else if (is<Document>(node)) {
+ Document& document = downcast<Document>(*node);
+ value->setDocumentURL(documentURLString(&document));
+ value->setBaseURL(documentBaseURLString(&document));
+ value->setXmlVersion(document.xmlVersion());
} else if (is<DocumentType>(node)) {
DocumentType& docType = downcast<DocumentType>(*node);
value->setPublicId(docType.publicId());
@@ -1728,10 +1728,8 @@
Node* InspectorDOMAgent::innerParentNode(Node* node)
{
- if (node->isDocumentNode()) {
- Document* document = toDocument(node);
- return document->ownerElement();
- }
+ if (is<Document>(node))
+ return downcast<Document>(*node).ownerElement();
return node->parentNode();
}
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (174088 => 174089)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -100,8 +100,8 @@
static Frame* frameForScriptExecutionContext(ScriptExecutionContext* context)
{
Frame* frame = nullptr;
- if (context->isDocument())
- frame = toDocument(context)->frame();
+ if (is<Document>(context))
+ frame = downcast<Document>(context)->frame();
return frame;
}
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (174088 => 174089)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2014-09-29 22:23:20 UTC (rev 174089)
@@ -2062,8 +2062,8 @@
{
if (!context)
return nullptr;
- if (context->isDocument())
- return instrumentingAgentsForPage(toDocument(context)->page());
+ if (is<Document>(context))
+ return instrumentingAgentsForPage(downcast<Document>(context)->page());
return instrumentingAgentsForNonDocumentContext(context);
}
Modified: trunk/Source/WebCore/loader/TextTrackLoader.cpp (174088 => 174089)
--- trunk/Source/WebCore/loader/TextTrackLoader.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/loader/TextTrackLoader.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -117,7 +117,7 @@
void TextTrackLoader::corsPolicyPreventedLoad()
{
DEPRECATED_DEFINE_STATIC_LOCAL(String, consoleMessage, (ASCIILiteral("Cross-origin text track load denied by Cross-Origin Resource Sharing policy.")));
- Document* document = toDocument(m_scriptExecutionContext);
+ Document* document = downcast<Document>(m_scriptExecutionContext);
document->addConsoleMessage(MessageSource::Security, MessageLevel::Error, consoleMessage);
m_state = Failed;
}
@@ -126,7 +126,7 @@
{
ASSERT(m_resource == resource);
- Document* document = toDocument(m_scriptExecutionContext);
+ Document* document = downcast<Document>(m_scriptExecutionContext);
if (!m_crossOriginMode.isNull()
&& !document->securityOrigin()->canRequest(resource->response().url())
&& !resource->passesAccessControlCheck(document->securityOrigin())) {
@@ -155,8 +155,8 @@
{
cancelLoad();
- ASSERT(m_scriptExecutionContext->isDocument());
- Document* document = toDocument(m_scriptExecutionContext);
+ ASSERT(is<Document>(m_scriptExecutionContext));
+ Document* document = downcast<Document>(m_scriptExecutionContext);
CachedResourceRequest cueRequest(ResourceRequest(document->completeURL(url)));
if (!crossOriginMode.isNull()) {
Modified: trunk/Source/WebCore/loader/ThreadableLoader.cpp (174088 => 174089)
--- trunk/Source/WebCore/loader/ThreadableLoader.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/loader/ThreadableLoader.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -59,7 +59,7 @@
if (context->isWorkerGlobalScope())
return WorkerThreadableLoader::create(toWorkerGlobalScope(context), client, WorkerRunLoop::defaultMode(), request, options);
- return DocumentThreadableLoader::create(toDocument(*context), *client, request, options);
+ return DocumentThreadableLoader::create(downcast<Document>(*context), *client, request, options);
}
void ThreadableLoader::loadResourceSynchronously(ScriptExecutionContext* context, const ResourceRequest& request, ThreadableLoaderClient& client, const ThreadableLoaderOptions& options)
@@ -71,7 +71,7 @@
return;
}
- DocumentThreadableLoader::loadResourceSynchronously(*toDocument(context), request, client, options);
+ DocumentThreadableLoader::loadResourceSynchronously(*downcast<Document>(context), request, client, options);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp (174088 => 174089)
--- trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -101,14 +101,14 @@
void WorkerThreadableLoader::MainThreadBridge::mainThreadCreateLoader(ScriptExecutionContext& context, MainThreadBridge* thisPtr, PassOwnPtr<CrossThreadResourceRequestData> requestData, ThreadableLoaderOptions options, const String& outgoingReferrer)
{
ASSERT(isMainThread());
- Document* document = toDocument(&context);
+ Document& document = downcast<Document>(context);
OwnPtr<ResourceRequest> request(ResourceRequest::adopt(requestData));
request->setHTTPReferrer(outgoingReferrer);
// FIXME: If the a site requests a local resource, then this will return a non-zero value but the sync path
// will return a 0 value. Either this should return 0 or the other code path should do a callback with
// a failure.
- thisPtr->m_mainThreadLoader = DocumentThreadableLoader::create(*document, *thisPtr, *request, options);
+ thisPtr->m_mainThreadLoader = DocumentThreadableLoader::create(document, *thisPtr, *request, options);
ASSERT(thisPtr->m_mainThreadLoader);
}
Modified: trunk/Source/WebCore/page/ContentSecurityPolicy.cpp (174088 => 174089)
--- trunk/Source/WebCore/page/ContentSecurityPolicy.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/page/ContentSecurityPolicy.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -1577,20 +1577,20 @@
m_scriptExecutionContext->enforceSandboxFlags(mask);
}
-static String stripURLForUseInReport(Document* document, const URL& url)
+static String stripURLForUseInReport(Document& document, const URL& url)
{
if (!url.isValid())
return String();
if (!url.isHierarchical() || url.protocolIs("file"))
return url.protocol();
- return document->securityOrigin()->canRequest(url) ? url.strippedForUseAsReferrer() : SecurityOrigin::create(url)->toString();
+ return document.securityOrigin()->canRequest(url) ? url.strippedForUseAsReferrer() : SecurityOrigin::create(url)->toString();
}
#if ENABLE(CSP_NEXT)
-static void gatherSecurityPolicyViolationEventData(SecurityPolicyViolationEventInit& init, Document* document, const String& directiveText, const String& effectiveDirective, const URL& blockedURL, const String& header)
+static void gatherSecurityPolicyViolationEventData(SecurityPolicyViolationEventInit& init, Document& document, const String& directiveText, const String& effectiveDirective, const URL& blockedURL, const String& header)
{
- init.documentURI = document->url().string();
- init.referrer = document->referrer();
+ init.documentURI = document.url().string();
+ init.referrer = document.referrer();
init.blockedURI = stripURLForUseInReport(document, blockedURL);
init.violatedDirective = directiveText;
init.effectiveDirective = effectiveDirective;
@@ -1613,11 +1613,11 @@
logToConsole(consoleMessage, contextURL, contextLine, state);
// FIXME: Support sending reports from worker.
- if (!m_scriptExecutionContext->isDocument())
+ if (!is<Document>(*m_scriptExecutionContext))
return;
- Document* document = toDocument(m_scriptExecutionContext);
- Frame* frame = document->frame();
+ Document& document = downcast<Document>(*m_scriptExecutionContext);
+ Frame* frame = document.frame();
if (!frame)
return;
@@ -1626,7 +1626,7 @@
// FIXME: This code means that we're gathering information like line numbers twice. Once we can bring this out from behind the flag, we should reuse the data gathered here when generating the JSON report below.
SecurityPolicyViolationEventInit init;
gatherSecurityPolicyViolationEventData(init, document, directiveText, effectiveDirective, blockedURL, header);
- document->enqueueDocumentEvent(SecurityPolicyViolationEvent::create(eventNames().securitypolicyviolationEvent, init));
+ document.enqueueDocumentEvent(SecurityPolicyViolationEvent::create(eventNames().securitypolicyviolationEvent, init));
}
#endif
@@ -1644,8 +1644,8 @@
// harmless information.
RefPtr<InspectorObject> cspReport = InspectorObject::create();
- cspReport->setString(ASCIILiteral("document-uri"), document->url().strippedForUseAsReferrer());
- cspReport->setString(ASCIILiteral("referrer"), document->referrer());
+ cspReport->setString(ASCIILiteral("document-uri"), document.url().strippedForUseAsReferrer());
+ cspReport->setString(ASCIILiteral("referrer"), document.referrer());
cspReport->setString(ASCIILiteral("violated-directive"), directiveText);
#if ENABLE(CSP_NEXT)
if (experimentalFeaturesEnabled())
Modified: trunk/Source/WebCore/page/Crypto.cpp (174088 => 174089)
--- trunk/Source/WebCore/page/Crypto.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/page/Crypto.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -59,7 +59,7 @@
Document* Crypto::document() const
{
- return toDocument(scriptExecutionContext());
+ return downcast<Document>(scriptExecutionContext());
}
void Crypto::getRandomValues(ArrayBufferView* array, ExceptionCode& ec)
Modified: trunk/Source/WebCore/page/DOMTimer.cpp (174088 => 174089)
--- trunk/Source/WebCore/page/DOMTimer.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/page/DOMTimer.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -120,8 +120,8 @@
// is destroyed, or if explicitly cancelled by removeById.
DOMTimer* timer = new DOMTimer(context, WTF::move(action), timeout, singleShot);
#if PLATFORM(IOS)
- if (context->isDocument()) {
- Document& document = toDocument(*context);
+ if (is<Document>(context)) {
+ Document& document = downcast<Document>(*context);
bool didDeferTimeout = document.frame() && document.frame()->timersPaused();
if (!didDeferTimeout && timeout <= 100 && singleShot) {
WKSetObservedContentChange(WKContentIndeterminateChange);
@@ -173,8 +173,8 @@
#if PLATFORM(IOS)
Document* document = nullptr;
- if (context->isDocument()) {
- document = toDocument(context);
+ if (is<Document>(context)) {
+ document = downcast<Document>(context);
ASSERT(!document->frame()->timersPaused());
}
#endif
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (174088 => 174089)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -973,8 +973,8 @@
bool allowFocus = WindowFocusAllowedIndicator::windowFocusAllowed() || !m_frame->settings().windowFocusRestricted();
if (context) {
ASSERT(isMainThread());
- Document* activeDocument = toDocument(context);
- if (opener() && opener() != this && activeDocument->domWindow() == opener())
+ Document& activeDocument = downcast<Document>(*context);
+ if (opener() && opener() != this && activeDocument.domWindow() == opener())
allowFocus = true;
}
@@ -1025,12 +1025,8 @@
if (context) {
ASSERT(isMainThread());
- Document* activeDocument = toDocument(context);
- if (!activeDocument)
+ if (!downcast<Document>(*context).canNavigate(m_frame))
return;
-
- if (!activeDocument->canNavigate(m_frame))
- return;
}
bool allowScriptsToCloseWindows = m_frame->settings().allowScriptsToCloseWindows();
@@ -1413,24 +1409,24 @@
Document* DOMWindow::document() const
{
ScriptExecutionContext* context = ContextDestructionObserver::scriptExecutionContext();
- return toDocument(context);
+ return downcast<Document>(context);
}
PassRefPtr<StyleMedia> DOMWindow::styleMedia() const
{
if (!isCurrentlyDisplayedInFrame())
- return 0;
+ return nullptr;
if (!m_media)
m_media = StyleMedia::create(m_frame);
return m_media.get();
}
-PassRefPtr<CSSStyleDeclaration> DOMWindow::getComputedStyle(Element* elt, const String& pseudoElt) const
+PassRefPtr<CSSStyleDeclaration> DOMWindow::getComputedStyle(Element* element, const String& pseudoElt) const
{
- if (!elt)
- return 0;
+ if (!element)
+ return nullptr;
- return CSSComputedStyleDeclaration::create(elt, false, pseudoElt);
+ return CSSComputedStyleDeclaration::create(element, false, pseudoElt);
}
PassRefPtr<CSSRuleList> DOMWindow::getMatchedCSSRules(Element* element, const String& pseudoElement, bool authorOnly) const
Modified: trunk/Source/WebCore/page/DragController.cpp (174088 => 174089)
--- trunk/Source/WebCore/page/DragController.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/page/DragController.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -192,10 +192,10 @@
m_page.mainFrame().eventHandler().cancelDragAndDrop(createMouseEvent(dragData), dataTransfer.get());
dataTransfer->setAccessPolicy(DataTransferAccessPolicy::Numb); // Invalidate dataTransfer here for security.
}
- mouseMovedIntoDocument(0);
+ mouseMovedIntoDocument(nullptr);
if (m_fileInputElementUnderMouse)
m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false);
- m_fileInputElementUnderMouse = 0;
+ m_fileInputElementUnderMouse = nullptr;
}
DragOperation DragController::dragUpdated(DragData& dragData)
@@ -255,7 +255,7 @@
m_dragDestinationAction = m_client.actionMaskForDrag(dragData);
if (m_dragDestinationAction == DragDestinationActionNone) {
- cancelDrag(); // FIXME: Why not call mouseMovedIntoDocument(0)?
+ cancelDrag(); // FIXME: Why not call mouseMovedIntoDocument(nullptr)?
return DragOperationNone;
}
Modified: trunk/Source/WebCore/page/EventSource.cpp (174088 => 174089)
--- trunk/Source/WebCore/page/EventSource.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/page/EventSource.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -77,25 +77,25 @@
{
if (url.isEmpty()) {
ec = SYNTAX_ERR;
- return 0;
+ return nullptr;
}
URL fullURL = context.completeURL(url);
if (!fullURL.isValid()) {
ec = SYNTAX_ERR;
- return 0;
+ return nullptr;
}
// FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved.
bool shouldBypassMainWorldContentSecurityPolicy = false;
- if (context.isDocument()) {
- Document& document = toDocument(context);
+ if (is<Document>(context)) {
+ Document& document = downcast<Document>(context);
shouldBypassMainWorldContentSecurityPolicy = document.frame()->script().shouldBypassMainWorldContentSecurityPolicy();
}
if (!shouldBypassMainWorldContentSecurityPolicy && !context.contentSecurityPolicy()->allowConnectToSource(fullURL)) {
// FIXME: Should this be throwing an exception?
ec = SECURITY_ERR;
- return 0;
+ return nullptr;
}
RefPtr<EventSource> source = adoptRef(new EventSource(context, fullURL, eventSourceInit));
Modified: trunk/Source/WebCore/page/FocusController.cpp (174088 => 174089)
--- trunk/Source/WebCore/page/FocusController.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/page/FocusController.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -876,8 +876,8 @@
Element* focusedElement = focusedDocument->focusedElement();
Node* container = focusedDocument;
- if (container->isDocumentNode())
- toDocument(container)->updateLayoutIgnorePendingStylesheets();
+ if (is<Document>(container))
+ downcast<Document>(*container).updateLayoutIgnorePendingStylesheets();
// Figure out the starting rect.
LayoutRect startingRect;
@@ -900,8 +900,8 @@
consumed = advanceFocusDirectionallyInContainer(container, startingRect, direction, event);
startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore border */);
container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(direction, container);
- if (container && container->isDocumentNode())
- toDocument(container)->updateLayoutIgnorePendingStylesheets();
+ if (container && is<Document>(container))
+ downcast<Document>(*container).updateLayoutIgnorePendingStylesheets();
} while (!consumed && container);
return consumed;
Modified: trunk/Source/WebCore/page/History.cpp (174088 => 174089)
--- trunk/Source/WebCore/page/History.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/page/History.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -117,7 +117,7 @@
return;
ASSERT(isMainThread());
- Document* activeDocument = toDocument(context);
+ Document* activeDocument = downcast<Document>(context);
if (!activeDocument)
return;
Modified: trunk/Source/WebCore/page/SpatialNavigation.cpp (174088 => 174089)
--- trunk/Source/WebCore/page/SpatialNavigation.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/page/SpatialNavigation.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -366,8 +366,8 @@
bool scrollInDirection(Node* container, FocusDirection direction)
{
ASSERT(container);
- if (container->isDocumentNode())
- return scrollInDirection(toDocument(container)->frame(), direction);
+ if (is<Document>(container))
+ return scrollInDirection(downcast<Document>(*container).frame(), direction);
if (!container->renderBox())
return false;
@@ -435,11 +435,11 @@
ASSERT(node);
Node* parent = node;
do {
- if (parent->isDocumentNode())
- parent = toDocument(parent)->document().frame()->ownerElement();
+ if (is<Document>(parent))
+ parent = downcast<Document>(*parent).document().frame()->ownerElement();
else
parent = parent->parentNode();
- } while (parent && !canScrollInDirection(parent, direction) && !parent->isDocumentNode());
+ } while (parent && !canScrollInDirection(parent, direction) && !is<Document>(parent));
return parent;
}
@@ -451,8 +451,8 @@
if (is<HTMLSelectElement>(container))
return false;
- if (container->isDocumentNode())
- return canScrollInDirection(toDocument(container)->frame(), direction);
+ if (is<Document>(container))
+ return canScrollInDirection(downcast<Document>(*container).frame(), direction);
if (!isScrollableNode(container))
return false;
@@ -520,8 +520,8 @@
{
ASSERT(node && node->renderer() && !node->document().view()->needsLayout());
- if (node->isDocumentNode())
- return frameRectInAbsoluteCoordinates(toDocument(node)->frame());
+ if (is<Document>(node))
+ return frameRectInAbsoluteCoordinates(downcast<Document>(*node).frame());
LayoutRect rect = rectToAbsoluteCoordinates(node->document().frame(), node->boundingBox());
// For authors that use border instead of outline in their CSS, we compensate by ignoring the border when calculating
Modified: trunk/Source/WebCore/svg/SVGDocument.h (174088 => 174089)
--- trunk/Source/WebCore/svg/SVGDocument.h 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/svg/SVGDocument.h 2014-09-29 22:23:20 UTC (rev 174089)
@@ -54,7 +54,7 @@
SPECIALIZE_TYPE_TRAITS_BEGIN(SVGDocument)
static bool isSVGDocument(const Document& document) { return document.isSVGDocument(); }
- static bool isSVGDocument(const Node& node) { return node.isDocumentNode() && isSVGDocument(toDocument(node)); }
+ static bool isSVGDocument(const Node& node) { return is<Document>(node) && isSVGDocument(downcast<Document>(node)); }
SPECIALIZE_TYPE_TRAITS_END()
} // namespace WebCore
Modified: trunk/Source/WebCore/testing/Internals.cpp (174088 => 174089)
--- trunk/Source/WebCore/testing/Internals.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/testing/Internals.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -319,13 +319,13 @@
Document* Internals::contextDocument() const
{
- return toDocument(scriptExecutionContext());
+ return downcast<Document>(scriptExecutionContext());
}
Frame* Internals::frame() const
{
if (!contextDocument())
- return 0;
+ return nullptr;
return contextDocument()->frame();
}
@@ -1916,8 +1916,8 @@
Document* document;
if (!node)
document = contextDocument();
- else if (node->isDocumentNode())
- document = toDocument(node);
+ else if (is<Document>(node))
+ document = downcast<Document>(node);
else if (is<HTMLIFrameElement>(node))
document = downcast<HTMLIFrameElement>(*node).contentDocument();
else {
Modified: trunk/Source/WebCore/testing/js/WebCoreTestSupport.cpp (174088 => 174089)
--- trunk/Source/WebCore/testing/js/WebCoreTestSupport.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/testing/js/WebCoreTestSupport.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -46,8 +46,8 @@
JSLockHolder lock(exec);
JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
ScriptExecutionContext* scriptContext = globalObject->scriptExecutionContext();
- if (scriptContext->isDocument())
- globalObject->putDirect(exec->vm(), Identifier(exec, Internals::internalsId), toJS(exec, globalObject, Internals::create(toDocument(scriptContext))));
+ if (is<Document>(scriptContext))
+ globalObject->putDirect(exec->vm(), Identifier(exec, Internals::internalsId), toJS(exec, globalObject, Internals::create(downcast<Document>(scriptContext))));
}
void resetInternalsObject(JSContextRef context)
@@ -56,7 +56,7 @@
JSLockHolder lock(exec);
JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
ScriptExecutionContext* scriptContext = globalObject->scriptExecutionContext();
- Page* page = toDocument(scriptContext)->frame()->page();
+ Page* page = downcast<Document>(scriptContext)->frame()->page();
Internals::resetToConsistentState(page);
InternalSettings::from(page)->resetToConsistentState();
}
Modified: trunk/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp (174088 => 174089)
--- trunk/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -228,7 +228,7 @@
ASSERT(context);
ASSERT(!isClosing());
MutexLocker lock(m_workerDocumentsLock);
- m_workerDocuments.add(toDocument(context));
+ m_workerDocuments.add(downcast<Document>(context));
}
void SharedWorkerProxy::documentDetached(Document* document)
Modified: trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp (174088 => 174089)
--- trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -83,11 +83,11 @@
{
// FIXME: This need to be revisited when we support nested worker one day
ASSERT(m_scriptExecutionContext);
- Document* document = toDocument(m_scriptExecutionContext);
- GroupSettings* settings = 0;
- if (document->page())
- settings = &document->page()->group().groupSettings();
- RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, settings, sourceCode, *this, *this, startMode, document->contentSecurityPolicy()->deprecatedHeader(), document->contentSecurityPolicy()->deprecatedHeaderType(), document->topOrigin());
+ Document& document = downcast<Document>(*m_scriptExecutionContext);
+ GroupSettings* settings = nullptr;
+ if (document.page())
+ settings = &document.page()->group().groupSettings();
+ RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, settings, sourceCode, *this, *this, startMode, document.contentSecurityPolicy()->deprecatedHeader(), document.contentSecurityPolicy()->deprecatedHeaderType(), document.topOrigin());
workerThreadCreated(thread);
thread->start();
InspectorInstrumentation::didStartWorkerGlobalScope(m_scriptExecutionContext.get(), this, scriptURL);
Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (174088 => 174089)
--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2014-09-29 22:23:20 UTC (rev 174089)
@@ -155,7 +155,7 @@
Document* XMLHttpRequest::document() const
{
ASSERT(scriptExecutionContext());
- return toDocument(scriptExecutionContext());
+ return downcast<Document>(scriptExecutionContext());
}
SecurityOrigin* XMLHttpRequest::securityOrigin() const
@@ -487,10 +487,10 @@
// FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved.
bool shouldBypassMainWorldContentSecurityPolicy = false;
- if (scriptExecutionContext()->isDocument()) {
- Document* document = toDocument(scriptExecutionContext());
- if (document->frame())
- shouldBypassMainWorldContentSecurityPolicy = document->frame()->script().shouldBypassMainWorldContentSecurityPolicy();
+ if (is<Document>(scriptExecutionContext())) {
+ Document& document = downcast<Document>(*scriptExecutionContext());
+ if (document.frame())
+ shouldBypassMainWorldContentSecurityPolicy = document.frame()->script().shouldBypassMainWorldContentSecurityPolicy();
}
if (!shouldBypassMainWorldContentSecurityPolicy && !scriptExecutionContext()->contentSecurityPolicy()->allowConnectToSource(url)) {
// FIXME: Should this be throwing an exception?
Modified: trunk/Source/WebKit2/ChangeLog (174088 => 174089)
--- trunk/Source/WebKit2/ChangeLog 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebKit2/ChangeLog 2014-09-29 22:23:20 UTC (rev 174089)
@@ -1,3 +1,18 @@
+2014-09-29 Christophe Dumez <cdu...@apple.com>
+
+ Use is<>() / downcast<>() for Document
+ https://bugs.webkit.org/show_bug.cgi?id=137221
+
+ Reviewed by Andreas Kling.
+
+ Use is<>() / downcast<>() for Document instead of isDocumentNode() /
+ toDocument().
+
+ * WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm:
+ (-[WKDOMDocument createElement:]):
+ (-[WKDOMDocument createTextNode:]):
+ (-[WKDOMDocument body]):
+
2014-09-29 Commit Queue <commit-qu...@webkit.org>
Unreviewed, rolling out r174045.
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm (174088 => 174089)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm 2014-09-29 22:14:13 UTC (rev 174088)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm 2014-09-29 22:23:20 UTC (rev 174089)
@@ -39,17 +39,17 @@
{
// FIXME: Do something about the exception.
WebCore::ExceptionCode ec = 0;
- return WebKit::toWKDOMElement(toDocument(_impl.get())->createElement(tagName, ec).get());
+ return WebKit::toWKDOMElement(WebCore::downcast<WebCore::Document>(*_impl).createElement(tagName, ec).get());
}
- (WKDOMText *)createTextNode:(NSString *)data
{
- return WebKit::toWKDOMText(toDocument(_impl.get())->createTextNode(data).get());
+ return WebKit::toWKDOMText(WebCore::downcast<WebCore::Document>(*_impl).createTextNode(data).get());
}
- (WKDOMElement *)body
{
- return WebKit::toWKDOMElement(toDocument(_impl.get())->body());
+ return WebKit::toWKDOMElement(WebCore::downcast<WebCore::Document>(*_impl).body());
}
@end