Unreviewed, rolling out r142343.
authortkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 10 Feb 2013 14:24:46 +0000 (14:24 +0000)
committertkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 10 Feb 2013 14:24:46 +0000 (14:24 +0000)
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142400 268f45cc-cd09-0410-ab3c-d52691b4dbfc

21 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/css/plugIns.css
Source/WebCore/html/HTMLPlugInElement.cpp
Source/WebCore/html/HTMLPlugInImageElement.cpp
Source/WebCore/html/HTMLPlugInImageElement.h
Source/WebCore/page/ChromeClient.h
Source/WebCore/platform/LocalizedStrings.cpp
Source/WebCore/platform/LocalizedStrings.h
Source/WebCore/platform/blackberry/LocalizedStringsBlackBerry.cpp
Source/WebCore/platform/chromium/LocalizedStringsChromium.cpp
Source/WebCore/platform/efl/LocalizedStringsEfl.cpp
Source/WebCore/platform/gtk/LocalizedStringsGtk.cpp
Source/WebCore/platform/qt/LocalizedStringsQt.cpp
Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp
Source/WebCore/rendering/RenderSnapshottedPlugIn.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h

index 813ee43..84a87f7 100644 (file)
@@ -1,3 +1,52 @@
+2013-02-10  Kent Tamura  <tkent@chromium.org>
+
+        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.
+
+        * 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:
+
 2013-02-10  Andreas Kling  <akling@apple.com>
 
         RenderText: Access characters through m_text instead of caching data pointers separately.
index 4288c2b..6cef6e4 100644 (file)
@@ -139,23 +139,6 @@ __ZN7WebCore11HistoryItemC1ERKN3WTF6StringES4_d
 __ZN7WebCore11HistoryItemC1ERKNS_4KURLERKN3WTF6StringES7_S7_
 __ZN7WebCore11HistoryItemC1Ev
 __ZN7WebCore11HistoryItemD1Ev
-__ZNK7WebCore9InlineBox14caretMaxOffsetEv
-__ZN7WebCore9InlineBox14selectionStateEv
-__ZN7WebCore9InlineBox14dirtyLineBoxesEv
-__ZNK7WebCore9InlineBox22canAccommodateEllipsisEbii
-__ZN7WebCore9InlineBox11extractLineEv
-__ZN7WebCore9InlineBox14adjustPositionEff
-__ZN7WebCore9InlineBoxdlEPvm
-__ZN7WebCore9InlineBox5paintERNS_9PaintInfoERKNS_11LayoutPointENS_10LayoutUnitES6_
-__ZN7WebCore9InlineBox10attachLineEv
-__ZNK7WebCore9InlineBox16baselinePositionENS_12FontBaselineE
-__ZN7WebCore9InlineBox11nodeAtPointERKNS_14HitTestRequestERNS_13HitTestResultERKNS_15HitTestLocationERKNS_11LayoutPointENS_10LayoutUnitESC_
-__ZN7WebCore9InlineBox10deleteLineEPNS_11RenderArenaE
-__ZN7WebCore9InlineBox7destroyEPNS_11RenderArenaE
-__ZN7WebCore9InlineBox16placeEllipsisBoxEbfffRfRb
-__ZNK7WebCore9InlineBox17reportMemoryUsageEPN3WTF16MemoryObjectInfoE
-__ZNK7WebCore9InlineBox14caretMinOffsetEv
-__ZNK7WebCore9InlineBox10lineHeightEv
 __ZN7WebCore11JSDOMWindow6s_infoE
 __ZN7WebCore11MemoryCache11setDisabledEb
 __ZN7WebCore11MemoryCache13getStatisticsEv
index 5395679..bce716d 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/*
- * This is the UA StyleSheet for <object> and <embed> elements.
- *
- * Such elements, when snapshotted (paused), will contain a ShadowRoot
- * with the following structure:
- *
- * <object>
- *   #ShadowRoot
- *     <div class="snapshot-container">
- *       <div class="snapshot-overlay"></div> <!-- e.g. for dimming content -->
- *         <div class="snapshot-label">
- *           <div class="snapshot-title">Snapshotted Plug-In</div>
- *           <div class="snapshot-subtitle">Click to restart</div>
- *         </div>
- *       </div>
- *     </div>
- *
- */
-
-object::-webkit-snapshotted-plugin-content,
-embed::-webkit-snapshotted-plugin-content
-{
-    position: relative;
-    display: inline-block;
-    width: 100%;
-    height: 100%;
-}
-
-object::-webkit-snapshotted-plugin-content *,
-embed::-webkit-snapshotted-plugin-content *
-{
-    -webkit-user-select: none;
-}
-
-object::-webkit-snapshotted-plugin-content .snapshot-container,
-embed::-webkit-snapshotted-plugin-content .snapshot-container
-{
-    position: absolute;
-    width: 100%;
-    height: 100%;
-}
-
-object::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-overlay,
-embed::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-overlay
-{
-    display: none;
-}
-
-object::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label,
-embed::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label
-{
-    position: absolute;
-    background-color: white;
-    color: black;
-    margin: 1em;
-    padding: 0.25em 2em;
-    text-align: center;
-}
-
-object::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label .snapshot-title,
-embed::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label .snapshot-title
-{
-    font-weight: bold;
-}
-
-object::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label .snapshot-subtitle,
-embed::-webkit-snapshotted-plugin-content .snapshot-container .snapshot-label .snapshot-subtitle
-{
-    font-style: italic;
-    color: #444;
-}
+/* plug-ins */
+p{} /*Needed by Windows because it doesn't like empty files*/
index 1aa836d..e2902ad 100644 (file)
@@ -201,10 +201,10 @@ void HTMLPlugInElement::defaultEventHandler(Event* event)
             toRenderEmbeddedObject(r)->handleUnavailablePluginIndicatorEvent(event);
             return;
         }
