Bug 90834 - the body of seamless iframes should default to margin:0
Summary: the body of seamless iframes should default to margin:0
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mike West
URL:
Keywords: WebExposed
Depends on: 105916
Blocks: 45950 105903
  Show dependency treegraph
 
Reported: 2012-07-09 16:28 PDT by Ojan Vafai
Modified: 2013-01-03 06:31 PST (History)
14 users (show)

See Also:


Attachments
Patch (11.74 KB, patch)
2013-01-01 16:18 PST, Mike West
no flags Details | Formatted Diff | Diff
Patch (16.45 KB, patch)
2013-01-01 17:11 PST, Mike West
no flags Details | Formatted Diff | Diff
Patch (14.00 KB, patch)
2013-01-02 10:29 PST, Mike West
no flags Details | Formatted Diff | Diff
Patch for landing (13.32 KB, patch)
2013-01-03 05:31 PST, Mike West
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ojan Vafai 2012-07-09 16:28:23 PDT
http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=1657

<!DOCTYPE html>
...<style>
 iframe { border: solid;  float: left; }
</style>
<iframe seamless srcdoc="<div style='background:yellow'>TEST</div>"></iframe>
Comment 1 Eric Seidel (no email) 2012-07-11 15:31:12 PDT
Hixie mentioned that body margins were already complicated to calculate so this case shouldn't be hard to add... but I'm not yet sure where to find that code.
Comment 2 Eric Seidel (no email) 2012-07-11 15:34:58 PDT
Yes, a quick grep of our codebase shows margins are ridiculously complicated. :)  Still unsure where this code needs to go though....
Comment 3 Mike West 2013-01-01 14:37:49 PST
Is this value actually calculated? My understanding was that default values for elements are loaded via the user agent's stylesheet (in this case, http://trac.webkit.org/browser/trunk/Source/WebCore/css/html.css#L59).

It looks like one approach might be to define a 'seamless.css' that we'd pull in via StyleResolver:: ensureDefaultStyleSheetsForElement (http://trac.webkit.org/browser/trunk/Source/WebCore/css/StyleResolver.cpp#L547). Assuming that's not a terrible idea, I'll hack that together quickly to see if it works at all.
Comment 4 Mike West 2013-01-01 16:18:02 PST
Created attachment 181000 [details]
Patch
Comment 5 Mike West 2013-01-01 16:20:12 PST
After more than a bit of fiddling, StyleResolver::matchUARules looks like the right place to pull in a new stylesheet. I still have no idea what I'm doing here, so I'd very much appreciate a careful eye on this patch. It works*, but it might be the totally wrong way to do things.

*on the Chromium port on my local machine. :)
Comment 6 Eric Seidel (no email) 2013-01-01 16:20:58 PST
Ccing the Style ninjas again. :)
Comment 7 Mike West 2013-01-01 16:21:47 PST
(In reply to comment #6)
> Ccing the Style ninjas again. :)

You're seriously fast. I was looking up the email addresses from the last patch... :)
Comment 8 EFL EWS Bot 2013-01-01 16:21:56 PST
Comment on attachment 181000 [details]
Patch

Attachment 181000 [details] did not pass efl-ews (efl):
Output: http://queues.webkit.org/results/15603913
Comment 9 Eric Seidel (no email) 2013-01-01 16:23:14 PST
Comment on attachment 181000 [details]
Patch

There are a bunch of tests which specifically add this margin: 0 for easier testing.  Those tests could be modified now.

This patch looks great to me!

I would leave Antti/Kling 24hrs to comment, in case I'm missing something.
Comment 10 Eric Seidel (no email) 2013-01-01 16:26:42 PST
Comment on attachment 181000 [details]
Patch

This all compiles with seamless off, right?
Comment 11 Andreas Kling 2013-01-01 16:27:08 PST
Comment on attachment 181000 [details]
Patch

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

> Source/WebCore/css/StyleResolver.cpp:1361
> +        if (!defaultSeamlessStyle)
> +            loadSeamlessStyle();
> +        matchUARules(result, defaultSeamlessStyle);

This pattern seems overly verbose, it would be nicer if we could just do:

matchUARules(result, defaultSeamlessStyle());

(I see that we already have code like this elsewhere in StyleResolver.cpp, but I think we can do better.)

