Title: [174065] trunk/Source
Revision
174065
Author
[email protected]
Date
2014-09-29 09:58:42 -0700 (Mon, 29 Sep 2014)

Log Message

Make is<>() / downcast<>() work for HTMLDocument and its subclasses
https://bugs.webkit.org/show_bug.cgi?id=137169

Reviewed by Darin Adler.

Source/WebCore:

Make is<>() / downcast<>() work for HTMLDocument and its subclasses by
using the SPECIALIZE_TYPE_TRAITS_*() macro. Drop the DOCUMENT_TYPE_CASTS()
macro as it is no longer needed.

No new tests, no behavior change.

* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::namedItemGetter):
(WebCore::JSDOMWindow::getOwnPropertySlot):
(WebCore::JSDOMWindow::getOwnPropertySlotByIndex):
* dom/Document.cpp:
(WebCore::Document::prepareForDestruction):
(WebCore::Document::processHttpEquiv):
(WebCore::eventTargetElementForDocument):
* dom/Document.h:
* dom/Element.cpp:
(WebCore::Element::insertedInto):
(WebCore::Element::removedFrom):
(WebCore::Element::updateName):
(WebCore::Element::updateId):
* html/HTMLDocument.h:
(WebCore::isHTMLDocument):
* html/HTMLElement.cpp:
(WebCore::HTMLElement::matchesReadWritePseudoClass):
* html/HTMLEmbedElement.cpp:
(WebCore::HTMLEmbedElement::updateWidget):
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::parseAttribute):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::parseAttribute):
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::updateDocNamedItem):
* html/ImageDocument.cpp:
(WebCore::ImageDocumentParser::document):
* html/ImageDocument.h:
(WebCore::isImageDocument):
* html/MediaDocument.h:
(WebCore::isMediaDocument):
* html/PluginDocument.cpp:
(WebCore::PluginDocumentParser::createDocumentStructure):
* html/PluginDocument.h:
(WebCore::isPluginDocument):
* loader/SubframeLoader.cpp:
(WebCore::SubframeLoader::loadPlugin):
* page/DragController.cpp:
(WebCore::DragController::operationForLoad):
* page/FrameView.cpp:
(WebCore::determineLayerFlushThrottleState):

Source/WebKit/win:

Use is<>() / downcast<>() for HTMLDocument and its subclasses.

* DOMHTMLClasses.cpp:
(DOMHTMLDocument::URL):
(DOMHTMLDocument::body):
(DOMHTMLDocument::forms):

Source/WebKit2:

Use is<>() / downcast<>() for HTMLDocument and its subclasses.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::pdfDocumentForPrintingFrame):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (174064 => 174065)


--- trunk/Source/WebCore/ChangeLog	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/ChangeLog	2014-09-29 16:58:42 UTC (rev 174065)
@@ -1,3 +1,59 @@
+2014-09-29  Christophe Dumez  <[email protected]>
+
+        Make is<>() / downcast<>() work for HTMLDocument and its subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137169
+
+        Reviewed by Darin Adler.
+
+        Make is<>() / downcast<>() work for HTMLDocument and its subclasses by
+        using the SPECIALIZE_TYPE_TRAITS_*() macro. Drop the DOCUMENT_TYPE_CASTS()
+        macro as it is no longer needed.
+
+        No new tests, no behavior change.
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::namedItemGetter):
+        (WebCore::JSDOMWindow::getOwnPropertySlot):
+        (WebCore::JSDOMWindow::getOwnPropertySlotByIndex):
+        * dom/Document.cpp:
+        (WebCore::Document::prepareForDestruction):
+        (WebCore::Document::processHttpEquiv):
+        (WebCore::eventTargetElementForDocument):
+        * dom/Document.h:
+        * dom/Element.cpp:
+        (WebCore::Element::insertedInto):
+        (WebCore::Element::removedFrom):
+        (WebCore::Element::updateName):
+        (WebCore::Element::updateId):
+        * html/HTMLDocument.h:
+        (WebCore::isHTMLDocument):
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::matchesReadWritePseudoClass):
+        * html/HTMLEmbedElement.cpp:
+        (WebCore::HTMLEmbedElement::updateWidget):
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::parseAttribute):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::parseAttribute):
+        * html/HTMLObjectElement.cpp:
+        (WebCore::HTMLObjectElement::updateDocNamedItem):
+        * html/ImageDocument.cpp:
+        (WebCore::ImageDocumentParser::document):
+        * html/ImageDocument.h:
+        (WebCore::isImageDocument):
+        * html/MediaDocument.h:
+        (WebCore::isMediaDocument):
+        * html/PluginDocument.cpp:
+        (WebCore::PluginDocumentParser::createDocumentStructure):
+        * html/PluginDocument.h:
+        (WebCore::isPluginDocument):
+        * loader/SubframeLoader.cpp:
+        (WebCore::SubframeLoader::loadPlugin):
+        * page/DragController.cpp:
+        (WebCore::DragController::operationForLoad):
+        * page/FrameView.cpp:
+        (WebCore::determineLayerFlushThrottleState):
+
 2014-09-29  Bruno de Oliveira Abinader  <[email protected]>
 
         Revert "Support for :enabled selector on Anchor & Area elements"

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (174064 => 174065)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2014-09-29 16:58:42 UTC (rev 174065)
@@ -80,19 +80,19 @@
 
     ASSERT(BindingSecurity::shouldAllowAccessToDOMWindow(exec, thisObj->impl()));
     ASSERT(document);