-    } else if (r && r->isSnapshottedPlugIn() && displayState() < PlayingWithPendingMouseClick) {
-        toRenderSnapshottedPlugIn(r)->handleEvent(event);
-        HTMLFrameOwnerElement::defaultEventHandler(event);
-        return;
+        if (r->isSnapshottedPlugIn() && displayState() < PlayingWithPendingMouseClick) {
+            toRenderSnapshottedPlugIn(r)->handleEvent(event);
+            return;
+        }
     }
 
     if (!r || !r->isWidget())
index 12fa106..597bcc5 100644 (file)
 #include "config.h"
 #include "HTMLPlugInImageElement.h"
 
-#include "Chrome.h"
-#include "ChromeClient.h"
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
 #include "FrameView.h"
-#include "HTMLDivElement.h"
 #include "HTMLImageLoader.h"
+#include "HTMLNames.h"
 #include "Image.h"
-#include "LocalizedStrings.h"
 #include "Logging.h"
 #include "MouseEvent.h"
 #include "NodeRenderStyle.h"
-#include "NodeRenderingContext.h"
 #include "Page.h"
 #include "PlugInClient.h"
 #include "PlugInOriginHash.h"
 #include "SchemeRegistry.h"
 #include "SecurityOrigin.h"
 #include "Settings.h"
-#include "ShadowRoot.h"
 #include "StyleResolver.h"
-#include "Text.h"
 
 namespace WebCore {
 
-using namespace HTMLNames;
-
 static const int autoStartPlugInSizeThresholdWidth = 1;
 static const int autoStartPlugInSizeThresholdHeight = 1;
 static const int autoShowLabelSizeThresholdWidth = 400;
@@ -69,9 +61,7 @@ HTMLPlugInImageElement::HTMLPlugInImageElement(const QualifiedName& tagName, Doc
     , m_needsWidgetUpdate(!createdByParser)
     , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPreferPlugInsForImages)
     , m_needsDocumentActivationCallbacks(false)
-    , m_shouldShowSnapshotLabelAutomatically(false)
     , m_simulatedMouseClickTimer(this, &HTMLPlugInImageElement::simulatedMouseClickTimerFired, simulatedMouseClickTimerDelay)
-    , m_swapRendererTimer(this, &HTMLPlugInImageElement::swapRendererTimerFired)
 {
     setHasCustomCallbacks();
 }
@@ -142,34 +132,27 @@ RenderObject* HTMLPlugInImageElement::createRenderer(RenderArena* arena, RenderS
         m_needsDocumentActivationCallbacks = true;
         document()->registerForPageCacheSuspensionCallbacks(this);
     }
-
-    if (displayState() == DisplayingSnapshot) {
-        RenderSnapshottedPlugIn* renderSnapshottedPlugIn = new (arena) RenderSnapshottedPlugIn(this);
-        renderSnapshottedPlugIn->updateSnapshot(m_snapshotImage);
-        if (m_shouldShowSnapshotLabelAutomatically)
-            renderSnapshottedPlugIn->setShouldShowLabelAutomatically();
-        return renderSnapshottedPlugIn;
-    }
-
+    
     // Fallback content breaks the DOM->Renderer class relationship of this
     // class and all superclasses because createObject won't necessarily
     // return a RenderEmbeddedObject, RenderPart or even RenderWidget.
     if (useFallbackContent())
         return RenderObject::createObject(this, style);
-
     if (isImageType()) {
         RenderImage* image = new (arena) RenderImage(this);
         image->setImageResource(RenderImageResource::create());
         return image;
     }
 
+    if (document()->page() && document()->page()->settings()->plugInSnapshottingEnabled())
+        return new (arena) RenderSnapshottedPlugIn(this);
     return new (arena) RenderEmbeddedObject(this);
 }
 
 bool HTMLPlugInImageElement::willRecalcStyle(StyleChange)
 {
     // FIXME: Why is this necessary?  Manual re-attach is almost always wrong.
-    if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageType() && (displayState() != DisplayingSnapshot))
+    if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageType())
         reattach();
     return true;
 }
