Title: [144347] tags/Safari-537.31.11/Source/WebCore

Diff

Modified: tags/Safari-537.31.11/Source/WebCore/ChangeLog (144346 => 144347)


--- tags/Safari-537.31.11/Source/WebCore/ChangeLog	2013-02-28 20:13:18 UTC (rev 144346)
+++ tags/Safari-537.31.11/Source/WebCore/ChangeLog	2013-02-28 20:15:21 UTC (rev 144347)
@@ -1,5 +1,35 @@
 2013-02-28  Lucas Forschler  <[email protected]>
 
+        Merge r143680
+
+    2013-02-21  Dean Jackson  <[email protected]>
+
+            Better sizing model for Snapshotted plugins
+            https://bugs.webkit.org/show_bug.cgi?id=110541
+
+            Reviewed by Simon Fraser.
+
+            Clarify the way we apply sizing rules to snapshotted plug-ins. In
+            testing we've found that plug-ins smaller than 40px in either
+            dimension should never be frozen. Also, larger plugins should
+            be explicitly marked, because often they are the single dominant
+            element on the page.
+
+            As a drive-by, I removed the flag that indicated whether or not
+            the label should show automatically. It wasn't being used. This is
+            all determined from the shadow root and its CSS now.
+
+            * html/HTMLPlugInImageElement.cpp:
+            (WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement): New values for size thresholds.
+            (WebCore::HTMLPlugInImageElement::createRenderer): Remove call to setShouldShowSnapshotLabelAutomatically.
+            (WebCore::classNameForShadowRoot): Remove logging and clearly assign sizing classes.
+            (WebCore::HTMLPlugInImageElement::updateSnapshotInfo): We don't need the page size any more.
+            (WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn): Use new constant names.
+            * html/HTMLPlugInImageElement.h:
+            (HTMLPlugInImageElement): Remove setShouldShowSnapshotLabelAutomatically.
+
+2013-02-28  Lucas Forschler  <[email protected]>
+
         Merge r142958
 
     2013-02-14  Ryosuke Niwa  <[email protected]>

Modified: tags/Safari-537.31.11/Source/WebCore/html/HTMLPlugInImageElement.cpp (144346 => 144347)


--- tags/Safari-537.31.11/Source/WebCore/html/HTMLPlugInImageElement.cpp	2013-02-28 20:13:18 UTC (rev 144346)
+++ tags/Safari-537.31.11/Source/WebCore/html/HTMLPlugInImageElement.cpp	2013-02-28 20:15:21 UTC (rev 144347)
@@ -53,13 +53,10 @@
 
 using namespace HTMLNames;
 
-static const int autoStartPlugInSizeDimensionThreshold = 1;
-static const int autoShowLabelSizeWidthThreshold = 400;
-static const int autoShowLabelSizeHeightThreshold = 300;
-
 static const int sizingTinyDimensionThreshold = 40;
 static const int sizingSmallWidthThreshold = 250;
-static const int sizingMediumWidthThreshold = 600;
+static const int sizingMediumWidthThreshold = 450;
+static const int sizingMediumHeightThreshold = 300;
 
 // This delay should not exceed the snapshot delay in PluginView.cpp
 static const double simulatedMouseClickTimerDelay = .75;
@@ -73,7 +70,6 @@
     , m_needsWidgetUpdate(!createdByParser)
     , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPreferPlugInsForImages)
     , m_needsDocumentActivationCallbacks(false)
-    , m_shouldShowSnapshotLabelAutomatically(false)
     , m_simulatedMouseClickTimer(this, &HTMLPlugInImageElement::simulatedMouseClickTimerFired, simulatedMouseClickTimerDelay)
     , m_swapRendererTimer(this, &HTMLPlugInImageElement::swapRendererTimerFired)
 {
@@ -157,8 +153,6 @@
     if (displayState() == DisplayingSnapshot) {
         RenderSnapshottedPlugIn* renderSnapshottedPlugIn = new (arena) RenderSnapshottedPlugIn(this);
         renderSnapshottedPlugIn->updateSnapshot(m_snapshotImage);
-        if (m_shouldShowSnapshotLabelAutomatically)
-            renderSnapshottedPlugIn->setShouldShowLabelAutomatically();
         return renderSnapshottedPlugIn;
     }
 
@@ -300,34 +294,25 @@
         renderer()->repaint();
 }
 
