Changeset 142507 in webkit


Ignore:
Timestamp:
Feb 11, 2013 1:34:50 PM (11 years ago)
Author:
dino@apple.com
Message:

Source/WebCore: Source/WebCore: Snapshotted plug-in should use shadow root
https://bugs.webkit.org/show_bug.cgi?id=108284

Reviewed by Simon Fraser.

Take three - relanding after rollout in r142400 that was caused by a global
selector interfering with CSS Instrumentation in the Inspector.

A snapshotted plugin needs to indicate to the user that it can be clicked
to be restarted. Previously this was done with an image that had embedded
text. Instead, we now use an internal shadow root to embed some markup that
will display instructions that can be localised.

The UA stylesheet for plug-ins provides a default styling for the label, which
can be overridden by ports.

In the process, RenderSnapshottedPlugIn no longer inherits from RenderEmbeddedObject,
since it is only responsible for drawing a paused plug-in. The snapshot creation
can work with the default renderer, but a shadow root requires something like
RenderBlock in order to draw its children. We swap from one renderer to another when
necessary either by creating the shadow root or by explicitly detaching and attaching
the plugin element.

Unfortunately this is difficult to test, because the snapshotting requires
time to execute, and also a PluginView to be instantiated.

  • css/plugIns.css:

(object::-webkit-snapshotted-plugin-content): New rules for a default label style.

  • platform/LocalizedStrings.cpp: Make sure all ports have plugin strings, now it is called.
  • platform/LocalizedStrings.h:
  • platform/blackberry/LocalizedStringsBlackBerry.cpp:
  • platform/chromium/LocalizedStringsChromium.cpp:
  • platform/efl/LocalizedStringsEfl.cpp:
  • platform/gtk/LocalizedStringsGtk.cpp:
  • platform/qt/LocalizedStringsQt.cpp:
  • html/HTMLPlugInElement.cpp:

(WebCore::HTMLPlugInElement::defaultEventHandler): Take into account the fact
that RenderSnapshottedPlugIn no longer is an embedded object.

  • html/HTMLPlugInImageElement.cpp:

(WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement): New default values in constructor.
(WebCore::HTMLPlugInElement::defaultEventHandler): Make sure to call base class.
(WebCore::HTMLPlugInElement::willRecalcStyle): No need to reattach if we're a snapshot.
(WebCore::HTMLPlugInImageElement::createRenderer): If we're showing a snapshot, create such

a renderer, otherwise use the typical plug-in path.

(WebCore::HTMLPlugInImageElement::updateSnapshot): Keep a record of the snapshot, since we'll

need to give it to the renderer.

(WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot): Build a subtree that will display a label.

  • html/HTMLPlugInImageElement.h:

(HTMLPlugInImageElement): New member variable to record the snapshot image and whether the label

should show immediately.

(WebCore::HTMLPlugInImageElement::swapRendererTimerFired): The callback function triggered when we need

to swap to the Shadow Root.

(WebCore::HTMLPlugInImageElement::userDidClickSnapshot): The user has tapped on the snapshot so the plugin

in being recreated. Make sure we reattach so that a plugin renderer will be created.

(WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn): Make sure we set the right

displayState for snapshots.

  • html/HTMLPlugInImageElement.h:

(HTMLPlugInImageElement): The new methods listed above.
(WebCore::HTMLPlugInImageElement::setShouldShowSnapshotLabelAutomatically): Indicates whether or not

a snapshot should be immediately labeled.

  • page/ChromeClient.h: No need for plugInStartLabelImage any more.
  • rendering/RenderSnapshottedPlugIn.cpp:

(WebCore::RenderSnapshottedPlugIn::RenderSnapshottedPlugIn): New inheritance.
(WebCore::RenderSnapshottedPlugIn::paint): If we're in the background paint phase, render the snapshot image.
(WebCore::RenderSnapshottedPlugIn::paintSnapshotImage): Rename.
(WebCore::RenderSnapshottedPlugIn::paintSnapshot): Rename.
(WebCore::RenderSnapshottedPlugIn::paintSnapshotWithLabel): Rename. No need for label sizes.
(WebCore::RenderSnapshottedPlugIn::getCursor):
(WebCore::RenderSnapshottedPlugIn::handleEvent): The renderer doesn't restart the plug-in any more. Tell the element and it will do it.

  • rendering/RenderSnapshottedPlugIn.h:

(RenderSnapshottedPlugIn): New inheritance. Some method renaming.

Source/WebKit2: Snapshotted plug-in should use shadow root
https://bugs.webkit.org/show_bug.cgi?id=108284

Reviewed by Simon Fraser.

Take three of this commit - after rollout in r142400 and r142405.
We no longer have any need for plugInStartLabelImage.

  • WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp: Remove plugInStartLabelImage.
  • WebProcess/InjectedBundle/InjectedBundlePageUIClient.h: Ditto.
  • WebProcess/WebCoreSupport/WebChromeClient.cpp: Ditto.
  • WebProcess/WebCoreSupport/WebChromeClient.h: Ditto.

Tools: Remove use of plugInStartLabelImage
https://bugs.webkit.org/show_bug.cgi?id=108273

Reviewed by Simon Fraser.

Take two - after rollout in r142405.
Removed plugInStartLabelImage entry from client structure.

  • WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:

(WTR::InjectedBundlePage::InjectedBundlePage):

