summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-06 00:36:52 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-06 00:36:52 +0000
commit4c870b4013b3cf658c40e2c7b98e0a419ae7236f (patch)
treee701a8ab7b093e04367a0956e7ff94a702806e6c /chrome
parent983f7bd3fa88bbdac942dbfaf0269b1684a5c1ee (diff)
downloadchromium_src-4c870b4013b3cf658c40e2c7b98e0a419ae7236f.zip
chromium_src-4c870b4013b3cf658c40e2c7b98e0a419ae7236f.tar.gz
chromium_src-4c870b4013b3cf658c40e2c7b98e0a419ae7236f.tar.bz2
Eliminate CursorChromium's dependency on webkit/glue.
Also modified WidgetChromium to use ChromiumBridge instead of talking to ChromeClientChromium. I want to eliminate that fake interface in favor of just having our code talk directly to ChromeClientImpl, but that means a dependency on webkit/glue, so I needed to use ChromiumBridge. Long-term, I'd like to propose changes upstream to HostWindow and ChromeClient to avoid this usage of ChromiumBridge. The most impactful part of this CL is the change to move the enumeration of cursor types from WebCursor to PlatformCursor. This means that WebCursor consumers no longer have access to the type enumeration. I replaced that with helper functions on WebCursor. I think the result not only achieves the goal of breaking CursorChromium's dependency on webkit/glue but is also much cleaner. R=iyengar,eseidel Review URL: http://codereview.chromium.org/9072 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4846 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/render_widget_host_view_win.cc32
-rw-r--r--chrome/browser/render_widget_host_view_win.h8
-rw-r--r--chrome/common/ipc_message_utils.cc75
-rw-r--r--chrome/common/ipc_message_utils.h14
-rw-r--r--chrome/common/render_messages_internal.h5
5 files changed, 32 insertions, 102 deletions
diff --git a/chrome/browser/render_widget_host_view_win.cc b/chrome/browser/render_widget_host_view_win.cc
index ab9275a..3b2e961 100644
--- a/chrome/browser/render_widget_host_view_win.cc
+++ b/chrome/browser/render_widget_host_view_win.cc
@@ -67,8 +67,8 @@ RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget)
: render_widget_host_(widget),
- real_cursor_(LoadCursor(NULL, IDC_ARROW)),
- real_cursor_type_(WebCursor::ARROW),
+ cursor_(LoadCursor(NULL, IDC_ARROW)),
+ cursor_is_custom_(false),
track_mouse_leave_(false),
ime_notification_(false),
is_hidden_(false),
@@ -85,8 +85,8 @@ RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget)
}
RenderWidgetHostViewWin::~RenderWidgetHostViewWin() {
- if (real_cursor_type_ == WebCursor::CUSTOM)
- DestroyIcon(real_cursor_);
+ if (cursor_is_custom_)
+ DestroyIcon(cursor_);
ResetTooltip();
}
@@ -222,35 +222,33 @@ void RenderWidgetHostViewWin::UpdateCursor(const WebCursor& cursor) {
// If the last active cursor was a custom cursor, we need to destroy
// it before setting the new one.
- if (real_cursor_type_ == WebCursor::CUSTOM)
- DestroyIcon(real_cursor_);
+ if (cursor_is_custom_)
+ DestroyIcon(cursor_);
- real_cursor_type_ = cursor.type();
- if (real_cursor_type_ == cursor.WebCursor::CUSTOM) {
- real_cursor_ = cursor.GetCustomCursor();
+ cursor_is_custom_ = cursor.IsCustom();
+ if (cursor_is_custom_) {
+ cursor_ = cursor.GetCustomCursor();
} else {
// We cannot pass in NULL as the module handle as this would only
// work for standard win32 cursors. We can also receive cursor
// types which are defined as webkit resources. We need to specify
// the module handle of chrome.dll while loading these cursors.
- real_cursor_ = cursor.GetCursor(module_handle);
+ cursor_ = cursor.GetCursor(module_handle);
}
UpdateCursorIfOverSelf();
}
void RenderWidgetHostViewWin::UpdateCursorIfOverSelf() {
- static HINSTANCE module_handle =
- GetModuleHandle(chrome::kBrowserResourcesDll);
+ static HCURSOR kCursorArrow = LoadCursor(NULL, IDC_ARROW);
+ static HCURSOR kCursorAppStarting = LoadCursor(NULL, IDC_APPSTARTING);
- HCURSOR display_cursor = real_cursor_;
+ HCURSOR display_cursor = cursor_;
// If a page is in the loading state, we want to show the Arrow+Hourglass
// cursor only when the current cursor is the ARROW cursor. In all other
// cases we should continue to display the current cursor.
- if (is_loading_ && (real_cursor_type_ == WebCursor::ARROW)) {
- WebCursor page_loading_cursor(WebCursor::APPSTARTING);
- display_cursor = page_loading_cursor.GetCursor(module_handle);
- }
+ if (is_loading_ && display_cursor == kCursorArrow)
+ display_cursor = kCursorAppStarting;
// If the mouse is over our HWND, then update the cursor state immediately.
CPoint pt;
diff --git a/chrome/browser/render_widget_host_view_win.h b/chrome/browser/render_widget_host_view_win.h
index 1d15674..ce0497b7 100644
--- a/chrome/browser/render_widget_host_view_win.h
+++ b/chrome/browser/render_widget_host_view_win.h
@@ -210,11 +210,11 @@ class RenderWidgetHostViewWin :
// The associated Model.
RenderWidgetHost* render_widget_host_;
- // The real cursor type for the page.
- WebCursor::Type real_cursor_type_;
+ // The cursor for the page. This is passed up from the renderer.
+ HCURSOR cursor_;
- // The real cursor for the page. This is passed down from the renderer
- HCURSOR real_cursor_;
+ // True if cursor_ is a custom cursor that needs to be destroyed later.
+ bool cursor_is_custom_;
// Indicates if the page is loading.
bool is_loading_;
diff --git a/chrome/common/ipc_message_utils.cc b/chrome/common/ipc_message_utils.cc
index 8a29ccd..2512ff4 100644
--- a/chrome/common/ipc_message_utils.cc
+++ b/chrome/common/ipc_message_utils.cc
@@ -8,7 +8,6 @@
#include "googleurl/src/gurl.h"
#include "SkBitmap.h"
#include "webkit/glue/dom_operations.h"
-#include "webkit/glue/webcursor.h"
namespace IPC {
@@ -44,13 +43,6 @@ struct SkBitmap_Data {
}
};
-struct WebCursor_Data {
- WebCursor::Type cursor_type;
- int hotspot_x;
- int hotspot_y;
- SkBitmap_Data bitmap_info;
-};
-
} // namespace
@@ -182,73 +174,6 @@ void ParamTraits<gfx::Size>::Log(const gfx::Size& p, std::wstring* l) {
l->append(StringPrintf(L"(%d, %d)", p.width(), p.height()));
}
-
-void ParamTraits<WebCursor>::Write(Message* m, const WebCursor& p) {
- const SkBitmap& src_bitmap = p.bitmap();
- WebCursor_Data web_cursor_info;
- web_cursor_info.cursor_type = p.type();
- web_cursor_info.hotspot_x = p.hotspot_x();
- web_cursor_info.hotspot_y = p.hotspot_y();
- web_cursor_info.bitmap_info.InitSkBitmapDataForTransfer(src_bitmap);
-
- size_t fixed_data = sizeof(web_cursor_info);
- m->WriteData(reinterpret_cast<const char*>(&web_cursor_info),
- static_cast<int>(fixed_data));
- size_t pixel_size = src_bitmap.getSize();
- m->WriteBool(pixel_size != 0);
- if (pixel_size) {
- SkAutoLockPixels src_bitmap_lock(src_bitmap);
- m->WriteData(reinterpret_cast<const char*>(src_bitmap.getPixels()),
- static_cast<int>(pixel_size));
- }
-}
-
-bool ParamTraits<WebCursor>::Read(const Message* m, void** iter, WebCursor* r) {
- const char* fixed_data = NULL;
- int fixed_data_size = 0;
- if (!m->ReadData(iter, &fixed_data, &fixed_data_size) ||
- (fixed_data_size <= 0)) {
- NOTREACHED();
- return false;
- }
- DCHECK(fixed_data_size == sizeof(WebCursor_Data));
-
- const WebCursor_Data* web_cursor_info =
- reinterpret_cast<const WebCursor_Data*>(fixed_data);
-
- bool variable_data_avail;
- if (!m->ReadBool(iter, &variable_data_avail)) {
- NOTREACHED();
- return false;
- }
-
- // No variable data indicates that this is not a custom cursor.
- if (variable_data_avail) {
- const char* variable_data = NULL;
- int variable_data_size = 0;
- if (!m->ReadData(iter, &variable_data, &variable_data_size) ||
- variable_data_size <= 0) {
- NOTREACHED();
- return false;
- }
-
- SkBitmap dest_bitmap;
- web_cursor_info->bitmap_info.InitSkBitmapFromData(&dest_bitmap,
- variable_data,
- variable_data_size);
- r->set_bitmap(dest_bitmap);
- r->set_hotspot(web_cursor_info->hotspot_x, web_cursor_info->hotspot_y);
- }
-
- r->set_type(web_cursor_info->cursor_type);
- return true;
-}
-
-void ParamTraits<WebCursor>::Log(const WebCursor& p, std::wstring* l) {
- l->append(L"<WebCursor>");
-}
-
-
void ParamTraits<webkit_glue::WebApplicationInfo>::Write(
Message* m, const webkit_glue::WebApplicationInfo& p) {
WriteParam(m, p.title);
diff --git a/chrome/common/ipc_message_utils.h b/chrome/common/ipc_message_utils.h
index 1a4c3b1..4fd66e1 100644
--- a/chrome/common/ipc_message_utils.h
+++ b/chrome/common/ipc_message_utils.h
@@ -16,12 +16,12 @@
#include "webkit/glue/cache_manager.h"
#include "webkit/glue/console_message_level.h"
#include "webkit/glue/find_in_page_request.h"
+#include "webkit/glue/webcursor.h"
#include "webkit/glue/window_open_disposition.h"
// Forward declarations.
class GURL;
class SkBitmap;
-class WebCursor;
namespace gfx {
class Point;
@@ -750,9 +750,15 @@ struct ParamTraits<XFORM> {
template <>
struct ParamTraits<WebCursor> {
typedef WebCursor param_type;
- static void Write(Message* m, const param_type& p);
- static bool Read(const Message* m, void** iter, param_type* r);
- static void Log(const param_type& p, std::wstring* l);
+ static void Write(Message* m, const param_type& p) {
+ p.Serialize(m);
+ }
+ static bool Read(const Message* m, void** iter, param_type* r) {
+ return r->Deserialize(m, iter);
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(L"<WebCursor>");
+ }
};
struct LogData {
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 286b2e5..4e6643c 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -13,13 +13,14 @@
#include "base/gfx/rect.h"
#include "base/shared_memory.h"
#include "chrome/common/ipc_message_macros.h"
-#include "webkit/glue/dom_operations.h"
+#include "skia/include/SkBitmap.h"
#include "webkit/glue/console_message_level.h"
#include "webkit/glue/context_node_types.h"
+#include "webkit/glue/dom_operations.h"
#include "webkit/glue/screen_info.h"
#include "webkit/glue/webcursor.h"
-#include "webkit/glue/webplugin.h"
#include "webkit/glue/webinputevent.h"
+#include "webkit/glue/webplugin.h"
void RenderMessagesInit();