@@ -275,72 +258,11 @@ void HTMLPlugInImageElement::updateWidgetCallback(Node* n, unsigned)
 
 void HTMLPlugInImageElement::updateSnapshot(PassRefPtr<Image> image)
 {
-    if (displayState() > DisplayingSnapshot)
+    if (displayState() > DisplayingSnapshot || !renderer()->isSnapshottedPlugIn())
         return;
 
-    m_snapshotImage = image;
-    if (renderer()->isSnapshottedPlugIn()) {
-        toRenderSnapshottedPlugIn(renderer())->updateSnapshot(image);
-        return;
-    }
-
+    toRenderSnapshottedPlugIn(renderer())->updateSnapshot(image);
     setDisplayState(DisplayingSnapshot);
-    m_swapRendererTimer.startOneShot(0);
-}
-
-void HTMLPlugInImageElement::didAddUserAgentShadowRoot(ShadowRoot* root)
-{
-    Document* doc = document();
-
-    RefPtr<Element> shadowContainer = HTMLDivElement::create(doc);
-    shadowContainer->setPseudo(AtomicString("-webkit-snapshotted-plugin-content", AtomicString::ConstructFromLiteral));
-
-    RefPtr<Element> container = HTMLDivElement::create(doc);
-    container->setAttribute(classAttr, AtomicString("snapshot-container", AtomicString::ConstructFromLiteral));
-
-    RefPtr<Element> overlay = HTMLDivElement::create(doc);
-    overlay->setAttribute(classAttr, AtomicString("snapshot-overlay", AtomicString::ConstructFromLiteral));
-    container->appendChild(overlay, ASSERT_NO_EXCEPTION);
-
-    RefPtr<Element> label = HTMLDivElement::create(doc);
-    label->setAttribute(classAttr, AtomicString("snapshot-label", AtomicString::ConstructFromLiteral));
-
-    String titleText = snapshottedPlugInLabelTitle();
-    String subtitleText = snapshottedPlugInLabelSubtitle();
-    if (document()->page()) {
-        String clientTitleText = document()->page()->chrome()->client()->plugInStartLabelTitle();
-        if (!clientTitleText.isEmpty())
-            titleText = clientTitleText;
-        String clientSubtitleText = document()->page()->chrome()->client()->plugInStartLabelSubtitle();
-        if (!clientSubtitleText.isEmpty())
-            subtitleText = clientSubtitleText;
-    }
-
-    RefPtr<Element> title = HTMLDivElement::create(doc);
-    title->setAttribute(classAttr, AtomicString("snapshot-title", AtomicString::ConstructFromLiteral));
-    title->appendChild(doc->createTextNode(titleText), ASSERT_NO_EXCEPTION);
-    label->appendChild(title, ASSERT_NO_EXCEPTION);
-
-    RefPtr<Element> subTitle = HTMLDivElement::create(doc);
-    subTitle->setAttribute(classAttr, AtomicString("snapshot-subtitle", AtomicString::ConstructFromLiteral));
-    subTitle->appendChild(doc->createTextNode(subtitleText), ASSERT_NO_EXCEPTION);
-    label->appendChild(subTitle, ASSERT_NO_EXCEPTION);
-
-    container->appendChild(label, ASSERT_NO_EXCEPTION);
-
-    shadowContainer->appendChild(container, ASSERT_NO_EXCEPTION);
-    root->appendChild(shadowContainer, ASSERT_NO_EXCEPTION);
-}
-
-void HTMLPlugInImageElement::swapRendererTimerFired(Timer<HTMLPlugInImageElement>*)
-{
-    ASSERT(displayState() == DisplayingSnapshot);
-    if (userAgentShadowRoot())
-        return;
-
-    // Create a shadow root, which will trigger the code to add a snapshot container
-    // and reattach, thus making a new Renderer.
-    ensureUserAgentShadowRoot();
 }
 
 void HTMLPlugInImageElement::userDidClickSnapshot(PassRefPtr<MouseEvent> event)
@@ -348,8 +270,6 @@ void HTMLPlugInImageElement::userDidClickSnapshot(PassRefPtr<MouseEvent> event)
     m_pendingClickEventFromSnapshot = event;
     if (document()->page() && !SchemeRegistry::shouldTreatURLSchemeAsLocal(document()->page()->mainFrame()->document()->baseURL().protocol()))
         document()->page()->plugInClient()->addAutoStartOrigin(document()->page()->mainFrame()->document()->baseURL().host(), m_plugInOriginHash);
