Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (130687 => 130688)
--- trunk/Source/WebCore/CMakeLists.txt 2012-10-08 21:20:15 UTC (rev 130687)
+++ trunk/Source/WebCore/CMakeLists.txt 2012-10-08 21:27:29 UTC (rev 130688)
@@ -2117,6 +2117,7 @@
rendering/RenderScrollbarTheme.cpp
rendering/RenderSearchField.cpp
rendering/RenderSlider.cpp
+ rendering/RenderSnapshottedPlugIn.cpp
rendering/RenderTable.cpp
rendering/RenderTableCaption.cpp
rendering/RenderTableCell.cpp
Modified: trunk/Source/WebCore/ChangeLog (130687 => 130688)
--- trunk/Source/WebCore/ChangeLog 2012-10-08 21:20:15 UTC (rev 130687)
+++ trunk/Source/WebCore/ChangeLog 2012-10-08 21:27:29 UTC (rev 130688)
@@ -1,3 +1,73 @@
+2012-10-08 Jon Lee <jon...@apple.com>
+
+ Add render object that paints plugin snapshots
+ https://bugs.webkit.org/show_bug.cgi?id=98322
+ <rdar://problem/12426546>
+
+ Reviewed by Simon Fraser.
+
+ First, teach plugins to maintain a set of states when plugin snapshotting is enabled.
+
+ Second, a new RenderSnapshottedPlugIn class is a RenderEmbeddedObject that knows how to paint
+ snapshots when the plugin is not visibly playing. It maintains a RenderImageResource to
+ the generated poster image.
+
+ * html/HTMLPlugInElement.cpp:
+ (WebCore::HTMLPlugInElement::HTMLPlugInElement): By default all plugins play on load.
+ * html/HTMLPlugInElement.h: Move the inheritance of ImageLoaderClientBase down to
+ HTMLPlugInImageElement, since that is the class that actually deals with image-based plugins.
+ (WebCore::HTMLPlugInElement::displayState): Add bit for display state.
+ (WebCore::HTMLPlugInElement::setDisplayState):
+ (WebCore::HTMLPlugInElement::updateSnapshot):
+
+ * html/HTMLPlugInImageElement.cpp:
+ (WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement): If plugin snapshotting is
+ enabled, plugin state is set to wait for a poster image.
+ (WebCore::HTMLPlugInImageElement::createRenderer): Create RenderSnapshottedPlugIn if
+ plugin snapshotting is enabled.
+ (WebCore::HTMLPlugInImageElement::updateSnapshot): Once a snapshot is available, update the
+ renderer and set its state to wait for user input to start the plugin.
+ * html/HTMLPlugInImageElement.h:
+ (HTMLPlugInImageElement):
+
+ * rendering/RenderObject.h:
+ (WebCore::RenderObject::isSnapshottedPlugIn): Add new function to identify
+ RenderSnapshottedPlugIn instances. Since RenderSnapshottedPlugIn inherits from
+ RenderEmbeddedObject, isEmbeddedObject() still returns true.
+ * rendering/RenderEmbeddedObject.h:
+ (RenderEmbeddedObject): Elevate a few virtual methods to protected for
+ RenderSnapshottedPlugIn to override.
+
+ * rendering/RenderSnapshottedPlugIn.cpp: Added.
+ (WebCore::RenderSnapshottedPlugIn::RenderSnapshottedPlugIn): Initialize snapshot
+ resource.
+ (WebCore::RenderSnapshottedPlugIn::~RenderSnapshottedPlugIn): Shut down snapshot
+ image resource to remove the renderer as a client, and remove image from memory cache.
+ (WebCore::RenderSnapshottedPlugIn::plugInImageElement): Convenience function to get the
+ HTML element.
+ (WebCore::RenderSnapshottedPlugIn::updateSnapshot): Cache the snapshot, and repaint.
+ (WebCore::RenderSnapshottedPlugIn::paint): If the plugin is not playing, paint like a
+ RenderImage does.
+ (WebCore::RenderSnapshottedPlugIn::paintReplaced): Paint the snapshot and overlay if the
+ plugin is not playing.
+ (WebCore::RenderSnapshottedPlugIn::paintReplacedSnapshot): Inspired by
+ RenderImage::paintReplaced() and RenderImage::paintIntoRect().
+ * rendering/RenderSnapshottedPlugIn.h: Added.
+ (WebCore::RenderSnapshottedPlugIn::isSnapshottedPlugin): Returns true.
+
+ * rendering/RenderTheme.h: Add a function that paints the overlay on top of the snapshot.
+ * rendering/RenderThemeMac.h:
+ * rendering/RenderThemeMac.mm:
+ (WebCore::RenderThemeMac::paintPlugInSnapshotOverlay):
+
+ * WebCore.xcodeproj/project.pbxproj: Add new RenderSnapshottedPlugIn class.
+ * CMakeLists.txt: Ditto.
+ * GNUmakefile.list.am: Ditto.
+ * Target.pri: Ditto.
+ * WebCore.gypi: Ditto.
+ * WebCore.vcproj/WebCore.vcproj: Ditto.
+ * rendering/RenderingAllInOne.cpp: Ditto.
+
2012-10-08 Hans Muller <hmul...@adobe.com>
[CSS Exclusions] Add support for polygonal shapes
Modified: trunk/Source/WebCore/GNUmakefile.list.am (130687 => 130688)
--- trunk/Source/WebCore/GNUmakefile.list.am 2012-10-08 21:20:15 UTC (rev 130687)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2012-10-08 21:27:29 UTC (rev 130688)
@@ -5085,6 +5085,8 @@
Source/WebCore/rendering/RenderSelectionInfo.h \
Source/WebCore/rendering/RenderSlider.cpp \
Source/WebCore/rendering/RenderSlider.h \
+ Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp \
+ Source/WebCore/rendering/RenderSnapshottedPlugIn.h \
Source/WebCore/rendering/RenderTableCaption.cpp \
Source/WebCore/rendering/RenderTableCaption.h \
Source/WebCore/rendering/RenderTableCell.cpp \
Modified: trunk/Source/WebCore/Target.pri (130687 => 130688)
--- trunk/Source/WebCore/Target.pri 2012-10-08 21:20:15 UTC (rev 130687)
+++ trunk/Source/WebCore/Target.pri 2012-10-08 21:27:29 UTC (rev 130688)
@@ -1184,6 +1184,7 @@
rendering/RenderScrollbarTheme.cpp \
rendering/RenderSearchField.cpp \
rendering/RenderSlider.cpp \
+ rendering/RenderSnapshottedPlugIn.cpp \
rendering/RenderTable.cpp \
rendering/RenderTableCaption.cpp \
rendering/RenderTableCell.cpp \
@@ -2383,6 +2384,7 @@
rendering/RenderScrollbarTheme.h \
rendering/RenderSearchField.h \
rendering/RenderSlider.h \
+ rendering/RenderSnapshottedPlugIn.h \
rendering/RenderTableCaption.h \
rendering/RenderTableCell.h \
rendering/RenderTableCol.h \
Modified: trunk/Source/WebCore/WebCore.gypi (130687 => 130688)
--- trunk/Source/WebCore/WebCore.gypi 2012-10-08 21:20:15 UTC (rev 130687)
+++ trunk/Source/WebCore/WebCore.gypi 2012-10-08 21:27:29 UTC (rev 130688)
@@ -3432,6 +3432,8 @@
'rendering/RenderSelectionInfo.h',
'rendering/RenderSlider.cpp',
'rendering/RenderSlider.h',
+ 'rendering/RenderSnapshottedPlugIn.cpp',
+ 'rendering/RenderSnapshottedPlugIn.h',
'rendering/RenderTable.cpp',
'rendering/RenderTable.h',
'rendering/RenderTableCaption.cpp',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (130687 => 130688)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-10-08 21:20:15 UTC (rev 130687)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-10-08 21:27:29 UTC (rev 130688)
@@ -42167,6 +42167,62 @@
>
</File>
<File
+ RelativePath="..\rendering\RenderSnapshottedPlugIn.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug_All|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Production|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\rendering\RenderSnapshottedPlugIn.h"
+ >
+ </File>
+ <File
RelativePath="..\rendering\svg\RenderSVGAllInOne.cpp"
>
</File>
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (130687 => 130688)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-10-08 21:20:15 UTC (rev 130687)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-10-08 21:27:29 UTC (rev 130688)
@@ -909,6 +909,8 @@
3194620413022BF1004BB3F8 /* DOMWebKitAnimationList.h in Headers */ = {isa = PBXBuildFile; fileRef = 3194620213022BF1004BB3F8 /* DOMWebKitAnimationList.h */; };
3194620513022BF1004BB3F8 /* DOMWebKitAnimationList.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3194620313022BF1004BB3F8 /* DOMWebKitAnimationList.mm */; };
3194623213022F65004BB3F8 /* JSWebKitAnimationListCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3194623113022F65004BB3F8 /* JSWebKitAnimationListCustom.cpp */; };
+ 31955A86160D199000858025 /* RenderSnapshottedPlugIn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31E8D8BA160BC94B004CE8F5 /* RenderSnapshottedPlugIn.cpp */; };
+ 31955A88160D199200858025 /* RenderSnapshottedPlugIn.h in Headers */ = {isa = PBXBuildFile; fileRef = 31E8D8BB160BC94C004CE8F5 /* RenderSnapshottedPlugIn.h */; settings = {ATTRIBUTES = (Private, ); }; };
319AE063142D6B24006563A1 /* StyleFilterData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 319AE061142D6B24006563A1 /* StyleFilterData.cpp */; };
319AE064142D6B24006563A1 /* StyleFilterData.h in Headers */ = {isa = PBXBuildFile; fileRef = 319AE062142D6B24006563A1 /* StyleFilterData.h */; settings = {ATTRIBUTES = (Private, ); }; };
319E68871327C911004AC91A /* JSWebKitAnimationCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 319E68861327C911004AC91A /* JSWebKitAnimationCustom.cpp */; };
@@ -8040,6 +8042,8 @@
31C0FF460E4CEFDD007D6FE5 /* DOMWebKitTransitionEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWebKitTransitionEvent.h; sourceTree = "<group>"; };
31C0FF470E4CEFDD007D6FE5 /* DOMWebKitTransitionEvent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMWebKitTransitionEvent.mm; sourceTree = "<group>"; };
31C0FF480E4CEFDD007D6FE5 /* DOMWebKitTransitionEventInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWebKitTransitionEventInternal.h; sourceTree = "<group>"; };
+ 31E8D8BA160BC94B004CE8F5 /* RenderSnapshottedPlugIn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSnapshottedPlugIn.cpp; sourceTree = "<group>"; };
+ 31E8D8BB160BC94C004CE8F5 /* RenderSnapshottedPlugIn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSnapshottedPlugIn.h; sourceTree = "<group>"; };
31EC1D5014FEFD0800C94662 /* NotificationPermissionCallback.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = NotificationPermissionCallback.idl; path = Modules/notifications/NotificationPermissionCallback.idl; sourceTree = "<group>"; };
31EC1DAC14FF26EA00C94662 /* NotificationPermissionCallback.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NotificationPermissionCallback.h; path = Modules/notifications/NotificationPermissionCallback.h; sourceTree = "<group>"; };
31EC1E2614FF60EE00C94662 /* JSNotificationPermissionCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNotificationPermissionCallback.cpp; sourceTree = "<group>"; };
@@ -21489,6 +21493,8 @@
0F11A54E0F39233100C37884 /* RenderSelectionInfo.h */,
AB247A6A0AFD6383003FA5FD /* RenderSlider.cpp */,
AB247A6B0AFD6383003FA5FD /* RenderSlider.h */,
+ 31E8D8BA160BC94B004CE8F5 /* RenderSnapshottedPlugIn.cpp */,
+ 31E8D8BB160BC94C004CE8F5 /* RenderSnapshottedPlugIn.h */,
A8DF4AE20980C42C0052981B /* RenderTable.cpp */,
A8DF4AE10980C42C0052981B /* RenderTable.h */,
6ED878C2147493F4004C3597 /* RenderTableCaption.cpp */,
@@ -25544,6 +25550,7 @@
931CBD0F161A44E900E4C874 /* ScrollingStateScrollingNode.h in Headers */,
931CBD11161A44E900E4C874 /* ScrollingStateTree.h in Headers */,
6EAF34101613869A00859625 /* ExclusionPolygon.h in Headers */,
+ 31955A88160D199200858025 /* RenderSnapshottedPlugIn.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -28642,6 +28649,7 @@
931CBD10161A44E900E4C874 /* ScrollingStateTree.cpp in Sources */,
931CBD13161A44F800E4C874 /* ScrollingStateNodeMac.mm in Sources */,
6EAF340F1613869A00859625 /* ExclusionPolygon.cpp in Sources */,
+ 31955A86160D199000858025 /* RenderSnapshottedPlugIn.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: trunk/Source/WebCore/html/HTMLPlugInElement.cpp (130687 => 130688)
--- trunk/Source/WebCore/html/HTMLPlugInElement.cpp 2012-10-08 21:20:15 UTC (rev 130687)
+++ trunk/Source/WebCore/html/HTMLPlugInElement.cpp 2012-10-08 21:27:29 UTC (rev 130688)
@@ -55,6 +55,7 @@
, m_NPObject(0)
#endif
, m_isCapturingMouseEvents(false)
+ , m_displayState(Playing)
{
}
Modified: trunk/Source/WebCore/html/HTMLPlugInElement.h (130687 => 130688)
--- trunk/Source/WebCore/html/HTMLPlugInElement.h 2012-10-08 21:20:15 UTC (rev 130687)
+++ trunk/Source/WebCore/html/HTMLPlugInElement.h 2012-10-08 21:27:29 UTC (rev 130688)
@@ -1,7 +1,7 @@
/*
* Copyright (C) 1999 Lars Knoll (kn...@kde.org)
* (C) 1999 Antti Koivisto (koivi...@kde.org)
- * Copyright (C) 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -33,11 +33,12 @@
namespace WebCore {
+class Image;
class RenderEmbeddedObject;
class RenderWidget;
class Widget;
-class HTMLPlugInElement : public HTMLFrameOwnerElement, public ImageLoaderClientBase<HTMLPlugInElement> {
+class HTMLPlugInElement : public HTMLFrameOwnerElement {
public:
virtual ~HTMLPlugInElement();
@@ -47,6 +48,15 @@
Widget* pluginWidget() const;
+ enum DisplayState {
+ WaitingForSnapshot,
+ DisplayingSnapshot,
+ Playing
+ };
+ DisplayState displayState() const { return m_displayState; }
+ void setDisplayState(DisplayState state) { m_displayState = state; }
+ virtual void updateSnapshot(Image*) { }
+
#if ENABLE(NETSCAPE_PLUGIN_API)
NPObject* getNPObject();
#endif
@@ -84,6 +94,8 @@
NPObject* m_NPObject;
#endif
bool m_isCapturingMouseEvents;
+
+ DisplayState m_displayState;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp (130687 => 130688)
--- trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp 2012-10-08 21:20:15 UTC (rev 130687)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp 2012-10-08 21:27:29 UTC (rev 130688)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2011, 2012 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -31,7 +31,9 @@
#include "Page.h"
#include "RenderEmbeddedObject.h"
#include "RenderImage.h"
+#include "RenderSnapshottedPlugIn.h"
#include "SecurityOrigin.h"
+#include "Settings.h"
#include "StyleResolver.h"
namespace WebCore {
@@ -47,6 +49,9 @@
, m_needsDocumentActivationCallbacks(false)
{
setHasCustomCallbacks();
+
+ if (document->page() && document->page()->settings()->plugInSnapshottingEnabled())
+ setDisplayState(WaitingForSnapshot);
}
HTMLPlugInImageElement::~HTMLPlugInImageElement()
@@ -141,6 +146,9 @@
image->setImageResource(RenderImageResource::create());
return image;
}
+
+ if (document()->page() && document()->page()->settings()->plugInSnapshottingEnabled())
+ return new (arena) RenderSnapshottedPlugIn(this);
return new (arena) RenderEmbeddedObject(this);
}
@@ -253,4 +261,13 @@
static_cast<HTMLPlugInImageElement*>(n)->updateWidgetIfNecessary();
}
+void HTMLPlugInImageElement::updateSnapshot(Image* image)
+{
+ if (displayState() > WaitingForSnapshot || !renderer()->isSnapshottedPlugIn())
+ return;
+
+ toRenderSnapshottedPlugIn(renderer())->updateSnapshot(image);
+ setDisplayState(DisplayingSnapshot);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.h (130687 => 130688)
--- trunk/Source/WebCore/html/HTMLPlugInImageElement.h 2012-10-08 21:20:15 UTC (rev 130687)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.h 2012-10-08 21:27:29 UTC (rev 130688)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009, 2011, 2012 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -42,7 +42,7 @@
};
// Base class for HTMLObjectElement and HTMLEmbedElement
-class HTMLPlugInImageElement : public HTMLPlugInElement {
+class HTMLPlugInImageElement : public HTMLPlugInElement, public ImageLoaderClientBase<HTMLPlugInImageElement> {
public:
virtual ~HTMLPlugInImageElement();
@@ -90,6 +90,8 @@
void updateWidgetIfNecessary();
virtual bool useFallbackContent() const { return false; }
+ virtual void updateSnapshot(Image*) OVERRIDE;
+
bool m_needsWidgetUpdate;
bool m_shouldPreferPlugInsForImages;
bool m_needsDocumentActivationCallbacks;
Modified: trunk/Source/WebCore/rendering/RenderEmbeddedObject.h (130687 => 130688)
--- trunk/Source/WebCore/rendering/RenderEmbeddedObject.h 2012-10-08 21:20:15 UTC (rev 130687)
+++ trunk/Source/WebCore/rendering/RenderEmbeddedObject.h 2012-10-08 21:27:29 UTC (rev 130688)
@@ -1,7 +1,7 @@
/*
* Copyright (C) 1999 Lars Knoll (kn...@kde.org)
* (C) 2000 Simon Hausmann <hausm...@kde.org>
- * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -56,14 +56,16 @@
virtual bool allowsAcceleratedCompositing() const;
#endif
+protected:
+ virtual void paintReplaced(PaintInfo&, const LayoutPoint&);
+ virtual void paint(PaintInfo&, const LayoutPoint&);
+
+ virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
+
private:
virtual const char* renderName() const { return "RenderEmbeddedObject"; }
virtual bool isEmbeddedObject() const { return true; }
- virtual void paintReplaced(PaintInfo&, const LayoutPoint&);
- virtual void paint(PaintInfo&, const LayoutPoint&);
- virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
-
#if USE(ACCELERATED_COMPOSITING)
virtual bool requiresLayer() const;
#endif
Modified: trunk/Source/WebCore/rendering/RenderObject.h (130687 => 130688)
--- trunk/Source/WebCore/rendering/RenderObject.h 2012-10-08 21:20:15 UTC (rev 130687)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2012-10-08 21:27:29 UTC (rev 130688)
@@ -3,7 +3,7 @@
* (C) 2000 Antti Koivisto (koivi...@kde.org)
* (C) 2000 Dirk Mueller (muel...@kde.org)
* (C) 2004 Allan Sandfeld Jensen (k...@carewolf.com)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved.
* Copyright (C) 2009 Google Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
@@ -337,6 +337,7 @@
#if ENABLE(METER_ELEMENT)
virtual bool isMeter() const { return false; }
#endif
+ virtual bool isSnapshottedPlugIn() const { return false; }
#if ENABLE(PROGRESS_ELEMENT)
virtual bool isProgress() const { return false; }
#endif
Added: trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp (0 => 130688)
--- trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp (rev 0)
+++ trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp 2012-10-08 21:27:29 UTC (rev 130688)
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RenderSnapshottedPlugIn.h"
+
+#include "Cursor.h"
+#include "FrameView.h"
+#include "Gradient.h"
+#include "HTMLPlugInImageElement.h"
+#include "PaintInfo.h"
+#include "Path.h"
+
+namespace WebCore {
+
+RenderSnapshottedPlugIn::RenderSnapshottedPlugIn(HTMLPlugInImageElement* element)
+ : RenderEmbeddedObject(element)
+ , m_snapshotResource(RenderImageResource::create())
+{
+ m_snapshotResource->initialize(this);
+}
+
+RenderSnapshottedPlugIn::~RenderSnapshottedPlugIn()
+{
+ ASSERT(m_snapshotResource);
+ m_snapshotResource->shutdown();
+}
+
+HTMLPlugInImageElement* RenderSnapshottedPlugIn::plugInImageElement() const
+{
+ return static_cast<HTMLPlugInImageElement*>(node());
+}
+
+void RenderSnapshottedPlugIn::updateSnapshot(Image* image)
+{
+ // Zero-size plugins will have no image.
+ if (!image)
+ return;
+
+ m_snapshotResource->setCachedImage(new CachedImage(image));
+ repaint();
+}
+
+void RenderSnapshottedPlugIn::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+{
+ if (plugInImageElement()->displayState() < HTMLPlugInElement::Playing) {
+ RenderReplaced::paint(paintInfo, paintOffset);
+ return;
+ }
+
+ RenderEmbeddedObject::paint(paintInfo, paintOffset);
+}
+
+void RenderSnapshottedPlugIn::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+{
+ if (plugInImageElement()->displayState() < HTMLPlugInElement::Playing) {
+ paintReplacedSnapshot(paintInfo, paintOffset);
+ theme()->paintPlugInSnapshotOverlay(this, paintInfo, paintOffset);
+ return;
+ }
+
+ RenderEmbeddedObject::paintReplaced(paintInfo, paintOffset);
+}
+
+void RenderSnapshottedPlugIn::paintReplacedSnapshot(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+{
+ // This code should be similar to RenderImage::paintReplaced() and RenderImage::paintIntoRect().
+ LayoutUnit cWidth = contentWidth();
+ LayoutUnit cHeight = contentHeight();
+ if (!cWidth || !cHeight)
+ return;
+
+ RefPtr<Image> image = m_snapshotResource->image();
+ if (!image || image->isNull())
+ return;
+
+ GraphicsContext* context = paintInfo.context;
+#if PLATFORM(MAC)
+ if (style()->highlight() != nullAtom && !context->paintingDisabled())
+ paintCustomHighlight(toPoint(paintOffset - location()), style()->highlight(), true);
+#endif
+
+ LayoutSize contentSize(cWidth, cHeight);
+ LayoutPoint contentLocation = paintOffset;
+ contentLocation.move(borderLeft() + paddingLeft(), borderTop() + paddingTop());
+
+ LayoutRect rect(contentLocation, contentSize);
+ IntRect alignedRect = pixelSnappedIntRect(rect);
+ if (alignedRect.width() <= 0 || alignedRect.height() <= 0)
+ return;
+
+ bool useLowQualityScaling = shouldPaintAtLowQuality(context, image.get(), image.get(), alignedRect.size());
+ context->drawImage(image.get(), style()->colorSpace(), alignedRect, CompositeSourceOver, shouldRespectImageOrientation(), useLowQualityScaling);
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h (0 => 130688)
--- trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h (rev 0)
+++ trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h 2012-10-08 21:27:29 UTC (rev 130688)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef RenderSnapshottedPlugIn_h
+#define RenderSnapshottedPlugIn_h
+
+#include "RenderEmbeddedObject.h"
+
+#include "RenderImageResource.h"
+#include "RenderTheme.h"
+
+namespace WebCore {
+
+class HTMLPlugInImageElement;
+
+class RenderSnapshottedPlugIn : public RenderEmbeddedObject {
+public:
+ RenderSnapshottedPlugIn(HTMLPlugInImageElement*);
+ virtual ~RenderSnapshottedPlugIn();
+
+ void updateSnapshot(Image*);
+
+private:
+ HTMLPlugInImageElement* plugInImageElement() const;
+ virtual const char* renderName() const { return "RenderSnapshottedPlugIn"; }
+
+ virtual bool isSnapshottedPlugIn() const OVERRIDE { return true; }
+ virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE;
+ virtual void paintReplaced(PaintInfo&, const LayoutPoint&) OVERRIDE;
+ void paintReplacedSnapshot(PaintInfo&, const LayoutPoint&);
+
+ OwnPtr<RenderImageResource> m_snapshotResource;
+};
+
+inline RenderSnapshottedPlugIn* toRenderSnapshottedPlugIn(RenderObject* object)
+{
+ ASSERT(!object || object->isSnapshottedPlugIn());
+ return static_cast<RenderSnapshottedPlugIn*>(object);
+}
+
+// This will catch anyone doing an unnecessary cast.
+void toRenderSnapshottedPlugIn(const RenderSnapshottedPlugIn*);
+
+} // namespace WebCore
+
+#endif // RenderSnapshottedPlugIn_h
Modified: trunk/Source/WebCore/rendering/RenderTheme.h (130687 => 130688)
--- trunk/Source/WebCore/rendering/RenderTheme.h 2012-10-08 21:20:15 UTC (rev 130687)
+++ trunk/Source/WebCore/rendering/RenderTheme.h 2012-10-08 21:27:29 UTC (rev 130688)
@@ -35,6 +35,7 @@
namespace WebCore {
+class CSSStyleSheet;
class Element;
class FileList;
class HTMLInputElement;
@@ -46,7 +47,7 @@
#if ENABLE(PROGRESS_ELEMENT)
class RenderProgress;
#endif
-class CSSStyleSheet;
+class RenderSnapshottedPlugIn;
class RenderTheme : public RefCounted<RenderTheme> {
protected:
@@ -241,6 +242,8 @@
virtual String fileListDefaultLabel(bool multipleFilesAllowed) const;
virtual String fileListNameForWidth(const FileList*, const Font&, int width, bool multipleFilesAllowed) const;
+ virtual void paintPlugInSnapshotOverlay(RenderSnapshottedPlugIn*, const PaintInfo&, const LayoutPoint&) const { }
+
protected:
// The platform selection color.
virtual Color platformActiveSelectionBackgroundColor() const;
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.h (130687 => 130688)
--- trunk/Source/WebCore/rendering/RenderThemeMac.h 2012-10-08 21:20:15 UTC (rev 130687)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.h 2012-10-08 21:27:29 UTC (rev 130688)
@@ -101,6 +101,9 @@
virtual bool usesTestModeFocusRingColor() const;
// A view associated to the contained document. Subclasses may not have such a view and return a fake.
virtual NSView* documentViewFor(RenderObject*) const;
+
+ virtual void paintPlugInSnapshotOverlay(RenderSnapshottedPlugIn*, const PaintInfo&, const LayoutPoint&) const OVERRIDE;
+
protected:
RenderThemeMac();
virtual ~RenderThemeMac();
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (130687 => 130688)
--- trunk/Source/WebCore/rendering/RenderThemeMac.mm 2012-10-08 21:20:15 UTC (rev 130687)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm 2012-10-08 21:27:29 UTC (rev 130688)
@@ -41,6 +41,7 @@
#import "RenderMedia.h"
#import "RenderMediaControls.h"
#import "RenderSlider.h"
+#import "RenderSnapshottedPlugIn.h"
#import "RenderView.h"
#import "SharedBuffer.h"
#import "StringTruncator.h"
@@ -2232,4 +2233,43 @@
return StringTruncator::centerTruncate(strToTruncate, width, font, StringTruncator::EnableRoundingHacks);
}
+void RenderThemeMac::paintPlugInSnapshotOverlay(RenderSnapshottedPlugIn* renderer, const PaintInfo& paintInfo, const LayoutPoint& paintOffset) const
+{
+ LayoutUnit cWidth = renderer->contentWidth();
+ LayoutUnit cHeight = renderer->contentHeight();
+ if (!cWidth || !cHeight)
+ return;
+
+ GraphicsContext* context = paintInfo.context;
+ GraphicsContextStateSaver saver(*context);
+
+ LayoutSize borderAndPadding(renderer->borderLeft() + renderer->paddingLeft(), renderer->borderTop() + renderer->paddingTop());
+
+ LayoutSize contentSize(cWidth, cHeight);
+ LayoutPoint contentLocation = paintOffset;
+ contentLocation.move(borderAndPadding);
+
+ RefPtr<Gradient> g = Gradient::create(contentLocation, FloatPoint(contentLocation.x(), contentLocation.y() + cHeight));
+ g->addColorStop(0, Color(.5f, .5, .5, .7));
+ g->addColorStop(.2, Color(.54f, .54, .54, .3));
+ g->addColorStop(.6, Color(.62f, .62, .62, .3));
+ g->addColorStop(1, Color(.7f, .7, .7, .95));
+ context->setFillGradient(g.release());
+ context->fillRect(pixelSnappedIntRect(LayoutRect(contentLocation, contentSize)));
+
+ static const float diameter = 50, triangleRadius = 12;
+ LayoutPoint center = contentLocation;
+ center.move(cWidth / 2, cHeight / 2);
+ context->setFillColor(Color(.4f, .4, .4, .7), ColorSpaceSRGB);
+ context->fillEllipse(FloatRect(center.x() - diameter / 2, center.y() - diameter / 2, diameter, diameter));
+
+ Path p;
+ p.moveTo(FloatPoint(center.x() - triangleRadius * 3 / 4, center.y() - triangleRadius));
+ p.addLineTo(FloatPoint(center.x() + triangleRadius * 5 / 4, center.y()));
+ p.addLineTo(FloatPoint(center.x() - triangleRadius * 3 / 4, center.y() + triangleRadius));
+ p.closeSubpath();
+ context->setFillColor(Color(1.f, 1.f, 1.f, .9f), ColorSpaceSRGB);
+ context->fillPath(p);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/RenderingAllInOne.cpp (130687 => 130688)
--- trunk/Source/WebCore/rendering/RenderingAllInOne.cpp 2012-10-08 21:20:15 UTC (rev 130687)
+++ trunk/Source/WebCore/rendering/RenderingAllInOne.cpp 2012-10-08 21:27:29 UTC (rev 130688)
@@ -95,6 +95,7 @@
#include "RenderScrollbarTheme.cpp"
#include "RenderSearchField.cpp"
#include "RenderSlider.cpp"
+#include "RenderSnapshottedPlugin.cpp"
#include "RenderTable.cpp"
#include "RenderTableCaption.cpp"
#include "RenderTableCell.cpp"