-    ASSERT(document->isHTMLDocument());
+    ASSERT(is<HTMLDocument>(document));
 
     AtomicStringImpl* atomicPropertyName = propertyName.publicName();
-    if (!atomicPropertyName || !toHTMLDocument(*document).hasWindowNamedItem(*atomicPropertyName))
+    if (!atomicPropertyName || !downcast<HTMLDocument>(*document).hasWindowNamedItem(*atomicPropertyName))
         return JSValue::encode(jsUndefined());
 
-    if (UNLIKELY(toHTMLDocument(*document).windowNamedItemContainsMultipleElements(*atomicPropertyName))) {
+    if (UNLIKELY(downcast<HTMLDocument>(*document).windowNamedItemContainsMultipleElements(*atomicPropertyName))) {
         RefPtr<HTMLCollection> collection = document->windowNamedItems(atomicPropertyName);
         ASSERT(collection->length() > 1);
         return JSValue::encode(toJS(exec, thisObj->globalObject(), WTF::getPtr(collection)));
     }
 
-    return JSValue::encode(toJS(exec, thisObj->globalObject(), toHTMLDocument(*document).windowNamedItem(*atomicPropertyName)));
+    return JSValue::encode(toJS(exec, thisObj->globalObject(), downcast<HTMLDocument>(*document).windowNamedItem(*atomicPropertyName)));
 }
 
 #if ENABLE(USER_MESSAGE_HANDLERS)
@@ -244,9 +244,9 @@
 
     // Allow shortcuts like 'Image1' instead of document.images.Image1
     Document* document = thisObject->impl().frame()->document();
