Bug 91448 - Unify allowfullscreen logic in Document::webkitFullScreenEnabled and fullScreenIsAllowedForElement.
Summary: Unify allowfullscreen logic in Document::webkitFullScreenEnabled and fullScre...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Vincent Scheib
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-16 17:13 PDT by Vincent Scheib
Modified: 2012-07-18 13:06 PDT (History)
3 users (show)

See Also:


Attachments
Patch (2.28 KB, patch)
2012-07-17 08:11 PDT, Vincent Scheib
no flags Details | Formatted Diff | Diff
Patch (9.06 KB, patch)
2012-07-17 13:48 PDT, Vincent Scheib
no flags Details | Formatted Diff | Diff
Patch (9.06 KB, patch)
2012-07-17 14:23 PDT, Vincent Scheib
no flags Details | Formatted Diff | Diff
Patch (9.03 KB, patch)
2012-07-17 16:37 PDT, Vincent Scheib
no flags Details | Formatted Diff | Diff
Patch (8.83 KB, patch)
2012-07-18 10:30 PDT, Vincent Scheib
no flags Details | Formatted Diff | Diff
Patch (8.61 KB, patch)
2012-07-18 10:46 PDT, Vincent Scheib
no flags Details | Formatted Diff | Diff
Patch (8.61 KB, patch)
2012-07-18 11:02 PDT, Vincent Scheib
no flags Details | Formatted Diff | Diff
Patch (8.65 KB, patch)
2012-07-18 11:07 PDT, Vincent Scheib
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Scheib 2012-07-16 17:13:22 PDT
Simplify Document::webkitFullScreenEnabled element traversal.
Comment 1 Vincent Scheib 2012-07-17 08:11:51 PDT
Created attachment 152766 [details]
Patch
Comment 2 Vincent Scheib 2012-07-17 08:14:37 PDT
Pointer lock will be using the same iframe allow logic. Reducing the code here first.
Comment 3 Jer Noble 2012-07-17 09:18:51 PDT
This patch subtly changes the behavior of Document::requestFullScreenForElement().  Before, a JavaScript call "iframe.webkitEnterFullScreen()" on an iframe without an "webkitallowfullscreen" attribute would allow the iframe to enter full screen mode.  This makes sense, since it's the element owner that decides whether the full screen request will be accepted.

With this patch, element->allowFullScreen() is checked against the requested element if that element is an iframe.  This causes the above case (requesting full screen on an iframe directly) to fail.  I believe the Document::fullScreenIsAllowedForElement() function could still be simplified, but there would have to be one iteration of finding the element's owner element before the do/while loop.
Comment 4 Vincent Scheib 2012-07-17 13:48:16 PDT
Created attachment 152817 [details]
Patch
Comment 5 Vincent Scheib 2012-07-17 13:49:43 PDT
Thanks Jer, I've written a test to identify that particular case and adjusted the patch to handle it. Please take a look.
Comment 6 Vincent Scheib 2012-07-17 13:55:21 PDT
Comment on attachment 152817 [details]
Patch

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

> Source/WebCore/html/HTMLFrameElementBase.cpp:253
> +    return (hasAttribute(webkitallowfullscreenAttr) || !isFrameElementBase())

Jer, I migrated this logic of !isFrameElementBase(), but we do not have a test that detects this logic being in place. Can you describe what scenario this logic is handling?
Comment 7 Build Bot 2012-07-17 14:11:14 PDT
Comment on attachment 152817 [details]
Patch

