Bug 70055 - [WK2] WebFrameLoaderClient::shouldFallback() should use a port-specific implementation
Summary: [WK2] WebFrameLoaderClient::shouldFallback() should use a port-specific imple...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jesus Sanchez-Palencia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-13 14:29 PDT by Jesus Sanchez-Palencia
Modified: 2011-10-21 13:51 PDT (History)
9 users (show)

See Also:


Attachments
Patch (9.98 KB, patch)
2011-10-13 14:44 PDT, Jesus Sanchez-Palencia
no flags Details | Formatted Diff | Diff
Patch (10.14 KB, patch)
2011-10-14 07:25 PDT, Jesus Sanchez-Palencia
no flags Details | Formatted Diff | Diff
Patch (10.33 KB, patch)
2011-10-14 15:19 PDT, Jesus Sanchez-Palencia
no flags Details | Formatted Diff | Diff
Patch (2.09 KB, patch)
2011-10-20 16:20 PDT, Jesus Sanchez-Palencia
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jesus Sanchez-Palencia 2011-10-13 14:29:13 PDT
In WebKit 1 each port had its own implementation of FrameLoaderClient::shouldFallback since there was a port specific implementation of FrameLoaderClient itself. For instance, Qt and EFL use cancelledError and interruptedForPolicyChangeError to decide if they should fallback or not, while Mac only uses cancelledError and PlugInWillHandleLoad. GTK uses all of them.

However, in WebKit 2 all ports are currently sharing a single WebFrameLoaderClient implementation and, therefore, the same shouldFallback implementation. As I'm not aware of the fallback decisions for all ports, I believe this function should have a port specific implementation and it could sit on Source/WebKit2/WebProcess/WebCoreSupport/WebErrors.h.
Comment 1 Jesus Sanchez-Palencia 2011-10-13 14:44:26 PDT
Created attachment 110909 [details]
Patch
Comment 2 Luiz Agostini 2011-10-13 16:36:59 PDT
Comment on attachment 110909 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=110909&action=review

> Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:-985
> -    DEFINE_STATIC_LOCAL(const ResourceError, cancelledError, (this->cancelledError(ResourceRequest())));
> -    DEFINE_STATIC_LOCAL(const ResourceError, pluginWillHandleLoadError, (this->pluginWillHandleLoadError(ResourceResponse())));

r- because you ignored static and const in all the implementations of shouldFallBack that you provided.

> Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm:93
> +    ResourceError errorCancelled = cancelledError(ResourceRequest());
> +    ResourceError errorPluginWillHandleLoad = pluginWillHandleLoadError(ResourceResponse());

Ditto.

> Source/WebKit2/WebProcess/WebCoreSupport/qt/WebErrorsQt.cpp:91
> +    ResourceError errorCancelled = cancelledError(ResourceRequest());
> +    ResourceError errorPluginWillHandleLoad = pluginWillHandleLoadError(ResourceResponse());
> +    ResourceError errorInterruptedForPolicyChange = interruptedForPolicyChangeError(ResourceRequest());

Ditto.

> Source/WebKit2/WebProcess/WebCoreSupport/win/WebErrorsWin.cpp:84
> +    ResourceError errorCancelled = cancelledError(ResourceRequest());
> +    ResourceError errorPluginWillHandleLoad = pluginWillHandleLoadError(ResourceResponse());

