Changeset 138611 in webkit


Ignore:
Timestamp:
Jan 2, 2013 1:17:41 AM (11 years ago)
Author:
mkwst@chromium.org
Message:

The 'body' of seamless IFrames should default to 'margin: 0'
https://bugs.webkit.org/show_bug.cgi?id=90834

Reviewed by Eric Seidel.

Source/WebCore:

Documents displayed in seamless iframes should override the 'body'
element's normal 8px default margins with 0px, in order to ensure that
contents are displayed flush with the boundries of the seamless box.[1]

This patch does so by adding a new user agent stylesheet for seamless
documents, and teaching the StyleResolver how and when to apply it.

[1]: http://lists.w3.org/Archives/Public/public-whatwg-archive/2012Jul/0039.html

Test: fast/frames/seamless/seamless-body-margin.html

  • DerivedSources.make:
  • DerivedSources.pri:
  • GNUmakefile.am:
  • WebCore.gyp/WebCore.gyp:
  • WebCore.vcproj/WebCore.vcproj:
  • CMakeLists.txt:

Added a new CSS file! Let's tell everyone!

  • css/StyleResolver.cpp:

(WebCore):
(WebCore::loadSeamlessStyle):
(WebCore::StyleResolver::matchUARules):
(WebCore::StyleResolver::collectFeatures):
(WebCore::StyleResolver::reportMemoryUsage):

Load the new stylesheet, and apply it to the document in
matchUARules iff the document should be displayed seamlessly.

  • css/seamless.css: Added.

(body):

Stylesheet containing defaults for seamless documents.

LayoutTests:

  • fast/frames/seamless/seamless-body-margin-expected.txt: Added.
  • fast/frames/seamless/seamless-body-margin.html: Added.

New test to explicitly check 'body' margins.

  • fast/frames/seamless/resources/nested-seamless.html:
  • fast/frames/seamless/resources/quirks-square.html:
  • fast/frames/seamless/resources/two-inline-blocks.html:
  • fast/frames/seamless/seamless-inherited-origin-expected.txt:
  • fast/frames/seamless/seamless-inherited-origin.html:

Updated these tests to remove the assumption that the body had an
8px margin.

