Bug 111242 - Plugins that are appropriately large w.r.t page size should autostart
Summary: Plugins that are appropriately large w.r.t page size should autostart
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Plug-ins (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dean Jackson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2013-03-01 21:05 PST by Dean Jackson
Modified: 2013-03-03 11:39 PST (History)
7 users (show)

See Also:


Attachments
Patch (4.77 KB, patch)
2013-03-01 21:10 PST, Dean Jackson
no flags Details | Formatted Diff | Diff
Patch (5.03 KB, patch)
2013-03-01 21:15 PST, Dean Jackson
no flags Details | Formatted Diff | Diff
Patch (4.89 KB, patch)
2013-03-02 22:28 PST, Dean Jackson
beidson: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dean Jackson 2013-03-01 21:05:47 PST
A "full-page" flash site should never snapshot. The trick is getting the definition of full-page correct. I suggest something like the following:

- plugin is in the main frame (not an iframe)
- plugin is sized with %, and those are bigger than say 95
- the final size of the plugin is again about 95% of the viewport width and height
Comment 1 Dean Jackson 2013-03-01 21:06:10 PST
<rdar://problem/13328176>
Comment 2 Dean Jackson 2013-03-01 21:10:47 PST
Created attachment 191092 [details]
Patch
Comment 3 Dean Jackson 2013-03-01 21:15:37 PST
Created attachment 191093 [details]
Patch
Comment 4 Tim Horton 2013-03-01 23:05:38 PST
Comment on attachment 191093 [details]
Patch

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

> Source/WebCore/ChangeLog:15
> +        - The plug-in is in the main frame (not an iframe).
> +        - The plug-in is sized using %, and both width and height are above 96%.
> +        - The final width and height of the plug-in is more than 95% of the viewport
> +          width and height respectively.

This seems strange. What's the downside to something like thresholding area(intersection(plugin rect, frame visible rect)) / area(frame visible rect)?

> Source/WebCore/html/HTMLPlugInImageElement.cpp:430
> +    RenderEmbeddedObject* renderEmbeddedObject = toRenderEmbeddedObject(renderer());

Technically you could go to renderbox instead if you wanted, I think... not that that changes anything.

> Source/WebCore/html/HTMLPlugInImageElement.cpp:441
> +    if (inMainFrame && styleWidth.isPercent() && (styleWidth.percent() > sizingFullPageThresholdPercentage)
> +        && styleHeight.isPercent() && (styleHeight.percent() > sizingFullPageThresholdPercentage)
> +        && (static_cast<float>(contentWidth) / visibleViewSize.width() * 100 > sizingFullPageThresholdPercentage)
> +        && (static_cast<float>(contentHeight) / visibleViewSize.height() * 100 > sizingFullPageThresholdPercentage)) {

That's quite the condition. Is there anything we can do to make this less insane?
Comment 5 Jon Lee 2013-03-01 23:38:24 PST
Comment on attachment 191093 [details]
Patch

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

> Source/WebCore/ChangeLog:13
> +        - The plug-in is sized using %, and both width and height are above 96%.

Given that I think all the sites that use percentages use 100%, we should just go for that instead.

>> Source/WebCore/ChangeLog:15
>> +          width and height respectively.
> 
> This seems strange. What's the downside to something like thresholding area(intersection(plugin rect, frame visible rect)) / area(frame visible rect)?

Checking the height and width separately is more restrictive, which I think is good, but I think we do need to clip the width and height against the visible frame rect. Consider a full-page size plugin that's initially placed mostly along the bottom border of the page.

> Source/WebCore/ChangeLog:20
> +        the tests above.

How about considering the border box of the plugin element instead?

>> Source/WebCore/html/HTMLPlugInImageElement.cpp:441
>> +        && (static_cast<float>(contentHeight) / visibleViewSize.height() * 100 > sizingFullPageThresholdPercentage)) {
> 
> That's quite the condition. Is there anything we can do to make this less insane?

We might have to extend this to clip the width and height against the frame.
Comment 6 Maciej Stachowiak 2013-03-02 12:11:01 PST
(In reply to comment #4)
> (From update of attachment 191093 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=191093&action=review
> 
> > Source/WebCore/ChangeLog:15
> > +        - The plug-in is in the main frame (not an iframe).
> > +        - The plug-in is sized using %, and both width and height are above 96%.
> > +        - The final width and height of the plug-in is more than 95% of the viewport
> > +          width and height respectively.
> 
> This seems strange. What's the downside to something like thresholding area(intersection(plugin rect, frame visible rect)) / area(frame visible rect)?

Tim's rule seems more logical to me too, but maybe there is a reason for Dean's?
Comment 7 Dean Jackson 2013-03-02 19:51:50 PST
Comment on attachment 191093 [details]
Patch

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

>>>> Source/WebCore/ChangeLog:15
>>>> +          width and height respectively.
>>> 
>>> This seems strange. What's the downside to something like thresholding area(intersection(plugin rect, frame visible rect)) / area(frame visible rect)?
>> 
>> Checking the height and width separately is more restrictive, which I think is good, but I think we do need to clip the width and height against the visible frame rect. Consider a full-page size plugin that's initially placed mostly along the bottom border of the page.
> 
> Tim's rule seems more logical to me too, but maybe there is a reason for Dean's?

I have no attachment to the logic I posted. I'll upload a patch that compares area ratios.

>> Source/WebCore/ChangeLog:20
>> +        the tests above.
> 
> How about considering the border box of the plugin element instead?

I should have been a little more clear. zombo.com is an extremely simple page. The "border" is just the default 8px margin on the <body>. The plugin takes up all the available space it can, but if the window size is, say 200x200, then the plugin can only get 186x186.

Most full-page plugin sites do margin:0;padding;0 then object 100% * 100%, so I feel like this will be a fairly rarely hit rule.

>> Source/WebCore/html/HTMLPlugInImageElement.cpp:430
>> +    RenderEmbeddedObject* renderEmbeddedObject = toRenderEmbeddedObject(renderer());
> 
> Technically you could go to renderbox instead if you wanted, I think... not that that changes anything.

That's true! I just moved the code around, but I'll swap to RenderBox as well.

>>> Source/WebCore/html/HTMLPlugInImageElement.cpp:441
>>> +        && (static_cast<float>(contentHeight) / visibleViewSize.height() * 100 > sizingFullPageThresholdPercentage)) {
>> 
>> That's quite the condition. Is there anything we can do to make this less insane?
> 
> We might have to extend this to clip the width and height against the frame.

It does look over-complex, but it isn't really too bad. How about I separate it into some nested tests? (unfortunately we're testing FOR something here, so I can't return early).

We need the logic to make sure we don't miss plugins that are 100% by 100% but contained in an element that provides the sizing (that isn't the body).
Comment 8 Dean Jackson 2013-03-02 22:28:28 PST
Created attachment 191126 [details]
Patch
Comment 9 Dean Jackson 2013-03-02 22:49:32 PST
New patch uses area calculation, which makes the logic look a little more friendly. And RenderBox rather than RenderEmbeddedObject.
Comment 10 Dean Jackson 2013-03-02 22:50:43 PST
It seems this comment in the review didn't get posted here:

I was going to add the intersection, but I'm not sure there would be many cases where it is different from just the plugin rect. Remember that we're already testing for 100% w/h, so it would be unusual to have a bunch of content on the page and then a 100% plugin.
Comment 11 Jon Lee 2013-03-02 23:22:18 PST
(In reply to comment #10)
> It seems this comment in the review didn't get posted here:
> 
> I was going to add the intersection, but I'm not sure there would be many cases where it is different from just the plugin rect. Remember that we're already testing for 100% w/h, so it would be unusual to have a bunch of content on the page and then a 100% plugin.

Ok! Unofficial r=me.
Comment 12 Brady Eidson 2013-03-03 10:58:37 PST
Comment on attachment 191126 [details]
Patch

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

> Source/WebCore/ChangeLog:19
> +        This is definitely not foolproof. For example, zombo.com has a slight
> +        border around its plug-in. As the window size gets smaller, the body margin
> +        takes up more than 5% of the width or height, and the plug-in doesn't pass
> +        the tests above.

How could you not fix zombo com???  You are supposed to be able to do anything there!!!
Comment 13 Dean Jackson 2013-03-03 11:39:03 PST
Committed r144577: <http://trac.webkit.org/changeset/144577>