Bug 80164

Summary: [Qt] QWebNavigationRequest 'action' property should have an enum type instead of int
Product: WebKit Reporter: Caio Marcelo de Oliveira Filho <cmarcelo>
Component: New BugsAssignee: Caio Marcelo de Oliveira Filho <cmarcelo>
Status: RESOLVED FIXED    
Severity: Normal CC: hausmann, menard, ossy, vestbo, webkit.review.bot, zoltan
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 78821    
Attachments:
Description Flags
Patch
none
Patch hausmann: review+

Caio Marcelo de Oliveira Filho
Reported 2012-03-02 08:56:02 PST
[Qt] QWebNavigationRequest 'action' property should have an enum type instead of int
Attachments
Patch (6.74 KB, patch)
2012-03-02 09:03 PST, Caio Marcelo de Oliveira Filho
no flags
Patch (5.88 KB, patch)
2012-03-05 11:40 PST, Caio Marcelo de Oliveira Filho
hausmann: review+
Caio Marcelo de Oliveira Filho
Comment 1 2012-03-02 09:03:31 PST
Rafael Brandao
Comment 2 2012-03-05 09:43:49 PST
Comment on attachment 129909 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=129909&action=review > Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h:86 > + RequestActionCount, Shouldn't this be named ActionCountRequest instead (to follow other names pattern)?
Caio Marcelo de Oliveira Filho
Comment 3 2012-03-05 09:49:15 PST
Comment on attachment 129909 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=129909&action=review >> Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h:86 >> + RequestActionCount, > > Shouldn't this be named ActionCountRequest instead (to follow other names pattern)? It is the Count of RequestActions, it is not an action to be performed itself.
Tor Arne Vestbø
Comment 4 2012-03-05 09:55:27 PST
Comment on attachment 129909 [details] Patch after discussion on IRC
Caio Marcelo de Oliveira Filho
Comment 5 2012-03-05 11:40:13 PST
Simon Hausmann
Comment 6 2012-03-06 10:09:05 PST
Comment on attachment 130167 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=130167&action=review > Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h:86 > + IgnoreRequest = 0xFF Why not simply leave it as its original value and use DownloadRequest = IgnoreRequest + 1? It seems strange to have a gap in the _existing_ enums. or enum NavigationRequestAction { AcceptRequest, IgnoreRequest, LastRequestAction = IgnoreRequest /* Mark internal in docs! */ } DownloadRequest = LastRequest I recall seeing the pattern like this in Qt. (see qnamespace.h)
Caio Marcelo de Oliveira Filho
Comment 7 2012-03-06 13:32:58 PST
Comment on attachment 130167 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=130167&action=review >> Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h:86 >> + IgnoreRequest = 0xFF > > Why not simply leave it as its original value and use DownloadRequest = IgnoreRequest + 1? > It seems strange to have a gap in the _existing_ enums. > > or > > enum NavigationRequestAction { > AcceptRequest, > IgnoreRequest, > LastRequestAction = IgnoreRequest /* Mark internal in docs! */ > } > > DownloadRequest = LastRequest > > I recall seeing the pattern like this in Qt. (see qnamespace.h) In Qt we use this pattern for ItemDataRole, people create their roles with values >= UserRole. The difference is that functions taking roles as parameter actually take int (see QAbstractItemModel methods). If we want to use the enum type as the property type and as storage for the property (member m_action is of the enum type), we are saying we accept only values inside enum range. It may work in GCC if the value is out of range, but GCC still is unhappy when we construct switch() statements using the type. Casting to int in the switch() alleviates this second problem, but with no true guarantee. Tor-Arne explicitly preferred we do not "clutter" the QML API with the "LastRequestAction" or "RequestActionCount".
Caio Marcelo de Oliveira Filho
Comment 8 2012-03-07 04:29:21 PST
Note You need to log in before you can comment on or make changes to this bug.