-
-    reattach();
 }
 
 void HTMLPlugInImageElement::dispatchPendingMouseClick()
@@ -399,12 +319,16 @@ void HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn(const KURL& url)
         return;
     }
 
+    if (!renderer()->isSnapshottedPlugIn()) {
+        LOG(Plugins, "%p Renderer is not snapshotted plugin, set to play", this);
+        return;
+    }
     if (ScriptController::processingUserGesture()) {
         LOG(Plugins, "%p Script is processing user gesture, set to play", this);
         return;
     }
 
-    LayoutRect rect = toRenderEmbeddedObject(renderer())->contentBoxRect();
+    LayoutRect rect = toRenderSnapshottedPlugIn(renderer())->contentBoxRect();
     int width = rect.width();
     int height = rect.height();
     if (!width || !height || (width <= autoStartPlugInSizeThresholdWidth && height <= autoStartPlugInSizeThresholdHeight)) {
@@ -427,13 +351,10 @@ void HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn(const KURL& url)
     }
 
     if (shouldPlugInShowLabelAutomatically(document()->page()->mainFrame()->view()->contentsSize(), this))
-        setShouldShowSnapshotLabelAutomatically();
+        toRenderSnapshottedPlugIn(renderer())->setShouldShowLabelAutomatically();
 
     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);
-    // We may have got to this point by restarting a snapshotted plug-in, in which case we don't want to
-    // reset the display state.
-    if (displayState() != PlayingWithPendingMouseClick)
-        setDisplayState(WaitingForSnapshot);
+    setDisplayState(WaitingForSnapshot);
 }
 
 void HTMLPlugInImageElement::subframeLoaderDidCreatePlugIn(const Widget* widget)
index 3949cd7..04731b5 100644 (file)
 
 #include "RenderStyle.h"
 #include <wtf/OwnPtr.h>
-#include <wtf/RefPtr.h>
 
 namespace WebCore {
 
 class HTMLImageLoader;
 class FrameLoader;
-class Image;
 class MouseEvent;
 class Widget;
 
@@ -39,7 +37,7 @@ enum PluginCreationOption {
     CreateAnyWidgetType,
     CreateOnlyNonNetscapePlugins,
 };
-
+    
 enum PreferPlugInsForImagesOption {
     ShouldPreferPlugInsForImages,
     ShouldNotPreferPlugInsForImages
@@ -94,31 +92,22 @@ protected:
 private:
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
     virtual bool willRecalcStyle(StyleChange);
-
-    void didAddUserAgentShadowRoot(ShadowRoot*) OVERRIDE;
-
+    
     virtual void finishParsingChildren();
 
     void updateWidgetIfNecessary();
     virtual bool useFallbackContent() const { return false; }
-
+    
     virtual void updateSnapshot(PassRefPtr<Image>) OVERRIDE;
     virtual void dispatchPendingMouseClick() OVERRIDE;
     void simulatedMouseClickTimerFired(DeferrableOneShotTimer<HTMLPlugInImageElement>*);
 
-    void swapRendererTimerFired(Timer<HTMLPlugInImageElement>*);
-
-    void setShouldShowSnapshotLabelAutomatically() { m_shouldShowSnapshotLabelAutomatically = true; }
-
     bool m_needsWidgetUpdate;
     bool m_shouldPreferPlugInsForImages;
     bool m_needsDocumentActivationCallbacks;
-    bool m_shouldShowSnapshotLabelAutomatically;
     RefPtr<RenderStyle> m_customStyleForPageCache;
     RefPtr<MouseEvent> m_pendingClickEventFromSnapshot;
     DeferrableOneShotTimer<HTMLPlugInImageElement> m_simulatedMouseClickTimer;
-    Timer<HTMLPlugInImageElement> m_swapRendererTimer;
-    RefPtr<Image> m_snapshotImage;
 };
 
 } // namespace WebCore
index 5f6ce39..3403b39 100644 (file)
@@ -373,6 +373,7 @@ public:
 
     virtual bool isEmptyChromeClient() const { return false; }
 
+    virtual PassRefPtr<Image> plugInStartLabelImage(RenderSnapshottedPlugIn::LabelSize) const { return 0; }
     virtual String plugInStartLabelTitle() const { return String(); }
     virtual String plugInStartLabelSubtitle() const { return String(); }
     virtual String plugInExtraStyleSheet() const { return String(); }
index 32d0783..0006a05 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003, 2006, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2006, 2009, 2010, 2012 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Igalia S.L
  *
  * Redistribution and use in source and binary forms, with or without
index fd81ff8..b477f47 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003, 2006, 2009, 2011, 2012, 2013 Apple Inc.  All rights reserved.
+ * Copyright (C) 2003, 2006, 2009, 2011 Apple Inc.  All rights reserved.
  * Copyright (C) 2010 Igalia S.L
  *
  * Redistribution and use in source and binary forms, with or without
