Changeset 142400 in webkit


Ignore:
Timestamp:
Feb 10, 2013 6:24:46 AM (11 years ago)
Author:
tkent@chromium.org
Message:

Unreviewed, rolling out r142343.
http://trac.webkit.org/changeset/142343
https://bugs.webkit.org/show_bug.cgi?id=108284

It might make inspector/profiler/selector-profiler-url.html
crashy.

Source/WebCore:

  • WebCore.exp.in:
  • css/plugIns.css:

(p):

  • html/HTMLPlugInElement.cpp:

(WebCore::HTMLPlugInElement::defaultEventHandler):

  • html/HTMLPlugInImageElement.cpp:

(WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement):
(WebCore::HTMLPlugInImageElement::createRenderer):
(WebCore::HTMLPlugInImageElement::willRecalcStyle):
(WebCore::HTMLPlugInImageElement::updateSnapshot):
(WebCore::HTMLPlugInImageElement::userDidClickSnapshot):
(WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn):

  • html/HTMLPlugInImageElement.h:

(WebCore):
(HTMLPlugInImageElement):

  • page/ChromeClient.h:

(WebCore::ChromeClient::plugInStartLabelImage):

  • platform/LocalizedStrings.cpp:
  • platform/LocalizedStrings.h:
  • platform/blackberry/LocalizedStringsBlackBerry.cpp:
  • platform/chromium/LocalizedStringsChromium.cpp:
  • platform/efl/LocalizedStringsEfl.cpp:

(WebCore):

  • platform/gtk/LocalizedStringsGtk.cpp:

(WebCore):

  • platform/qt/LocalizedStringsQt.cpp:
  • rendering/RenderSnapshottedPlugIn.cpp:

(WebCore):
(WebCore::RenderSnapshottedPlugIn::RenderSnapshottedPlugIn):
(WebCore::RenderSnapshottedPlugIn::paint):
(WebCore::RenderSnapshottedPlugIn::paintReplaced):
(WebCore::RenderSnapshottedPlugIn::paintSnapshot):
(WebCore::RenderSnapshottedPlugIn::paintReplacedSnapshot):
(WebCore::RenderSnapshottedPlugIn::startLabelImage):
(WebCore::RenderSnapshottedPlugIn::paintReplacedSnapshotWithLabel):
(WebCore::RenderSnapshottedPlugIn::getCursor):
(WebCore::RenderSnapshottedPlugIn::handleEvent):
(WebCore::RenderSnapshottedPlugIn::tryToFitStartLabel):

  • rendering/RenderSnapshottedPlugIn.h:

Source/WebKit2:

  • WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp:

(WebKit::InjectedBundlePageUIClient::plugInStartLabelImage):
(WebKit):

  • WebProcess/InjectedBundle/InjectedBundlePageUIClient.h:

(InjectedBundlePageUIClient):

  • WebProcess/WebCoreSupport/WebChromeClient.cpp:

(WebKit::WebChromeClient::plugInStartLabelImage):
(WebKit):

  • WebProcess/WebCoreSupport/WebChromeClient.h:

(WebChromeClient):

