Changeset 140863 in webkit


Ignore:
Timestamp:
Jan 25, 2013 1:54:20 PM (11 years ago)
Author:
dino@apple.com
Message:

Add a user agent stylesheet for plugins
https://bugs.webkit.org/show_bug.cgi?id=107890

Reviewed by Alexey Proskuryakov.

Source/WebCore:

As a step along the way to providing a Shadow DOM for plug-in elements, add a
User Agent stylesheet that is loaded when an embed or object element is
in the document. At the moment the stylesheet is empty.

The stylesheet can be overridden by the RenderTheme or the ChromeClient, allowing
ports to provide a custom appearance. This involved hooking up some virtual methods
on ChromeClient, the stubs of which are already implemented in WK2.
As a drive-by, since snapshotted plugins will need some localization I've also
exposed the ChromeClient methods to get text labels.

  • CMakeLists.txt: Add plugIns.css.
  • DerivedSources.make: Ditto.
  • DerivedSources.pri: Ditto.
  • GNUmakefile.am: Ditto.
  • WebCore.gyp/WebCore.gyp: Ditto.
  • WebCore.vcproj/WebCore.vcproj: Ditto.
  • WebCore.vcxproj/WebCore.vcxproj: Ditto.
  • WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
  • WebCore.xcodeproj/project.pbxproj: Ditoo.
  • css/StyleResolver.cpp:

(WebCore::ensureDefaultStyleSheetsForElement): Load and inject new plugInsStyleSheet if there is an object or embed element.

  • css/plugIns.css: Added. Empty for now.
  • page/ChromeClient.h: New methods for querying the client.

(WebCore::ChromeClient::plugInStartLabelTitle):
(WebCore::ChromeClient::plugInStartLabelSubtitle):
(WebCore::ChromeClient::plugInExtraStyleSheet):

  • rendering/RenderTheme.h:

(WebCore::RenderTheme::extraPlugInsStyleSheet): Allow the theme to provide an extra stylesheet.

Source/WebKit2:

  • WebProcess/InjectedBundle/API/c/WKBundlePage.h: Rename client callbacks

to have a "create" prefix, making it clear that these generate new Strings.

  • WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp: Actually call into

the injected bundle to retrieve any custom stylesheet for plugins.
(WebKit::InjectedBundlePageUIClient::plugInExtraStyleSheet):

  • WebProcess/WebCoreSupport/WebChromeClient.h:

(WebChromeClient): Add override keyword onto virtual functions now
that the base class has implementations.

