- Revision
- 173987
- Author
- [email protected]
- Date
- 2014-09-25 17:34:56 -0700 (Thu, 25 Sep 2014)
Log Message
Add support for is<SVGDocument>() / downcast<SVGDocument>()
https://bugs.webkit.org/show_bug.cgi?id=137128
Reviewed by Ryosuke Niwa.
Add support for is<SVGDocument>() / downcast<SVGDocument>() by using
the SPECIALIZE_TYPE_TRAITS_*() macro, instead of the
DOCUMENT_TYPE_CASTS() one.
No new tests, no behavior change.
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::remoteSVGRootElement):
* html/HTMLFrameOwnerElement.cpp:
(WebCore::HTMLFrameOwnerElement::getSVGDocument):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::handleMouseMoveEvent):
(WebCore::EventHandler::handleMouseReleaseEvent):
* page/Frame.cpp:
(WebCore::Frame::setPageAndTextZoomFactors):
* page/FrameView.cpp:
(WebCore::FrameView::scrollToAnchor):
* svg/SVGDocument.h:
(WebCore::isSVGDocument):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::hasSingleSecurityOrigin):
(WebCore::SVGImage::setContainerSize):
(WebCore::SVGImage::containerSize):
(WebCore::SVGImage::embeddedContentBox):
(WebCore::SVGImage::hasRelativeWidth):
(WebCore::SVGImage::hasRelativeHeight):
(WebCore::SVGImage::computeIntrinsicDimensions):
(WebCore::SVGImage::startAnimation):
(WebCore::SVGImage::stopAnimation):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (173986 => 173987)
--- trunk/Source/WebCore/ChangeLog 2014-09-26 00:34:40 UTC (rev 173986)
+++ trunk/Source/WebCore/ChangeLog 2014-09-26 00:34:56 UTC (rev 173987)
@@ -1,3 +1,41 @@
+2014-09-25 Christophe Dumez <[email protected]>
+
+ Add support for is<SVGDocument>() / downcast<SVGDocument>()
+ https://bugs.webkit.org/show_bug.cgi?id=137128
+
+ Reviewed by Ryosuke Niwa.
+
+ Add support for is<SVGDocument>() / downcast<SVGDocument>() by using
+ the SPECIALIZE_TYPE_TRAITS_*() macro, instead of the
+ DOCUMENT_TYPE_CASTS() one.
+
+ No new tests, no behavior change.
+
+ * accessibility/AccessibilityRenderObject.cpp:
+ (WebCore::AccessibilityRenderObject::remoteSVGRootElement):
+ * html/HTMLFrameOwnerElement.cpp:
+ (WebCore::HTMLFrameOwnerElement::getSVGDocument):
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::handleMousePressEvent):
+ (WebCore::EventHandler::handleMouseMoveEvent):
+ (WebCore::EventHandler::handleMouseReleaseEvent):
+ * page/Frame.cpp:
+ (WebCore::Frame::setPageAndTextZoomFactors):
+ * page/FrameView.cpp:
+ (WebCore::FrameView::scrollToAnchor):
+ * svg/SVGDocument.h:
+ (WebCore::isSVGDocument):
+ * svg/graphics/SVGImage.cpp:
+ (WebCore::SVGImage::hasSingleSecurityOrigin):
+ (WebCore::SVGImage::setContainerSize):
+ (WebCore::SVGImage::containerSize):
+ (WebCore::SVGImage::embeddedContentBox):
+ (WebCore::SVGImage::hasRelativeWidth):
+ (WebCore::SVGImage::hasRelativeHeight):
+ (WebCore::SVGImage::computeIntrinsicDimensions):
+ (WebCore::SVGImage::startAnimation):
+ (WebCore::SVGImage::stopAnimation):
+
2014-09-25 Said Abou-Hallawa <[email protected]>
Rename CSSKeyframesRule insertRule to appendRule (57910)
Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (173986 => 173987)
--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2014-09-26 00:34:40 UTC (rev 173986)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2014-09-26 00:34:56 UTC (rev 173987)
@@ -2881,10 +2881,10 @@
Frame& frame = frameView->frame();
Document* document = frame.document();
- if (!document || !document->isSVGDocument())
+ if (!document || !is<SVGDocument>(document))
return nullptr;
- SVGSVGElement* rootElement = toSVGDocument(*document).rootElement();
+ SVGSVGElement* rootElement = downcast<SVGDocument>(*document).rootElement();
if (!rootElement)
return nullptr;
RenderObject* rendererRoot = rootElement->renderer();
Modified: trunk/Source/WebCore/html/HTMLFrameOwnerElement.cpp (173986 => 173987)
--- trunk/Source/WebCore/html/HTMLFrameOwnerElement.cpp 2014-09-26 00:34:40 UTC (rev 173986)
+++ trunk/Source/WebCore/html/HTMLFrameOwnerElement.cpp 2014-09-26 00:34:56 UTC (rev 173987)
@@ -114,8 +114,8 @@
SVGDocument* HTMLFrameOwnerElement::getSVGDocument(ExceptionCode& ec) const
{
Document* document = contentDocument();
- if (document && document->isSVGDocument())
- return toSVGDocument(document);
+ if (document && is<SVGDocument>(document))
+ return downcast<SVGDocument>(document);
// Spec: http://www.w3.org/TR/SVG/struct.html#InterfaceGetSVGDocument
ec = NOT_SUPPORTED_ERR;
return nullptr;
Modified: trunk/Source/WebCore/page/EventHandler.cpp (173986 => 173987)
--- trunk/Source/WebCore/page/EventHandler.cpp 2014-09-26 00:34:40 UTC (rev 173986)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2014-09-26 00:34:56 UTC (rev 173987)
@@ -759,11 +759,10 @@
if (event.isOverWidget() && passWidgetMouseDownEventToWidget(event))
return true;
- if (m_frame.document()->isSVGDocument()
- && toSVGDocument(*m_frame.document()).zoomAndPanEnabled()) {
+ if (is<SVGDocument>(m_frame.document()) && downcast<SVGDocument>(*m_frame.document()).zoomAndPanEnabled()) {
if (event.event().shiftKey() && singleClick) {
m_svgPan = true;
- toSVGDocument(*m_frame.document()).startPan(m_frame.view()->windowToContents(event.event().position()));
+ downcast<SVGDocument>(*m_frame.document()).startPan(m_frame.view()->windowToContents(event.event().position()));
return true;
}
}
@@ -1893,7 +1892,7 @@
#endif
if (m_svgPan) {
- toSVGDocument(m_frame.document())->updatePan(m_frame.view()->windowToContents(m_lastKnownMousePosition));
+ downcast<SVGDocument>(*m_frame.document()).updatePan(m_frame.view()->windowToContents(m_lastKnownMousePosition));
return true;
}
@@ -2037,7 +2036,7 @@
if (m_svgPan) {
m_svgPan = false;
- toSVGDocument(m_frame.document())->updatePan(m_frame.view()->windowToContents(m_lastKnownMousePosition));
+ downcast<SVGDocument>(*m_frame.document()).updatePan(m_frame.view()->windowToContents(m_lastKnownMousePosition));
return true;
}
Modified: trunk/Source/WebCore/page/Frame.cpp (173986 => 173987)
--- trunk/Source/WebCore/page/Frame.cpp 2014-09-26 00:34:40 UTC (rev 173986)
+++ trunk/Source/WebCore/page/Frame.cpp 2014-09-26 00:34:56 UTC (rev 173987)
@@ -967,10 +967,8 @@
// Respect SVGs zoomAndPan="disabled" property in standalone SVG documents.
// FIXME: How to handle compound documents + zoomAndPan="disabled"? Needs SVG WG clarification.
- if (document->isSVGDocument()) {
- if (!toSVGDocument(*document).zoomAndPanEnabled())
- return;
- }
+ if (is<SVGDocument>(document) && !downcast<SVGDocument>(*document).zoomAndPanEnabled())
+ return;
if (m_pageZoomFactor != pageZoomFactor) {
if (FrameView* view = this->view()) {
Modified: trunk/Source/WebCore/page/FrameView.cpp (173986 => 173987)
--- trunk/Source/WebCore/page/FrameView.cpp 2014-09-26 00:34:40 UTC (rev 173986)
+++ trunk/Source/WebCore/page/FrameView.cpp 2014-09-26 00:34:56 UTC (rev 173987)
@@ -1960,8 +1960,8 @@
// Setting to null will clear the current target.
frame().document()->setCSSTarget(anchorElement);
- if (frame().document()->isSVGDocument()) {
- if (SVGSVGElement* svg = toSVGDocument(*frame().document()).rootElement()) {
+ if (is<SVGDocument>(frame().document())) {
+ if (SVGSVGElement* svg = downcast<SVGDocument>(*frame().document()).rootElement()) {
svg->setupInitialView(name, anchorElement);
if (!anchorElement)
return true;
Modified: trunk/Source/WebCore/svg/SVGDocument.h (173986 => 173987)
--- trunk/Source/WebCore/svg/SVGDocument.h 2014-09-26 00:34:40 UTC (rev 173986)
+++ trunk/Source/WebCore/svg/SVGDocument.h 2014-09-26 00:34:56 UTC (rev 173987)
@@ -52,11 +52,11 @@
FloatPoint m_translate;
};
-inline bool isSVGDocument(const Document& document) { return document.isSVGDocument(); }
-void isSVGDocument(const SVGDocument&); // Catch unnecessary runtime check of type known at compile time.
+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)); }
+SPECIALIZE_TYPE_TRAITS_END()
-DOCUMENT_TYPE_CASTS(SVGDocument)
-
} // namespace WebCore
#endif // SVGDocument_h
Modified: trunk/Source/WebCore/svg/graphics/SVGImage.cpp (173986 => 173987)
--- trunk/Source/WebCore/svg/graphics/SVGImage.cpp 2014-09-26 00:34:40 UTC (rev 173986)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.cpp 2014-09-26 00:34:56 UTC (rev 173987)
@@ -63,12 +63,16 @@
ASSERT(!m_chromeClient || !m_chromeClient->image());
}
-bool SVGImage::hasSingleSecurityOrigin() const
+inline SVGSVGElement* SVGImage::rootElement() const
{
if (!m_page)
- return true;
+ return nullptr;
+ return downcast<SVGDocument>(*m_page->mainFrame().document()).rootElement();
+}
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+bool SVGImage::hasSingleSecurityOrigin() const
+{
+ SVGSVGElement* rootElement = this->rootElement();
if (!rootElement)
return true;
@@ -83,10 +87,10 @@
void SVGImage::setContainerSize(const FloatSize& size)
{
- if (!m_page || !usesContainerSize())
+ if (!usesContainerSize())
return;
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+ SVGSVGElement* rootElement = this->rootElement();
if (!rootElement)
return;
RenderSVGRoot* renderer = toRenderSVGRoot(rootElement->renderer());
@@ -101,9 +105,7 @@
IntSize SVGImage::containerSize() const
{
- if (!m_page)
- return IntSize();
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+ SVGSVGElement* rootElement = this->rootElement();
if (!rootElement)
return IntSize();
@@ -262,26 +264,22 @@
RenderBox* SVGImage::embeddedContentBox() const
{
- if (!m_page)
- return 0;
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+ SVGSVGElement* rootElement = this->rootElement();
if (!rootElement)
- return 0;
+ return nullptr;
return toRenderBox(rootElement->renderer());
}
FrameView* SVGImage::frameView() const
{
if (!m_page)
- return 0;
+ return nullptr;
return m_page->mainFrame().view();
}
bool SVGImage::hasRelativeWidth() const
{
- if (!m_page)
- return false;
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+ SVGSVGElement* rootElement = this->rootElement();
if (!rootElement)
return false;
return rootElement->intrinsicWidth().isPercent();
@@ -289,9 +287,7 @@
bool SVGImage::hasRelativeHeight() const
{
- if (!m_page)
- return false;
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+ SVGSVGElement* rootElement = this->rootElement();
if (!rootElement)
return false;
return rootElement->intrinsicHeight().isPercent();
@@ -299,9 +295,7 @@
void SVGImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
{
- if (!m_page)
- return;
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+ SVGSVGElement* rootElement = this->rootElement();
if (!rootElement)
return;
@@ -318,9 +312,7 @@
// FIXME: support catchUpIfNecessary.
void SVGImage::startAnimation(CatchUpAnimation)
{
- if (!m_page)
- return;
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+ SVGSVGElement* rootElement = this->rootElement();
if (!rootElement)
return;
rootElement->unpauseAnimations();
@@ -329,9 +321,7 @@
void SVGImage::stopAnimation()
{
- if (!m_page)
- return;
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+ SVGSVGElement* rootElement = this->rootElement();
if (!rootElement)
return;
rootElement->pauseAnimations();
Modified: trunk/Source/WebCore/svg/graphics/SVGImage.h (173986 => 173987)
--- trunk/Source/WebCore/svg/graphics/SVGImage.h 2014-09-26 00:34:40 UTC (rev 173986)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.h 2014-09-26 00:34:56 UTC (rev 173987)
@@ -37,6 +37,7 @@
class ImageBuffer;
class Page;
class RenderBox;
+class SVGSVGElement;
class SVGImageChromeClient;
class SVGImageForContainer;
@@ -95,6 +96,8 @@
void drawPatternForContainer(GraphicsContext*, const FloatSize, float, const FloatRect&, const AffineTransform&, const FloatPoint&, ColorSpace,
CompositeOperator, const FloatRect&, BlendMode);
+ SVGSVGElement* rootElement() const;
+
std::unique_ptr<SVGImageChromeClient> m_chromeClient;
std::unique_ptr<Page> m_page;
FloatSize m_intrinsicSize;