-    if (document->isHTMLDocument()) {
+    if (is<HTMLDocument>(document)) {
         AtomicStringImpl* atomicPropertyName = propertyName.publicName();
-        if (atomicPropertyName && toHTMLDocument(*document).hasWindowNamedItem(*atomicPropertyName)) {
+        if (atomicPropertyName && downcast<HTMLDocument>(*document).hasWindowNamedItem(*atomicPropertyName)) {
             slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, namedItemGetter);
             return true;
         }
@@ -321,9 +321,9 @@
 
     // Allow shortcuts like 'Image1' instead of document.images.Image1
     Document* document = thisObject->impl().frame()->document();
-    if (document->isHTMLDocument()) {
+    if (is<HTMLDocument>(document)) {
         AtomicStringImpl* atomicPropertyName = propertyName.publicName();
-        if (atomicPropertyName && toHTMLDocument(*document).hasWindowNamedItem(*atomicPropertyName)) {
+        if (atomicPropertyName && downcast<HTMLDocument>(*document).hasWindowNamedItem(*atomicPropertyName)) {
             slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, namedItemGetter);
             return true;
         }

Modified: trunk/Source/WebCore/dom/Document.cpp (174064 => 174065)


--- trunk/Source/WebCore/dom/Document.cpp	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/dom/Document.cpp	2014-09-29 16:58:42 UTC (rev 174065)
@@ -2107,8 +2107,8 @@
     if (hasLivingRenderTree())
         destroyRenderTree();
 
-    if (isPluginDocument())
-        toPluginDocument(this)->detachFromPluginElement();
+    if (is<PluginDocument>(*this))
+        downcast<PluginDocument>(*this).detachFromPluginElement();
 
 #if ENABLE(POINTER_LOCK)
     if (page())
@@ -2879,9 +2879,9 @@
 
     case HTTPHeaderName::SetCookie:
         // FIXME: make setCookie work on XML documents too; e.g. in case of <html:meta .....>
-        if (isHTMLDocument()) {
+        if (is<HTMLDocument>(*this)) {
             // Exception (for sandboxed documents) ignored.
-            toHTMLDocument(*this).setCookie(content, IGNORE_EXCEPTION);
+            downcast<HTMLDocument>(*this).setCookie(content, IGNORE_EXCEPTION);
         }
         break;
 
@@ -5900,19 +5900,17 @@
 }
 #endif
 
-Element* eventTargetElementForDocument(Document* doc)
+Element* eventTargetElementForDocument(Document* document)
 {
-    if (!doc)
+    if (!document)
         return nullptr;
-    Element* element = doc->focusedElement();
-    if (!element && doc->isPluginDocument()) {
-        PluginDocument* pluginDocument = toPluginDocument(doc);
-        element = pluginDocument->pluginElement();
-    }
-    if (!element && doc->isHTMLDocument())
-        element = doc->body();
+    Element* element = document->focusedElement();
+    if (!element && is<PluginDocument>(document))
+        element = downcast<PluginDocument>(*document).pluginElement();
+    if (!element && is<HTMLDocument>(document))
+        element = document->body();
     if (!element)
-        element = doc->documentElement();
+        element = document->documentElement();
     return element;
 }
 

Modified: trunk/Source/WebCore/dom/Document.h (174064 => 174065)


--- trunk/Source/WebCore/dom/Document.h	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/dom/Document.h	2014-09-29 16:58:42 UTC (rev 174065)
@@ -1747,9 +1747,6 @@
 
 NODE_TYPE_CASTS(Document)
 
-#define DOCUMENT_TYPE_CASTS(ToClassName) \
-    TYPE_CASTS_BASE(ToClassName, Document, document, WebCore::is##ToClassName(*document), WebCore::is##ToClassName(document))
-
 } // namespace WebCore
 
 namespace WTF {

Modified: trunk/Source/WebCore/dom/Element.cpp (174064 => 174065)


--- trunk/Source/WebCore/dom/Element.cpp	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/dom/Element.cpp	2014-09-29 16:58:42 UTC (rev 174065)
@@ -1338,7 +1338,7 @@
         elementRareData()->clearClassListValueForQuirksMode();
 
     TreeScope* newScope = &insertionPoint.treeScope();
-    HTMLDocument* newDocument = !wasInDocument && inDocument() && newScope->documentScope().isHTMLDocument() ? toHTMLDocument(&newScope->documentScope()) : nullptr;
+    HTMLDocument* newDocument = !wasInDocument && inDocument() && is<HTMLDocument>(newScope->documentScope()) ? &downcast<HTMLDocument>(newScope->documentScope()) : nullptr;
     if (newScope != &treeScope())
         newScope = nullptr;
 
@@ -1381,7 +1381,7 @@
 
     if (insertionPoint.isInTreeScope()) {
         TreeScope* oldScope = &insertionPoint.treeScope();
-        HTMLDocument* oldDocument = inDocument() && oldScope->documentScope().isHTMLDocument() ? toHTMLDocument(&oldScope->documentScope()) : nullptr;
+        HTMLDocument* oldDocument = inDocument() && is<HTMLDocument>(oldScope->documentScope()) ? &downcast<HTMLDocument>(oldScope->documentScope()) : nullptr;
         if (oldScope != &treeScope() || !isInTreeScope())
             oldScope = nullptr;
 
@@ -2588,9 +2588,9 @@
 
     if (!inDocument())
         return;
-    if (!document().isHTMLDocument())
+    if (!is<HTMLDocument>(document()))
         return;
-    updateNameForDocument(toHTMLDocument(document()), oldName, newName);
+    updateNameForDocument(downcast<HTMLDocument>(document()), oldName, newName);
 }
 
 void Element::updateNameForTreeScope(TreeScope& scope, const AtomicString& oldName, const AtomicString& newName)
@@ -2636,9 +2636,9 @@
 
     if (!inDocument())
         return;
-    if (!document().isHTMLDocument())
+    if (!is<HTMLDocument>(document()))
         return;
-    updateIdForDocument(toHTMLDocument(document()), oldId, newId, UpdateHTMLDocumentNamedItemMapsOnlyIfDiffersFromNameAttribute);
+    updateIdForDocument(downcast<HTMLDocument>(document()), oldId, newId, UpdateHTMLDocumentNamedItemMapsOnlyIfDiffersFromNameAttribute);
 }
 
 void Element::updateIdForTreeScope(TreeScope& scope, const AtomicString& oldId, const AtomicString& newId)

Modified: trunk/Source/WebCore/html/HTMLDocument.h (174064 => 174065)


--- trunk/Source/WebCore/html/HTMLDocument.h	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/html/HTMLDocument.h	2014-09-29 16:58:42 UTC (rev 174065)
@@ -97,11 +97,11 @@
     DocumentOrderedMap m_windowNamedItem;
 };
 
-inline bool isHTMLDocument(const Document& document) { return document.isHTMLDocument(); }
-void isHTMLDocument(const HTMLDocument&); // Catch unnecessary runtime check of type known at compile time.
+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)); }
+SPECIALIZE_TYPE_TRAITS_END()
 