Ditto.
Comment 3 Jesus Sanchez-Palencia 2011-10-14 07:25:53 PDT
Created attachment 111011 [details]
Patch
Comment 4 Jesus Sanchez-Palencia 2011-10-14 07:36:15 PDT
(In reply to comment #2)
> r- because you ignored static and const in all the implementations of shouldFallBack that you provided.

Thanks for the review, Luis. I've uploaded a new patch here.
Comment 5 Luiz Agostini 2011-10-14 11:37:19 PDT
Comment on attachment 111011 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=111011&action=review

> Source/WebKit2/WebProcess/WebCoreSupport/qt/WebErrorsQt.cpp:91
> +    static const ResourceError errorCancelled = cancelledError(ResourceRequest());
> +    static const ResourceError errorPluginWillHandleLoad = pluginWillHandleLoadError(ResourceResponse());
> +    static const ResourceError errorInterruptedForPolicyChange = interruptedForPolicyChangeError(ResourceRequest());

Static local variables like these have indeterminated order of construction and destruction. They may cause really hard to find bugs.
These variables should probably leak (you should be using pointers).

Do you have strong reasons for not using the DEFINE_STATIC_LOCAL macro?
Comment 6 Collabora GTK+ EWS bot 2011-10-14 11:49:03 PDT
Comment on attachment 111011 [details]
Patch

Attachment 111011 [details] did not pass gtk-ews (gtk):
Output: http://queues.webkit.org/results/10054607
Comment 7 Gustavo Noronha (kov) 2011-10-14 12:16:32 PDT
Comment on attachment 111011 [details]
Patch

Attachment 111011 [details] did not pass gtk-ews (gtk):
Output: http://queues.webkit.org/results/10068412
Comment 8 Jesus Sanchez-Palencia 2011-10-14 15:19:36 PDT
Created attachment 111093 [details]
Patch
Comment 9 Luiz Agostini 2011-10-17 10:56:45 PDT
Comment on attachment 111093 [details]
Patch

This patch causes behavior changes in EFL and GTK ports. The guys that are responsible for those ports should be notified.

Looking at ResourceErrorBase.h, I think that ResourceError::isCancellation is not trivially equivalent to error.errorCode() == cancelledError.errorCode(). It may cause unwanted behavior changes in Mac and Win.

I would prefer to make sure that there will be behavior changes only in Qt port. You could file bugs to other ports if you think that they need changes as well.
Comment 10 Jesus Sanchez-Palencia 2011-10-17 11:10:29 PDT
(In reply to comment #9)
> (From update of attachment 111093 [details])
> This patch causes behavior changes in EFL and GTK ports. The guys that are responsible for those ports should be notified.

My idea was to keep the behavior they had on WebKit1 because I believe the behavior change was caused by WebFrameLoaderClient implementation itself and they weren't even aware of it. Of course I can be wrong and I'm already contacting people from both ports in order to gather their opinion.

> 
> Looking at ResourceErrorBase.h, I think that ResourceError::isCancellation is not trivially equivalent to error.errorCode() == cancelledError.errorCode(). It may cause unwanted behavior changes in Mac and Win.

You are right, there is no way to make sure people are handling this as we are in Qt, so I will modify the patch to use isCancellation() or the errorCode() accordingly to each port's previous implementation.
Comment 11 Luiz Agostini 2011-10-17 11:28:23 PDT
(In reply to comment #10)
> (In reply to comment #9)
> > (From update of attachment 111093 [details] [details])
> > This patch causes behavior changes in EFL and GTK ports. The guys that are responsible for those ports should be notified.
> 
> My idea was to keep the behavior they had on WebKit1 because I believe the behavior change was caused by WebFrameLoaderClient implementation itself and they weren't even aware of it. Of course I can be wrong and I'm already contacting people from both ports in order to gather their opinion.
> 

Just let me know if they are aware of the changes and if they are ok with them.

> > 
> > Looking at ResourceErrorBase.h, I think that ResourceError::isCancellation is not trivially equivalent to error.errorCode() == cancelledError.errorCode(). It may cause unwanted behavior changes in Mac and Win.
> 
> You are right, there is no way to make sure people are handling this as we are in Qt, so I will modify the patch to use isCancellation() or the errorCode() accordingly to each port's previous implementation.

Nice.

Otherwise it looks good.
Comment 12 Gustavo Noronha (kov) 2011-10-17 11:40:17 PDT
Comment on attachment 111093 [details]
Patch

I consider the code duplication to be unnecessary. For GTK+ I believe the current cross-platform shouldFallback is being enough. We might review our needs when we review all our APIs later this year. For the moment I would say an #ifdef inside shouldFallback adding/removing the checks as necessary for the ports that need it is the best way to go. If it turns out that most ports need customization that they can't share with others, than I would see this change as reasonable.
Comment 13 Raphael Kubo da Costa (:rakuco) 2011-10-17 11:47:26 PDT
CC'ing the Samsung guys who probably know better about EFL's port of WebKit2. At first glance, we're fine with keeping the implementation unified, even if that changes behavior.
Comment 14 Jesus Sanchez-Palencia 2011-10-17 12:09:10 PDT
(In reply to comment #12) and (In reply to comment #13):

Ok, guys, thanks for all your feedback. I was talking to Luiz on irc and following the comments we decided to add just a #ifdef for Qt for the time being. This way we don't change anything for any port but ours and if it ever gets to a point where we have reached an "ifdef mayhem" there, then we can move to something more specific like the proposed patch.

Just for the sake of curiosity, Luiz also agrees that a FrameLoaderClient impl per port on WebKit2 might not be an option.

I will upload a patch later with the changes for Qt. Thanks again for the feedback!
Comment 15 Jesus Sanchez-Palencia 2011-10-20 16:20:22 PDT
Created attachment 111866 [details]
Patch
Comment 16 WebKit Review Bot 2011-10-21 13:51:21 PDT
Comment on attachment 111866 [details]
Patch

Clearing flags on attachment: 111866

Committed r98138: <http://trac.webkit.org/changeset/98138>
Comment 17 WebKit Review Bot 2011-10-21 13:51:29 PDT
All reviewed patches have been landed.  Closing bug.