index ea3dd0c..aad24dd 100644 (file)
@@ -617,16 +617,4 @@ String fileButtonNoFilesSelectedLabel()
     return String::fromUTF8(s_resource.getString(BlackBerry::Platform::FILE_BUTTON_NO_FILE_SELECTED_LABEL));
 }
 
-String snapshottedPlugInLabelTitle()
-{
-    notImplemented();
-    return String();
-}
-
-String snapshottedPlugInLabelSubtitle()
-{
-    notImplemented();
-    return String();
-}
-
 } // namespace WebCore
index be898c3..8ee28a7 100644 (file)
@@ -416,8 +416,6 @@ String contextMenuItemTagEnterVideoFullscreen() { return String(); }
 String contextMenuItemTagMediaPlay() { return String(); }
 String contextMenuItemTagMediaPause() { return String(); }
 String contextMenuItemTagMediaMute() { return String(); }
-String snapshottedPlugInLabelTitle() { return String(); }
-String snapshottedPlugInLabelSubtitle() { return String(); }
 
 #if ENABLE(VIDEO_TRACK)
 String textTrackClosedCaptionsText() { return String(); }
index 5877106..0609f59 100644 (file)
@@ -610,15 +610,4 @@ String textTrackNoLabelText()
 }
 #endif
 
-String snapshottedPlugInLabelTitle()
-{
-    return String("Snapshotted Plug-In");
-}
-
-String snapshottedPlugInLabelSubtitle()
-{
-    return String("Click to restart");
-}
-
-
 }
index b50d8af..2b2c0f3 100644 (file)
@@ -774,14 +774,4 @@ String textTrackNoLabelText()
 }
 #endif
 
-String snapshottedPlugInLabelTitle()
-{
-    return String::fromUTF8(C_("Snapshotted Plug-In", "Title of the label to show on a snapshotted plug-in"));
-}
-
-String snapshottedPlugInLabelSubtitle()
-{
-    return String::fromUTF8(C_("Click to restart", "Subtitle of the label to show on a snapshotted plug-in"));
-}
-
 }
index 9141f86..08a27a9 100644 (file)
@@ -723,18 +723,6 @@ String validationMessageBadInputForNumberText()
     return validationMessageTypeMismatchText();
 }
 