-static AtomicString classNameForShadowRootSize(const IntSize& viewContentsSize, const Node* node)
+static AtomicString classNameForShadowRoot(const Node* node)
 {
     DEFINE_STATIC_LOCAL(const AtomicString, plugInTinySizeClassName, ("tiny", AtomicString::ConstructFromLiteral));
     DEFINE_STATIC_LOCAL(const AtomicString, plugInSmallSizeClassName, ("small", AtomicString::ConstructFromLiteral));
     DEFINE_STATIC_LOCAL(const AtomicString, plugInMediumSizeClassName, ("medium", AtomicString::ConstructFromLiteral));
     DEFINE_STATIC_LOCAL(const AtomicString, plugInLargeSizeClassName, ("large", AtomicString::ConstructFromLiteral));
 
-    LayoutRect plugInClipRect = node->renderer()->absoluteClippedOverflowRect();
-    LayoutRect viewContentsRect(LayoutPoint::zero(), LayoutSize(viewContentsSize));
-    if (!viewContentsRect.contains(plugInClipRect)) {
-        LOG(Plugins, "%p Plug-in rect: (%d %d, %d %d) not contained in document of size %d %d", node, plugInClipRect.pixelSnappedX(), plugInClipRect.pixelSnappedY(), plugInClipRect.pixelSnappedWidth(), plugInClipRect.pixelSnappedHeight(), viewContentsSize.width(), viewContentsSize.height());
-        return nullAtom;
-    }
+    RenderBox* renderBox = static_cast<RenderBox*>(node->renderer());
+    LayoutUnit width = renderBox->contentWidth();
+    LayoutUnit height = renderBox->contentHeight();
 
-    if (plugInClipRect.pixelSnappedWidth() < sizingTinyDimensionThreshold || plugInClipRect.pixelSnappedHeight() < sizingTinyDimensionThreshold) {
-        LOG(Plugins, "%p Tiny Size: %d %d", node, plugInClipRect.pixelSnappedWidth(), plugInClipRect.pixelSnappedHeight());
+    if (width < sizingTinyDimensionThreshold || height < sizingTinyDimensionThreshold)
         return plugInTinySizeClassName;
-    }
 
-    if (plugInClipRect.pixelSnappedWidth() < sizingSmallWidthThreshold) {
-        LOG(Plugins, "%p Small Size: %d %d", node, plugInClipRect.pixelSnappedWidth(), plugInClipRect.pixelSnappedHeight());
+    if (width < sizingSmallWidthThreshold)
         return plugInSmallSizeClassName;
-    }
 
-    if (plugInClipRect.pixelSnappedWidth() < sizingMediumWidthThreshold) {
-        LOG(Plugins, "%p Medium Size: %d %d", node, plugInClipRect.pixelSnappedWidth(), plugInClipRect.pixelSnappedHeight());
+    if (width < sizingMediumWidthThreshold || height < sizingMediumHeightThreshold)
         return plugInMediumSizeClassName;
-    }
 
     return plugInLargeSizeClassName;
 }
@@ -339,7 +324,7 @@
         return;
 
     Element* shadowContainer = static_cast<Element*>(root->firstChild());
-    shadowContainer->setAttribute(classAttr, classNameForShadowRootSize(document()->page()->mainFrame()->view()->contentsSize(), this));   
+    shadowContainer->setAttribute(classAttr, classNameForShadowRoot(this));
 }
 
 void HTMLPlugInImageElement::didAddUserAgentShadowRoot(ShadowRoot* root)
@@ -423,25 +408,6 @@
     m_pendingClickEventFromSnapshot = nullptr;
 }
 
-static bool shouldPlugInShowLabelAutomatically(const IntSize& viewContentsSize, const Node* node)
-{
-    LayoutRect plugInClipRect = node->renderer()->absoluteClippedOverflowRect();
-    LayoutRect viewContentsRect(LayoutPoint::zero(), LayoutSize(viewContentsSize));
-    if (!viewContentsRect.contains(plugInClipRect)) {
-        LOG(Plugins, "%p Plug-in rect: (%d %d, %d %d) not contained in document of size %d %d", node, plugInClipRect.pixelSnappedX(), plugInClipRect.pixelSnappedY(), plugInClipRect.pixelSnappedWidth(), plugInClipRect.pixelSnappedHeight(), viewContentsSize.width(), viewContentsSize.height());
-        return false;
-    }
-
-    if (plugInClipRect.pixelSnappedWidth() < autoShowLabelSizeWidthThreshold
-        || plugInClipRect.pixelSnappedHeight() < autoShowLabelSizeHeightThreshold) {
-        LOG(Plugins, "%p Size: %d %d", node, plugInClipRect.pixelSnappedWidth(), plugInClipRect.pixelSnappedHeight());
-        return false;
-    }
-
-    LOG(Plugins, "%p Auto-show label", node);
-    return true;
-}
-
 void HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn(const KURL& url)
 {
     if (!document()->page()
@@ -461,7 +427,7 @@
     LayoutRect rect = toRenderEmbeddedObject(renderer())->contentBoxRect();
     int width = rect.width();
     int height = rect.height();
-    if (!width || !height || (width <= autoStartPlugInSizeDimensionThreshold && height <= autoStartPlugInSizeDimensionThreshold)) {
+    if (!width || !height || (width <= sizingTinyDimensionThreshold || height <= sizingTinyDimensionThreshold)) {
         LOG(Plugins, "%p Plug-in is %dx%d, set to play", this, width, height);
         return;
     }
@@ -480,9 +446,6 @@
         return;
     }
 
-    if (shouldPlugInShowLabelAutomatically(document()->page()->mainFrame()->view()->contentsSize(), this))
-        setShouldShowSnapshotLabelAutomatically();
-
     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.

Modified: tags/Safari-537.31.11/Source/WebCore/html/HTMLPlugInImageElement.h (144346 => 144347)


--- tags/Safari-537.31.11/Source/WebCore/html/HTMLPlugInImageElement.h	2013-02-28 20:13:18 UTC (rev 144346)
+++ tags/Safari-537.31.11/Source/WebCore/html/HTMLPlugInImageElement.h	2013-02-28 20:15:21 UTC (rev 144347)
@@ -112,14 +112,11 @@
 
     void swapRendererTimerFired(Timer<HTMLPlugInImageElement>*);
 
-    void setShouldShowSnapshotLabelAutomatically() { m_shouldShowSnapshotLabelAutomatically = true; }
-
     virtual bool isPlugInImageElement() const OVERRIDE { return 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;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to