-DOCUMENT_TYPE_CASTS(HTMLDocument)
-
 } // namespace WebCore
 
 #endif // HTMLDocument_h

Modified: trunk/Source/WebCore/html/HTMLElement.cpp (174064 => 174065)


--- trunk/Source/WebCore/html/HTMLElement.cpp	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/html/HTMLElement.cpp	2014-09-29 16:58:42 UTC (rev 174065)
@@ -379,10 +379,8 @@
     } while (currentElement);
 
     const Document& document = this->document();
-    if (document.isHTMLDocument()) {
-        const HTMLDocument& htmlDocument = toHTMLDocument(document);
-        return htmlDocument.inDesignMode();
-    }
+    if (is<HTMLDocument>(document))
+        return downcast<HTMLDocument>(document).inDesignMode();
     return false;
 }
 

Modified: trunk/Source/WebCore/html/HTMLEmbedElement.cpp (174064 => 174065)


--- trunk/Source/WebCore/html/HTMLEmbedElement.cpp	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/html/HTMLEmbedElement.cpp	2014-09-29 16:58:42 UTC (rev 174065)
@@ -166,11 +166,11 @@
     Ref<HTMLEmbedElement> protect(*this); // Loading the plugin might remove us from the document.
     bool beforeLoadAllowedLoad = guardedDispatchBeforeLoadEvent(m_url);
     if (!beforeLoadAllowedLoad) {
-        if (document().isPluginDocument()) {
+        if (is<PluginDocument>(document())) {
             // Plugins inside plugin documents load differently than other plugins. By the time
             // we are here in a plugin document, the load of the plugin (which is the plugin document's
             // main resource) has already started. We need to explicitly cancel the main resource load here.
-            toPluginDocument(&document())->cancelManualPluginLoad();
+            downcast<PluginDocument>(document()).cancelManualPluginLoad();
         }
         return;
     }

Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (174064 => 174065)


--- trunk/Source/WebCore/html/HTMLImageElement.cpp	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp	2014-09-29 16:58:42 UTC (rev 174065)
@@ -182,8 +182,8 @@
     } else {
         if (name == nameAttr) {
             bool willHaveName = !value.isNull();
-            if (hasName() != willHaveName && inDocument() && document().isHTMLDocument()) {
-                HTMLDocument& document = toHTMLDocument(this->document());
+            if (hasName() != willHaveName && inDocument() && is<HTMLDocument>(document())) {
+                HTMLDocument& document = downcast<HTMLDocument>(this->document());
                 const AtomicString& id = getIdAttribute();
                 if (!id.isEmpty() && id != getNameAttribute()) {
                     if (willHaveName)

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (174064 => 174065)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2014-09-29 16:58:42 UTC (rev 174065)
@@ -1795,11 +1795,11 @@
     setShouldDelayLoadEvent(false);
 
     // 6 - Abort the overall resource selection algorithm.
-    m_currentSourceNode = 0;
+    m_currentSourceNode = nullptr;
 
 #if PLATFORM(COCOA)
-    if (document().isMediaDocument())
-        toMediaDocument(document()).mediaElementSawUnsupportedTracks();
+    if (is<MediaDocument>(document()))
+        downcast<MediaDocument>(document()).mediaElementSawUnsupportedTracks();
 #endif
 }
 
@@ -4208,8 +4208,8 @@
     // The MediaPlayer came across content it cannot completely handle.
     // This is normally acceptable except when we are in a standalone
     // MediaDocument. If so, tell the document what has happened.
-    if (document().isMediaDocument())
-        toMediaDocument(document()).mediaElementSawUnsupportedTracks();
+    if (is<MediaDocument>(document()))
+        downcast<MediaDocument>(document()).mediaElementSawUnsupportedTracks();
 }
 
 void HTMLMediaElement::mediaPlayerResourceNotSupported(MediaPlayer*)

Modified: trunk/Source/WebCore/html/HTMLObjectElement.cpp (174064 => 174065)


--- trunk/Source/WebCore/html/HTMLObjectElement.cpp	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/html/HTMLObjectElement.cpp	2014-09-29 16:58:42 UTC (rev 174065)
@@ -435,8 +435,8 @@
             isNamedItem = false;
         child = child->nextSibling();
     }
-    if (isNamedItem != wasNamedItem && inDocument() && document().isHTMLDocument()) {
-        HTMLDocument& document = toHTMLDocument(this->document());
+    if (isNamedItem != wasNamedItem && inDocument() && is<HTMLDocument>(document())) {
+        HTMLDocument& document = downcast<HTMLDocument>(this->document());
 
         const AtomicString& id = getIdAttribute();
         if (!id.isEmpty()) {

Modified: trunk/Source/WebCore/html/ImageDocument.cpp (174064 => 174065)


--- trunk/Source/WebCore/html/ImageDocument.cpp	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/html/ImageDocument.cpp	2014-09-29 16:58:42 UTC (rev 174065)
@@ -176,7 +176,7 @@
 {
     // Only used during parsing, so document is guaranteed to be non-null.
     ASSERT(RawDataDocumentParser::document());
-    return toImageDocument(*RawDataDocumentParser::document());
+    return downcast<ImageDocument>(*RawDataDocumentParser::document());
 }
 
 void ImageDocumentParser::appendBytes(DocumentWriter&, const char*, size_t)

Modified: trunk/Source/WebCore/html/ImageDocument.h (174064 => 174065)


--- trunk/Source/WebCore/html/ImageDocument.h	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/html/ImageDocument.h	2014-09-29 16:58:42 UTC (rev 174065)
@@ -82,11 +82,11 @@
     bool m_shouldShrinkImage;
 };
 
-inline bool isImageDocument(const Document& document) { return document.isImageDocument(); }
-void isImageDocument(const ImageDocument&); // Catch unnecessary runtime check of type known at compile time.
+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)); }
+SPECIALIZE_TYPE_TRAITS_END()
 
-DOCUMENT_TYPE_CASTS(ImageDocument)
-
 }
 
 #endif // ImageDocument_h

