Bug 25217 - Clean up SVGLocatable.cpp
Summary: Clean up SVGLocatable.cpp
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-15 12:22 PDT by Eric Seidel (no email)
Modified: 2009-04-15 12:33 PDT (History)
0 users

See Also:


Attachments
Simplify nearestViewportElement and farthestViewportElement using isViewportElement and a for loop (4.97 KB, patch)
2009-04-15 12:23 PDT, Eric Seidel (no email)
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2009-04-15 12:22:59 PDT
Clean up SVGLocatable.cpp

See attached (simple) patch.
Comment 1 Eric Seidel (no email) 2009-04-15 12:23:49 PDT
Created attachment 29511 [details]
Simplify nearestViewportElement and farthestViewportElement using isViewportElement and a for loop

 WebCore/ChangeLog            |   16 +++++++++
 WebCore/svg/SVGLocatable.cpp |   72 ++++++++++++++++--------------------------
 2 files changed, 43 insertions(+), 45 deletions(-)
Comment 2 Simon Fraser (smfr) 2009-04-15 12:29:21 PDT
Comment on attachment 29511 [details]
Simplify nearestViewportElement and farthestViewportElement using isViewportElement and a for loop


> +static bool isViewportElement(Node* node)
>  {
> -    Node* n = e->parentNode();
> -    while (n && !n->isDocumentNode()) {
> -        if (n->hasTagName(SVGNames::svgTag) || n->hasTagName(SVGNames::symbolTag) ||
> -            n->hasTagName(SVGNames::imageTag))
> -            return static_cast<SVGElement*>(n);
> +    if (node->hasTagName(SVGNames::svgTag)
> +        || node->hasTagName(SVGNames::symbolTag)
>  #if ENABLE(SVG_FOREIGN_OBJECT)
> -        if (n->hasTagName(SVGNames::foreignObjectTag))
> -            return static_cast<SVGElement*>(n);
> +        || node->hasTagName(SVGNames::foreignObjectTag)
>  #endif
> +        || node->hasTagName(SVGNames::imageTag))
> +            return true;
> +    return false;

You could just do

   return node->hasTagName(SVGNames::svgTag) || .......

r=me either way.
Comment 3 Eric Seidel (no email) 2009-04-15 12:33:39 PDT
Committing to http://svn.webkit.org/repository/webkit/trunk ...
	M	WebCore/ChangeLog
	M	WebCore/svg/SVGLocatable.cpp
Committed r42552