Location:
trunk/Source
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r142398 r142400  
     12013-02-10  Kent Tamura  <tkent@chromium.org>
     2
     3        Unreviewed, rolling out r142343.
     4        http://trac.webkit.org/changeset/142343
     5        https://bugs.webkit.org/show_bug.cgi?id=108284
     6
     7        It might make inspector/profiler/selector-profiler-url.html
     8        crashy.
     9
     10        * WebCore.exp.in:
     11        * css/plugIns.css:
     12        (p):
     13        * html/HTMLPlugInElement.cpp:
     14        (WebCore::HTMLPlugInElement::defaultEventHandler):
     15        * html/HTMLPlugInImageElement.cpp:
     16        (WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement):
     17        (WebCore::HTMLPlugInImageElement::createRenderer):
     18        (WebCore::HTMLPlugInImageElement::willRecalcStyle):
     19        (WebCore::HTMLPlugInImageElement::updateSnapshot):
     20        (WebCore::HTMLPlugInImageElement::userDidClickSnapshot):
     21        (WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn):
     22        * html/HTMLPlugInImageElement.h:
     23        (WebCore):
     24        (HTMLPlugInImageElement):
     25        * page/ChromeClient.h:
     26        (WebCore::ChromeClient::plugInStartLabelImage):
     27        * platform/LocalizedStrings.cpp:
     28        * platform/LocalizedStrings.h:
     29        * platform/blackberry/LocalizedStringsBlackBerry.cpp:
     30        * platform/chromium/LocalizedStringsChromium.cpp:
     31        * platform/efl/LocalizedStringsEfl.cpp:
     32        (WebCore):
     33        * platform/gtk/LocalizedStringsGtk.cpp:
     34        (WebCore):
     35        * platform/qt/LocalizedStringsQt.cpp:
     36        * rendering/RenderSnapshottedPlugIn.cpp:
     37        (WebCore):
     38        (WebCore::RenderSnapshottedPlugIn::RenderSnapshottedPlugIn):
     39        (WebCore::RenderSnapshottedPlugIn::paint):
     40        (WebCore::RenderSnapshottedPlugIn::paintReplaced):
     41        (WebCore::RenderSnapshottedPlugIn::paintSnapshot):
     42        (WebCore::RenderSnapshottedPlugIn::paintReplacedSnapshot):
     43        (WebCore::RenderSnapshottedPlugIn::startLabelImage):
     44        (WebCore::RenderSnapshottedPlugIn::paintReplacedSnapshotWithLabel):
     45        (WebCore::RenderSnapshottedPlugIn::getCursor):
     46        (WebCore::RenderSnapshottedPlugIn::handleEvent):
     47        (WebCore::RenderSnapshottedPlugIn::tryToFitStartLabel):
     48        * rendering/RenderSnapshottedPlugIn.h:
     49
    1502013-02-10  Andreas Kling  <akling@apple.com>
    251
  • trunk/Source/WebCore/WebCore.exp.in

    r142381 r142400  
    140140__ZN7WebCore11HistoryItemC1Ev
    141141__ZN7WebCore11HistoryItemD1Ev
    142 __ZNK7WebCore9InlineBox14caretMaxOffsetEv
    143 __ZN7WebCore9InlineBox14selectionStateEv
    144 __ZN7WebCore9InlineBox14dirtyLineBoxesEv
    145 __ZNK7WebCore9InlineBox22canAccommodateEllipsisEbii
    146 __ZN7WebCore9InlineBox11extractLineEv
    147 __ZN7WebCore9InlineBox14adjustPositionEff
    148 __ZN7WebCore9InlineBoxdlEPvm
    149 __ZN7WebCore9InlineBox5paintERNS_9PaintInfoERKNS_11LayoutPointENS_10LayoutUnitES6_
    150 __ZN7WebCore9InlineBox10attachLineEv
    151 __ZNK7WebCore9InlineBox16baselinePositionENS_12FontBaselineE
    152 __ZN7WebCore9InlineBox11nodeAtPointERKNS_14HitTestRequestERNS_13HitTestResultERKNS_15HitTestLocationERKNS_11LayoutPointENS_10LayoutUnitESC_
    153 __ZN7WebCore9InlineBox10deleteLineEPNS_11RenderArenaE
    154 __ZN7WebCore9InlineBox7destroyEPNS_11RenderArenaE
    155 __ZN7WebCore9InlineBox16placeEllipsisBoxEbfffRfRb
    156 __ZNK7WebCore9InlineBox17reportMemoryUsageEPN3WTF16MemoryObjectInfoE
    157 __ZNK7WebCore9InlineBox14caretMinOffsetEv
    158 __ZNK7WebCore9InlineBox10lineHeightEv
    159142__ZN7WebCore11JSDOMWindow6s_infoE
    160143__ZN7WebCore11MemoryCache11setDisabledEb
  • trunk/Source/WebCore/css/plugIns.css

    r142343 r142400  
    2323 */
    2424
    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 
    44 object::-webkit-snapshotted-plugin-content,
    45 embed::-webkit-snapshotted-plugin-content
    46 {
    47     position: relative;
    48     display: inline-block;
    49     width: 100%;
    50     height: 100%;
    51 }
    52 
    53 object::-webkit-snapshotted-plugin-content *,
    54 embed::-webkit-snapshotted-plugin-content *
    55 {
    56     -webkit-user-select: none;
    57 }
    58 
    59 object::-webkit-snapshotted-plugin-content .snapshot-container,
    60 embed::-webkit-snapshotted-plugin-content .snapshot-container
    61 {
    62     position: absolute;
    63     width: 100%;
    64     height: 100%;
    65 }
    66 
    67 object::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-overlay,
    68 embed::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-overlay
    69 {
    70     display: none;
    71 }
    72 
    73 object::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label,
    74 embed::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label
    75 {
    76     position: absolute;
    77     background-color: white;
    78     color: black;
    79     margin: 1em;
    80     padding: 0.25em 2em;
    81     text-align: center;
    82 }
    83 
    84 object::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label .snapshot-title,
    85 embed::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label .snapshot-title
    86 {
    87     font-weight: bold;
    88 }
    89 
    90 object::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label .snapshot-subtitle,
    91 embed::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label .snapshot-subtitle
    92 {
    93     font-style: italic;
    94     color: #444;
    95 }
     25/* plug-ins */
     26p{} /*Needed by Windows because it doesn't like empty files*/
  • trunk/Source/WebCore/html/HTMLPlugInElement.cpp

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

    r142343 r142400  
    2222#include "HTMLPlugInImageElement.h"
    2323
    24 #include "Chrome.h"
    25 #include "ChromeClient.h"
    2624#include "Frame.h"
    2725#include "FrameLoader.h"
    2826#include "FrameLoaderClient.h"
    2927#include "FrameView.h"
    30 #include "HTMLDivElement.h"
    3128#include "HTMLImageLoader.h"
     29#include "HTMLNames.h"
    3230#include "Image.h"
    33 #include "LocalizedStrings.h"
    3431#include "Logging.h"
    3532#include "MouseEvent.h"
    3633#include "NodeRenderStyle.h"
    37 #include "NodeRenderingContext.h"
    3834#include "Page.h"
    3935#include "PlugInClient.h"
     
    4642#include "SecurityOrigin.h"
    4743#include "Settings.h"
    48 #include "ShadowRoot.h"
    4944#include "StyleResolver.h"
    50 #include "Text.h"
    5145
    5246namespace WebCore {
    53 
    54 using namespace HTMLNames;
    5547
    5648static const int autoStartPlugInSizeThresholdWidth = 1;
     
    7062    , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPreferPlugInsForImages)
    7163    , m_needsDocumentActivationCallbacks(false)
    72     , m_shouldShowSnapshotLabelAutomatically(false)
    7364    , m_simulatedMouseClickTimer(this, &HTMLPlugInImageElement::simulatedMouseClickTimerFired, simulatedMouseClickTimerDelay)
    74     , m_swapRendererTimer(this, &HTMLPlugInImageElement::swapRendererTimerFired)
    7565{
    7666    setHasCustomCallbacks();
     
    143133        document()->registerForPageCacheSuspensionCallbacks(this);
    144134    }
    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 
     135   
    154136    // Fallback content breaks the DOM->Renderer class relationship of this
    155137    // class and all superclasses because createObject won't necessarily
     
    157139    if (useFallbackContent())
    158140        return RenderObject::createObject(this, style);
    159 
    160141    if (isImageType()) {
    161142        RenderImage* image = new (arena) RenderImage(this);
     
    164145    }
    165146
     147    if (document()->page() && document()->page()->settings()->plugInSnapshottingEnabled())
     148        return new (arena) RenderSnapshottedPlugIn(this);
    166149    return new (arena) RenderEmbeddedObject(this);
    167150}
     
    170153{
    171154    // FIXME: Why is this necessary?  Manual re-attach is almost always wrong.
    172     if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageType() && (displayState() != DisplayingSnapshot))
     155    if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageType())
    173156        reattach();
    174157    return true;
     
    276259void HTMLPlugInImageElement::updateSnapshot(PassRefPtr<Image> image)
    277260{
    278     if (displayState() > DisplayingSnapshot)
    279         return;
    280 
    281     m_snapshotImage = image;
    282     if (renderer()->isSnapshottedPlugIn()) {
    283         toRenderSnapshottedPlugIn(renderer())->updateSnapshot(image);
    284         return;
    285     }
    286 
     261    if (displayState() > DisplayingSnapshot || !renderer()->isSnapshottedPlugIn())
     262        return;
     263
     264    toRenderSnapshottedPlugIn(renderer())->updateSnapshot(image);
    287265    setDisplayState(DisplayingSnapshot);
    288     m_swapRendererTimer.startOneShot(0);
    289 }
    290 
    291 void 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 
    335 void 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();
    344266}
    345267
     
    349271    if (document()->page() && !SchemeRegistry::shouldTreatURLSchemeAsLocal(document()->page()->mainFrame()->document()->baseURL().protocol()))
    350272        document()->page()->plugInClient()->addAutoStartOrigin(document()->page()->mainFrame()->document()->baseURL().host(), m_plugInOriginHash);
    351 
    352     reattach();
    353273}
    354274
     
    400320    }
    401321
     322    if (!renderer()->isSnapshottedPlugIn()) {
     323        LOG(Plugins, "%p Renderer is not snapshotted plugin, set to play", this);
     324        return;
     325    }
    402326    if (ScriptController::processingUserGesture()) {
    403327        LOG(Plugins, "%p Script is processing user gesture, set to play", this);
     
    405329    }
    406330
    407     LayoutRect rect = toRenderEmbeddedObject(renderer())->contentBoxRect();
     331    LayoutRect rect = toRenderSnapshottedPlugIn(renderer())->contentBoxRect();
    408332    int width = rect.width();
    409333    int height = rect.height();
     
    428352
    429353    if (shouldPlugInShowLabelAutomatically(document()->page()->mainFrame()->view()->contentsSize(), this))
    430         setShouldShowSnapshotLabelAutomatically();
     354        toRenderSnapshottedPlugIn(renderer())->setShouldShowLabelAutomatically();
    431355
    432356    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);
    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);
     357    setDisplayState(WaitingForSnapshot);
    437358}
    438359
  • trunk/Source/WebCore/html/HTMLPlugInImageElement.h

    r142343 r142400  
    2626#include "RenderStyle.h"
    2727#include <wtf/OwnPtr.h>
    28 #include <wtf/RefPtr.h>
    2928
    3029namespace WebCore {
     
    3231class HTMLImageLoader;
    3332class FrameLoader;
    34 class Image;
    3533class MouseEvent;
    3634class Widget;
     
    4038    CreateOnlyNonNetscapePlugins,
    4139};
    42 
     40   
    4341enum PreferPlugInsForImagesOption {
    4442    ShouldPreferPlugInsForImages,
     
    9593    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
    9694    virtual bool willRecalcStyle(StyleChange);
    97 
    98     void didAddUserAgentShadowRoot(ShadowRoot*) OVERRIDE;
    99 
     95   
    10096    virtual void finishParsingChildren();
    10197
    10298    void updateWidgetIfNecessary();
    10399    virtual bool useFallbackContent() const { return false; }
    104 
     100   
    105101    virtual void updateSnapshot(PassRefPtr<Image>) OVERRIDE;
    106102    virtual void dispatchPendingMouseClick() OVERRIDE;
    107103    void simulatedMouseClickTimerFired(DeferrableOneShotTimer<HTMLPlugInImageElement>*);
    108104
    109     void swapRendererTimerFired(Timer<HTMLPlugInImageElement>*);
    110 
    111     void setShouldShowSnapshotLabelAutomatically() { m_shouldShowSnapshotLabelAutomatically = true; }
    112 
    113105    bool m_needsWidgetUpdate;
    114106    bool m_shouldPreferPlugInsForImages;
    115107    bool m_needsDocumentActivationCallbacks;
    116     bool m_shouldShowSnapshotLabelAutomatically;
    117108    RefPtr<RenderStyle> m_customStyleForPageCache;
    118109    RefPtr<MouseEvent> m_pendingClickEventFromSnapshot;
    119110    DeferrableOneShotTimer<HTMLPlugInImageElement> m_simulatedMouseClickTimer;
    120     Timer<HTMLPlugInImageElement> m_swapRendererTimer;
    121     RefPtr<Image> m_snapshotImage;
    122111};
    123112
  • trunk/Source/WebCore/page/ChromeClient.h

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

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

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

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

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

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

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

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

    r142343 r142400  
    4141#include "PaintInfo.h"
    4242#include "Path.h"
    43 #include "RenderView.h"
    4443#include "SourceGraphic.h"
    4544
     
    4847static const int autoStartPlugInSizeThresholdWidth = 1;
    4948static const int autoStartPlugInSizeThresholdHeight = 1;
     49static const int startLabelPadding = 10; // Label should be 10px from edge of box.
     50static 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.
    5051static const double showLabelAfterMouseOverDelay = 1;
    5152static const double showLabelAutomaticallyDelay = 3;
     
    100101
    101102RenderSnapshottedPlugIn::RenderSnapshottedPlugIn(HTMLPlugInImageElement* element)
    102     : RenderBlock(element)
     103    : RenderEmbeddedObject(element)
    103104    , m_snapshotResource(RenderImageResource::create())
    104105    , m_shouldShowLabel(false)
     
    145146void RenderSnapshottedPlugIn::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    146147{
    147     if (paintInfo.phase == PaintPhaseBlockBackground && plugInImageElement()->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick) {
     148    if (plugInImageElement()->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick) {
     149        RenderReplaced::paint(paintInfo, paintOffset);
     150        return;
     151    }
     152
     153    RenderEmbeddedObject::paint(paintInfo, paintOffset);
     154}
     155
     156void RenderSnapshottedPlugIn::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
     157{
     158    if (plugInImageElement()->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick) {
    148159        if (m_shouldShowLabel)
    149             paintSnapshotWithLabel(paintInfo, paintOffset);
     160            paintReplacedSnapshotWithLabel(paintInfo, paintOffset);
    150161        else
    151             paintSnapshot(paintInfo, paintOffset);
    152     }
    153 
    154     RenderBlock::paint(paintInfo, paintOffset);
    155 }
    156 
    157 void RenderSnapshottedPlugIn::paintSnapshotImage(Image* image, PaintInfo& paintInfo, const LayoutPoint& paintOffset)
     162            paintReplacedSnapshot(paintInfo, paintOffset);
     163        return;
     164    }
     165
     166    RenderEmbeddedObject::paintReplaced(paintInfo, paintOffset);
     167}
     168
     169void RenderSnapshottedPlugIn::paintSnapshot(Image* image, PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    158170{
    159171    LayoutUnit cWidth = contentWidth();
     
    169181
    170182    LayoutSize contentSize(cWidth, cHeight);
    171     LayoutPoint contentLocation = location() + paintOffset;
     183    LayoutPoint contentLocation = paintOffset;
    172184    contentLocation.move(borderLeft() + paddingLeft(), borderTop() + paddingTop());
    173185
     
    181193}
    182194
    183 void RenderSnapshottedPlugIn::paintSnapshot(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
     195void RenderSnapshottedPlugIn::paintReplacedSnapshot(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    184196{
    185197    RefPtr<Image> image = m_snapshotResource->image();
     
    187199        return;
    188200
    189     paintSnapshotImage(image.get(), paintInfo, paintOffset);
     201    paintSnapshot(image.get(), paintInfo, paintOffset);
     202}
     203
     204Image* 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];
    190220}
    191221
     
    209239#endif
    210240
    211 void RenderSnapshottedPlugIn::paintSnapshotWithLabel(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
     241void RenderSnapshottedPlugIn::paintReplacedSnapshotWithLabel(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    212242{
    213243    if (contentBoxRect().isEmpty())
     
    218248
    219249    m_showedLabelOnce = true;
    220     LayoutRect labelRect;
     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;
    221266
    222267    RefPtr<Image> snapshotImage = m_snapshotResource->image();
     
    225270
    226271#if ENABLE(FILTERS)
    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     }
     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;
    237278#endif
    238279
    239     paintSnapshotImage(snapshotImage.get(), paintInfo, paintOffset);
     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());
    240287}
    241288
     
    263310        return SetCursor;
    264311    }
    265     return RenderBlock::getCursor(point, overrideCursor);
     312    return RenderEmbeddedObject::getCursor(point, overrideCursor);
    266313}
    267314
     
    279326        plugInImageElement()->setDisplayState(HTMLPlugInElement::PlayingWithPendingMouseClick);
    280327        plugInImageElement()->userDidClickSnapshot(mouseEvent);
     328
     329        if (widget()) {
     330            if (Frame* frame = document()->frame())
     331                frame->loader()->client()->recreatePlugin(widget());
     332            repaint();
     333        }
    281334        event->setDefaultHandled();
    282335    } else if (event->type() == eventNames().mousedownEvent) {
     
    306359}
    307360
     361LayoutRect 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
    308382void RenderSnapshottedPlugIn::resetDelayTimer(ShowReason reason)
    309383{
  • trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h

    r142343 r142400  
    2828
    2929#include "RenderBlock.h"
     30#include "RenderEmbeddedObject.h"
    3031#include "RenderImageResource.h"
    3132#include "Timer.h"
     
    3536class HTMLPlugInImageElement;
    3637
    37 class RenderSnapshottedPlugIn : public RenderBlock {
     38class RenderSnapshottedPlugIn : public RenderEmbeddedObject {
    3839public:
    3940    explicit RenderSnapshottedPlugIn(HTMLPlugInImageElement*);
    4041    virtual ~RenderSnapshottedPlugIn();
     42
     43    enum LabelSize {
     44        LabelSizeSmall,
     45        LabelSizeLarge,
     46        NoLabel,
     47    };
    4148
    4249    void updateSnapshot(PassRefPtr<Image>);
     
    5461    virtual bool isSnapshottedPlugIn() const OVERRIDE { return true; }
    5562    virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE;
     63    virtual void paintReplaced(PaintInfo&, const LayoutPoint&) OVERRIDE;
    5664
    57     void paintSnapshot(PaintInfo&, const LayoutPoint&);
    58     void paintSnapshotWithLabel(PaintInfo&, const LayoutPoint&);
    59     void paintSnapshotImage(Image*, PaintInfo&, const LayoutPoint&);
     65    void paintReplacedSnapshot(PaintInfo&, const LayoutPoint&);
     66    void paintReplacedSnapshotWithLabel(PaintInfo&, const LayoutPoint&);
     67    void paintSnapshot(Image*, PaintInfo&, const LayoutPoint&);
    6068    void repaintLabel();
     69
     70    LayoutRect tryToFitStartLabel(LabelSize, const LayoutRect& contentBox) const;
     71    Image* startLabelImage(LabelSize) const;
    6172
    6273    enum ShowReason {
  • trunk/Source/WebKit2/ChangeLog

    r142393 r142400  
     12013-02-10  Kent Tamura  <tkent@chromium.org>
     2
     3        Unreviewed, rolling out r142343.
     4        http://trac.webkit.org/changeset/142343
     5        https://bugs.webkit.org/show_bug.cgi?id=108284
     6
     7        It might make inspector/profiler/selector-profiler-url.html
     8        crashy.
     9
     10        * WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp:
     11        (WebKit::InjectedBundlePageUIClient::plugInStartLabelImage):
     12        (WebKit):
     13        * WebProcess/InjectedBundle/InjectedBundlePageUIClient.h:
     14        (InjectedBundlePageUIClient):
     15        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     16        (WebKit::WebChromeClient::plugInStartLabelImage):
     17        (WebKit):
     18        * WebProcess/WebCoreSupport/WebChromeClient.h:
     19        (WebChromeClient):
     20
    1212013-02-10  Zan Dobersek  <zdobersek@igalia.com>
    222
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp

    r142347 r142400  
    164164}
    165165
     166PassRefPtr<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
    166186String InjectedBundlePageUIClient::plugInStartLabelTitle() const
    167187{
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h

    r142343 r142400  
    3030#include "WKBundlePage.h"
    3131#include "WebEvent.h"
     32#include "WebImage.h"
    3233#include <WebCore/RenderSnapshottedPlugIn.h>
    3334#include <wtf/Forward.h>
     
    7172    uint64_t didExceedDatabaseQuota(WebPage*, WebSecurityOrigin*, const String& databaseName, const String& databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes);
    7273
     74    PassRefPtr<WebImage> plugInStartLabelImage(WebCore::RenderSnapshottedPlugIn::LabelSize) const;
    7375    String plugInStartLabelTitle() const;
    7476    String plugInStartLabelSubtitle() const;
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp

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

    r142343 r142400  
    2929
    3030#include <WebCore/ChromeClient.h>
     31#include <WebCore/Image.h>
    3132#include <WebCore/ViewportArguments.h>
    3233#include <wtf/text/WTFString.h>
     
    218219    virtual void logDiagnosticMessage(const String& message, const String& description, const String& success) OVERRIDE;
    219220
     221    virtual PassRefPtr<WebCore::Image> plugInStartLabelImage(WebCore::RenderSnapshottedPlugIn::LabelSize) const OVERRIDE;
    220222    virtual String plugInStartLabelTitle() const OVERRIDE;
    221223    virtual String plugInStartLabelSubtitle() const OVERRIDE;
Note: See TracChangeset for help on using the changeset viewer.