Modified: trunk/Source/WebCore/html/MediaDocument.h (174064 => 174065)


--- trunk/Source/WebCore/html/MediaDocument.h	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/html/MediaDocument.h	2014-09-29 16:58:42 UTC (rev 174065)
@@ -56,11 +56,11 @@
     String m_outgoingReferrer;
 };
 
-inline bool isMediaDocument(const Document& document) { return document.isMediaDocument(); }
-void isMediaDocument(const MediaDocument&); // Catch unnecessary runtime check of type known at compile time.
+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)); }
+SPECIALIZE_TYPE_TRAITS_END()
 
-DOCUMENT_TYPE_CASTS(MediaDocument)
-
 }
 
 #endif

Modified: trunk/Source/WebCore/html/PluginDocument.cpp (174064 => 174065)


--- trunk/Source/WebCore/html/PluginDocument.cpp	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/html/PluginDocument.cpp	2014-09-29 16:58:42 UTC (rev 174065)
@@ -104,7 +104,7 @@
     if (loader)
         m_embedElement->setAttribute(typeAttr, loader->writer().mimeType());
 
-    toPluginDocument(document())->setPluginElement(m_embedElement);
+    downcast<PluginDocument>(*document()).setPluginElement(m_embedElement);
 
     body->appendChild(embedElement, IGNORE_EXCEPTION);
 }

