Bug 137128 - Add support for is<SVGDocument>() / downcast<SVGDocument>()
Summary: Add support for is<SVGDocument>() / downcast<SVGDocument>()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on: 137056
Blocks:
  Show dependency treegraph
 
Reported: 2014-09-25 14:14 PDT by Chris Dumez
Modified: 2014-09-25 17:35 PDT (History)
20 users (show)

See Also:


Attachments
Patch (11.64 KB, patch)
2014-09-25 14:17 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (13.10 KB, patch)
2014-09-25 16:39 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2014-09-25 14:14:09 PDT
Add support for is<SVGDocument>() / downcast<SVGDocument>() by using the SPECIALIZE_TYPE_TRAITS_*() macro, instead of the DOCUMENT_TYPE_CASTS() one.
Comment 1 Chris Dumez 2014-09-25 14:17:21 PDT
Created attachment 238671 [details]
Patch
Comment 2 WebKit Commit Bot 2014-09-25 14:19:22 PDT
Attachment 238671 [details] did not pass style-queue:


ERROR: Source/WebCore/svg/SVGDocument.h:57:  Code inside a namespace should not be indented.  [whitespace/indent] [4]
Total errors found: 1 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Ryosuke Niwa 2014-09-25 16:26:20 PDT
Comment on attachment 238671 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=238671&action=review

> Source/WebCore/page/EventHandler.cpp:763
> +    if (is<SVGDocument>(m_frame.document())
> +        && downcast<SVGDocument>(*m_frame.document()).zoomAndPanEnabled()) {

We can probably fit this in one line instead.

> Source/WebCore/page/Frame.cpp:971
> +    if (is<SVGDocument>(document)) {
> +        if (!downcast<SVGDocument>(*document).zoomAndPanEnabled())

Why don't we check both of these conditions in one if statement instead?

> Source/WebCore/page/FrameView.cpp:1964
> +    if (is<SVGDocument>(frame().document())) {
> +        if (SVGSVGElement* svg = downcast<SVGDocument>(*frame().document()).rootElement()) {

Ditto.

> Source/WebCore/svg/graphics/SVGImage.cpp:71
> -    SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
> +    SVGSVGElement* rootElement = downcast<SVGDocument>(*m_page->mainFrame().document()).rootElement();

Should we add a helper function to get the root element or nullptr?
Repeating the code over and over isn't so great...
Comment 4 Chris Dumez 2014-09-25 16:39:06 PDT
Created attachment 238682 [details]
Patch
Comment 5 WebKit Commit Bot 2014-09-25 16:42:05 PDT
Attachment 238682 [details] did not pass style-queue:


ERROR: Source/WebCore/svg/SVGDocument.h:57:  Code inside a namespace should not be indented.  [whitespace/indent] [4]
Total errors found: 1 in 9 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 WebKit Commit Bot 2014-09-25 17:35:08 PDT
Comment on attachment 238682 [details]
Patch

Clearing flags on attachment: 238682

Committed r173987: <http://trac.webkit.org/changeset/173987>
Comment 7 WebKit Commit Bot 2014-09-25 17:35:15 PDT
All reviewed patches have been landed.  Closing bug.