WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
137004
Use downcast<SVG*Element>() instead of toSVG*Element()
https://bugs.webkit.org/show_bug.cgi?id=137004
Summary
Use downcast<SVG*Element>() instead of toSVG*Element()
Chris Dumez
Reported
2014-09-22 09:23:09 PDT
Use downcast<SVG*Element>() instead of toSVG*Element() and get rid of the transition macros for SVG Elements.
Attachments
Patch
(124.44 KB, patch)
2014-09-22 09:27 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(131.48 KB, patch)
2014-09-22 10:34 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(147.49 KB, patch)
2014-09-22 15:51 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(147.71 KB, patch)
2014-09-22 16:30 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Chris Dumez
Comment 1
2014-09-22 09:27:27 PDT
Created
attachment 238484
[details]
Patch
Chris Dumez
Comment 2
2014-09-22 10:34:58 PDT
Created
attachment 238486
[details]
Patch
Benjamin Poulain
Comment 3
2014-09-22 14:41:38 PDT
Comment on
attachment 238486
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=238486&action=review
IMHO, you should review the use of pointers in the cases with: if (foo and foo->isBar()) downcast<Bar>(foo)->bang(); Some of them use "downcast<Bar>(foo)->bang();", other do "downcast<Bar>(*foo).bang();". Unifying the style would be nice.
> Source/WebCore/accessibility/AccessibilityNodeObject.cpp:1503 > + return downcast<SVGElement>(m_node)->title();
downcast<SVGElement>(*m_node).title()
> Source/WebCore/accessibility/AccessibilityRenderObject.cpp:2886 > + SVGSVGElement* rootElement = downcast<SVGDocument>(doc)->rootElement();
ditto.
> Source/WebCore/css/CSSCursorImageValue.cpp:53 > return 0;
nullptr
> Source/WebCore/rendering/RenderTableCell.cpp:183 > - // Nowrap is set, but we didn't actually use it because of the > + // Nowrap is set, but we didtoSVGImageElementn't actually use it because of the
hahahaha
> Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp:99 > - SVGGraphicsElement* styled = toSVGGraphicsElement(childNode); > + SVGGraphicsElement* styled = downcast<SVGGraphicsElement>(childNode);
Looks like this should be a ref.
> Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp:215 > - SVGGraphicsElement* element = toSVGGraphicsElement(object->node()); > + SVGGraphicsElement* element = downcast<SVGGraphicsElement>(object->node());
ditto.
> Source/WebCore/rendering/svg/RenderSVGTextPath.cpp:51 > - SVGPathElement* pathElement = toSVGPathElement(targetElement); > + SVGPathElement* pathElement = downcast<SVGPathElement>(targetElement);
ditto.
> Source/WebCore/rendering/svg/RenderSVGTransformableContainer.cpp:44 > SVGUseElement* useElement = 0;
nullptr
> Source/WebCore/rendering/svg/SVGRenderSupport.cpp:255 > + if (SVGElement* element = child->node()->isSVGElement() ? downcast<SVGElement>(child->node()) : 0) {
nullptr
> Source/WebCore/rendering/svg/SVGRenderingContext.cpp:109 > + SVGGraphicsElement& graphicsElement = *downcast<SVGGraphicsElement>(renderer.element());
I would put the dereference inside the downcast... not important though.
> Source/WebCore/rendering/svg/SVGTextLayoutEngine.cpp:429 > - SVGElement* lengthContext = toSVGElement(text->parent()->element()); > + SVGElement* lengthContext = downcast<SVGElement>(text->parent()->element()); > > RenderObject* textParent = text->parent(); > bool definesTextLength = textParent ? parentDefinesTextLength(textParent) : false;
There is something very very wrong going here, you should add a test. text->parent() can be null apparently since it is checked by the ternary operator. BUT, it is used for lengthContext.
> Source/WebCore/svg/SVGDocument.cpp:48 > return 0;
nullptr
> Source/WebCore/svg/SVGSVGElement.cpp:667 > if (element->hasTagName(SVGNames::svgTag)) {
Can this be isSVGSVGElement()?
> Source/WebCore/svg/SVGTextContentElement.cpp:294 > return 0;
nullptr
> Source/WebCore/svg/SVGTextContentElement.cpp:300 > return 0;
nullptr
> Source/WebCore/svg/animation/SVGSMILElement.cpp:171 > + SVGElement* svgTarget = target && target->isSVGElement() ? downcast<SVGElement>(target) : 0;
nullptr
Darin Adler
Comment 4
2014-09-22 15:15:11 PDT
(In reply to
comment #3
)
> Some of them use "downcast<Bar>(foo)->bang();", other do "downcast<Bar>(*foo).bang();". Unifying the style would be nice.
downcast<Bar>(foo)->bang() -- prettier downcast<Bar>(*foo).bang() -- clearer to the compiler when generating the code for downcast that foo can't be null, but modern compilers probably get this right already, since it knows that foo was dereferenced a couple lines earlier I’ve been using downcast<Bar>(*foo).bang() because I never want to depend on the compiler to not add a bogus null check.
Chris Dumez
Comment 5
2014-09-22 15:51:34 PDT
Created
attachment 238500
[details]
Patch
Chris Dumez
Comment 6
2014-09-22 16:30:58 PDT
Created
attachment 238504
[details]
Patch
WebKit Commit Bot
Comment 7
2014-09-22 17:55:12 PDT
Comment on
attachment 238504
[details]
Patch Clearing flags on attachment: 238504 Committed
r173859
: <
http://trac.webkit.org/changeset/173859
>
WebKit Commit Bot
Comment 8
2014-09-22 17:55:17 PDT
All reviewed patches have been landed. Closing bug.
Csaba Osztrogonác
Comment 9
2014-09-22 22:36:50 PDT
(In reply to
comment #7
)
> (From update of
attachment 238504
[details]
) > Clearing flags on attachment: 238504 > > Committed
r173859
: <
http://trac.webkit.org/changeset/173859
>
It broke the debug builds, please fix.
Chris Dumez
Comment 10
2014-09-22 22:43:24 PDT
(In reply to
comment #9
)
> (In reply to
comment #7
) > > (From update of
attachment 238504
[details]
[details]) > > Clearing flags on attachment: 238504 > > > > Committed
r173859
: <
http://trac.webkit.org/changeset/173859
> > It broke the debug builds, please fix.
Thanks for notifying me. I'll take a look now.
Chris Dumez
Comment 11
2014-09-22 23:01:06 PDT
(In reply to
comment #10
)
> (In reply to
comment #9
) > > (In reply to
comment #7
) > > > (From update of
attachment 238504
[details]
[details] [details]) > > > Clearing flags on attachment: 238504 > > > > > > Committed
r173859
: <
http://trac.webkit.org/changeset/173859
> > > It broke the debug builds, please fix. > > Thanks for notifying me. I'll take a look now.
http://trac.webkit.org/changeset/173866
should fix the build but I'll watch the bots to make sure.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug