Bug 54764

Summary: Remove redundant code in qt/WebCoreSupport
Product: WebKit Reporter: Fabrizio <fabrizio.machado>
Component: WebKit QtAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Trivial CC: ademar, commit-queue, suresh.voruganti
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
remove redundant checks none

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.