Location:
trunk
Files:
3 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r138608 r138611  
     12013-01-02  Mike West  <mkwst@chromium.org>
     2
     3        The 'body' of seamless IFrames should default to 'margin: 0'
     4        https://bugs.webkit.org/show_bug.cgi?id=90834
     5
     6        Reviewed by Eric Seidel.
     7
     8        * fast/frames/seamless/seamless-body-margin-expected.txt: Added.
     9        * fast/frames/seamless/seamless-body-margin.html: Added.
     10            New test to explicitly check 'body' margins.
     11        * fast/frames/seamless/resources/nested-seamless.html:
     12        * fast/frames/seamless/resources/quirks-square.html:
     13        * fast/frames/seamless/resources/two-inline-blocks.html:
     14        * fast/frames/seamless/seamless-inherited-origin-expected.txt:
     15        * fast/frames/seamless/seamless-inherited-origin.html:
     16            Updated these tests to remove the assumption that the body had an
     17            8px margin.
     18
    1192013-01-01  Christophe Dumez  <christophe.dumez@intel.com>
    220
  • trunk/LayoutTests/fast/frames/seamless/resources/nested-seamless.html

    r115742 r138611  
    11<!DOCTYPE html>
    22<style>
    3 body { margin: 0px; line-height: 0px; }
     3body { line-height: 0px; }
    44</style>
    55<iframe id="iframe" seamless src="square.html"></iframe>
  • trunk/LayoutTests/fast/frames/seamless/resources/quirks-square.html

    r115742 r138611  
    11<style>
    2 body { margin: 0px; line-height: 0px; }
     2body { line-height: 0px; }
    33</style>
    44<div style="background-color: green; width: 100px; height: 100px;"></div>
  • trunk/LayoutTests/fast/frames/seamless/resources/two-inline-blocks.html

    r118291 r138611  
    11<!DOCTYPE html>
    22<html><head><style>
    3 body { margin: 0px; line-height: 0px; }
     3body { line-height: 0px; }
    44/* FIXME: This vertical-align should not be needed, but without it the contentHeight()
    55of the document is reported as 4px too large, likely due to implied line decent? */
  • trunk/LayoutTests/fast/frames/seamless/seamless-inherited-origin-expected.txt

    r118737 r138611  
    22PASS iframe.seamless is true
    33PASS window.getComputedStyle(iframe).width is "200px"
    4 PASS window.getComputedStyle(iframe).height is "8px"
     4PASS window.getComputedStyle(iframe).height is "0px"
    55PASS window.getComputedStyle(iframe).width is "200px"
    66PASS window.getComputedStyle(iframe).height is "100px"
  • trunk/LayoutTests/fast/frames/seamless/seamless-inherited-origin.html

    r118291 r138611  
    1111
    1212    shouldBeEqualToString("window.getComputedStyle(iframe).width", "200px");
    13     // Initially about:blank has no content, thus no height, except the body
    14     // element defaults to margin: 8px (which gets collapsed to 8px when rendered).
    15     shouldBeEqualToString("window.getComputedStyle(iframe).height", "8px");
     13    // Initially about:blank has no content, thus no height.
     14    shouldBeEqualToString("window.getComputedStyle(iframe).height", "0px");
    1615
    1716    // Replace the empty document with a 100x100px square to test if it displays seamlessly.
  • trunk/Source/WebCore/CMakeLists.txt

    r138515 r138611  
    25362536    ${WEBCORE_DIR}/css/mediaControls.css
    25372537    ${WEBCORE_DIR}/css/quirks.css
     2538    ${WEBCORE_DIR}/css/seamless.css
    25382539    ${WEBCORE_DIR}/css/svg.css
    25392540    ${WEBCORE_DIR}/css/view-source.css
  • trunk/Source/WebCore/ChangeLog

    r138606 r138611  
     12013-01-02  Mike West  <mkwst@chromium.org>
     2
     3        The 'body' of seamless IFrames should default to 'margin: 0'
     4        https://bugs.webkit.org/show_bug.cgi?id=90834
     5
     6        Reviewed by Eric Seidel.
     7
     8        Documents displayed in seamless iframes should override the 'body'
     9        element's normal 8px default margins with 0px, in order to ensure that
     10        contents are displayed flush with the boundries of the seamless box.[1]
     11
     12        This patch does so by adding a new user agent stylesheet for seamless
     13        documents, and teaching the StyleResolver how and when to apply it.
     14
     15        [1]: http://lists.w3.org/Archives/Public/public-whatwg-archive/2012Jul/0039.html
     16
     17        Test: fast/frames/seamless/seamless-body-margin.html
     18
     19        * DerivedSources.make:
     20        * DerivedSources.pri:
     21        * GNUmakefile.am:
     22        * WebCore.gyp/WebCore.gyp:
     23        * WebCore.vcproj/WebCore.vcproj:
     24        * CMakeLists.txt:
     25            Added a new CSS file! Let's tell everyone!
     26        * css/StyleResolver.cpp:
     27        (WebCore):
     28        (WebCore::loadSeamlessStyle):
     29        (WebCore::StyleResolver::matchUARules):
     30        (WebCore::StyleResolver::collectFeatures):
     31        (WebCore::StyleResolver::reportMemoryUsage):
     32            Load the new stylesheet, and apply it to the document in
     33            matchUARules iff the document should be displayed seamlessly.
     34        * css/seamless.css: Added.
     35        (body):
     36            Stylesheet containing defaults for seamless documents.
     37
    1382013-01-01  Dan Bernstein  <mitz@apple.com>
    239
  • trunk/Source/WebCore/DerivedSources.make

    r137516 r138611  
    810810endif
    811811
     812ifeq ($(findstring ENABLE_IFRAME_SEAMLESS,$(FEATURE_DEFINES)), ENABLE_IFRAME_SEAMLESS)
     813    USER_AGENT_STYLE_SHEETS := $(USER_AGENT_STYLE_SHEETS) $(WebCore)/css/seamless.css
     814endif
     815
    812816UserAgentStyleSheets.h : css/make-css-file-arrays.pl bindings/scripts/preprocessor.pm $(USER_AGENT_STYLE_SHEETS)
    813817        perl -I$(WebCore)/bindings/scripts $< --defines "$(FEATURE_DEFINES)" $@ UserAgentStyleSheetsData.cpp $(USER_AGENT_STYLE_SHEETS)
  • trunk/Source/WebCore/DerivedSources.pri

    r137516 r138611  
    8383    $$PWD/css/mediaControlsQt.css \
    8484    $$PWD/css/mediaControlsQtFullscreen.css \
     85    $$PWD/css/seamless.css \
    8586    $$PWD/css/themeQtNoListboxes.css \
    8687    $$PWD/css/mobileThemeQt.css
  • trunk/Source/WebCore/GNUmakefile.am

    r138252 r138611  
    415415        $(WebCore)/css/mediaControls.css \
    416416        $(WebCore)/css/mediaControlsGtk.css \
    417         $(WebCore)/css/fullscreen.css
     417        $(WebCore)/css/fullscreen.css \
     418        $(WebCore)/css/seamless.css
    418419
    419420# new-style JavaScript bindings
     
    790791        Source/WebCore/css/mediaControlsGtk.css \
    791792        Source/WebCore/css/quirks.css \
     793        Source/WebCore/css/seamless.css \
    792794        Source/WebCore/css/svg.css \
    793795        Source/WebCore/css/SVGCSSPropertyNames.in \
  • trunk/Source/WebCore/WebCore.gyp/WebCore.gyp

    r138401 r138611  
    910910              '../css/mediaControlsChromiumAndroid.css',
    911911              '../css/fullscreen.css',
     912              '../css/seamless.css',
    912913              # Skip fullscreenQuickTime.
    913914            ],
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r138500 r138611  
    3816338163                        </File>
    3816438164                        <File
     38165                                RelativePath="..\css\seamless.css"
     38166                                >
     38167                        </File>
     38168                        <File
    3816538169                                RelativePath="..\css\ViewportStyleResolver.cpp"
    3816638170                                >
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r138572 r138611  
    207207static RuleSet* defaultQuirksStyle;
    208208static RuleSet* defaultPrintStyle;
     209static RuleSet* defaultSeamlessStyle;
    209210static RuleSet* defaultViewSourceStyle;
    210211static StyleSheetContents* simpleDefaultStyleSheet;
     
    543544    defaultViewSourceStyle = RuleSet::create().leakPtr();
    544545    defaultViewSourceStyle->addRulesFromSheet(parseUASheet(sourceUserAgentStyleSheet, sizeof(sourceUserAgentStyleSheet)), screenEval());
     546}
     547
     548static void loadSeamlessStyle()
     549{
     550    ASSERT(!defaultSeamlessStyle);
     551#if ENABLE(IFRAME_SEAMLESS)
     552    defaultSeamlessStyle = RuleSet::create().leakPtr();
     553    defaultSeamlessStyle->addRulesFromSheet(parseUASheet(seamlessUserAgentStyleSheet, sizeof(seamlessUserAgentStyleSheet)), screenEval());
     554#endif
    545555}
    546556
     
    13431353            loadViewSourceStyle();
    13441354        matchUARules(result, defaultViewSourceStyle);
     1355    }
     1356
     1357    // If the document is loaded inside a seamless iframe, then we match rules from the seamless sheet.
     1358    if (document()->shouldDisplaySeamlesslyWithParent()) {
     1359        if (!defaultSeamlessStyle)
     1360            loadSeamlessStyle();
     1361        matchUARules(result, defaultSeamlessStyle);
    13451362    }
    13461363}
     
    52825299        m_features.add(defaultViewSourceStyle->features());
    52835300    }
     5301    if (document()->shouldDisplaySeamlesslyWithParent()) {
     5302        if (!defaultSeamlessStyle)
     5303            loadSeamlessStyle();
     5304        m_features.add(defaultSeamlessStyle->features());
     5305    }
    52845306
    52855307    if (m_scopeResolver)
     
    53375359    info.addMember(defaultQuirksStyle);
    53385360    info.addMember(defaultPrintStyle);
     5361    info.addMember(defaultSeamlessStyle);
    53395362    info.addMember(defaultViewSourceStyle);
    53405363}
Note: See TracChangeset for help on using the changeset viewer.