[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75
jhoneycutt at apple.com
jhoneycutt at apple.com
Thu Oct 29 20:38:35 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit 6e174265881368f9b7a7ae89bafff03b3204ccd5
Author: jhoneycutt at apple.com <jhoneycutt at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Oct 3 02:51:49 2009 +0000
Make WebCore::PluginView participate in plug-in halting.
Reviewed by Sam Weinig.
WebCore:
Have plug-ins opt in to automatic halting.
Reviewed by NOBODY (OOPS!).
* platform/graphics/BitmapImage.h:
Declare a create() function that takes an HBITMAP.
* platform/graphics/win/ImageCGWin.cpp:
(WebCore::BitmapImage::create):
Use GetObject() to fill out a DIBSECTION structure for the given
HBITMAP. Call CGBitmapContextCreate() to create a CG context from the
bits of the bitmap. Create a CG image from the context, and pass this
when creating a new BitmapImage.
* plugins/PluginView.cpp:
(WebCore::PluginView::start):
If we successfully started, tell our parent frame's Page.
(WebCore::PluginView::stop):
Tell our parent frame's Page that we stopped.
(WebCore::PluginView::node):
* plugins/PluginView.h:
Inherit from HaltablePlugin.
(WebCore::PluginView::setPlatformPluginWidget):
On platforms where the platform plug-in widget is the WebCore::Widget's
platform widget, have setPlatformPluginWidget() call
setPlatformWidget().
* plugins/PluginViewNone.cpp:
(WebCore::PluginView::halt):
Stubbed.
(WebCore::PluginView::restart):
Stubbed.
* plugins/gtk/PluginViewGtk.cpp:
(WebCore::PluginView::halt):
Stubbed.
(WebCore::PluginView::restart):
Stubbed.
* plugins/mac/PluginViewMac.cpp:
(WebCore::PluginView::halt):
Stubbed.
(WebCore::PluginView::restart):
Stubbed.
* plugins/qt/PluginViewQt.cpp:
(WebCore::PluginView::halt):
Stubbed.
(WebCore::PluginView::restart):
Stubbed.
* plugins/win/PluginViewWin.cpp:
(WebCore::PluginView::platformDestroy):
After destroying the window, set the platform plug-in widget to 0 to
ensure that Widget isn't holding a stale handle.
(WebCore::PluginView::halt):
Have our element's RenderWidget display a screenshot of the plug-in,
then stop the plug-in and destroy it.
(WebCore::PluginView::restart):
Clear the RenderWidget's substitute image, then start the plug-in.
* rendering/RenderWidget.cpp:
(WebCore::RenderWidget::showSubstituteImage):
Set m_substituteImage to the passed image, and repaint.
(WebCore::RenderWidget::paint):
If we have a substitute image, paint that instead of allowing the
widget to paint itself.
* rendering/RenderWidget.h:
Declare showSubstituteImage(). Added a member to store the substitute
image.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49060 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index de16667..304239c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,78 @@
+2009-09-25 Jon Honeycutt <jhoneycutt at apple.com>
+
+ Make WebCore::PluginView participate in plug-in halting.
+
+ Reviewed by Sam Weinig.
+
+ * platform/graphics/BitmapImage.h:
+ Declare a create() function that takes an HBITMAP.
+
+ * platform/graphics/win/ImageCGWin.cpp:
+ (WebCore::BitmapImage::create):
+ Use GetObject() to fill out a DIBSECTION structure for the given
+ HBITMAP. Call CGBitmapContextCreate() to create a CG context from the
+ bits of the bitmap. Create a CG image from the context, and pass this
+ when creating a new BitmapImage.
+
+ * plugins/PluginView.cpp:
+ (WebCore::PluginView::start):
+ If we successfully started, tell our parent frame's Page.
+ (WebCore::PluginView::stop):
+ Tell our parent frame's Page that we stopped.
+ (WebCore::PluginView::node):
+
+ * plugins/PluginView.h:
+ Inherit from HaltablePlugin.
+ (WebCore::PluginView::setPlatformPluginWidget):
+ On platforms where the platform plug-in widget is the WebCore::Widget's
+ platform widget, have setPlatformPluginWidget() call
+ setPlatformWidget().
+
+ * plugins/PluginViewNone.cpp:
+ (WebCore::PluginView::halt):
+ Stubbed.
+ (WebCore::PluginView::restart):
+ Stubbed.
+
+ * plugins/gtk/PluginViewGtk.cpp:
+ (WebCore::PluginView::halt):
+ Stubbed.
+ (WebCore::PluginView::restart):
+ Stubbed.
+
+ * plugins/mac/PluginViewMac.cpp:
+ (WebCore::PluginView::halt):
+ Stubbed.
+ (WebCore::PluginView::restart):
+ Stubbed.
+
+ * plugins/qt/PluginViewQt.cpp:
+ (WebCore::PluginView::halt):
+ Stubbed.
+ (WebCore::PluginView::restart):
+ Stubbed.
+
+ * plugins/win/PluginViewWin.cpp:
+ (WebCore::PluginView::platformDestroy):
+ After destroying the window, set the platform plug-in widget to 0 to
+ ensure that Widget isn't holding a stale handle.
+ (WebCore::PluginView::halt):
+ Have our element's RenderWidget display a screenshot of the plug-in,
+ then stop the plug-in and destroy it.
+ (WebCore::PluginView::restart):
+ Clear the RenderWidget's substitute image, then start the plug-in.
+
+ * rendering/RenderWidget.cpp:
+ (WebCore::RenderWidget::showSubstituteImage):
+ Set m_substituteImage to the passed image, and repaint.
+ (WebCore::RenderWidget::paint):
+ If we have a substitute image, paint that instead of allowing the
+ widget to paint itself.
+
+ * rendering/RenderWidget.h:
+ Declare showSubstituteImage(). Added a member to store the substitute
+ image.
+
2009-10-02 Adam Barth <abarth at webkit.org>
Reviewed by Darin Adler.
diff --git a/WebCore/platform/graphics/BitmapImage.h b/WebCore/platform/graphics/BitmapImage.h
index 0f3f9aa..d712efb 100644
--- a/WebCore/platform/graphics/BitmapImage.h
+++ b/WebCore/platform/graphics/BitmapImage.h
@@ -141,6 +141,7 @@ public:
#endif
#if PLATFORM(WIN)
+ static PassRefPtr<BitmapImage> create(HBITMAP);
virtual bool getHBITMAP(HBITMAP);
virtual bool getHBITMAPOfSize(HBITMAP, LPSIZE);
#endif
diff --git a/WebCore/platform/graphics/win/ImageCGWin.cpp b/WebCore/platform/graphics/win/ImageCGWin.cpp
index 8a8e943..285fb71 100644
--- a/WebCore/platform/graphics/win/ImageCGWin.cpp
+++ b/WebCore/platform/graphics/win/ImageCGWin.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "Image.h"
#include "BitmapImage.h"
+#include "BitmapInfo.h"
#include "GraphicsContext.h"
#include <ApplicationServices/ApplicationServices.h>
@@ -34,6 +35,30 @@
namespace WebCore {
+PassRefPtr<BitmapImage> BitmapImage::create(HBITMAP hBitmap)
+{
+ DIBSECTION dibSection;
+ if (!GetObject(hBitmap, sizeof(DIBSECTION), &dibSection))
+ return 0;
+
+ ASSERT(dibSection.dsBm.bmBitsPixel == 32);
+ if (dibSection.dsBm.bmBitsPixel != 32)
+ return 0;
+
+ ASSERT(dibSection.dsBm.bmBits);
+ if (!dibSection.dsBm.bmBits)
+ return 0;
+
+ RetainPtr<CGColorSpaceRef> deviceRGB(AdoptCF, CGColorSpaceCreateDeviceRGB());
+ RetainPtr<CGContextRef> bitmapContext(AdoptCF, CGBitmapContextCreate(dibSection.dsBm.bmBits, dibSection.dsBm.bmWidth, dibSection.dsBm.bmHeight, 8,
+ dibSection.dsBm.bmWidthBytes, deviceRGB.get(), kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst));
+
+ // The BitmapImage takes ownership of this.
+ CGImageRef cgImage = CGBitmapContextCreateImage(bitmapContext.get());
+
+ return adoptRef(new BitmapImage(cgImage));
+}
+
bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, LPSIZE size)
{
ASSERT(bmp);
diff --git a/WebCore/plugins/PluginView.cpp b/WebCore/plugins/PluginView.cpp
index 28572a4..43bb967 100644
--- a/WebCore/plugins/PluginView.cpp
+++ b/WebCore/plugins/PluginView.cpp
@@ -234,7 +234,13 @@ bool PluginView::start()
if (!platformStart())
m_status = PluginStatusCanNotLoadPlugin;
- return (m_status == PluginStatusLoadedSuccessfully);
+ if (m_status != PluginStatusLoadedSuccessfully)
+ return false;
+
+ if (parentFrame()->page())
+ parentFrame()->page()->didStartPlugin(this);
+
+ return true;
}
PluginView::~PluginView()
@@ -274,6 +280,9 @@ void PluginView::stop()
if (!m_isStarted)
return;
+ if (parentFrame()->page())
+ parentFrame()->page()->didStopPlugin(this);
+
LOG(Plugins, "PluginView::stop(): Stopping plug-in '%s'", m_plugin->name().utf8().data());
HashSet<RefPtr<PluginStream> > streams = m_streams;
@@ -1214,4 +1223,10 @@ const char* PluginView::userAgentStatic()
}
#endif
+
+Node* PluginView::node() const
+{
+ return m_element;
+}
+
} // namespace WebCore
diff --git a/WebCore/plugins/PluginView.h b/WebCore/plugins/PluginView.h
index 54c1065..df94c4e 100644
--- a/WebCore/plugins/PluginView.h
+++ b/WebCore/plugins/PluginView.h
@@ -29,6 +29,7 @@
#include "CString.h"
#include "FrameLoadRequest.h"
+#include "HaltablePlugin.h"
#include "IntRect.h"
#include "KURL.h"
#include "PlatformString.h"
@@ -106,7 +107,7 @@ namespace WebCore {
virtual void didFail(const ResourceError&) = 0;
};
- class PluginView : public Widget, private PluginStreamClient, public PluginManualLoader {
+ class PluginView : public Widget, private PluginStreamClient, public PluginManualLoader, private HaltablePlugin {
public:
static PassRefPtr<PluginView> create(Frame* parentFrame, const IntSize&, Element*, const KURL&, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually);
virtual ~PluginView();
@@ -193,6 +194,11 @@ namespace WebCore {
void didFinishLoading();
void didFail(const ResourceError&);
+ // HaltablePlugin
+ virtual void halt();
+ virtual void restart();
+ virtual Node* node() const;
+
static bool isCallingPlugin();
bool start();
@@ -295,6 +301,7 @@ public:
void setPlatformPluginWidget(PlatformPluginWidget widget) { m_window = widget; }
#else
public:
+ void setPlatformPluginWidget(PlatformPluginWidget widget) { setPlatformWidget(widget); }
PlatformPluginWidget platformPluginWidget() const { return platformWidget(); }
#endif
diff --git a/WebCore/plugins/PluginViewNone.cpp b/WebCore/plugins/PluginViewNone.cpp
index b694214..d4601d4 100644
--- a/WebCore/plugins/PluginViewNone.cpp
+++ b/WebCore/plugins/PluginViewNone.cpp
@@ -136,4 +136,12 @@ void PluginView::updatePluginWidget()
notImplemented();
}
+void PluginView::halt()
+{
+}
+
+void PluginView::restart()
+{
+}
+
} // namespace WebCore
diff --git a/WebCore/plugins/gtk/PluginViewGtk.cpp b/WebCore/plugins/gtk/PluginViewGtk.cpp
index d843401..bc3a622 100644
--- a/WebCore/plugins/gtk/PluginViewGtk.cpp
+++ b/WebCore/plugins/gtk/PluginViewGtk.cpp
@@ -507,5 +507,13 @@ void PluginView::platformDestroy()
{
}
+void PluginView::halt()
+{
+}
+
+void PluginView::restart()
+{
+}
+
} // namespace WebCore
diff --git a/WebCore/plugins/mac/PluginViewMac.cpp b/WebCore/plugins/mac/PluginViewMac.cpp
index 226aab6..0ab91d1 100644
--- a/WebCore/plugins/mac/PluginViewMac.cpp
+++ b/WebCore/plugins/mac/PluginViewMac.cpp
@@ -692,6 +692,14 @@ NPError PluginView::handlePostReadFile(Vector<char>& buffer, uint32 len, const c
return NPERR_NO_ERROR;
}
+void PluginView::halt()
+{
+}
+
+void PluginView::restart()
+{
+}
+
} // namespace WebCore
#else
diff --git a/WebCore/plugins/qt/PluginViewQt.cpp b/WebCore/plugins/qt/PluginViewQt.cpp
index de7b879..0a9a566 100644
--- a/WebCore/plugins/qt/PluginViewQt.cpp
+++ b/WebCore/plugins/qt/PluginViewQt.cpp
@@ -498,4 +498,12 @@ void PluginView::platformDestroy()
delete platformPluginWidget();
}
+void PluginView::halt()
+{
+}
+
+void PluginView::restart()
+{
+}
+
} // namespace WebCore
diff --git a/WebCore/plugins/win/PluginViewWin.cpp b/WebCore/plugins/win/PluginViewWin.cpp
index 21ac2a4..bc18b61 100644
--- a/WebCore/plugins/win/PluginViewWin.cpp
+++ b/WebCore/plugins/win/PluginViewWin.cpp
@@ -29,6 +29,7 @@
#include "PluginView.h"
+#include "BitmapImage.h"
#include "Document.h"
#include "DocumentLoader.h"
#include "Element.h"
@@ -52,6 +53,7 @@
#include "PluginMessageThrottlerWin.h"
#include "PluginPackage.h"
#include "PluginMainThreadScheduler.h"
+#include "RenderWidget.h"
#include "JSDOMBinding.h"
#include "ScriptController.h"
#include "PluginDatabase.h"
@@ -1008,8 +1010,32 @@ bool PluginView::platformStart()
void PluginView::platformDestroy()
{
- if (platformPluginWidget())
- DestroyWindow(platformPluginWidget());
+ if (!platformPluginWidget())
+ return;
+
+ DestroyWindow(platformPluginWidget());
+ setPlatformPluginWidget(0);
+}
+
+void PluginView::halt()
+{
+ // Show a screenshot of the plug-in.
+ OwnPtr<HBITMAP> nodeImage(m_parentFrame->nodeImage(m_element));
+ toRenderWidget(m_element->renderer())->showSubstituteImage(BitmapImage::create(nodeImage.get()));
+
+ stop();
+ platformDestroy();
+}
+
+void PluginView::restart()
+{
+ ASSERT(!m_isStarted);
+
+ // Clear any substitute image.
+ toRenderWidget(m_element->renderer())->showSubstituteImage(0);
+
+ m_haveUpdatedPluginWidget = false;
+ start();
}
} // namespace WebCore
diff --git a/WebCore/rendering/RenderWidget.cpp b/WebCore/rendering/RenderWidget.cpp
index ef78b07..9af7137 100644
--- a/WebCore/rendering/RenderWidget.cpp
+++ b/WebCore/rendering/RenderWidget.cpp
@@ -175,6 +175,12 @@ void RenderWidget::styleDidChange(StyleDifference diff, const RenderStyle* oldSt
}
}
+void RenderWidget::showSubstituteImage(PassRefPtr<Image> prpImage)
+{
+ m_substituteImage = prpImage;
+ repaint();
+}
+
void RenderWidget::paint(PaintInfo& paintInfo, int tx, int ty)
{
if (!shouldPaint(paintInfo, tx, ty))
@@ -222,7 +228,10 @@ void RenderWidget::paint(PaintInfo& paintInfo, int tx, int ty)
// Tell the widget to paint now. This is the only time the widget is allowed
// to paint itself. That way it will composite properly with z-indexed layers.
- m_widget->paint(paintInfo.context, paintInfo.rect);
+ if (m_substituteImage)
+ paintInfo.context->drawImage(m_substituteImage.get(), m_widget->frameRect());
+ else
+ m_widget->paint(paintInfo.context, paintInfo.rect);
if (m_widget->isFrameView() && paintInfo.overlapTestRequests && !static_cast<FrameView*>(m_widget.get())->useSlowRepaints()) {
ASSERT(!paintInfo.overlapTestRequests->contains(this));
diff --git a/WebCore/rendering/RenderWidget.h b/WebCore/rendering/RenderWidget.h
index 098f69e..78537fd 100644
--- a/WebCore/rendering/RenderWidget.h
+++ b/WebCore/rendering/RenderWidget.h
@@ -40,6 +40,8 @@ public:
void updateWidgetPosition();
+ void showSubstituteImage(PassRefPtr<Image>);
+
protected:
RenderWidget(Node*);
@@ -66,6 +68,7 @@ private:
void deref(RenderArena*);
RefPtr<Widget> m_widget;
+ RefPtr<Image> m_substituteImage;
FrameView* m_frameView;
int m_refCount;
};
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list