-String snapshottedPlugInLabelTitle()
-{
-    notImplemented();
-    return String();
-}
-
-String snapshottedPlugInLabelSubtitle()
-{
-    notImplemented();
-    return String();
-}
-
 String localizedString(const char* key)
 {
     return String::fromUTF8(key, strlen(key));
index 23e0b10..a6351c9 100644 (file)
 #include "Page.h"
 #include "PaintInfo.h"
 #include "Path.h"
-#include "RenderView.h"
 #include "SourceGraphic.h"
 
 namespace WebCore {
 
 static const int autoStartPlugInSizeThresholdWidth = 1;
 static const int autoStartPlugInSizeThresholdHeight = 1;
+static const int startLabelPadding = 10; // Label should be 10px from edge of box.
+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.
 static const double showLabelAfterMouseOverDelay = 1;
 static const double showLabelAutomaticallyDelay = 3;
 static const int snapshotLabelBlurRadius = 5;
@@ -99,7 +100,7 @@ void RenderSnapshottedPlugInBlurFilter::apply()
 #endif
 
 RenderSnapshottedPlugIn::RenderSnapshottedPlugIn(HTMLPlugInImageElement* element)
-    : RenderBlock(element)
+    : RenderEmbeddedObject(element)
     , m_snapshotResource(RenderImageResource::create())
     , m_shouldShowLabel(false)
     , m_shouldShowLabelAutomatically(false)
@@ -144,17 +145,28 @@ void RenderSnapshottedPlugIn::updateSnapshot(PassRefPtr<Image> image)
 
 void RenderSnapshottedPlugIn::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
-    if (paintInfo.phase == PaintPhaseBlockBackground && plugInImageElement()->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick) {
+    if (plugInImageElement()->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick) {
+        RenderReplaced::paint(paintInfo, paintOffset);
+        return;
+    }
+
+    RenderEmbeddedObject::paint(paintInfo, paintOffset);
+}
+
+void RenderSnapshottedPlugIn::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+{
+    if (plugInImageElement()->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick) {
         if (m_shouldShowLabel)
-            paintSnapshotWithLabel(paintInfo, paintOffset);
+            paintReplacedSnapshotWithLabel(paintInfo, paintOffset);
         else
-            paintSnapshot(paintInfo, paintOffset);
+            paintReplacedSnapshot(paintInfo, paintOffset);
+        return;
     }
 
-    RenderBlock::paint(paintInfo, paintOffset);
+    RenderEmbeddedObject::paintReplaced(paintInfo, paintOffset);
 }
 
-void RenderSnapshottedPlugIn::paintSnapshotImage(Image* image, PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+void RenderSnapshottedPlugIn::paintSnapshot(Image* image, PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
     LayoutUnit cWidth = contentWidth();
     LayoutUnit cHeight = contentHeight();
@@ -168,7 +180,7 @@ void RenderSnapshottedPlugIn::paintSnapshotImage(Image* image, PaintInfo& paintI
 #endif
 
     LayoutSize contentSize(cWidth, cHeight);
-    LayoutPoint contentLocation = location() + paintOffset;
+    LayoutPoint contentLocation = paintOffset;
     contentLocation.move(borderLeft() + paddingLeft(), borderTop() + paddingTop());
 
     LayoutRect rect(contentLocation, contentSize);
@@ -180,13 +192,31 @@ void RenderSnapshottedPlugIn::paintSnapshotImage(Image* image, PaintInfo& paintI
     context->drawImage(image, style()->colorSpace(), alignedRect, CompositeSourceOver, shouldRespectImageOrientation(), useLowQualityScaling);
 }
 
-void RenderSnapshottedPlugIn::paintSnapshot(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+void RenderSnapshottedPlugIn::paintReplacedSnapshot(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
     RefPtr<Image> image = m_snapshotResource->image();
     if (!image || image->isNull())
         return;
 
-    paintSnapshotImage(image.get(), paintInfo, paintOffset);
+    paintSnapshot(image.get(), paintInfo, paintOffset);
+}
+
+Image* RenderSnapshottedPlugIn::startLabelImage(LabelSize size) const
+{
+    static Image* labelImages[2] = { 0, 0 };
+    static bool initializedImages[2] = { false, false };
+
+    int arrayIndex = static_cast<int>(size);
+    if (labelImages[arrayIndex])
+        return labelImages[arrayIndex];
+    if (initializedImages[arrayIndex])
+        return 0;
+
+    if (document()->page()) {
+        labelImages[arrayIndex] = document()->page()->chrome()->client()->plugInStartLabelImage(size).leakRef();
+        initializedImages[arrayIndex] = true;
+    }
+    return labelImages[arrayIndex];
 }
 
 #if ENABLE(FILTERS)
@@ -208,7 +238,7 @@ static PassRefPtr<Image> snapshottedPluginImageForLabelDisplay(PassRefPtr<Image>
 }
 #endif
 
-void RenderSnapshottedPlugIn::paintSnapshotWithLabel(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+void RenderSnapshottedPlugIn::paintReplacedSnapshotWithLabel(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
     if (contentBoxRect().isEmpty())
         return;
@@ -217,26 +247,43 @@ void RenderSnapshottedPlugIn::paintSnapshotWithLabel(PaintInfo& paintInfo, const
         return;
 
     m_showedLabelOnce = true;
-    LayoutRect labelRect;
+    LayoutRect rect = contentBoxRect();
+    LayoutRect labelRect = tryToFitStartLabel(LabelSizeLarge, rect);
+    LabelSize size = NoLabel;
+    if (!labelRect.isEmpty())
+        size = LabelSizeLarge;
+    else {
+        labelRect = tryToFitStartLabel(LabelSizeSmall, rect);
+        if (!labelRect.isEmpty())
+            size = LabelSizeSmall;
+        else
+            return;
+    }
+
+    Image* labelImage = startLabelImage(size);
+    if (!labelImage)
+        return;
 
     RefPtr<Image> snapshotImage = m_snapshotResource->image();
     if (!snapshotImage || snapshotImage->isNull())
         return;
 
 #if ENABLE(FILTERS)
-    // FIXME: Temporarily disabling the blur behind the label.
-    // https://bugs.webkit.org/show_bug.cgi?id=108368
-    if (!labelRect.isEmpty()) {
-        RefPtr<Image> blurredSnapshotImage = m_snapshotResourceForLabel->image();
-        if (!blurredSnapshotImage || blurredSnapshotImage->isNull()) {
-            blurredSnapshotImage = snapshottedPluginImageForLabelDisplay(snapshotImage, labelRect);
-            m_snapshotResourceForLabel->setCachedImage(new CachedImage(blurredSnapshotImage.get()));
-        }
-        snapshotImage = blurredSnapshotImage;
+    RefPtr<Image> blurredSnapshotImage = m_snapshotResourceForLabel->image();
+    if (!blurredSnapshotImage || blurredSnapshotImage->isNull()) {
+        blurredSnapshotImage = snapshottedPluginImageForLabelDisplay(snapshotImage, labelRect);
+        m_snapshotResourceForLabel->setCachedImage(new CachedImage(blurredSnapshotImage.get()));
     }
+    snapshotImage = blurredSnapshotImage;
 #endif
 
-    paintSnapshotImage(snapshotImage.get(), paintInfo, paintOffset);
+    paintSnapshot(snapshotImage.get(), paintInfo, paintOffset);
+
+    // Remember that the labelRect includes the label inset, so we need to adjust for it.
+    paintInfo.context->drawImage(labelImage, ColorSpaceDeviceRGB,
+                                 IntRect(roundedIntPoint(paintOffset + labelRect.location() - IntSize(startLabelInset, startLabelInset)),
+                                         roundedIntSize(labelRect.size() + IntSize(2 * startLabelInset, 2 * startLabelInset))),
+                                 labelImage->rect());
 }
 
 void RenderSnapshottedPlugIn::repaintLabel()
@@ -262,7 +309,7 @@ CursorDirective RenderSnapshottedPlugIn::getCursor(const LayoutPoint& point, Cur
         overrideCursor = handCursor();
         return SetCursor;
     }
-    return RenderBlock::getCursor(point, overrideCursor);
+    return RenderEmbeddedObject::getCursor(point, overrideCursor);
 }
 
 void RenderSnapshottedPlugIn::handleEvent(Event* event)
@@ -278,6 +325,12 @@ void RenderSnapshottedPlugIn::handleEvent(Event* event)
 
         plugInImageElement()->setDisplayState(HTMLPlugInElement::PlayingWithPendingMouseClick);
         plugInImageElement()->userDidClickSnapshot(mouseEvent);
+
+        if (widget()) {
+            if (Frame* frame = document()->frame())
+                frame->loader()->client()->recreatePlugin(widget());
+            repaint();
+        }
         event->setDefaultHandled();
     } else if (event->type() == eventNames().mousedownEvent) {
         if (mouseEvent->button() != LeftButton)
@@ -305,6 +358,27 @@ void RenderSnapshottedPlugIn::handleEvent(Event* event)
     }
 }
 
+LayoutRect RenderSnapshottedPlugIn::tryToFitStartLabel(LabelSize size, const LayoutRect& contentBox) const
+{
+    Image* labelImage = startLabelImage(size);
+    if (!labelImage)
+        return LayoutRect();
+
+    // Assume that the labelImage has been provided to match our device scale.
+    float scaleFactor = 1;
+    if (document()->page())
+        scaleFactor = document()->page()->deviceScaleFactor();
+    IntSize labelImageSize = labelImage->size();
+    labelImageSize.scale(1 / (scaleFactor ? scaleFactor : 1));
+
+    LayoutSize labelSize = labelImageSize - LayoutSize(2 * startLabelInset, 2 * startLabelInset);
+    LayoutRect candidateRect(contentBox.maxXMinYCorner() + LayoutSize(-startLabelPadding, startLabelPadding) + LayoutSize(-labelSize.width(), 0), labelSize);
+    // The minimum allowed content box size is the label image placed in the center of the box, surrounded by startLabelPadding.
+    if (candidateRect.x() < startLabelPadding || candidateRect.maxY() > contentBox.height() - startLabelPadding)
+        return LayoutRect();
+    return candidateRect;
+}
+
 void RenderSnapshottedPlugIn::resetDelayTimer(ShowReason reason)
 {
     m_showReason = reason;
index 946af9a..271c646 100644 (file)
@@ -27,6 +27,7 @@
 #define RenderSnapshottedPlugIn_h
 
 #include "RenderBlock.h"
+#include "RenderEmbeddedObject.h"
 #include "RenderImageResource.h"
 #include "Timer.h"
 
@@ -34,11 +35,17 @@ namespace WebCore {
 
 class HTMLPlugInImageElement;
 
-class RenderSnapshottedPlugIn : public RenderBlock {
+class RenderSnapshottedPlugIn : public RenderEmbeddedObject {
 public:
     explicit RenderSnapshottedPlugIn(HTMLPlugInImageElement*);
     virtual ~RenderSnapshottedPlugIn();
 
+    enum LabelSize {
+        LabelSizeSmall,
+        LabelSizeLarge,
+        NoLabel,
+    };
+
     void updateSnapshot(PassRefPtr<Image>);
 
     void handleEvent(Event*);
@@ -53,12 +60,16 @@ private:
     virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const OVERRIDE;
     virtual bool isSnapshottedPlugIn() const OVERRIDE { return true; }
     virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE;
+    virtual void paintReplaced(PaintInfo&, const LayoutPoint&) OVERRIDE;
 
-    void paintSnapshot(PaintInfo&, const LayoutPoint&);
-    void paintSnapshotWithLabel(PaintInfo&, const LayoutPoint&);
-    void paintSnapshotImage(Image*, PaintInfo&, const LayoutPoint&);
+    void paintReplacedSnapshot(PaintInfo&, const LayoutPoint&);
+    void paintReplacedSnapshotWithLabel(PaintInfo&, const LayoutPoint&);
+    void paintSnapshot(Image*, PaintInfo&, const LayoutPoint&);
     void repaintLabel();
 
+    LayoutRect tryToFitStartLabel(LabelSize, const LayoutRect& contentBox) const;
+    Image* startLabelImage(LabelSize) const;
+
     enum ShowReason {
         UserMousedOver,
         ShouldShowAutomatically
index 2a7dd7b..5d3f92f 100644 (file)
@@ -1,3 +1,23 @@
+2013-02-10  Kent Tamura  <tkent@chromium.org>
+
+        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.
+
+        * 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):
+
 2013-02-10  Zan Dobersek  <zdobersek@igalia.com>
 
         [WebKit2][Gtk] Remove the fullscreen manager proxy message receiver upon invalidating
index b6af642..fc935bd 100644 (file)
@@ -163,6 +163,26 @@ uint64_t InjectedBundlePageUIClient::didExceedDatabaseQuota(WebPage* page, WebSe
     return m_client.didExceedDatabaseQuota(toAPI(page), toAPI(origin), toAPI(databaseName.impl()), toAPI(databaseDisplayName.impl()), currentQuotaBytes, currentOriginUsageBytes, currentDatabaseUsageBytes, expectedUsageBytes, m_client.clientInfo);
 }
 
+PassRefPtr<WebImage> InjectedBundlePageUIClient::plugInStartLabelImage(RenderSnapshottedPlugIn::LabelSize size) const
+{
+    if (!m_client.plugInStartLabelImage)
+        return 0;
+
+    WKBundlePageLabelSize wkSize;
+    switch (size) {
+    case RenderSnapshottedPlugIn::LabelSizeSmall:
+        wkSize = WKBundlePageLabelSizeSmall;
+        break;
+    case RenderSnapshottedPlugIn::LabelSizeLarge:
+        wkSize = WKBundlePageLabelSizeLarge;
+        break;
+    default:
+        return 0;
+    }
+
+    return adoptRef(toImpl(m_client.plugInStartLabelImage(wkSize, m_client.clientInfo)));
+}
+
 String InjectedBundlePageUIClient::plugInStartLabelTitle() const
 {
     if (!m_client.createPlugInStartLabelTitle)
index ad8fe24..5696382 100644 (file)
@@ -29,6 +29,7 @@
 #include "APIClient.h"
 #include "WKBundlePage.h"
 #include "WebEvent.h"
+#include "WebImage.h"
 #include <WebCore/RenderSnapshottedPlugIn.h>
 #include <wtf/Forward.h>
 
@@ -70,6 +71,7 @@ public:
     void didReachApplicationCacheOriginQuota(WebPage*, WebSecurityOrigin*, int64_t totalBytesNeeded);
     uint64_t didExceedDatabaseQuota(WebPage*, WebSecurityOrigin*, const String& databaseName, const String& databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes);
 
+    PassRefPtr<WebImage> plugInStartLabelImage(WebCore::RenderSnapshottedPlugIn::LabelSize) const;
     String plugInStartLabelTitle() const;
     String plugInStartLabelSubtitle() const;
     String plugInExtraStyleSheet() const;
index 46907ce..33381ff 100644 (file)
@@ -798,6 +798,11 @@ void WebChromeClient::logDiagnosticMessage(const String& message, const String&
     m_page->injectedBundleDiagnosticLoggingClient().logDiagnosticMessage(m_page, message, description, success);
 }
 
+PassRefPtr<Image> WebChromeClient::plugInStartLabelImage(RenderSnapshottedPlugIn::LabelSize size) const
+{
+    return m_page->injectedBundleUIClient().plugInStartLabelImage(size)->bitmap()->createImage();
+}
+
 String WebChromeClient::plugInStartLabelTitle() const
 {
     return m_page->injectedBundleUIClient().plugInStartLabelTitle();
index 3ea3a3b..d2fc093 100644 (file)
@@ -28,6 +28,7 @@
 #define WebChromeClient_h
 
 #include <WebCore/ChromeClient.h>
+#include <WebCore/Image.h>
 #include <WebCore/ViewportArguments.h>
 #include <wtf/text/WTFString.h>
 
@@ -217,6 +218,7 @@ private:
 
     virtual void logDiagnosticMessage(const String& message, const String& description, const String& success) OVERRIDE;
 
+    virtual PassRefPtr<WebCore::Image> plugInStartLabelImage(WebCore::RenderSnapshottedPlugIn::LabelSize) const OVERRIDE;
     virtual String plugInStartLabelTitle() const OVERRIDE;
     virtual String plugInStartLabelSubtitle() const OVERRIDE;
     virtual String plugInExtraStyleSheet() const OVERRIDE;