Modified: trunk/Source/WebCore/html/PluginDocument.h (174064 => 174065)


--- trunk/Source/WebCore/html/PluginDocument.h	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/html/PluginDocument.h	2014-09-29 16:58:42 UTC (rev 174065)
@@ -61,11 +61,11 @@
     RefPtr<HTMLPlugInElement> m_pluginElement;
 };
 
-inline bool isPluginDocument(const Document& document) { return document.isPluginDocument(); }
-void isPluginDocument(const PluginDocument&); // Catch unnecessary runtime check of type known at compile time.
+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)); }
+SPECIALIZE_TYPE_TRAITS_END()
 
-DOCUMENT_TYPE_CASTS(PluginDocument)
-
 }
 
 #endif // PluginDocument_h

Modified: trunk/Source/WebCore/loader/SubframeLoader.cpp (174064 => 174065)


--- trunk/Source/WebCore/loader/SubframeLoader.cpp	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/loader/SubframeLoader.cpp	2014-09-29 16:58:42 UTC (rev 174065)
@@ -393,7 +393,7 @@
     pluginElement.subframeLoaderWillCreatePlugIn(url);
 
     IntSize contentSize = roundedIntSize(LayoutSize(renderer->contentWidth(), renderer->contentHeight()));
-    bool loadManually = document()->isPluginDocument() && !m_containsPlugins && toPluginDocument(document())->shouldLoadPluginManually();
+    bool loadManually = is<PluginDocument>(document()) && !m_containsPlugins && downcast<PluginDocument>(*document()).shouldLoadPluginManually();
 
 #if PLATFORM(IOS)
     // On iOS, we only tell the plugin to be in full page mode if the containing plugin document is the top level document.

Modified: trunk/Source/WebCore/page/DragController.cpp (174064 => 174065)


--- trunk/Source/WebCore/page/DragController.cpp	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/page/DragController.cpp	2014-09-29 16:58:42 UTC (rev 174065)
@@ -397,8 +397,8 @@
 
     bool pluginDocumentAcceptsDrags = false;
 