Location:
trunk
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r142506 r142507  
     12013-02-11  Dean Jackson  <dino@apple.com>
     2
     3        Source/WebCore: Snapshotted plug-in should use shadow root
     4        https://bugs.webkit.org/show_bug.cgi?id=108284
     5
     6        Reviewed by Simon Fraser.
     7
     8        Take three - relanding after rollout in r142400 that was caused by a global
     9        selector interfering with CSS Instrumentation in the Inspector.
     10
     11        A snapshotted plugin needs to indicate to the user that it can be clicked
     12        to be restarted. Previously this was done with an image that had embedded
     13        text. Instead, we now use an internal shadow root to embed some markup that
     14        will display instructions that can be localised.
     15
     16        The UA stylesheet for plug-ins provides a default styling for the label, which
     17        can be overridden by ports.
     18
     19        In the process, RenderSnapshottedPlugIn no longer inherits from RenderEmbeddedObject,
     20        since it is only responsible for drawing a paused plug-in. The snapshot creation
     21        can work with the default renderer, but a shadow root requires something like
     22        RenderBlock in order to draw its children. We swap from one renderer to another when
     23        necessary either by creating the shadow root or by explicitly detaching and attaching
     24        the plugin element.
     25
     26        Unfortunately this is difficult to test, because the snapshotting requires
     27        time to execute, and also a PluginView to be instantiated.
     28
     29        * css/plugIns.css:
     30        (object::-webkit-snapshotted-plugin-content): New rules for a default label style.
     31
     32        * platform/LocalizedStrings.cpp: Make sure all ports have plugin strings, now it is called.
     33        * platform/LocalizedStrings.h:
     34        * platform/blackberry/LocalizedStringsBlackBerry.cpp:
     35        * platform/chromium/LocalizedStringsChromium.cpp:
     36        * platform/efl/LocalizedStringsEfl.cpp:
     37        * platform/gtk/LocalizedStringsGtk.cpp:
     38        * platform/qt/LocalizedStringsQt.cpp:
     39
     40        * html/HTMLPlugInElement.cpp:
     41        (WebCore::HTMLPlugInElement::defaultEventHandler): Take into account the fact
     42        that RenderSnapshottedPlugIn no longer is an embedded object.
     43
     44        * html/HTMLPlugInImageElement.cpp:
     45        (WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement): New default values in constructor.
     46        (WebCore::HTMLPlugInElement::defaultEventHandler): Make sure to call base class.
     47        (WebCore::HTMLPlugInElement::willRecalcStyle): No need to reattach if we're a snapshot.
     48        (WebCore::HTMLPlugInImageElement::createRenderer): If we're showing a snapshot, create such
     49            a renderer, otherwise use the typical plug-in path.
     50        (WebCore::HTMLPlugInImageElement::updateSnapshot): Keep a record of the snapshot, since we'll
     51            need to give it to the renderer.
     52        (WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot): Build a subtree that will display a label.
     53        * html/HTMLPlugInImageElement.h:
     54        (HTMLPlugInImageElement): New member variable to record the snapshot image and whether the label
     55            should show immediately.
     56        (WebCore::HTMLPlugInImageElement::swapRendererTimerFired): The callback function triggered when we need
     57            to swap to the Shadow Root.
     58        (WebCore::HTMLPlugInImageElement::userDidClickSnapshot): The user has tapped on the snapshot so the plugin
     59            in being recreated. Make sure we reattach so that a plugin renderer will be created.
     60        (WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn): Make sure we set the right
     61            displayState for snapshots.
     62        * html/HTMLPlugInImageElement.h:
     63        (HTMLPlugInImageElement): The new methods listed above.
     64        (WebCore::HTMLPlugInImageElement::setShouldShowSnapshotLabelAutomatically): Indicates whether or not
     65            a snapshot should be immediately labeled.
     66
     67        * page/ChromeClient.h: No need for plugInStartLabelImage any more.
     68
     69        * rendering/RenderSnapshottedPlugIn.cpp:
     70        (WebCore::RenderSnapshottedPlugIn::RenderSnapshottedPlugIn): New inheritance.
     71        (WebCore::RenderSnapshottedPlugIn::paint): If we're in the background paint phase, render the snapshot image.
     72        (WebCore::RenderSnapshottedPlugIn::paintSnapshotImage): Rename.
     73        (WebCore::RenderSnapshottedPlugIn::paintSnapshot): Rename.
     74        (WebCore::RenderSnapshottedPlugIn::paintSnapshotWithLabel): Rename. No need for label sizes.
     75        (WebCore::RenderSnapshottedPlugIn::getCursor):
     76        (WebCore::RenderSnapshottedPlugIn::handleEvent): The renderer doesn't restart the plug-in any more. Tell the element and it will do it.
     77        * rendering/RenderSnapshottedPlugIn.h:
     78        (RenderSnapshottedPlugIn): New inheritance. Some method renaming.
     79
    1802013-02-11  Mike West  <mkwst@chromium.org>
    281
  • trunk/Source/WebCore/css/plugIns.css

    r142400 r142507  
    2323 */
    2424
    25 /* plug-ins */
    26 p{} /*Needed by Windows because it doesn't like empty files*/
     25/*
     26 * This is the UA StyleSheet for <object> and <embed> elements.
     27 *
     28 * Such elements, when snapshotted (paused), will contain a ShadowRoot
     29 * with the following structure:
     30 *
     31 * <object>
     32 *   #ShadowRoot
     33 *     <div class="snapshot-container">
     34 *       <div class="snapshot-overlay"></div> <!-- e.g. for dimming content -->
     35 *         <div class="snapshot-label">
     36 *           <div class="snapshot-title">Snapshotted Plug-In</div>
     37 *           <div class="snapshot-subtitle">Click to restart</div>
     38 *         </div>
     39 *       </div>
     40 *     </div>
     41 *
     42 */
     43
     44object::-webkit-snapshotted-plugin-content,
     45embed::-webkit-snapshotted-plugin-content
     46{
     47    position: relative;
     48    display: inline-block;
     49    width: 100%;
     50    height: 100%;
     51}
     52
     53object::-webkit-snapshotted-plugin-content .snapshot-container,
     54embed::-webkit-snapshotted-plugin-content .snapshot-container
     55{
     56    position: absolute;
     57    width: 100%;
     58    height: 100%;
     59}
     60
     61object::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-overlay,
     62embed::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-overlay
     63{
     64    display: none;
     65}
     66
     67object::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label,
     68embed::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label
     69{
     70    position: absolute;
     71    background-color: white;
     72    color: black;
     73    margin: 1em;
     74    padding: 0.25em 2em;
     75    text-align: center;
     76}
     77
     78object::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label .snapshot-title,
     79embed::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label .snapshot-title
     80{
     81    font-weight: bold;
     82}
     83
     84object::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label .snapshot-subtitle,
     85embed::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label .snapshot-subtitle
     86{
     87    font-style: italic;
     88    color: #444;
     89}
  • trunk/Source/WebCore/html/HTMLPlugInElement.cpp

    r142400 r142507  
    202202            return;
    203203        }
    204         if (r->isSnapshottedPlugIn() && displayState() < PlayingWithPendingMouseClick) {
    205             toRenderSnapshottedPlugIn(r)->handleEvent(event);
    206             return;
    207         }
     204    } else if (r && r->isSnapshottedPlugIn() && displayState() < PlayingWithPendingMouseClick) {
     205        toRenderSnapshottedPlugIn(r)->handleEvent(event);
     206        HTMLFrameOwnerElement::defaultEventHandler(event);
     207        return;
    208208    }
    209209
  • trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp

    r142400 r142507  
    2222#include "HTMLPlugInImageElement.h"
    2323
     24#include "Chrome.h"
     25#include "ChromeClient.h"
    2426#include "Frame.h"
    2527#include "FrameLoader.h"
    2628#include "FrameLoaderClient.h"
    2729#include "FrameView.h"
     30#include "HTMLDivElement.h"
    2831#include "HTMLImageLoader.h"
    29 #include "HTMLNames.h"
    3032#include "Image.h"
     33#include "LocalizedStrings.h"
    3134#include "Logging.h"
    3235#include "MouseEvent.h"
    3336#include "NodeRenderStyle.h"
     37#include "NodeRenderingContext.h"
    3438#include "Page.h"
    3539#include "PlugInClient.h"
     
    4246#include "SecurityOrigin.h"
    4347#include "Settings.h"
     48#include "ShadowRoot.h"
    4449#include "StyleResolver.h"
     50#include "Text.h"
    4551
    4652namespace WebCore {
     53
     54using namespace HTMLNames;
    4755
    4856static const int autoStartPlugInSizeThresholdWidth = 1;
     
    6270    , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPreferPlugInsForImages)
    6371    , m_needsDocumentActivationCallbacks(false)
     72    , m_shouldShowSnapshotLabelAutomatically(false)
    6473    , m_simulatedMouseClickTimer(this, &HTMLPlugInImageElement::simulatedMouseClickTimerFired, simulatedMouseClickTimerDelay)
     74    , m_swapRendererTimer(this, &HTMLPlugInImageElement::swapRendererTimerFired)
    6575{
    6676    setHasCustomCallbacks();
     
    133143        document()->registerForPageCacheSuspensionCallbacks(this);
    134144    }
    135    
     145
     146    if (displayState() == DisplayingSnapshot) {
     147        RenderSnapshottedPlugIn* renderSnapshottedPlugIn = new (arena) RenderSnapshottedPlugIn(this);
     148        renderSnapshottedPlugIn->updateSnapshot(m_snapshotImage);
     149        if (m_shouldShowSnapshotLabelAutomatically)
     150            renderSnapshottedPlugIn->setShouldShowLabelAutomatically();
     151        return renderSnapshottedPlugIn;
     152    }
     153
    136154    // Fallback content breaks the DOM->Renderer class relationship of this
    137155    // class and all superclasses because createObject won't necessarily
     
    139157    if (useFallbackContent())
    140158        return RenderObject::createObject(this, style);
     159
    141160    if (isImageType()) {
    142161        RenderImage* image = new (arena) RenderImage(this);
     
    145164    }
    146165
    147     if (document()->page() && document()->page()->settings()->plugInSnapshottingEnabled())
    148         return new (arena) RenderSnapshottedPlugIn(this);
    149166    return new (arena) RenderEmbeddedObject(this);
    150167}
     
    153170{
    154171    // FIXME: Why is this necessary?  Manual re-attach is almost always wrong.
    155     if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageType())
     172    if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageType() && (displayState() != DisplayingSnapshot))
    156173        reattach();
    157174    return true;
     
    259276void HTMLPlugInImageElement::updateSnapshot(PassRefPtr<Image> image)
    260277{
    261     if (displayState() > DisplayingSnapshot || !renderer()->isSnapshottedPlugIn())
    262         return;
    263 
    264     toRenderSnapshottedPlugIn(renderer())->updateSnapshot(image);
     278    if (displayState() > DisplayingSnapshot)
     279        return;
     280
     281    m_snapshotImage = image;
     282    if (renderer()->isSnapshottedPlugIn()) {
     283        toRenderSnapshottedPlugIn(renderer())->updateSnapshot(image);
     284        return;
     285    }
     286
    265287    setDisplayState(DisplayingSnapshot);
     288    m_swapRendererTimer.startOneShot(0);
     289}
     290
     291void HTMLPlugInImageElement::didAddUserAgentShadowRoot(ShadowRoot* root)
     292{
     293    Document* doc = document();
     294
     295    RefPtr<Element> shadowContainer = HTMLDivElement::create(doc);
     296    shadowContainer->setPseudo(AtomicString("-webkit-snapshotted-plugin-content", AtomicString::ConstructFromLiteral));
     297
     298    RefPtr<Element> container = HTMLDivElement::create(doc);
     299    container->setAttribute(classAttr, AtomicString("snapshot-container", AtomicString::ConstructFromLiteral));
     300
     301    RefPtr<Element> overlay = HTMLDivElement::create(doc);
     302    overlay->setAttribute(classAttr, AtomicString("snapshot-overlay", AtomicString::ConstructFromLiteral));
     303    container->appendChild(overlay, ASSERT_NO_EXCEPTION);
     304
     305    RefPtr<Element> label = HTMLDivElement::create(doc);
     306    label->setAttribute(classAttr, AtomicString("snapshot-label", AtomicString::ConstructFromLiteral));
     307
     308    String titleText = snapshottedPlugInLabelTitle();
     309    String subtitleText = snapshottedPlugInLabelSubtitle();
     310    if (document()->page()) {
     311        String clientTitleText = document()->page()->chrome()->client()->plugInStartLabelTitle();
     312        if (!clientTitleText.isEmpty())
     313            titleText = clientTitleText;
     314        String clientSubtitleText = document()->page()->chrome()->client()->plugInStartLabelSubtitle();
     315        if (!clientSubtitleText.isEmpty())
     316            subtitleText = clientSubtitleText;
     317    }
     318
     319    RefPtr<Element> title = HTMLDivElement::create(doc);
     320    title->setAttribute(classAttr, AtomicString("snapshot-title", AtomicString::ConstructFromLiteral));
     321    title->appendChild(doc->createTextNode(titleText), ASSERT_NO_EXCEPTION);
     322    label->appendChild(title, ASSERT_NO_EXCEPTION);
     323
     324    RefPtr<Element> subTitle = HTMLDivElement::create(doc);
     325    subTitle->setAttribute(classAttr, AtomicString("snapshot-subtitle", AtomicString::ConstructFromLiteral));
     326    subTitle->appendChild(doc->createTextNode(subtitleText), ASSERT_NO_EXCEPTION);
     327    label->appendChild(subTitle, ASSERT_NO_EXCEPTION);
     328
     329    container->appendChild(label, ASSERT_NO_EXCEPTION);
     330
     331    shadowContainer->appendChild(container, ASSERT_NO_EXCEPTION);
     332    root->appendChild(shadowContainer, ASSERT_NO_EXCEPTION);
     333}
     334
     335void HTMLPlugInImageElement::swapRendererTimerFired(Timer<HTMLPlugInImageElement>*)
     336{
     337    ASSERT(displayState() == DisplayingSnapshot);
     338    if (userAgentShadowRoot())
     339        return;
     340
     341    // Create a shadow root, which will trigger the code to add a snapshot container
     342    // and reattach, thus making a new Renderer.
     343    ensureUserAgentShadowRoot();
    266344}
    267345
     
    271349    if (document()->page() && !SchemeRegistry::shouldTreatURLSchemeAsLocal(document()->page()->mainFrame()->document()->baseURL().protocol()))
    272350        document()->page()->plugInClient()->addAutoStartOrigin(document()->page()->mainFrame()->document()->baseURL().host(), m_plugInOriginHash);
     351
     352    reattach();
    273353}
    274354
     
    320400    }
    321401
    322     if (!renderer()->isSnapshottedPlugIn()) {
    323         LOG(Plugins, "%p Renderer is not snapshotted plugin, set to play", this);
    324         return;
    325     }
    326402    if (ScriptController::processingUserGesture()) {
    327403        LOG(Plugins, "%p Script is processing user gesture, set to play", this);
     
    329405    }
    330406
    331     LayoutRect rect = toRenderSnapshottedPlugIn(renderer())->contentBoxRect();
     407    LayoutRect rect = toRenderEmbeddedObject(renderer())->contentBoxRect();
    332408    int width = rect.width();
    333409    int height = rect.height();
     
    352428
    353429    if (shouldPlugInShowLabelAutomatically(document()->page()->mainFrame()->view()->contentsSize(), this))
    354         toRenderSnapshottedPlugIn(renderer())->setShouldShowLabelAutomatically();
     430        setShouldShowSnapshotLabelAutomatically();
    355431
    356432    LOG(Plugins, "%p Plug-in hash %x is %dx%d, origin is not auto-start, set to wait for snapshot", this, m_plugInOriginHash, width, height);
    357     setDisplayState(WaitingForSnapshot);
     433    // We may have got to this point by restarting a snapshotted plug-in, in which case we don't want to
     434    // reset the display state.
     435    if (displayState() != PlayingWithPendingMouseClick)
     436        setDisplayState(WaitingForSnapshot);
    358437}
    359438
  • trunk/Source/WebCore/html/HTMLPlugInImageElement.h

    r142400 r142507  
    2626#include "RenderStyle.h"
    2727#include <wtf/OwnPtr.h>
     28#include <wtf/RefPtr.h>
    2829
    2930namespace WebCore {
     
    3132class HTMLImageLoader;
    3233class FrameLoader;
     34class Image;
    3335class MouseEvent;
    3436class Widget;
     
    3840    CreateOnlyNonNetscapePlugins,
    3941};
    40    
     42
    4143enum PreferPlugInsForImagesOption {
    4244    ShouldPreferPlugInsForImages,
     
    9395    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
    9496    virtual bool willRecalcStyle(StyleChange);
    95    
     97
     98    void didAddUserAgentShadowRoot(ShadowRoot*) OVERRIDE;
     99
    96100    virtual void finishParsingChildren();
    97101
    98102    void updateWidgetIfNecessary();
    99103    virtual bool useFallbackContent() const { return false; }
    100    
     104
    101105    virtual void updateSnapshot(PassRefPtr<Image>) OVERRIDE;
    102106    virtual void dispatchPendingMouseClick() OVERRIDE;
    103107    void simulatedMouseClickTimerFired(DeferrableOneShotTimer<HTMLPlugInImageElement>*);
    104108
     109    void swapRendererTimerFired(Timer<HTMLPlugInImageElement>*);
     110
     111    void setShouldShowSnapshotLabelAutomatically() { m_shouldShowSnapshotLabelAutomatically = true; }
     112
    105113    bool m_needsWidgetUpdate;
    106114    bool m_shouldPreferPlugInsForImages;
    107115    bool m_needsDocumentActivationCallbacks;
     116    bool m_shouldShowSnapshotLabelAutomatically;
    108117    RefPtr<RenderStyle> m_customStyleForPageCache;
    109118    RefPtr<MouseEvent> m_pendingClickEventFromSnapshot;
    110119    DeferrableOneShotTimer<HTMLPlugInImageElement> m_simulatedMouseClickTimer;
     120    Timer<HTMLPlugInImageElement> m_swapRendererTimer;
     121    RefPtr<Image> m_snapshotImage;
    111122};
    112123
  • trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp

    r142271 r142507  
    960960void InspectorCSSAgent::willMatchRule(StyleRule* rule, StyleResolver* styleResolver)
    961961{
     962//    printf("InspectorCSSAgent::willMatchRule %s\n", rule->selectorList().selectorsText().utf8().data());
    962963    if (m_currentSelectorProfile)
    963964        m_currentSelectorProfile->startSelector(styleResolver->inspectorCSSOMWrappers().getWrapperForRuleInSheets(rule, styleResolver->document()->styleSheetCollection()));
  • trunk/Source/WebCore/page/ChromeClient.h

    r142400 r142507  
    374374    virtual bool isEmptyChromeClient() const { return false; }
    375375
    376     virtual PassRefPtr<Image> plugInStartLabelImage(RenderSnapshottedPlugIn::LabelSize) const { return 0; }
    377376    virtual String plugInStartLabelTitle() const { return String(); }
    378377    virtual String plugInStartLabelSubtitle() const { return String(); }
  • trunk/Source/WebCore/platform/LocalizedStrings.cpp

    r142400 r142507  
    11/*
    2  * Copyright (C) 2003, 2006, 2009, 2010, 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2003, 2006, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
    33 * Copyright (C) 2010 Igalia S.L
    44 *
  • trunk/Source/WebCore/platform/LocalizedStrings.h

    r142400 r142507  
    11/*
    2  * Copyright (C) 2003, 2006, 2009, 2011 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2003, 2006, 2009, 2011, 2012, 2013 Apple Inc.  All rights reserved.
    33 * Copyright (C) 2010 Igalia S.L
    44 *
  • trunk/Source/WebCore/platform/blackberry/LocalizedStringsBlackBerry.cpp

    r142400 r142507  
    618618}
    619619
     620String snapshottedPlugInLabelTitle()
     621{
     622    notImplemented();
     623    return String();
     624}
     625
     626String snapshottedPlugInLabelSubtitle()
     627{
     628    notImplemented();
     629    return String();
     630}
     631
    620632} // namespace WebCore
  • trunk/Source/WebCore/platform/chromium/LocalizedStringsChromium.cpp

    r142400 r142507  
    417417String contextMenuItemTagMediaPause() { return String(); }
    418418String contextMenuItemTagMediaMute() { return String(); }
     419String snapshottedPlugInLabelTitle() { return String(); }
     420String snapshottedPlugInLabelSubtitle() { return String(); }
    419421
    420422#if ENABLE(VIDEO_TRACK)
  • trunk/Source/WebCore/platform/efl/LocalizedStringsEfl.cpp

    r142400 r142507  
    611611#endif
    612612
    613 }
     613String snapshottedPlugInLabelTitle()
     614{
     615    return String("Snapshotted Plug-In");
     616}
     617
     618String snapshottedPlugInLabelSubtitle()
     619{
     620    return String("Click to restart");
     621}
     622
     623
     624}
  • trunk/Source/WebCore/platform/gtk/LocalizedStringsGtk.cpp

    r142463 r142507  
    775775#endif
    776776
    777 }
     777String snapshottedPlugInLabelTitle()
     778{
     779    return String::fromUTF8(C_("Snapshotted Plug-In", "Title of the label to show on a snapshotted plug-in"));
     780}
     781
     782String snapshottedPlugInLabelSubtitle()
     783{
     784    return String::fromUTF8(C_("Click to restart", "Subtitle of the label to show on a snapshotted plug-in"));
     785}
     786
     787}
  • trunk/Source/WebCore/platform/qt/LocalizedStringsQt.cpp

    r142400 r142507  
    724724}
    725725
     726String snapshottedPlugInLabelTitle()
     727{
     728    notImplemented();
     729    return String();
     730}
     731
     732String snapshottedPlugInLabelSubtitle()
     733{
     734    notImplemented();
     735    return String();
     736}
     737
    726738String localizedString(const char* key)
    727739{
  • trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp

    r142400 r142507  
    4141#include "PaintInfo.h"
    4242#include "Path.h"
     43#include "RenderView.h"
    4344#include "SourceGraphic.h"
    4445
     
    4748static const int autoStartPlugInSizeThresholdWidth = 1;
    4849static const int autoStartPlugInSizeThresholdHeight = 1;
    49 static const int startLabelPadding = 10; // Label should be 10px from edge of box.
    50 static const int startLabelInset = 20; // But the label is inset from its box also. FIXME: This will be removed when we go to a ShadowDOM approach.
    5150static const double showLabelAfterMouseOverDelay = 1;
    5251static const double showLabelAutomaticallyDelay = 3;
     
    101100
    102101RenderSnapshottedPlugIn::RenderSnapshottedPlugIn(HTMLPlugInImageElement* element)
    103     : RenderEmbeddedObject(element)
     102    : RenderBlock(element)
    104103    , m_snapshotResource(RenderImageResource::create())
    105104    , m_shouldShowLabel(false)
     
    146145void RenderSnapshottedPlugIn::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    147146{
    148     if (plugInImageElement()->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick) {
    149         RenderReplaced::paint(paintInfo, paintOffset);
    150         return;
    151     }
    152 
    153     RenderEmbeddedObject::paint(paintInfo, paintOffset);
    154 }
    155 
    156 void RenderSnapshottedPlugIn::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    157 {
    158     if (plugInImageElement()->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick) {
     147    if (paintInfo.phase == PaintPhaseBlockBackground && plugInImageElement()->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick) {
    159148        if (m_shouldShowLabel)
    160             paintReplacedSnapshotWithLabel(paintInfo, paintOffset);
     149            paintSnapshotWithLabel(paintInfo, paintOffset);
    161150        else
    162             paintReplacedSnapshot(paintInfo, paintOffset);
    163         return;
    164     }
    165 
    166     RenderEmbeddedObject::paintReplaced(paintInfo, paintOffset);
    167 }
    168 
    169 void RenderSnapshottedPlugIn::paintSnapshot(Image* image, PaintInfo& paintInfo, const LayoutPoint& paintOffset)
     151            paintSnapshot(paintInfo, paintOffset);
     152    }
     153
     154    RenderBlock::paint(paintInfo, paintOffset);
     155}
     156
     157void RenderSnapshottedPlugIn::paintSnapshotImage(Image* image, PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    170158{
    171159    LayoutUnit cWidth = contentWidth();
     
    181169
    182170    LayoutSize contentSize(cWidth, cHeight);
    183     LayoutPoint contentLocation = paintOffset;
     171    LayoutPoint contentLocation = location() + paintOffset;
    184172    contentLocation.move(borderLeft() + paddingLeft(), borderTop() + paddingTop());
    185173
     
    193181}
    194182
    195 void RenderSnapshottedPlugIn::paintReplacedSnapshot(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
     183void RenderSnapshottedPlugIn::paintSnapshot(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    196184{
    197185    RefPtr<Image> image = m_snapshotResource->image();
     
    199187        return;
    200188
    201     paintSnapshot(image.get(), paintInfo, paintOffset);
    202 }
    203 
    204 Image* RenderSnapshottedPlugIn::startLabelImage(LabelSize size) const
    205 {
    206     static Image* labelImages[2] = { 0, 0 };
    207     static bool initializedImages[2] = { false, false };
    208 
    209     int arrayIndex = static_cast<int>(size);
    210     if (labelImages[arrayIndex])
    211         return labelImages[arrayIndex];
    212     if (initializedImages[arrayIndex])
    213         return 0;
    214 
    215     if (document()->page()) {
    216         labelImages[arrayIndex] = document()->page()->chrome()->client()->plugInStartLabelImage(size).leakRef();
    217         initializedImages[arrayIndex] = true;
    218     }
    219     return labelImages[arrayIndex];
     189    paintSnapshotImage(image.get(), paintInfo, paintOffset);
    220190}
    221191
     
    239209#endif
    240210
    241 void RenderSnapshottedPlugIn::paintReplacedSnapshotWithLabel(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
     211void RenderSnapshottedPlugIn::paintSnapshotWithLabel(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    242212{
    243213    if (contentBoxRect().isEmpty())
     
    248218
    249219    m_showedLabelOnce = true;
    250     LayoutRect rect = contentBoxRect();
    251     LayoutRect labelRect = tryToFitStartLabel(LabelSizeLarge, rect);
    252     LabelSize size = NoLabel;
    253     if (!labelRect.isEmpty())
    254         size = LabelSizeLarge;
    255     else {
    256         labelRect = tryToFitStartLabel(LabelSizeSmall, rect);
    257         if (!labelRect.isEmpty())
    258             size = LabelSizeSmall;
    259         else
    260             return;
    261     }
    262 
    263     Image* labelImage = startLabelImage(size);
    264     if (!labelImage)
    265         return;
     220    LayoutRect labelRect;
    266221
    267222    RefPtr<Image> snapshotImage = m_snapshotResource->image();
     
    270225
    271226#if ENABLE(FILTERS)
    272     RefPtr<Image> blurredSnapshotImage = m_snapshotResourceForLabel->image();
    273     if (!blurredSnapshotImage || blurredSnapshotImage->isNull()) {
    274         blurredSnapshotImage = snapshottedPluginImageForLabelDisplay(snapshotImage, labelRect);
    275         m_snapshotResourceForLabel->setCachedImage(new CachedImage(blurredSnapshotImage.get()));
    276     }
    277     snapshotImage = blurredSnapshotImage;
     227    // FIXME: Temporarily disabling the blur behind the label.
     228    // https://bugs.webkit.org/show_bug.cgi?id=108368
     229    if (!labelRect.isEmpty()) {
     230        RefPtr<Image> blurredSnapshotImage = m_snapshotResourceForLabel->image();
     231        if (!blurredSnapshotImage || blurredSnapshotImage->isNull()) {
     232            blurredSnapshotImage = snapshottedPluginImageForLabelDisplay(snapshotImage, labelRect);
     233            m_snapshotResourceForLabel->setCachedImage(new CachedImage(blurredSnapshotImage.get()));
     234        }
     235        snapshotImage = blurredSnapshotImage;
     236    }
    278237#endif
    279238
    280     paintSnapshot(snapshotImage.get(), paintInfo, paintOffset);
    281 
    282     // Remember that the labelRect includes the label inset, so we need to adjust for it.
    283     paintInfo.context->drawImage(labelImage, ColorSpaceDeviceRGB,
    284                                  IntRect(roundedIntPoint(paintOffset + labelRect.location() - IntSize(startLabelInset, startLabelInset)),
    285                                          roundedIntSize(labelRect.size() + IntSize(2 * startLabelInset, 2 * startLabelInset))),
    286                                  labelImage->rect());
     239    paintSnapshotImage(snapshotImage.get(), paintInfo, paintOffset);
    287240}
    288241
     
    310263        return SetCursor;
    311264    }
    312     return RenderEmbeddedObject::getCursor(point, overrideCursor);
     265    return RenderBlock::getCursor(point, overrideCursor);
    313266}
    314267
     
    326279        plugInImageElement()->setDisplayState(HTMLPlugInElement::PlayingWithPendingMouseClick);
    327280        plugInImageElement()->userDidClickSnapshot(mouseEvent);
    328 
    329         if (widget()) {
    330             if (Frame* frame = document()->frame())
    331                 frame->loader()->client()->recreatePlugin(widget());
    332             repaint();
    333         }
    334281        event->setDefaultHandled();
    335282    } else if (event->type() == eventNames().mousedownEvent) {
     
    359306}
    360307
    361 LayoutRect RenderSnapshottedPlugIn::tryToFitStartLabel(LabelSize size, const LayoutRect& contentBox) const
    362 {
    363     Image* labelImage = startLabelImage(size);
    364     if (!labelImage)
    365         return LayoutRect();
    366 
    367     // Assume that the labelImage has been provided to match our device scale.
    368     float scaleFactor = 1;
    369     if (document()->page())
    370         scaleFactor = document()->page()->deviceScaleFactor();
    371     IntSize labelImageSize = labelImage->size();
    372     labelImageSize.scale(1 / (scaleFactor ? scaleFactor : 1));
    373 
    374     LayoutSize labelSize = labelImageSize - LayoutSize(2 * startLabelInset, 2 * startLabelInset);
    375     LayoutRect candidateRect(contentBox.maxXMinYCorner() + LayoutSize(-startLabelPadding, startLabelPadding) + LayoutSize(-labelSize.width(), 0), labelSize);
    376     // The minimum allowed content box size is the label image placed in the center of the box, surrounded by startLabelPadding.
    377     if (candidateRect.x() < startLabelPadding || candidateRect.maxY() > contentBox.height() - startLabelPadding)
    378         return LayoutRect();
    379     return candidateRect;
    380 }
    381 
    382308void RenderSnapshottedPlugIn::resetDelayTimer(ShowReason reason)
    383309{
  • trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h

    r142400 r142507  
    2828
    2929#include "RenderBlock.h"
    30 #include "RenderEmbeddedObject.h"
    3130#include "RenderImageResource.h"
    3231#include "Timer.h"
     
    3635class HTMLPlugInImageElement;
    3736
    38 class RenderSnapshottedPlugIn : public RenderEmbeddedObject {
     37class RenderSnapshottedPlugIn : public RenderBlock {
    3938public:
    4039    explicit RenderSnapshottedPlugIn(HTMLPlugInImageElement*);
    4140    virtual ~RenderSnapshottedPlugIn();
    42 
    43     enum LabelSize {
    44         LabelSizeSmall,
    45         LabelSizeLarge,
    46         NoLabel,
    47     };
    4841
    4942    void updateSnapshot(PassRefPtr<Image>);
     
    6154    virtual bool isSnapshottedPlugIn() const OVERRIDE { return true; }
    6255    virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE;
    63     virtual void paintReplaced(PaintInfo&, const LayoutPoint&) OVERRIDE;
    6456
    65     void paintReplacedSnapshot(PaintInfo&, const LayoutPoint&);
    66     void paintReplacedSnapshotWithLabel(PaintInfo&, const LayoutPoint&);
    67     void paintSnapshot(Image*, PaintInfo&, const LayoutPoint&);
     57    void paintSnapshot(PaintInfo&, const LayoutPoint&);
     58    void paintSnapshotWithLabel(PaintInfo&, const LayoutPoint&);
     59    void paintSnapshotImage(Image*, PaintInfo&, const LayoutPoint&);
    6860    void repaintLabel();
    69 
    70     LayoutRect tryToFitStartLabel(LabelSize, const LayoutRect& contentBox) const;
    71     Image* startLabelImage(LabelSize) const;
    7261
    7362    enum ShowReason {
  • trunk/Source/WebKit2/ChangeLog

    r142502 r142507  
     12013-02-11  Dean Jackson  <dino@apple.com>
     2
     3        Snapshotted plug-in should use shadow root
     4        https://bugs.webkit.org/show_bug.cgi?id=108284
     5
     6        Reviewed by Simon Fraser.
     7
     8        Take three of this commit - after rollout in r142400 and r142405.
     9        We no longer have any need for plugInStartLabelImage.
     10
     11        * WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp: Remove plugInStartLabelImage.
     12        * WebProcess/InjectedBundle/InjectedBundlePageUIClient.h: Ditto.
     13        * WebProcess/WebCoreSupport/WebChromeClient.cpp: Ditto.
     14        * WebProcess/WebCoreSupport/WebChromeClient.h: Ditto.
     15
    1162013-02-11  Anders Carlsson  <andersca@apple.com>
    217
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h

    r142405 r142507  
    247247typedef void (*WKBundlePageReachedAppCacheOriginQuotaCallback)(WKBundlePageRef page, WKSecurityOriginRef origin, int64_t totalBytesNeeded, const void *clientInfo);
    248248typedef 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);
    249 typedef WKImageRef (*WKBundlePagePlugInStartLabelImageCallback)(WKBundlePageLabelSize size, const void *clientInfo);
    250249typedef WKStringRef (*WKBundlePagePlugInCreateStartLabelTitleCallback)(const void *clientInfo);
    251250typedef WKStringRef (*WKBundlePagePlugInCreateStartLabelSubtitleCallback)(const void *clientInfo);
     
    275274    // Version 2.
    276275    WKBundlePageExceededDatabaseQuotaCallback                           didExceedDatabaseQuota;
    277     WKBundlePagePlugInStartLabelImageCallback                           plugInStartLabelImage;
    278276    WKBundlePagePlugInCreateStartLabelTitleCallback                     createPlugInStartLabelTitle;
    279277    WKBundlePagePlugInCreateStartLabelSubtitleCallback                  createPlugInStartLabelSubtitle;
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp

    r142405 r142507  
    164164}
    165165
    166 PassRefPtr<WebImage> InjectedBundlePageUIClient::plugInStartLabelImage(RenderSnapshottedPlugIn::LabelSize size) const
    167 {
    168     if (!m_client.plugInStartLabelImage)
    169         return 0;
    170 
    171     WKBundlePageLabelSize wkSize;
    172     switch (size) {
    173     case RenderSnapshottedPlugIn::LabelSizeSmall:
    174         wkSize = WKBundlePageLabelSizeSmall;
    175         break;
    176     case RenderSnapshottedPlugIn::LabelSizeLarge:
    177         wkSize = WKBundlePageLabelSizeLarge;
    178         break;
    179     default:
    180         return 0;
    181     }
    182 
    183     return adoptRef(toImpl(m_client.plugInStartLabelImage(wkSize, m_client.clientInfo)));
    184 }
    185 
    186166String InjectedBundlePageUIClient::plugInStartLabelTitle() const
    187167{
    188     return String();
     168    if (!m_client.createPlugInStartLabelTitle)
     169        return String();
     170
     171    RefPtr<WebString> title = adoptRef(toImpl(m_client.createPlugInStartLabelTitle(m_client.clientInfo)));
     172    return title ? title->string() : String();
    189173}
    190174
    191175String InjectedBundlePageUIClient::plugInStartLabelSubtitle() const
    192176{
    193     return String();
     177    if (!m_client.createPlugInStartLabelSubtitle)
     178        return String();
     179
     180    RefPtr<WebString> subtitle = adoptRef(toImpl(m_client.createPlugInStartLabelSubtitle(m_client.clientInfo)));
     181    return subtitle ? subtitle->string() : String();
    194182}
    195183
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h

    r142400 r142507  
    3030#include "WKBundlePage.h"
    3131#include "WebEvent.h"
    32 #include "WebImage.h"
    3332#include <WebCore/RenderSnapshottedPlugIn.h>
    3433#include <wtf/Forward.h>
     
    7271    uint64_t didExceedDatabaseQuota(WebPage*, WebSecurityOrigin*, const String& databaseName, const String& databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes);
    7372
    74     PassRefPtr<WebImage> plugInStartLabelImage(WebCore::RenderSnapshottedPlugIn::LabelSize) const;
    7573    String plugInStartLabelTitle() const;
    7674    String plugInStartLabelSubtitle() const;
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r142400 r142507  
    799799}
    800800
    801 PassRefPtr<Image> WebChromeClient::plugInStartLabelImage(RenderSnapshottedPlugIn::LabelSize size) const
    802 {
    803     return m_page->injectedBundleUIClient().plugInStartLabelImage(size)->bitmap()->createImage();
    804 }
    805 
    806801String WebChromeClient::plugInStartLabelTitle() const
    807802{
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h

    r142400 r142507  
    2929
    3030#include <WebCore/ChromeClient.h>
    31 #include <WebCore/Image.h>
    3231#include <WebCore/ViewportArguments.h>
    3332#include <wtf/text/WTFString.h>
     
    219218    virtual void logDiagnosticMessage(const String& message, const String& description, const String& success) OVERRIDE;
    220219
    221     virtual PassRefPtr<WebCore::Image> plugInStartLabelImage(WebCore::RenderSnapshottedPlugIn::LabelSize) const OVERRIDE;
    222220    virtual String plugInStartLabelTitle() const OVERRIDE;
    223221    virtual String plugInStartLabelSubtitle() const OVERRIDE;
  • trunk/Tools/ChangeLog

    r142499 r142507  
     12013-02-11  Dean Jackson  <dino@apple.com>
     2
     3        Remove use of plugInStartLabelImage
     4        https://bugs.webkit.org/show_bug.cgi?id=108273
     5
     6        Reviewed by Simon Fraser.
     7
     8        Take two - after rollout in r142405.
     9        Removed plugInStartLabelImage entry from client structure.
     10
     11        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
     12        (WTR::InjectedBundlePage::InjectedBundlePage):
     13
    1142013-02-11  Tony Chang  <tony@chromium.org>
    215
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp

    r142405 r142507  
    369369        didReachApplicationCacheOriginQuota,
    370370        didExceedDatabaseQuota,
    371         0, /*plugInStartLabelImage*/
    372371        0, /*plugInStartLabelTitle*/
    373372        0, /*plugInStartLabelSubtitle*/
Note: See TracChangeset for help on using the changeset viewer.