> Source/WebCore/css/StyleResolver.cpp:5304
> +        if (!defaultSeamlessStyle)
> +            loadSeamlessStyle();
> +        m_features.add(defaultSeamlessStyle->features());

Again, would be nicer with just:

m_features.add(defaultSeamlessStyle()->features());
Comment 12 Mike West 2013-01-01 16:31:19 PST
(In reply to comment #10)
> (From update of attachment 181000 [details])
> This all compiles with seamless off, right?

It might. I'll check. There might be a warning for the empty function.

(In reply to comment #11)
> (From update of attachment 181000 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=181000&action=review
> 
> > Source/WebCore/css/StyleResolver.cpp:1361
> > +        if (!defaultSeamlessStyle)
> > +            loadSeamlessStyle();
> > +        matchUARules(result, defaultSeamlessStyle);
> 
> This pattern seems overly verbose, it would be nicer if we could just do:
> 
> matchUARules(result, defaultSeamlessStyle());
> 
> (I see that we already have code like this elsewhere in StyleResolver.cpp, but I think we can do better.)

Makes sense. I can update the viewsource loader in this patch as well, if you like, or I can split that refactoring out into a smaller separate patch. Which would you prefer?
Comment 13 Andreas Kling 2013-01-01 16:35:23 PST
(In reply to comment #12)
> (In reply to comment #10)
> > (From update of attachment 181000 [details] [details])
> > This all compiles with seamless off, right?
> 
> It might. I'll check. There might be a warning for the empty function.
> 
> (In reply to comment #11)
> > (From update of attachment 181000 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=181000&action=review
> > 
> > > Source/WebCore/css/StyleResolver.cpp:1361
> > > +        if (!defaultSeamlessStyle)
> > > +            loadSeamlessStyle();
> > > +        matchUARules(result, defaultSeamlessStyle);
> > 
> > This pattern seems overly verbose, it would be nicer if we could just do:
> > 
> > matchUARules(result, defaultSeamlessStyle());
> > 
> > (I see that we already have code like this elsewhere in StyleResolver.cpp, but I think we can do better.)
> 
> Makes sense. I can update the viewsource loader in this patch as well, if you like, or I can split that refactoring out into a smaller separate patch. Which would you prefer?

I'd do it separately. Atomic patches <3.
Comment 14 Mike West 2013-01-01 16:38:38 PST
(In reply to comment #13)
> I'd do it separately. Atomic patches <3.

That's what I hoped you'd say. Tiny patches FTW.

In that case, I'd just match the current style with this patch (after fixing EFL), and rework both cases in the next patch, since they'll be more or less exactly the same changes.
Comment 15 Mike West 2013-01-01 17:11:13 PST
Created attachment 181002 [details]
Patch
Comment 16 WebKit Review Bot 2013-01-02 01:18:59 PST
Comment on attachment 181002 [details]
Patch

Clearing flags on attachment: 181002

Committed r138611: <http://trac.webkit.org/changeset/138611>
Comment 17 WebKit Review Bot 2013-01-02 01:19:05 PST
All reviewed patches have been landed.  Closing bug.
Comment 18 Mike West 2013-01-02 02:10:11 PST
(In reply to comment #14)
> (In reply to comment #13)
> > I'd do it separately. Atomic patches <3.
> 
> That's what I hoped you'd say. Tiny patches FTW.
> 
> In that case, I'd just match the current style with this patch (after fixing EFL), and rework both cases in the next patch, since they'll be more or less exactly the same changes.

I've uploaded a patch for this bit at https://bugs.webkit.org/show_bug.cgi?id=105903.
Comment 19 Antti Koivisto 2013-01-02 03:27:59 PST
Comment on attachment 181002 [details]
Patch

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

> Source/WebCore/css/seamless.css:3
> +body {
> +    margin: 0;
> +}

It seems crazy to add all this machinery (including separate .css file!) just for matching this one rule. Lets find a lighter weight solution.

Also I'm not happy to see all these patches landing during holidays.
Comment 20 Mike West 2013-01-02 03:58:42 PST
(In reply to comment #19)
> (From update of attachment 181002 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=181002&action=review
> 
> > Source/WebCore/css/seamless.css:3
> > +body {
> > +    margin: 0;
> > +}
> 
> It seems crazy to add all this machinery (including separate .css file!) just for matching this one rule. Lets find a lighter weight solution.

What would you suggest? Would hard-coding a string into the StyleResolver (similar to the "simple" stylesheet) be appropriate, or is using the UA style machinery not the right answer at all?

> Also I'm not happy to see all these patches landing during holidays.

I'll roll both of the patches out. The intention certainly wasn't to surprise you; the holidays just gave me a some solid chunks of free time to ignore my day job and work through both of these bugs. :)
Comment 21 WebKit Review Bot 2013-01-02 04:00:45 PST
Re-opened since this is blocked by bug 105916
Comment 22 Antti Koivisto 2013-01-02 07:33:05 PST
> What would you suggest? Would hard-coding a string into the StyleResolver (similar to the "simple" stylesheet) be appropriate, or is using the UA style machinery not the right answer at all?

A pseudo class might be the nicest solution. Then could just have

body:-webkit-seamless-document { margin: 0 }

or similar on the default sheet and all the machinery will work magically. If you grep for "PseudoFullScreenDocument" you pretty much learn everything about implementing it.
Comment 23 Mike West 2013-01-02 10:29:31 PST
Created attachment 181035 [details]
Patch
Comment 24 Mike West 2013-01-02 10:31:14 PST
(In reply to comment #22)
> > What would you suggest? Would hard-coding a string into the StyleResolver (similar to the "simple" stylesheet) be appropriate, or is using the UA style machinery not the right answer at all?
> 
> A pseudo class might be the nicest solution. Then could just have
> 
> body:-webkit-seamless-document { margin: 0 }
> 
> or similar on the default sheet and all the machinery will work magically. If you grep for "PseudoFullScreenDocument" you pretty much learn everything about implementing it.

The attached patch is a stab at that approach. Would you mind taking a look? I've modeled it after the full-screen-document pseudoclass, in that it matches for all element types. That might be useful in the future if the spec changes to involve more overrides in the future.

What do you think?
Comment 25 WebKit Review Bot 2013-01-02 10:33:14 PST
Attachment 181035 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/fast..." exit_code: 1
Source/WebCore/rendering/style/RenderStyleConstants.h:79:  enum members should use InterCaps with an initial capital letter.  [readability/enum_casing] [4]
Total errors found: 1 in 14 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 26 Eric Seidel (no email) 2013-01-02 12:12:01 PST
Comment on attachment 181035 [details]
Patch

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

Seems reasonable to me.  But so did the last one.  I guess you should look for an antti in #webkit. :)

> LayoutTests/fast/frames/seamless/seamless-inherited-origin.html:14
> +    // Initially about:blank has no content, thus no height.
> +    shouldBeEqualToString("window.getComputedStyle(iframe).height", "0px");

This is only seamless documents end up with this magic 0px of course. :)
Comment 27 Antti Koivisto 2013-01-02 13:37:54 PST
Comment on attachment 181035 [details]
Patch

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

r=me with the changes

> Source/WebCore/css/CSSSelector.cpp:169
> +#if ENABLE(IFRAME_SEAMLESS)
> +    case PseudoSeamlessDocument:
> +        return SEAMLESS_DOCUMENT;
> +#endif

You should't need this (you are not using it anywhere). FULL_SCREEN_DOCUMENT and pals look equally pointless, I think someone was just cargo-culting.

>> Source/WebCore/rendering/style/RenderStyleConstants.h:79
>>      FULL_SCREEN, FULL_SCREEN_DOCUMENT, FULL_SCREEN_ANCESTOR, ANIMATING_FULL_SCREEN_TRANSITION,
>> +    SEAMLESS_DOCUMENT,
> 
> enum members should use InterCaps with an initial capital letter.  [readability/enum_casing] [4]

It would be good to remove FULL_SCREEN ones too in another patch if they are as useless as they look. I believe the confusingly named PseudoId enum is only relevant for pseudo elements never pseudo classes.
Comment 28 Mike West 2013-01-03 05:31:19 PST
Created attachment 181166 [details]
Patch for landing
Comment 29 WebKit Review Bot 2013-01-03 06:31:40 PST
Comment on attachment 181166 [details]
Patch for landing

Clearing flags on attachment: 181166

Committed r138709: <http://trac.webkit.org/changeset/138709>
Comment 30 WebKit Review Bot 2013-01-03 06:31:47 PST
All reviewed patches have been landed.  Closing bug.