[Webkit-unassigned] [Bug 15212] New: Useless checking for Item in FrameLoader::goBackOrForward(int distance)

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Sep 14 07:22:58 PDT 2007


http://bugs.webkit.org/show_bug.cgi?id=15212

           Summary: Useless checking for Item in
                    FrameLoader::goBackOrForward(int distance)
           Product: WebKit
           Version: 522+ (nightly)
          Platform: Macintosh
        OS/Version: Mac OS X 10.4
            Status: NEW
          Severity: Minor
          Priority: P2
         Component: History
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: mbritto at pleyo.com


There is no need to check if there is an item at this distance because the
check has already been performed in a previously :

This is the piece of code I'm talking about :
------------------------------------
    HistoryItem* item = list->itemAtIndex(distance);
    if (!item) {
        if (distance > 0) {
            int forwardListCount = list->forwardListCount();
            if (forwardListCount > 0) 
                item = list->itemAtIndex(forwardListCount);
        } else {
            int backListCount = list->forwardListCount();
            if (backListCount > 0)
                item = list->itemAtIndex(-backListCount);
        }
    }


There are three calls for FrameLoader::goBackOrForward(int distance) :
-----------------------------------------------------------
  1 - From FrameLoader::scheduleHistoryNavigation(int steps)
          -> which checks before the call if the step is "reachable" with
canGoBackOrForward(steps).
          -> if the step is unreachable, goBackOrForward() isn't called at all

  2 - From FrameLoader::redirectionTimerFired(Timer<FrameLoader>*)
          -> in case we have a ScheduledRedirection::historyNavigation
          -> a ScheduledRedirection::historyNavigation can only be created from
scheduleHistoryNavigation() (see point 1)

  3 - From ContextMenuController::contextMenuItemSelected(ContextMenuItem*
item)
          -> the context menu choice "back" or "forward" is disabled if there
no previous or next item

-

To sum up, I don't know how the item (from HistoryItem* item =
list->itemAtIndex(distance);) in goBackOrForward() could be null. 
Moreover there is something wrong in this useless part of code : int
backListCount = list->forwardListCount();


-- 
Configure bugmail: http://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list