Location:
trunk/Source
Files:
1 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r140804 r140863  
    25502550    ${WEBCORE_DIR}/css/mathml.css
    25512551    ${WEBCORE_DIR}/css/mediaControls.css
     2552    ${WEBCORE_DIR}/css/plugIns.css
    25522553    ${WEBCORE_DIR}/css/quirks.css
    25532554    ${WEBCORE_DIR}/css/svg.css
  • trunk/Source/WebCore/ChangeLog

    r140862 r140863  
     12013-01-25  Dean Jackson  <dino@apple.com>
     2
     3        Add a user agent stylesheet for plugins
     4        https://bugs.webkit.org/show_bug.cgi?id=107890
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        As a step along the way to providing a Shadow DOM for plug-in elements, add a
     9        User Agent stylesheet that is loaded when an embed or object element is
     10        in the document. At the moment the stylesheet is empty.
     11
     12        The stylesheet can be overridden by the RenderTheme or the ChromeClient, allowing
     13        ports to provide a custom appearance. This involved hooking up some virtual methods
     14        on ChromeClient, the stubs of which are already implemented in WK2.
     15        As a drive-by, since snapshotted plugins will need some localization I've also
     16        exposed the ChromeClient methods to get text labels.
     17
     18        * CMakeLists.txt: Add plugIns.css.
     19        * DerivedSources.make: Ditto.
     20        * DerivedSources.pri: Ditto.
     21        * GNUmakefile.am: Ditto.
     22        * WebCore.gyp/WebCore.gyp: Ditto.
     23        * WebCore.vcproj/WebCore.vcproj: Ditto.
     24        * WebCore.vcxproj/WebCore.vcxproj: Ditto.
     25        * WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
     26        * WebCore.xcodeproj/project.pbxproj: Ditoo.
     27        * css/StyleResolver.cpp:
     28        (WebCore::ensureDefaultStyleSheetsForElement): Load and inject new plugInsStyleSheet if there is an object or embed element.
     29        * css/plugIns.css: Added. Empty for now.
     30        * page/ChromeClient.h: New methods for querying the client.
     31        (WebCore::ChromeClient::plugInStartLabelTitle):
     32        (WebCore::ChromeClient::plugInStartLabelSubtitle):
     33        (WebCore::ChromeClient::plugInExtraStyleSheet):
     34        * rendering/RenderTheme.h:
     35        (WebCore::RenderTheme::extraPlugInsStyleSheet): Allow the theme to provide an extra stylesheet.
     36
    1372013-01-25  Eric Carlson  <eric.carlson@apple.com>
    238
  • trunk/Source/WebCore/DerivedSources.make

    r140604 r140863  
    802802# user agent style sheets
    803803
    804 USER_AGENT_STYLE_SHEETS = $(WebCore)/css/html.css $(WebCore)/css/quirks.css $(WebCore)/css/view-source.css $(WebCore)/css/themeWin.css $(WebCore)/css/themeWinQuirks.css
     804USER_AGENT_STYLE_SHEETS = $(WebCore)/css/html.css $(WebCore)/css/quirks.css $(WebCore)/css/view-source.css $(WebCore)/css/themeWin.css $(WebCore)/css/themeWinQuirks.css $(WebCore)/css/plugIns.css
    805805
    806806ifeq ($(findstring ENABLE_SVG,$(FEATURE_DEFINES)), ENABLE_SVG)
  • trunk/Source/WebCore/DerivedSources.pri

    r140604 r140863  
    8383    $$PWD/css/mediaControlsQt.css \
    8484    $$PWD/css/mediaControlsQtFullscreen.css \
     85    $$PWD/css/plugIns.css \
    8586    $$PWD/css/themeQtNoListboxes.css \
    8687    $$PWD/css/mobileThemeQt.css
  • trunk/Source/WebCore/GNUmakefile.am

    r140431 r140863  
    415415        $(WebCore)/css/mediaControls.css \
    416416        $(WebCore)/css/mediaControlsGtk.css \
    417         $(WebCore)/css/fullscreen.css
     417        $(WebCore)/css/fullscreen.css \
     418        $(WebCore)/css/plugIns.css
    418419
    419420# new-style JavaScript bindings
     
    814815        Source/WebCore/css/mediaControls.css \
    815816        Source/WebCore/css/mediaControlsGtk.css \
     817        Source/WebCore/css/plugIns.css \
    816818        Source/WebCore/css/quirks.css \
    817819        Source/WebCore/css/svg.css \
  • trunk/Source/WebCore/WebCore.gyp/WebCore.gyp

    r140800 r140863  
    925925              '../css/mediaControlsChromiumAndroid.css',
    926926              '../css/fullscreen.css',
     927              '../css/plugIns.css',
    927928              # Skip fullscreenQuickTime.
    928929            ],
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r140745 r140863  
    3827138271                        </File>
    3827238272                        <File
     38273                                RelativePath="..\css\plugIns.css"
     38274                                >
     38275                        </File>
     38276                        <File
    3827338277                                RelativePath="..\css\PropertySetCSSStyleDeclaration.cpp"
    3827438278                                >
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r140588 r140863  
    84048404    <None Include="..\css\html.css" />
    84058405    <None Include="..\css\mediaControls.css" />
     8406    <None Include="..\css\plugIns.css" />
    84068407    <None Include="..\css\quirks.css" />
    84078408    <None Include="..\xml\XPathGrammar.y" />
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r140588 r140863  
    1426814268      <Filter>css</Filter>
    1426914269    </None>
     14270    <None Include="..\css\plugIns.css">
     14271      <Filter>css</Filter>
     14272    </None>
    1427014273    <None Include="..\css\quirks.css">
    1427114274      <Filter>css</Filter>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r140745 r140863  
    82068206                316FE1100E6E1DA700BF6088 /* KeyframeAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KeyframeAnimation.h; path = animation/KeyframeAnimation.h; sourceTree = "<group>"; };
    82078207                31741AAB16635E45008A5B7E /* SimulatedClickOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SimulatedClickOptions.h; sourceTree = "<group>"; };
     8208                3189E6DB16B2103500386EA3 /* plugIns.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = plugIns.css; sourceTree = "<group>"; };
    82088209                319AE061142D6B24006563A1 /* StyleFilterData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StyleFilterData.cpp; path = style/StyleFilterData.cpp; sourceTree = "<group>"; };
    82098210                319AE062142D6B24006563A1 /* StyleFilterData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleFilterData.h; path = style/StyleFilterData.h; sourceTree = "<group>"; };
     
    2180821809                                D3AA10F2123A98AA0092152B /* MediaQueryMatcher.h */,
    2180921810                                A80E6CD10A1989CA007FB8C5 /* Pair.h */,
     21811                                3189E6DB16B2103500386EA3 /* plugIns.css */,
    2181021812                                E4BBED0C14F4025D003F0B98 /* PropertySetCSSStyleDeclaration.cpp */,
    2181121813                                E4BBED0D14F4025D003F0B98 /* PropertySetCSSStyleDeclaration.h */,
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r140845 r140863  
    5858#include "CachedImage.h"
    5959#include "CalculationValue.h"
     60#include "Chrome.h"
     61#include "ChromeClient.h"
    6062#include "ContentData.h"
    6163#include "ContextFeatures.h"
     
    221223static StyleSheetContents* mediaControlsStyleSheet;
    222224static StyleSheetContents* fullscreenStyleSheet;
     225static StyleSheetContents* plugInsStyleSheet;
    223226
    224227RenderStyle* StyleResolver::s_styleNotYetAvailable;
     
    593596    }
    594597#endif
     598
     599    if (!plugInsStyleSheet && (element->hasTagName(objectTag) || element->hasTagName(embedTag))) {
     600        String plugInsRules = String(plugInsUserAgentStyleSheet, sizeof(plugInsUserAgentStyleSheet)) + RenderTheme::themeForPage(element->document()->page())->extraPlugInsStyleSheet() + element->document()->page()->chrome()->client()->plugInExtraStyleSheet();
     601        plugInsStyleSheet = parseUASheet(plugInsRules);
     602        defaultStyle->addRulesFromSheet(plugInsStyleSheet, screenEval());
     603    }
    595604
    596605    ASSERT(defaultStyle->features().idsInRules.isEmpty());
  • trunk/Source/WebCore/page/ChromeClient.h

    r140286 r140863  
    375375
    376376    virtual PassRefPtr<Image> plugInStartLabelImage(RenderSnapshottedPlugIn::LabelSize) const { return 0; }
     377    virtual String plugInStartLabelTitle() const { return String(); }
     378    virtual String plugInStartLabelSubtitle() const { return String(); }
     379    virtual String plugInExtraStyleSheet() const { return String(); }
    377380
    378381    // FIXME: Port should return true using heuristic based on scrollable(RenderBox).
  • trunk/Source/WebCore/rendering/RenderTheme.h

    r140778 r140863  
    8787
    8888    // These methods return the theme's extra style sheets rules, to let each platform
    89     // adjust the default CSS rules in html.css, quirks.css, or mediaControls.css
     89    // adjust the default CSS rules in html.css, quirks.css, mediaControls.css, or plugIns.css
    9090    virtual String extraDefaultStyleSheet() { return String(); }
    9191    virtual String extraQuirksStyleSheet() { return String(); }
     92    virtual String extraPlugInsStyleSheet() { return String(); }
    9293#if ENABLE(VIDEO)
    93     virtual String extraMediaControlsStyleSheet() { return String(); };
     94    virtual String extraMediaControlsStyleSheet() { return String(); }
    9495#endif
    9596#if ENABLE(FULLSCREEN_API)
    96     virtual String extraFullScreenStyleSheet() { return String(); };
     97    virtual String extraFullScreenStyleSheet() { return String(); }
    9798#endif
    9899
  • trunk/Source/WebKit2/ChangeLog

    r140861 r140863  
     12013-01-25  Dean Jackson  <dino@apple.com>
     2
     3        Add a user agent stylesheet for plugins
     4        https://bugs.webkit.org/show_bug.cgi?id=107890
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * WebProcess/InjectedBundle/API/c/WKBundlePage.h: Rename client callbacks
     9        to have a "create" prefix, making it clear that these generate new Strings.
     10        * WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp: Actually call into
     11        the injected bundle to retrieve any custom stylesheet for plugins.
     12        (WebKit::InjectedBundlePageUIClient::plugInExtraStyleSheet):
     13        * WebProcess/WebCoreSupport/WebChromeClient.h:
     14        (WebChromeClient): Add override keyword onto virtual functions now
     15        that the base class has implementations.
     16
    1172013-01-25  Alexey Proskuryakov  <ap@apple.com>
    218
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h

    r140769 r140863  
    250250typedef uint64_t (*WKBundlePageExceededDatabaseQuotaCallback)(WKBundlePageRef page, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes, const void *clientInfo);
    251251typedef WKImageRef (*WKBundlePagePlugInStartLabelImageCallback)(WKBundlePageLabelSize size, const void *clientInfo);
    252 typedef WKStringRef (*WKBundlePagePlugInStartLabelTitleCallback)(const void *clientInfo);
    253 typedef WKStringRef (*WKBundlePagePlugInStartLabelSubtitleCallback)(const void *clientInfo);
    254 typedef WKStringRef (*WKBundlePagePlugInExtraStyleSheetCallback)(const void *clientInfo);
     252typedef WKStringRef (*WKBundlePagePlugInCreateStartLabelTitleCallback)(const void *clientInfo);
     253typedef WKStringRef (*WKBundlePagePlugInCreateStartLabelSubtitleCallback)(const void *clientInfo);
     254typedef WKStringRef (*WKBundlePagePlugInCreateExtraStyleSheetCallback)(const void *clientInfo);
    255255
    256256struct WKBundlePageUIClient {
     
    278278    WKBundlePageExceededDatabaseQuotaCallback                           didExceedDatabaseQuota;
    279279    WKBundlePagePlugInStartLabelImageCallback                           plugInStartLabelImage;
    280     WKBundlePagePlugInStartLabelTitleCallback                           plugInStartLabelTitle;
    281     WKBundlePagePlugInStartLabelSubtitleCallback                        plugInStartLabelSubtitle;
    282     WKBundlePagePlugInExtraStyleSheetCallback                           plugInExtraStyleSheet;
     280    WKBundlePagePlugInCreateStartLabelTitleCallback                     createPlugInStartLabelTitle;
     281    WKBundlePagePlugInCreateStartLabelSubtitleCallback                  createPlugInStartLabelSubtitle;
     282    WKBundlePagePlugInCreateExtraStyleSheetCallback                     createPlugInExtraStyleSheet;
    283283};
    284284typedef struct WKBundlePageUIClient WKBundlePageUIClient;
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp

    r140713 r140863  
    196196String InjectedBundlePageUIClient::plugInExtraStyleSheet() const
    197197{
    198     return String();
     198    RefPtr<WebString> styleSheet = adoptRef(toImpl(m_client.createPlugInExtraStyleSheet(m_client.clientInfo)));
     199    return styleSheet ? styleSheet->string() : String();
    199200}
    200201
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h

    r140713 r140863  
    220220
    221221    virtual PassRefPtr<WebCore::Image> plugInStartLabelImage(WebCore::RenderSnapshottedPlugIn::LabelSize) const OVERRIDE;
    222     virtual String plugInStartLabelTitle() const;
    223     virtual String plugInStartLabelSubtitle() const;
    224     virtual String plugInExtraStyleSheet() const;
     222    virtual String plugInStartLabelTitle() const OVERRIDE;
     223    virtual String plugInStartLabelSubtitle() const OVERRIDE;
     224    virtual String plugInExtraStyleSheet() const OVERRIDE;
    225225
    226226    String m_cachedToolTip;
Note: See TracChangeset for help on using the changeset viewer.