Bug 54764 - Remove redundant code in qt/WebCoreSupport
Summary: Remove redundant code in qt/WebCoreSupport
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Trivial
Assignee: Nobody
Depends on:
Reported: 2011-02-18 12:10 PST by Fabrizio
Modified: 2011-02-28 13:19 PST (History)
3 users (show)

See Also:

remove redundant checks (1.91 KB, patch)
2011-02-18 12:20 PST, Fabrizio
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fabrizio 2011-02-18 12:10:47 PST
The source files NotificationPresenterClientQt.cpp and DumpRenderTreeSupportQt.cpp have redundant checks after static_cast.

In NotificationPresenterClientQt.cpp, the final "if()" is not needed:
    if (!context || context->isWorkerContext())
        return 0;

    Document* document = static_cast<Document*>(context);
    if (!document)
        return 0;

The context pointer has already been checked, so it must be non-NULL when the static_cast occurs.  Thus, document will not be NULL and the check is redundant.

Similarly, in DumpRenderTreeSupportQt.cpp:
    if (!coreNode || !coreNode->renderer())
        return false;

    HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(coreNode);
    if (!inputElement)
        return false;

coreNode has already been checked and is non-NULL when the static_cast to HTMLInputElement* occurs.  The check after the cast is not needed.
Comment 1 Fabrizio 2011-02-18 12:20:54 PST
Created attachment 82995 [details]
remove redundant checks
Comment 2 WebKit Commit Bot 2011-02-18 21:58:06 PST
Comment on attachment 82995 [details]
remove redundant checks

Clearing flags on attachment: 82995

Committed r79098: <http://trac.webkit.org/changeset/79098>
Comment 3 WebKit Commit Bot 2011-02-18 21:58:11 PST
All reviewed patches have been landed.  Closing bug.
Comment 4 Suresh Voruganti 2011-02-28 07:49:37 PST
Please cherry pick the fix to Qtwebkit 2.1.x
Comment 5 Ademar Reis 2011-02-28 13:19:30 PST
I don't see the point of adding refactorings like this to a stable branch (qtwebkit-2.1.x). Removing from meta-bug. If it fixes a real problem, let me know.