diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 01:21:14 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 01:21:14 +0000 |
commit | d752e3f862f4ba9c094c88add5177ac2ad3a4136 (patch) | |
tree | d7c88f2e8dd7fb18f6be8c8914ff19edd60d1532 /webkit | |
parent | 1ac60480de8f8d3566387a91ecb6ac9b6169ab1f (diff) | |
download | chromium_src-d752e3f862f4ba9c094c88add5177ac2ad3a4136.zip chromium_src-d752e3f862f4ba9c094c88add5177ac2ad3a4136.tar.gz chromium_src-d752e3f862f4ba9c094c88add5177ac2ad3a4136.tar.bz2 |
Revert 34209 - Switch to using the dummy window for QD plugin drawing
Suspect this is the cause of a cluster of plugin layout test failures
which appear Mac-specific. E.g.
http://build.chromium.org/buildbot/waterfall/builders/Webkit%20Mac10.5/builds/7582/steps/webkit_tests/logs/stdio
LayoutTests/plugins/bindings-test.html = CRASH
LayoutTests/plugins/destroy-during-npp-new.html = CRASH
LayoutTests/plugins/destroy-stream-twice.html = CRASH
LayoutTests/plugins/document-open.html = CRASH
LayoutTests/plugins/embed-attributes-style.html = CRASH
LayoutTests/plugins/get-empty-url.html = CRASH
LayoutTests/plugins/getintidentifier-special-values.html = CRASH
LayoutTests/plugins/geturl-replace-query.html = CRASH
LayoutTests/plugins/invoke.html = CRASH
LayoutTests/plugins/netscape-construct.html = CRASH
LayoutTests/plugins/netscape-destroy-plugin-script-objects.html = CRASH
LayoutTests/plugins/netscape-enumerate.html = CRASH
LayoutTests/plugins/netscape-identifier-conversion.html = CRASH
LayoutTests/plugins/netscape-invoke-default.html = CRASH
LayoutTests/plugins/netscape-plugin-map-data-to-src.html = CRASH
LayoutTests/plugins/netscape-plugin-setwindow-size.html = CRASH
LayoutTests/plugins/npruntime.html = CRASH
LayoutTests/plugins/open-and-close-window-with-plugin.html = CRASH
LayoutTests/plugins/plugin-remove-subframe.html = CRASH
LayoutTests/plugins/reloadplugins-and-pages.html = CRASH
LayoutTests/plugins/return-error-from-new-stream-callback-in-full-frame-plugin.html = CRASH
LayoutTests/plugins/setProperty.html = CRASH
This simplifies things a bit over the old way, and should be a step closer to supporting more QDbased plugins.
Also makes the HandleInputEvent logic a bit clearer.
BUG=none
TEST=Quicktime movies should still play on the Mac.
Review URL: http://codereview.chromium.org/483004
TBR=stuartmorgan@chromium.org
Review URL: http://codereview.chromium.org/483006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34214 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/plugins/coregraphics_private_symbols_mac.h | 27 | ||||
-rw-r--r-- | webkit/glue/plugins/fake_plugin_window_tracker_mac.cc | 2 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl_mac.mm | 118 | ||||
-rw-r--r-- | webkit/webkit.gyp | 1 |
4 files changed, 78 insertions, 70 deletions
diff --git a/webkit/glue/plugins/coregraphics_private_symbols_mac.h b/webkit/glue/plugins/coregraphics_private_symbols_mac.h deleted file mode 100644 index 0342d6f..0000000 --- a/webkit/glue/plugins/coregraphics_private_symbols_mac.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_GLUE_PLUGINS_COREGRAPHICS_PRIVATE_SYMBOLS_MAC_H_ -#define WEBKIT_GLUE_PLUGINS_COREGRAPHICS_PRIVATE_SYMBOLS_MAC_H_ - -// These are CoreGraphics SPI, verified to exist in both 10.5 and 10.6. - -#ifdef __cplusplus -extern "C" { -#endif - -// Copies the contents of the window with id |wid| into the given rect in the -// given context -OSStatus CGContextCopyWindowCaptureContentsToRect( - CGContextRef, CGRect, int cid, int wid, int unknown); - -// Returns the connection ID we need for the third argument to -// CGContextCopyWindowCaptureContentsToRect -int _CGSDefaultConnection(void); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // WEBKIT_GLUE_PLUGINS_COREGRAPHICS_PRIVATE_SYMBOLS_MAC_H_ diff --git a/webkit/glue/plugins/fake_plugin_window_tracker_mac.cc b/webkit/glue/plugins/fake_plugin_window_tracker_mac.cc index 6f7f7ef..9f809a5 100644 --- a/webkit/glue/plugins/fake_plugin_window_tracker_mac.cc +++ b/webkit/glue/plugins/fake_plugin_window_tracker_mac.cc @@ -26,7 +26,7 @@ WindowRef FakePluginWindowTracker::GenerateFakeWindowForDelegate( Rect window_bounds = { 0, 0, 100, 100 }; WindowRef new_ref = NULL; if (CreateNewWindow(kDocumentWindowClass, - kWindowNoTitleBarAttribute, + kWindowStandardDocumentAttributes, &window_bounds, &new_ref) == noErr) { CFDictionaryAddValue(window_to_delegate_map_, new_ref, delegate); diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm index 240249f..e20b915 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm +++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm @@ -20,7 +20,6 @@ #include "webkit/default_plugin/plugin_impl.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/webplugin.h" -#include "webkit/glue/plugins/coregraphics_private_symbols_mac.h" #include "webkit/glue/plugins/fake_plugin_window_tracker_mac.h" #include "webkit/glue/plugins/plugin_constants_win.h" #include "webkit/glue/plugins/plugin_instance.h" @@ -77,6 +76,7 @@ WebPluginDelegateImpl::WebPluginDelegateImpl( plugin_(NULL), instance_(instance), parent_(containing_view), + qd_world_(0), quirks_(0), null_event_factory_(this), waiting_to_die_(false), @@ -109,6 +109,12 @@ WebPluginDelegateImpl::WebPluginDelegateImpl( WebPluginDelegateImpl::~WebPluginDelegateImpl() { std::set<WebPluginDelegateImpl*>* delegates = g_active_delegates.Pointer(); delegates->erase(this); +#ifndef NP_NO_QUICKDRAW + if (qd_port_.port) { + DisposeGWorld(qd_port_.port); + DisposeGWorld(qd_world_); + } +#endif } void WebPluginDelegateImpl::PluginDestroyed() { @@ -117,7 +123,7 @@ void WebPluginDelegateImpl::PluginDestroyed() { if (instance_->event_model() == NPEventModelCarbon) { if (PluginDrawingModel() == NPDrawingModelQuickDraw) { - // Tell the plugin it should stop drawing into the window (which will go + // Tell the plugin it should stop drawing into the GWorld (which will go // away when the next idle event arrives). window_.x = 0; window_.y = 0; @@ -158,8 +164,6 @@ void WebPluginDelegateImpl::PlatformInitialize() { Rect window_bounds = { 0, 0, window_rect_.height(), window_rect_.width() }; SetWindowBounds(reinterpret_cast<WindowRef>(cg_context_.window), kWindowContentRgn, &window_bounds); - qd_port_.port = - GetWindowPort(reinterpret_cast<WindowRef>(cg_context_.window)); switch (PluginDrawingModel()) { #ifndef NP_NO_QUICKDRAW @@ -191,12 +195,38 @@ void WebPluginDelegateImpl::PlatformDestroyInstance() { } void WebPluginDelegateImpl::UpdateContext(CGContextRef context) { - // Flash on the Mac apparently caches the context from the struct it receives - // in NPP_SetWindow, and continues to use it even when the contents of the + // Flash on the Mac apparently caches the context from the struct it recieves + // in NPP_SetWindow, and continue to use it even when the contents of the // struct have changed, so we need to call NPP_SetWindow again if the context // changes. if (context != cg_context_.context) { cg_context_.context = context; +#ifndef NP_NO_QUICKDRAW + if (PluginDrawingModel() == NPDrawingModelQuickDraw) { + if (qd_port_.port) { + DisposeGWorld(qd_port_.port); + DisposeGWorld(qd_world_); + qd_port_.port = NULL; + qd_world_ = NULL; + } + Rect window_bounds = { + 0, 0, window_rect_.height(), window_rect_.width() + }; + // Create a GWorld pointing at the same bits as our CGContextRef + NewGWorldFromPtr(&qd_world_, k32BGRAPixelFormat, &window_bounds, + NULL, NULL, 0, + static_cast<Ptr>(CGBitmapContextGetData(context)), + static_cast<SInt32>(CGBitmapContextGetBytesPerRow(context))); + // Create a GWorld for the plugin to paint into whenever it wants + NewGWorld(&qd_port_.port, k32ARGBPixelFormat, &window_bounds, + NULL, NULL, kNativeEndianPixMap); + SetGWorld(qd_port_.port, NULL); + // Fill with black + ForeColor(blackColor); + BackColor(whiteColor); + PaintRect(&window_bounds); + } +#endif WindowlessSetWindow(true); } } @@ -270,19 +300,28 @@ void WebPluginDelegateImpl::WindowlessPaint(gfx::NativeDrawingContext context, // Plugins using the QuickDraw drawing model do not restrict their // drawing to update events the way that CoreGraphics-based plugins // do. When we are asked to paint, we therefore just copy from the - // plugin's hidden window into our shared memory bitmap context. - CGRect window_bounds = CGRectMake(0, 0, - window_rect_.width(), - window_rect_.height()); - CGWindowID window_id = HIWindowGetCGWindowID( - reinterpret_cast<WindowRef>(cg_context_.window)); - CGContextSaveGState(context); - CGContextTranslateCTM(context, 0, window_rect_.height()); - CGContextScaleCTM(context, 1.0, -1.0); - CGContextCopyWindowCaptureContentsToRect(context, window_bounds, - _CGSDefaultConnection(), - window_id, 0); - CGContextRestoreGState(context); + // plugin's persistent offscreen GWorld into our shared memory bitmap + // context. + Rect window_bounds = { + 0, 0, window_rect_.height(), window_rect_.width() + }; + PixMapHandle plugin_pixmap = GetGWorldPixMap(qd_port_.port); + if (LockPixels(plugin_pixmap)) { + PixMapHandle shared_pixmap = GetGWorldPixMap(qd_world_); + if (LockPixels(shared_pixmap)) { + SetGWorld(qd_world_, NULL); + // Set foreground and background colors to avoid "colorizing" the + // image. + ForeColor(blackColor); + BackColor(whiteColor); + CopyBits(reinterpret_cast<BitMap*>(*plugin_pixmap), + reinterpret_cast<BitMap*>(*shared_pixmap), + &window_bounds, &window_bounds, srcCopy, NULL); + UnlockPixels(shared_pixmap); + } + UnlockPixels(plugin_pixmap); + } + break; } #endif case NPDrawingModelCoreGraphics: { @@ -707,36 +746,33 @@ bool WebPluginDelegateImpl::HandleInputEvent(const WebInputEvent& event, switch (PluginDrawingModel()) { #ifndef NP_NO_QUICKDRAW case NPDrawingModelQuickDraw: - SetPort(qd_port_.port); + SetGWorld(qd_port_.port, NULL); + ret = instance()->NPP_HandleEvent(&np_event) != 0; break; #endif case NPDrawingModelCoreGraphics: CGContextSaveGState(cg_context_.context); - break; - } - - switch (instance()->event_model()) { + switch (instance()->event_model()) { #ifndef NP_NO_CARBON - case NPEventModelCarbon: - // Send the event to the plugin. - ret = instance()->NPP_HandleEvent(&np_event) != 0; - break; + case NPEventModelCarbon: + // Send the event to the plugin. + ret = instance()->NPP_HandleEvent(&np_event) != 0; + break; #endif - case NPEventModelCocoa: { - NPCocoaEvent np_cocoa_event; - if (!NPCocoaEventFromWebInputEvent(event, &np_cocoa_event)) { - LOG(WARNING) << "NPCocoaEventFromWebInputEvent failed"; - return false; + case NPEventModelCocoa: { + NPCocoaEvent np_cocoa_event; + if (!NPCocoaEventFromWebInputEvent(event, &np_cocoa_event)) { + LOG(WARNING) << "NPCocoaEventFromWebInputEvent failed"; + return false; + } + ret = instance()->NPP_HandleEvent( + reinterpret_cast<NPEvent*>(&np_cocoa_event)) != 0; + break; + } } - ret = instance()->NPP_HandleEvent( - reinterpret_cast<NPEvent*>(&np_cocoa_event)) != 0; + CGContextRestoreGState(cg_context_.context); break; - } } - - if (PluginDrawingModel() == NPDrawingModelCoreGraphics) - CGContextRestoreGState(cg_context_.context); - return ret; } @@ -787,7 +823,7 @@ void WebPluginDelegateImpl::OnNullEvent() { #ifndef NP_NO_QUICKDRAW // Quickdraw-based plugins can draw at any time, so tell the renderer to // repaint. - // TODO: only do this if the contents of the offscreen window has changed, + // TODO: only do this if the contents of the offscreen GWorld has changed, // so as not to spam the renderer with an unchanging image. if (PluginDrawingModel() == NPDrawingModelQuickDraw) instance()->webplugin()->Invalidate(); diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index c2bb0b6..041aabc 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -258,7 +258,6 @@ 'glue/media/simple_data_source.h', 'glue/media/video_renderer_impl.cc', 'glue/media/video_renderer_impl.h', - 'glue/plugins/coregraphics_private_symbols_mac.h', 'glue/plugins/nphostapi.h', 'glue/plugins/fake_plugin_window_tracker_mac.h', 'glue/plugins/fake_plugin_window_tracker_mac.cc', |