Attachment 152817 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/13282237
Comment 8 Vincent Scheib 2012-07-17 14:23:33 PDT
Created attachment 152830 [details]
Patch
Comment 9 Vincent Scheib 2012-07-17 16:37:21 PDT
Created attachment 152872 [details]
Patch
Comment 10 Vincent Scheib 2012-07-17 16:38:16 PDT
(In reply to comment #6)
> (From update of attachment 152817 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=152817&action=review
> 
> > Source/WebCore/html/HTMLFrameElementBase.cpp:253
> > +    return (hasAttribute(webkitallowfullscreenAttr) || !isFrameElementBase())
> 
> Jer, I migrated this logic of !isFrameElementBase(), but we do not have a test that detects this logic being in place. Can you describe what scenario this logic is handling?

Doh, nevermind. As I moved the implementation to FrameElementBase I've removed that.
Comment 11 Jer Noble 2012-07-17 16:58:09 PDT
Comment on attachment 152872 [details]
Patch

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

> Source/WebCore/dom/Document.cpp:5371
> +    HTMLFrameOwnerElement* owner = element->document()->ownerElement();
> +    if (!owner)
> +        return true;
> +    return owner->fullscreenIsAllowedByAllOwners();

This could be more easily written as:

if (HTMLFrameOwnerElement* owner = element->document()->ownerElement())
    return owner->fullscreenIsAllowedByAllOwners();
return true;

> Source/WebCore/dom/Document.cpp:5583
>      HTMLFrameOwnerElement* owner = ownerElement();
>      if (!owner)
>          return true;
> -
> -    do {
> -        if (!owner->isFrameElementBase())
> -            continue;
> -
> -        if (!static_cast<HTMLFrameElementBase*>(owner)->allowFullScreen())
> -            return false;
> -    } while ((owner = owner->document()->ownerElement()));
> -
> -    return true;        
> +    return owner->fullscreenIsAllowedByAllOwners();

This too.

> Source/WebCore/html/HTMLFrameElementBase.cpp:253
> +    HTMLFrameOwnerElement* owner = document()->ownerElement();
> +    return hasAttribute(webkitallowfullscreenAttr) && (!owner || owner->fullscreenIsAllowedByAllOwners());

Why recurse?  It'd be trivial to walk up the owner chain instead.  This function could even exist as a free function in Document.cpp.  There's really no need for it to be a class function on HTMLFrameElementBase.

> Source/WebCore/html/HTMLFrameOwnerElement.h:61
> +#if ENABLE(FULLSCREEN_API)
> +    virtual bool fullscreenIsAllowedByAllOwners() const { return false; }
> +#endif

This is probably a good idea (to provide a base implementation in HTMLFrameOwnerElement that is overridden in HTMLFrameElementBase), but there's no need to rename the function and provide a new implementation (see above about the free function possibility).
Comment 12 Vincent Scheib 2012-07-18 10:30:10 PDT
Created attachment 153041 [details]
Patch
Comment 13 Vincent Scheib 2012-07-18 10:46:33 PDT
Created attachment 153044 [details]
Patch
Comment 14 Jer Noble 2012-07-18 10:55:53 PDT
View in context: https://bugs.webkit.org/attachment.cgi?id=153041&action=review

Looking good!  Just a couple of nits.

> Source/WebCore/dom/Document.cpp:591
> +    // 4. The fullscreenEnabled attribute must return true if the context object and all ancestor
> +    // browsing context's documents have their fullscreen enabled flag set, or false otherwise.

Nit: please leave this comment in Document::webkitFullscreenEnabled().

> Source/WebCore/dom/Document.cpp:594
> +    // Top-level browsing contexts are implied to have their allowFullScreen attribute set.
> +    if (owner) {

Nit: please return (true) early in this case. Otherwise the comment doesn't make (as much) sense.  (Also, other reviewers tend to prefer early returns to indented conditionals like this one.)

Unofficial r=me.
Comment 15 Jer Noble 2012-07-18 10:56:17 PDT
(In reply to comment #14)
> > Source/WebCore/dom/Document.cpp:591
> > +    // 4. The fullscreenEnabled attribute must return true if the context object and all ancestor
> > +    // browsing context's documents have their fullscreen enabled flag set, or false otherwise.
> 
> Nit: please leave this comment in Document::webkitFullscreenEnabled().

Looks like your latest patch does this.  Thanks!
Comment 16 Early Warning System Bot 2012-07-18 10:59:24 PDT
Comment on attachment 153044 [details]
Patch

Attachment 153044 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/13271648
Comment 17 Vincent Scheib 2012-07-18 11:02:40 PDT
Created attachment 153049 [details]
Patch
Comment 18 Vincent Scheib 2012-07-18 11:04:27 PDT
Thanks Jer, looks nice and clean now - easy to reuse for pointer lock.
enne, take a look?
Comment 19 Vincent Scheib 2012-07-18 11:07:14 PDT
Created attachment 153050 [details]
Patch
Comment 20 Adrienne Walker 2012-07-18 11:18:56 PDT
Comment on attachment 153050 [details]
Patch

R=me.
Comment 21 WebKit Review Bot 2012-07-18 13:06:25 PDT
Comment on attachment 153050 [details]
Patch

Clearing flags on attachment: 153050

Committed r123005: <http://trac.webkit.org/changeset/123005>
Comment 22 WebKit Review Bot 2012-07-18 13:06:30 PDT
All reviewed patches have been landed.  Closing bug.