-    if (doc && doc->isPluginDocument()) {
-        const Widget* widget = toPluginDocument(doc)->pluginWidget();
+    if (doc && is<PluginDocument>(doc)) {
+        const Widget* widget = downcast<PluginDocument>(*doc).pluginWidget();
         const PluginViewBase* pluginView = (widget && widget->isPluginViewBase()) ? toPluginViewBase(widget) : nullptr;
 
         if (pluginView)

Modified: trunk/Source/WebCore/page/FrameView.cpp (174064 => 174065)


--- trunk/Source/WebCore/page/FrameView.cpp	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebCore/page/FrameView.cpp	2014-09-29 16:58:42 UTC (rev 174065)
@@ -2311,7 +2311,7 @@
         return 0;
     // Disable for image documents so large GIF animations don't get throttled during loading.
     auto* document = page.mainFrame().document();
-    if (!document || isImageDocument(*document))
+    if (!document || is<ImageDocument>(*document))
         return 0;
     return LayerFlushThrottleState::Enabled;
 }

Modified: trunk/Source/WebKit/win/ChangeLog (174064 => 174065)


--- trunk/Source/WebKit/win/ChangeLog	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebKit/win/ChangeLog	2014-09-29 16:58:42 UTC (rev 174065)
@@ -1,3 +1,17 @@
+2014-09-29  Christophe Dumez  <[email protected]>
+
+        Make is<>() / downcast<>() work for HTMLDocument and its subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137169
+
+        Reviewed by Darin Adler.
+
+        Use is<>() / downcast<>() for HTMLDocument and its subclasses.
+
+        * DOMHTMLClasses.cpp:
+        (DOMHTMLDocument::URL):
+        (DOMHTMLDocument::body):
+        (DOMHTMLDocument::forms):
+
 2014-09-28  Gyuyoung Kim  <[email protected]>
 
         Use std::unique_ptr for ContextMenuController

Modified: trunk/Source/WebKit/win/DOMHTMLClasses.cpp (174064 => 174065)


--- trunk/Source/WebKit/win/DOMHTMLClasses.cpp	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebKit/win/DOMHTMLClasses.cpp	2014-09-29 16:58:42 UTC (rev 174065)
@@ -250,18 +250,18 @@
     if (!result)
         return E_POINTER;
 
-    *result = BString(toHTMLDocument(m_document)->url()).release();
+    *result = BString(downcast<HTMLDocument>(*m_document).url()).release();
     return S_OK;
 }
     
 HRESULT STDMETHODCALLTYPE DOMHTMLDocument::body( 
         /* [retval][out] */ IDOMHTMLElement** bodyElement)
 {
-    *bodyElement = 0;
-    if (!m_document || !m_document->isHTMLDocument())
+    *bodyElement = nullptr;
+    if (!m_document || !is<HTMLDocument>(m_document))
         return E_FAIL;
 
-    HTMLDocument& htmlDoc = toHTMLDocument(*m_document);
+    HTMLDocument& htmlDoc = downcast<HTMLDocument>(*m_document);
     COMPtr<IDOMElement> domElement;
     domElement.adoptRef(DOMHTMLElement::createInstance(htmlDoc.body()));
     if (domElement)
@@ -300,11 +300,11 @@
 HRESULT STDMETHODCALLTYPE DOMHTMLDocument::forms( 
         /* [retval][out] */ IDOMHTMLCollection** collection)
 {
-    *collection = 0;
-    if (!m_document || !m_document->isHTMLDocument())
+    *collection = nullptr;
+    if (!m_document || !is<HTMLDocument>(m_document))
         return E_FAIL;
 
-    HTMLDocument& htmlDoc = toHTMLDocument(*m_document);
+    HTMLDocument& htmlDoc = downcast<HTMLDocument>(*m_document);
     RefPtr<HTMLCollection> forms = htmlDoc.forms();
     *collection = DOMHTMLCollection::createInstance(forms.get());
     return S_OK;

Modified: trunk/Source/WebKit2/ChangeLog (174064 => 174065)


--- trunk/Source/WebKit2/ChangeLog	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebKit2/ChangeLog	2014-09-29 16:58:42 UTC (rev 174065)
@@ -1,3 +1,15 @@
+2014-09-29  Christophe Dumez  <[email protected]>
+
+        Make is<>() / downcast<>() work for HTMLDocument and its subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137169
+
+        Reviewed by Darin Adler.
+
+        Use is<>() / downcast<>() for HTMLDocument and its subclasses.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::pdfDocumentForPrintingFrame):
+
 2014-09-29  Tibor Meszaros  <[email protected]>
 
         Fix !ENABLE(INSPECTOR) build after r173929

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (174064 => 174065)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-09-29 16:31:33 UTC (rev 174064)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-09-29 16:58:42 UTC (rev 174065)
@@ -3688,14 +3688,14 @@
 {
     Document* document = coreFrame->document();
     if (!document)
-        return 0;
+        return nullptr;
 
-    if (!document->isPluginDocument())
-        return 0;
+    if (!is<PluginDocument>(document))
+        return nullptr;
 
-    PluginView* pluginView = static_cast<PluginView*>(toPluginDocument(document)->pluginWidget());
+    PluginView* pluginView = static_cast<PluginView*>(downcast<PluginDocument>(*document).pluginWidget());
     if (!pluginView)
-        return 0;
+        return nullptr;
 
     return pluginView->pdfDocumentForPrinting();
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to