diff options
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/build/glue/glue.vcproj | 4 | ||||
-rw-r--r-- | webkit/glue/SConscript | 1 | ||||
-rw-r--r-- | webkit/glue/chrome_client_impl.cc | 7 | ||||
-rw-r--r-- | webkit/glue/chrome_client_impl.h | 11 | ||||
-rw-r--r-- | webkit/glue/chromium_bridge_impl.cc | 40 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.cc | 41 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.h | 4 | ||||
-rw-r--r-- | webkit/glue/webcursor.cc | 205 | ||||
-rw-r--r-- | webkit/glue/webcursor.h | 163 | ||||
-rw-r--r-- | webkit/glue/webcursor_win.cc | 203 | ||||
-rw-r--r-- | webkit/glue/webplugin_impl.cc | 11 | ||||
-rw-r--r-- | webkit/port/page/chromium/ChromeClientChromium.h | 3 | ||||
-rw-r--r-- | webkit/port/platform/chromium/ChromiumBridge.h | 7 | ||||
-rw-r--r-- | webkit/port/platform/chromium/CursorChromium.cpp | 126 | ||||
-rw-r--r-- | webkit/port/platform/chromium/PlatformCursor.h | 80 | ||||
-rw-r--r-- | webkit/port/platform/chromium/WidgetChromium.cpp | 31 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.cc | 2 |
17 files changed, 508 insertions, 431 deletions
diff --git a/webkit/build/glue/glue.vcproj b/webkit/build/glue/glue.vcproj index 3ce56f3..dcae341 100644 --- a/webkit/build/glue/glue.vcproj +++ b/webkit/build/glue/glue.vcproj @@ -521,6 +521,10 @@ > </File> <File + RelativePath="..\..\glue\webcursor_win.cc" + > + </File> + <File RelativePath="..\..\glue\webdatasource_impl.cc" > </File> diff --git a/webkit/glue/SConscript b/webkit/glue/SConscript index 61d3aa0..0870d6b 100644 --- a/webkit/glue/SConscript +++ b/webkit/glue/SConscript @@ -101,6 +101,7 @@ if env['PLATFORM'] == 'win32': if env['PLATFORM'] == 'win32': input_files.extend([ + 'webcursor_win.cc', 'webinputevent_win.cc', 'webkit_glue_win.cc', ]) diff --git a/webkit/glue/chrome_client_impl.cc b/webkit/glue/chrome_client_impl.cc index b8cb4dd..081d4c7 100644 --- a/webkit/glue/chrome_client_impl.cc +++ b/webkit/glue/chrome_client_impl.cc @@ -461,11 +461,8 @@ void ChromeClientImpl::popupOpened(WebCore::FramelessScrollView* popup_view, } } -void ChromeClientImpl::setCursor(const WebCore::Cursor& cursor) { -#if defined(OS_WIN) - // TODO(pinkerton): figure out the cursor delegate methods +void ChromeClientImpl::SetCursor(const WebCursor& cursor) { WebViewDelegate* d = webview_->delegate(); if (d) - d->SetCursor(webview_, cursor.impl()); -#endif + d->SetCursor(webview_, cursor); } diff --git a/webkit/glue/chrome_client_impl.h b/webkit/glue/chrome_client_impl.h index 7da89d3..706fedb 100644 --- a/webkit/glue/chrome_client_impl.h +++ b/webkit/glue/chrome_client_impl.h @@ -11,10 +11,12 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "ChromeClientChromium.h" MSVC_POP_WARNING(); +class WebCursor; class WebViewImpl; + namespace WebCore { - class SecurityOrigin; - struct WindowFeatures; +class SecurityOrigin; +struct WindowFeatures; } // Handles window-level notifications from WebCore on behalf of a WebView. @@ -23,6 +25,8 @@ public: ChromeClientImpl(WebViewImpl* webview); virtual ~ChromeClientImpl(); + WebViewImpl* webview() { return webview_; } + virtual void chromeDestroyed(); virtual void setWindowRect(const WebCore::FloatRect&); @@ -113,7 +117,8 @@ public: virtual void popupOpened(WebCore::FramelessScrollView* popup_view, const WebCore::IntRect& bounds, bool focus_on_show); - virtual void setCursor(const WebCore::Cursor&); + + void SetCursor(const WebCursor& cursor); private: WebViewImpl* webview_; // weak pointer diff --git a/webkit/glue/chromium_bridge_impl.cc b/webkit/glue/chromium_bridge_impl.cc index c936b30..ff977ef 100644 --- a/webkit/glue/chromium_bridge_impl.cc +++ b/webkit/glue/chromium_bridge_impl.cc @@ -5,13 +5,22 @@ #include "config.h" #include "ChromiumBridge.h" +#include "Cursor.h" +#include "Frame.h" +#include "FrameView.h" #include "HostWindow.h" +#include "Page.h" #include "PlatformWidget.h" #include "ScrollView.h" #include "Widget.h" +#undef LOG +#include "webkit/glue/chrome_client_impl.h" #include "webkit/glue/glue_util.h" +#include "webkit/glue/webcursor.h" #include "webkit/glue/webkit_glue.h" +#include "webkit/glue/webview_impl.h" +#include "webkit/glue/webview_delegate.h" namespace WebCore { @@ -19,6 +28,23 @@ static PlatformWidget ToPlatform(Widget* widget) { return widget ? widget->root()->hostWindow()->platformWindow() : 0; } +static ChromeClientImpl* ToChromeClient(Widget* widget) { + FrameView* view; + if (widget->isFrameView()) { + view = static_cast<FrameView*>(widget); + } else if (widget->parent() && widget->parent()->isFrameView()) { + view = static_cast<FrameView*>(widget->parent()); + } else { + return NULL; + } + + Page* page = view->frame() ? view->frame()->page() : NULL; + if (!page) + return NULL; + + return static_cast<ChromeClientImpl*>(page->chrome()->client()); +} + // Screen --------------------------------------------------------------------- int ChromiumBridge::screenDepth(Widget* widget) { @@ -43,4 +69,18 @@ IntRect ChromiumBridge::screenAvailableRect(Widget* widget) { webkit_glue::GetScreenInfo(ToPlatform(widget)).available_rect); } +// Widget --------------------------------------------------------------------- + +void ChromiumBridge::widgetSetCursor(Widget* widget, const Cursor& cursor) { + ChromeClientImpl* chrome_client = ToChromeClient(widget); + if (chrome_client) + chrome_client->SetCursor(WebCursor(cursor.impl())); +} + +void ChromiumBridge::widgetSetFocus(Widget* widget) { + ChromeClientImpl* chrome_client = ToChromeClient(widget); + if (chrome_client) + chrome_client->focus(); +} + } // namespace WebCore diff --git a/webkit/glue/plugins/webplugin_delegate_impl.cc b/webkit/glue/plugins/webplugin_delegate_impl.cc index 38fdde7..fd31ab7 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.cc +++ b/webkit/glue/plugins/webplugin_delegate_impl.cc @@ -973,6 +973,14 @@ bool WebPluginDelegateImpl::HandleEvent(NPEvent* event, bool ret = instance()->NPP_HandleEvent(event) != 0; + // Snag a reference to the current cursor ASAP in case the plugin modified + // it. There is a nasty race condition here with the multiprocess browser + // as someone might be setting the cursor in the main process as well. + HCURSOR last_cursor; + if (WM_MOUSEMOVE == event->event) { + last_cursor = ::GetCursor(); + } + if (pop_user_gesture) { instance()->PopPopupsEnabledState(); } @@ -1000,43 +1008,12 @@ bool WebPluginDelegateImpl::HandleEvent(NPEvent* event, } if (WM_MOUSEMOVE == event->event) { - HCURSOR actual_cursor = ::GetCursor(); - *cursor = GetCursorType(actual_cursor); + cursor->InitFromCursor(last_cursor); } return ret; } -WebCursor::Type WebPluginDelegateImpl::GetCursorType( - HCURSOR cursor) const { - static HCURSOR standard_cursors[] = { - LoadCursor(NULL, IDC_ARROW), - LoadCursor(NULL, IDC_IBEAM), - LoadCursor(NULL, IDC_WAIT), - LoadCursor(NULL, IDC_CROSS), - LoadCursor(NULL, IDC_UPARROW), - LoadCursor(NULL, IDC_SIZE), - LoadCursor(NULL, IDC_ICON), - LoadCursor(NULL, IDC_SIZENWSE), - LoadCursor(NULL, IDC_SIZENESW), - LoadCursor(NULL, IDC_SIZEWE), - LoadCursor(NULL, IDC_SIZENS), - LoadCursor(NULL, IDC_SIZEALL), - LoadCursor(NULL, IDC_NO), - LoadCursor(NULL, IDC_HAND), - LoadCursor(NULL, IDC_APPSTARTING), - LoadCursor(NULL, IDC_HELP), - }; - - for (int cursor_index = 0; cursor_index < arraysize(standard_cursors); - cursor_index++) { - if (cursor == standard_cursors[cursor_index]) - return static_cast<WebCursor::Type>(cursor_index); - } - - return WebCursor::ARROW; -} - WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( int resource_id, const std::string &url, bool notify_needed, void *notify_data, void* existing_stream) { diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h index 6d67dc7..57f7273 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.h +++ b/webkit/glue/plugins/webplugin_delegate_impl.h @@ -165,10 +165,6 @@ class WebPluginDelegateImpl : public WebPluginDelegate { // Closes down and destroys our plugin instance. void DestroyInstance(); - // Returns the cursor type. - // TODO(iyengar) Add support for custom cursors. - WebCursor::Type GetCursorType(HCURSOR cursor) const; - // used for windowed plugins HWND windowed_handle_; bool windowed_did_set_window_; diff --git a/webkit/glue/webcursor.cc b/webkit/glue/webcursor.cc index 718be01..e001a11 100644 --- a/webkit/glue/webcursor.cc +++ b/webkit/glue/webcursor.cc @@ -2,172 +2,83 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "webkit/glue/webcursor.h" -#include "webkit/glue/webkit_resources.h" +#include "config.h" +#include "PlatformCursor.h" -#if defined(OS_WIN) -#include "base/gfx/gdi_util.h" -#endif +#undef LOG +#include "base/logging.h" +#include "base/pickle.h" +#include "webkit/glue/webcursor.h" WebCursor::WebCursor() - : type_(ARROW), - hotspot_x_(0), - hotspot_y_(0), - bitmap_() { + : type_(WebCore::PlatformCursor::typePointer) { } -WebCursor::WebCursor(Type cursor_type) - : type_(cursor_type), - hotspot_x_(0), - hotspot_y_(0), - bitmap_() { -} - -WebCursor::WebCursor(const WebCursorBitmapPtr bitmap, - int hotspot_x, - int hotspot_y) - : type_(ARROW), - hotspot_x_(0), - hotspot_y_(0) { - if (bitmap) { - type_ = CUSTOM; - hotspot_x_ = hotspot_x; - hotspot_y_ = hotspot_y; -#if defined(OS_MACOSX) - CGImageRetain(bitmap_ = bitmap); -#else - bitmap_ = *bitmap; -#endif - } else { -#if defined(OS_MACOSX) - bitmap_ = NULL; -#else - memset(&bitmap_, 0, sizeof(bitmap_)); -#endif - } +WebCursor::WebCursor(const WebCore::PlatformCursor& platform_cursor) + : type_(platform_cursor.type()), + hotspot_(platform_cursor.hotSpot().x(), platform_cursor.hotSpot().y()) { + if (IsCustom()) + SetCustomData(platform_cursor.customImage().get()); } -WebCursor::~WebCursor() { -#if defined(OS_MACOSX) - CGImageRelease(bitmap_); -#endif -} +bool WebCursor::Deserialize(const Pickle* pickle, void** iter) { + int type, hotspot_x, hotspot_y, size_x, size_y, data_len; + const char* data; + + // Leave |this| unmodified unless we are going to return success. + if (!pickle->ReadInt(iter, &type) || + !pickle->ReadInt(iter, &hotspot_x) || + !pickle->ReadInt(iter, &hotspot_y) || + !pickle->ReadInt(iter, &size_x) || + !pickle->ReadInt(iter, &size_y) || + !pickle->ReadData(iter, &data, &data_len)) + return false; -WebCursor::WebCursor(const WebCursor& other) { - type_ = other.type_; - hotspot_x_ = other.hotspot_x_; - hotspot_y_ = other.hotspot_y_; -#if defined(OS_MACOSX) - bitmap_ = NULL; // set_bitmap releases bitmap_. -#endif - set_bitmap(other.bitmap_); -} + type_ = type; + hotspot_.set_x(hotspot_x); + hotspot_.set_y(hotspot_y); + custom_size_.set_width(size_x); + custom_size_.set_height(size_y); -WebCursor& WebCursor::operator=(const WebCursor& other) { - if (this != &other) { - type_ = other.type_; - hotspot_x_ = other.hotspot_x_; - hotspot_y_ = other.hotspot_y_; - set_bitmap(other.bitmap_); + custom_data_.clear(); + if (data_len > 0) { + custom_data_.resize(data_len); + memcpy(&custom_data_[0], data, data_len); } - return *this; -} -#if defined(OS_WIN) -HCURSOR WebCursor::GetCursor(HINSTANCE module_handle) const { - if (type_ == CUSTOM) - return NULL; - - static LPCWSTR cursor_resources[] = { - IDC_ARROW, - IDC_IBEAM, - IDC_WAIT, - IDC_CROSS, - IDC_UPARROW, - IDC_SIZE, - IDC_ICON, - IDC_SIZENWSE, - IDC_SIZENESW, - IDC_SIZEWE, - IDC_SIZENS, - IDC_SIZEALL, - IDC_NO, - IDC_HAND, - IDC_APPSTARTING, - IDC_HELP, - // webkit resources - MAKEINTRESOURCE(IDC_ALIAS), - MAKEINTRESOURCE(IDC_CELL), - MAKEINTRESOURCE(IDC_COLRESIZE), - MAKEINTRESOURCE(IDC_COPYCUR), - MAKEINTRESOURCE(IDC_ROWRESIZE), - MAKEINTRESOURCE(IDC_VERTICALTEXT), - MAKEINTRESOURCE(IDC_ZOOMIN), - MAKEINTRESOURCE(IDC_ZOOMOUT) - }; - - HINSTANCE instance_to_use = NULL; - if (type_ > HELP) - instance_to_use = module_handle; - - HCURSOR cursor_handle = LoadCursor(instance_to_use, - cursor_resources[type_]); - return cursor_handle; + return true; } -HCURSOR WebCursor::GetCustomCursor() const { - if (type_ != CUSTOM) - return NULL; - - BITMAPINFO cursor_bitmap_info = {0}; - gfx::CreateBitmapHeader(bitmap_.width(), bitmap_.height(), - reinterpret_cast<BITMAPINFOHEADER*>(&cursor_bitmap_info)); - HDC dc = ::GetDC(0); - HDC workingDC = CreateCompatibleDC(dc); - HBITMAP bitmap_handle = CreateDIBSection(dc, &cursor_bitmap_info, - DIB_RGB_COLORS, 0, 0, 0); - SkAutoLockPixels bitmap_lock(bitmap_); - SetDIBits(0, bitmap_handle, 0, bitmap_.height(), - bitmap_.getPixels(), &cursor_bitmap_info, DIB_RGB_COLORS); - - HBITMAP old_bitmap = reinterpret_cast<HBITMAP>(SelectObject(workingDC, - bitmap_handle)); - SetBkMode(workingDC, TRANSPARENT); - SelectObject(workingDC, old_bitmap); - - HBITMAP mask = CreateBitmap(bitmap_.width(), bitmap_.height(), - 1, 1, NULL); - ICONINFO ii = {0}; - ii.fIcon = FALSE; - ii.xHotspot = hotspot_x_; - ii.yHotspot = hotspot_y_; - ii.hbmMask = mask; - ii.hbmColor = bitmap_handle; - - HCURSOR cursor_handle = CreateIconIndirect(&ii); +bool WebCursor::Serialize(Pickle* pickle) const { + if (!pickle->WriteInt(type_) || + !pickle->WriteInt(hotspot_.x()) || + !pickle->WriteInt(hotspot_.y()) || + !pickle->WriteInt(custom_size_.width()) || + !pickle->WriteInt(custom_size_.height())) + return false; - DeleteObject(mask); - DeleteObject(bitmap_handle); - DeleteDC(workingDC); - ::ReleaseDC(0, dc); - return cursor_handle; + const char* data = NULL; + if (!custom_data_.empty()) + data = &custom_data_[0]; + return pickle->WriteData(data, custom_data_.size()); } -#endif -#if !defined(OS_MACOSX) -bool WebCursor::IsSameBitmap(const WebCursorBitmap& bitmap) const { - SkAutoLockPixels new_bitmap_lock(bitmap); - SkAutoLockPixels bitmap_lock(bitmap_); - return (memcmp(bitmap_.getPixels(), bitmap.getPixels(), - bitmap_.getSize()) == 0); +bool WebCursor::IsCustom() const { + return type_ == WebCore::PlatformCursor::typeCustom; } bool WebCursor::IsEqual(const WebCursor& other) const { - if (type_ != other.type_) - return false; + if (!IsCustom()) + return type_ == other.type_; - if(type_ == CUSTOM) - return IsSameBitmap(other.bitmap_); - return true; + return hotspot_ == other.hotspot_ && + custom_size_ == other.custom_size_ && + custom_data_ == other.custom_data_; +} + +#if !defined(OS_WIN) +void WebCursor::SetCustomData(WebCore::Image* image) { + // Please create webcursor_{$platform}.cc for your port. + NOTIMPLEMENTED(); } #endif diff --git a/webkit/glue/webcursor.h b/webkit/glue/webcursor.h index 6f555fd..92e27f3 100644 --- a/webkit/glue/webcursor.h +++ b/webkit/glue/webcursor.h @@ -2,132 +2,71 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef WEBCURSOR_H__ -#define WEBCURSOR_H__ +#ifndef WEBKIT_GLUE_WEBCURSOR_H_ +#define WEBKIT_GLUE_WEBCURSOR_H_ -#include "build/build_config.h" +#include "base/gfx/point.h" +#include "base/gfx/size.h" -#if defined(OS_MACOSX) -#include <CoreGraphics/CoreGraphics.h> -#else -#include "skia/include/SkBitmap.h" -#endif +#include <vector> -// Use CGImage on the Mac and SkBitmap on other platforms. WebCursorBitmapPtr -// is a corresponding pointer type: because CGImageRef is already a pointer -// type, we can just use that directly in the constructor, but we need an -// SkBitmap* in the Skia case. -// -// TODO(port): We should use a bitmap abstraction container. -#if defined(OS_MACOSX) -typedef CGImageRef WebCursorBitmap; -typedef WebCursorBitmap WebCursorBitmapPtr; -#else -typedef SkBitmap WebCursorBitmap; -typedef SkBitmap* WebCursorBitmapPtr; +#if defined(OS_WIN) +typedef struct HINSTANCE__* HINSTANCE; +typedef struct HICON__* HICON; +typedef HICON HCURSOR; #endif -// This class provides the functionality of a generic cursor type. The intent -// is to stay away from platform specific code here. We do have win32 specific -// functionality to retreive a HCURSOR from a cursor type. -// TODO(iyengar) : Win32 specific functionality needs to be taken out of this -// object -class WebCursor -{ -public: - // Supported cursor types. - enum Type { - ARROW, - IBEAM, - WAIT, - CROSS, - UPARROW, - SIZE, - ICON, - SIZENWSE, - SIZENESW, - SIZEWE, - SIZENS, - SIZEALL, - NO, - HAND, - APPSTARTING, - HELP, - ALIAS, - CELL, - COLRESIZE, - COPYCUR, - ROWRESIZE, - VERTICALTEXT, - ZOOMIN, - ZOOMOUT, - CUSTOM - }; +class Pickle; + +namespace WebCore { +class Image; +class PlatformCursor; +} +// This class encapsulates a cross-platform description of a cursor. Platform +// specific methods are provided to translate the cross-platform cursor into a +// platform specific cursor. It is also possible to serialize / de-serialize a +// WebCursor. +class WebCursor { + public: WebCursor(); - WebCursor(Type cursor_type); - WebCursor(const WebCursorBitmapPtr bitmap, int hotspot_x, int hotspot_y); - ~WebCursor(); - - WebCursor(const WebCursor& other); - WebCursor& operator = (const WebCursor&); - - Type type() const { return type_; }; - int hotspot_x() const { return hotspot_x_; } - int hotspot_y() const { return hotspot_y_; } - const WebCursorBitmap& bitmap() const { return bitmap_; } - - void set_type(Type cursor_type) { - type_ = cursor_type; - } - - void set_bitmap(const WebCursorBitmap& bitmap) { -#if defined(OS_MACOSX) - WebCursorBitmap old_bitmap = bitmap_; - CGImageRetain(bitmap_ = bitmap); - CGImageRelease(old_bitmap); -#else - bitmap_ = bitmap; -#endif - } + explicit WebCursor(const WebCore::PlatformCursor& platform_cursor); + + // Serialization / De-serialization + bool Deserialize(const Pickle* pickle, void** iter); + bool Serialize(Pickle* pickle) const; - void set_hotspot(int hotspot_x, int hotspot_y) { - hotspot_x_ = hotspot_x; - hotspot_y_ = hotspot_y; - } + // Returns true if GetCustomCursor should be used to allocate a platform + // specific cursor object. Otherwise GetCursor should be used. + bool IsCustom() const; + + // Returns true if the current cursor object contains the same cursor as the + // cursor object passed in. If the current cursor is a custom cursor, we also + // compare the bitmaps to verify whether they are equal. + bool IsEqual(const WebCursor& other) const; #if defined(OS_WIN) - // Returns the cursor handle. If the cursor type is a win32 or safari - // cursor, we use LoadCursor to load the cursor. - // Returns NULL on error. + // If the underlying cursor type is not a custom cursor, this functions uses + // the LoadCursor API to load the cursor and returns it. The caller SHOULD + // NOT pass the resulting handling to DestroyCursor. Returns NULL on error. HCURSOR GetCursor(HINSTANCE module_handle) const; - // If the underlying cursor type is a custom cursor, this function converts - // the WebCursorBitmap to a cursor and returns the same. The responsiblity of - // freeing the cursor handle lies with the caller. - // Returns NULL on error. + + // If the underlying cursor type is a custom cursor, this function generates + // a cursor and returns it. The responsiblity of freeing the cursor handle + // lies with the caller. Returns NULL on error. HCURSOR GetCustomCursor() const; -#endif -// TODO(port): Comparing CGImageRefs can be a heavyweight operation on the -// Mac. Don't do it if it's not needed. Maybe we can avoid this type of -// comparison on other platforms too. -#if !defined(OS_MACOSX) - // Returns true if the passed in WebCursorBitmap is the same as the the - // current WebCursorBitmap. We use memcmp to compare the two bitmaps. - bool IsSameBitmap(const WebCursorBitmap& bitmap) const; - - // Returns true if the current cursor object contains the same - // cursor as the cursor object passed in. If the current cursor - // is a custom cursor, we also compare the bitmaps to verify - // whether they are equal. - bool IsEqual(const WebCursor& other) const; + // Initialize this from the given Windows cursor. + void InitFromCursor(HCURSOR handle); #endif -protected: - Type type_; - int hotspot_x_; - int hotspot_y_; - WebCursorBitmap bitmap_; + private: + void SetCustomData(WebCore::Image* image); + + int type_; + gfx::Point hotspot_; + gfx::Size custom_size_; + std::vector<char> custom_data_; }; -#endif // WEBCURSOR_H__ +#endif // WEBKIT_GLUE_WEBCURSOR_H_ diff --git a/webkit/glue/webcursor_win.cc b/webkit/glue/webcursor_win.cc new file mode 100644 index 0000000..8671367 --- /dev/null +++ b/webkit/glue/webcursor_win.cc @@ -0,0 +1,203 @@ +// Copyright (c) 2008 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. + +#include "config.h" +#include "NativeImageSkia.h" +#include "PlatformCursor.h" + +#undef LOG +#include "base/gfx/gdi_util.h" +#include "base/logging.h" +#include "skia/include/SkBitmap.h" +#include "webkit/glue/webcursor.h" +#include "webkit/glue/webkit_resources.h" + +using WebCore::PlatformCursor; + +static LPCWSTR ToCursorID(PlatformCursor::Type type) { + switch (type) { + case PlatformCursor::typePointer: + return IDC_ARROW; + case PlatformCursor::typeCross: + return IDC_CROSS; + case PlatformCursor::typeHand: + return IDC_HAND; + case PlatformCursor::typeIBeam: + return IDC_IBEAM; + case PlatformCursor::typeWait: + return IDC_WAIT; + case PlatformCursor::typeHelp: + return IDC_HELP; + case PlatformCursor::typeEastResize: + return IDC_SIZEWE; + case PlatformCursor::typeNorthResize: + return IDC_SIZENS; + case PlatformCursor::typeNorthEastResize: + return IDC_SIZENESW; + case PlatformCursor::typeNorthWestResize: + return IDC_SIZENWSE; + case PlatformCursor::typeSouthResize: + return IDC_SIZENS; + case PlatformCursor::typeSouthEastResize: + return IDC_SIZENWSE; + case PlatformCursor::typeSouthWestResize: + return IDC_SIZENESW; + case PlatformCursor::typeWestResize: + return IDC_SIZEWE; + case PlatformCursor::typeNorthSouthResize: + return IDC_SIZENS; + case PlatformCursor::typeEastWestResize: + return IDC_SIZEWE; + case PlatformCursor::typeNorthEastSouthWestResize: + return IDC_SIZENESW; + case PlatformCursor::typeNorthWestSouthEastResize: + return IDC_SIZENWSE; + case PlatformCursor::typeColumnResize: + return MAKEINTRESOURCE(IDC_COLRESIZE); + case PlatformCursor::typeRowResize: + return MAKEINTRESOURCE(IDC_ROWRESIZE); + case PlatformCursor::typeMiddlePanning: + return MAKEINTRESOURCE(IDC_PAN_MIDDLE); + case PlatformCursor::typeEastPanning: + return MAKEINTRESOURCE(IDC_PAN_EAST); + case PlatformCursor::typeNorthPanning: + return MAKEINTRESOURCE(IDC_PAN_NORTH); + case PlatformCursor::typeNorthEastPanning: + return MAKEINTRESOURCE(IDC_PAN_NORTH_EAST); + case PlatformCursor::typeNorthWestPanning: + return MAKEINTRESOURCE(IDC_PAN_NORTH_WEST); + case PlatformCursor::typeSouthPanning: + return MAKEINTRESOURCE(IDC_PAN_SOUTH); + case PlatformCursor::typeSouthEastPanning: + return MAKEINTRESOURCE(IDC_PAN_SOUTH_EAST); + case PlatformCursor::typeSouthWestPanning: + return MAKEINTRESOURCE(IDC_PAN_SOUTH_WEST); + case PlatformCursor::typeWestPanning: + return MAKEINTRESOURCE(IDC_PAN_WEST); + case PlatformCursor::typeMove: + return IDC_SIZEALL; + case PlatformCursor::typeVerticalText: + return MAKEINTRESOURCE(IDC_VERTICALTEXT); + case PlatformCursor::typeCell: + return MAKEINTRESOURCE(IDC_CELL); + case PlatformCursor::typeContextMenu: + return MAKEINTRESOURCE(IDC_ARROW); + case PlatformCursor::typeAlias: + return MAKEINTRESOURCE(IDC_ALIAS); + case PlatformCursor::typeProgress: + return IDC_APPSTARTING; + case PlatformCursor::typeNoDrop: + return IDC_NO; + case PlatformCursor::typeCopy: + return MAKEINTRESOURCE(IDC_COPYCUR); + case PlatformCursor::typeNone: + return IDC_ARROW; + case PlatformCursor::typeNotAllowed: + return IDC_NO; + case PlatformCursor::typeZoomIn: + return MAKEINTRESOURCE(IDC_ZOOMIN); + case PlatformCursor::typeZoomOut: + return MAKEINTRESOURCE(IDC_ZOOMOUT); + } + NOTREACHED(); + return NULL; +} + +static bool IsSystemCursorID(LPCWSTR cursor_id) { + return cursor_id >= IDC_ARROW; // See WinUser.h +} + +static PlatformCursor::Type ToPlatformCursorType(HCURSOR cursor) { + static struct { + HCURSOR cursor; + PlatformCursor::Type type; + } kStandardCursors[] = { + { LoadCursor(NULL, IDC_ARROW), PlatformCursor::typePointer }, + { LoadCursor(NULL, IDC_IBEAM), PlatformCursor::typeIBeam }, + { LoadCursor(NULL, IDC_WAIT), PlatformCursor::typeWait }, + { LoadCursor(NULL, IDC_CROSS), PlatformCursor::typeCross }, + { LoadCursor(NULL, IDC_SIZENWSE), PlatformCursor::typeNorthWestResize }, + { LoadCursor(NULL, IDC_SIZENESW), PlatformCursor::typeNorthEastResize }, + { LoadCursor(NULL, IDC_SIZEWE), PlatformCursor::typeEastWestResize }, + { LoadCursor(NULL, IDC_SIZENS), PlatformCursor::typeNorthSouthResize }, + { LoadCursor(NULL, IDC_SIZEALL), PlatformCursor::typeMove }, + { LoadCursor(NULL, IDC_NO), PlatformCursor::typeNotAllowed }, + { LoadCursor(NULL, IDC_HAND), PlatformCursor::typeHand }, + { LoadCursor(NULL, IDC_APPSTARTING), PlatformCursor::typeProgress }, + { LoadCursor(NULL, IDC_HELP), PlatformCursor::typeHelp }, + }; + for (int i = 0; i < arraysize(kStandardCursors); i++) { + if (cursor == kStandardCursors[i].cursor) + return kStandardCursors[i].type; + } + return PlatformCursor::typePointer; +} + +HCURSOR WebCursor::GetCursor(HINSTANCE module_handle) const { + if (IsCustom()) + return NULL; + + LPCWSTR cursor_id = ToCursorID(static_cast<PlatformCursor::Type>(type_)); + + if (IsSystemCursorID(cursor_id)) + module_handle = NULL; + + return LoadCursor(module_handle, cursor_id); +} + +HCURSOR WebCursor::GetCustomCursor() const { + if (!IsCustom()) + return NULL; + + BITMAPINFO cursor_bitmap_info = {0}; + gfx::CreateBitmapHeader( + custom_size_.width(), custom_size_.height(), + reinterpret_cast<BITMAPINFOHEADER*>(&cursor_bitmap_info)); + HDC dc = GetDC(0); + HDC workingDC = CreateCompatibleDC(dc); + HBITMAP bitmap_handle = CreateDIBSection( + dc, &cursor_bitmap_info, DIB_RGB_COLORS, 0, 0, 0); + SetDIBits( + 0, bitmap_handle, 0, custom_size_.height(), &custom_data_[0], + &cursor_bitmap_info, DIB_RGB_COLORS); + + HBITMAP old_bitmap = reinterpret_cast<HBITMAP>( + SelectObject(workingDC, bitmap_handle)); + SetBkMode(workingDC, TRANSPARENT); + SelectObject(workingDC, old_bitmap); + + HBITMAP mask = CreateBitmap( + custom_size_.width(), custom_size_.height(), 1, 1, NULL); + ICONINFO ii = {0}; + ii.fIcon = FALSE; + ii.xHotspot = hotspot_.x(); + ii.yHotspot = hotspot_.y(); + ii.hbmMask = mask; + ii.hbmColor = bitmap_handle; + + HCURSOR cursor_handle = CreateIconIndirect(&ii); + + DeleteObject(mask); + DeleteObject(bitmap_handle); + DeleteDC(workingDC); + ReleaseDC(0, dc); + return cursor_handle; +} + +void WebCursor::InitFromCursor(HCURSOR cursor) { + // TODO(iyengar) Add support for custom cursors. + *this = WebCursor(ToPlatformCursorType(cursor)); +} + +void WebCursor::SetCustomData(WebCore::Image* image) { + WebCore::NativeImagePtr image_ptr = image->nativeImageForCurrentFrame(); + if (!image_ptr) + return; + + SkAutoLockPixels bitmap_lock(*image_ptr); + custom_data_.resize(image_ptr->getSize()); + memcpy(&custom_data_[0], image_ptr->getPixels(), image_ptr->getSize()); + custom_size_.set_width(image_ptr->width()); + custom_size_.set_height(image_ptr->height()); +} diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc index c428002..6d3fef8 100644 --- a/webkit/glue/webplugin_impl.cc +++ b/webkit/glue/webplugin_impl.cc @@ -46,8 +46,10 @@ MSVC_POP_WARNING(); #include "base/string_util.h" #include "base/sys_string_conversions.h" #include "net/base/escape.h" +#include "webkit/glue/chrome_client_impl.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/multipart_response_delegate.h" +#include "webkit/glue/webcursor.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webplugin_impl.h" #include "webkit/glue/plugins/plugin_host.h" @@ -869,13 +871,14 @@ void WebPluginImpl::handleMouseEvent(WebCore::MouseEvent* event) { // TODO(pkasting): http://b/1119691 This conditional seems exactly backwards, // but it matches Safari's code, and if I reverse it, giving focus to a // transparent (windowless) plugin fails. - WebCursor current_web_cursor; - if (!delegate_->HandleEvent(&np_event, ¤t_web_cursor)) + WebCursor cursor; + if (!delegate_->HandleEvent(&np_event, &cursor)) event->setDefaultHandled(); // A windowless plugin can change the cursor in response to the WM_MOUSEMOVE // event. We need to reflect the changed cursor in the frame view as the - // the mouse is moved in the boundaries of the windowless plugin. - parent_view->setCursor(WebCore::PlatformCursor(current_web_cursor)); + // mouse is moved in the boundaries of the windowless plugin. + static_cast<ChromeClientImpl*>( + parent_view->frame()->page()->chrome()->client())->SetCursor(cursor); #else NOTIMPLEMENTED(); #endif diff --git a/webkit/port/page/chromium/ChromeClientChromium.h b/webkit/port/page/chromium/ChromeClientChromium.h index 31633ae..39d2e39 100644 --- a/webkit/port/page/chromium/ChromeClientChromium.h +++ b/webkit/port/page/chromium/ChromeClientChromium.h @@ -29,9 +29,6 @@ namespace WebCore { virtual void popupOpened(FramelessScrollView* popupView, const IntRect& bounds, bool focus_on_show) = 0; - - // Set the current cursor. - virtual void setCursor(const Cursor& cursor) = 0; }; } diff --git a/webkit/port/platform/chromium/ChromiumBridge.h b/webkit/port/platform/chromium/ChromiumBridge.h index b7ff628..e0a461f5 100644 --- a/webkit/port/platform/chromium/ChromiumBridge.h +++ b/webkit/port/platform/chromium/ChromiumBridge.h @@ -31,6 +31,7 @@ #define ChromiumBridge_h namespace WebCore { + class Cursor; class IntRect; class Widget; @@ -39,12 +40,16 @@ namespace WebCore { class ChromiumBridge { public: - // Screen information ------------------------------------------------- + // Screen ------------------------------------------------------------- static int screenDepth(Widget*); static int screenDepthPerComponent(Widget*); static bool screenIsMonochrome(Widget*); static IntRect screenRect(Widget*); static IntRect screenAvailableRect(Widget*); + + // Widget ------------------------------------------------------------- + static void widgetSetCursor(Widget*, const Cursor&); + static void widgetSetFocus(Widget*); }; } diff --git a/webkit/port/platform/chromium/CursorChromium.cpp b/webkit/port/platform/chromium/CursorChromium.cpp index 7c7e534..90485fe 100644 --- a/webkit/port/platform/chromium/CursorChromium.cpp +++ b/webkit/port/platform/chromium/CursorChromium.cpp @@ -26,17 +26,6 @@ #include "config.h" #include "Cursor.h" -#include "Image.h" -#include "IntPoint.h" -#include "NativeImageSkia.h" -#include "NotImplemented.h" - -#include "base/basictypes.h" -#include "webkit/glue/webcursor.h" -#include "webkit/glue/webkit_resources.h" -#include "webkit/glue/webkit_glue.h" - -#define ALPHA_CURSORS namespace WebCore { @@ -45,21 +34,9 @@ Cursor::Cursor(const Cursor& other) { } -Cursor::Cursor(Image* img, const IntPoint& hotspot) +Cursor::Cursor(Image* image, const IntPoint& hotSpot) + : m_impl(image, hotSpot) { - // If we don't have a valid bitmap, then fallback to the default - // cursor (ARROW). - NativeImagePtr bitmap = img->nativeImageForCurrentFrame(); - if (!bitmap) - return; - - m_impl.set_type(WebCursor::CUSTOM); - m_impl.set_hotspot(hotspot.x(), hotspot.y()); -#if defined(OS_MACOSX) - m_impl.set_bitmap(bitmap); -#else - m_impl.set_bitmap(*bitmap); -#endif } Cursor::~Cursor() @@ -79,258 +56,247 @@ Cursor::Cursor(PlatformCursor c) const Cursor& pointerCursor() { - // The double-parenthesis here and elsewhere is a glorious hack to work - // around a corner in C++ parsing. Otherwise, code like - // Cursor c(PlatformCursor(...)); - // is parsed as a *function* declaration (since PlatformCursor is a type, - // after all). - static const Cursor c((PlatformCursor(WebCursor::ARROW))); + static const Cursor c(PlatformCursor::typePointer); return c; } const Cursor& crossCursor() { - static const Cursor c((PlatformCursor(WebCursor::CROSS))); + static const Cursor c(PlatformCursor::typeCross); return c; } const Cursor& handCursor() { - static const Cursor c((PlatformCursor(WebCursor::HAND))); + static const Cursor c(PlatformCursor::typeHand); return c; } const Cursor& iBeamCursor() { - static const Cursor c((PlatformCursor(WebCursor::IBEAM))); + static const Cursor c(PlatformCursor::typeIBeam); return c; } const Cursor& waitCursor() { - static const Cursor c((PlatformCursor(WebCursor::WAIT))); + static const Cursor c(PlatformCursor::typeWait); return c; } const Cursor& helpCursor() { - static const Cursor c((PlatformCursor(WebCursor::HELP))); + static const Cursor c(PlatformCursor::typeHelp); return c; } const Cursor& eastResizeCursor() { - static const Cursor c((PlatformCursor(WebCursor::SIZEWE))); + static const Cursor c(PlatformCursor::typeEastResize); return c; } const Cursor& northResizeCursor() { - static const Cursor c((PlatformCursor(WebCursor::SIZENS))); + static const Cursor c(PlatformCursor::typeNorthResize); return c; } const Cursor& northEastResizeCursor() { - static const Cursor c((PlatformCursor(WebCursor::SIZENESW))); + static const Cursor c(PlatformCursor::typeNorthEastResize); return c; } const Cursor& northWestResizeCursor() { - static const Cursor c((PlatformCursor(WebCursor::SIZENWSE))); + static const Cursor c(PlatformCursor::typeNorthWestResize); return c; } const Cursor& southResizeCursor() { - static const Cursor c((PlatformCursor(WebCursor::SIZENS))); + static const Cursor c(PlatformCursor::typeSouthResize); return c; } const Cursor& southEastResizeCursor() { - static const Cursor c((PlatformCursor(WebCursor::SIZENWSE))); + static const Cursor c(PlatformCursor::typeSouthEastResize); return c; } const Cursor& southWestResizeCursor() { - static const Cursor c((PlatformCursor(WebCursor::SIZENESW))); + static const Cursor c(PlatformCursor::typeSouthWestResize); return c; } const Cursor& westResizeCursor() { - static const Cursor c((PlatformCursor(WebCursor::SIZEWE))); + static const Cursor c(PlatformCursor::typeWestResize); return c; } const Cursor& northSouthResizeCursor() { - static const Cursor c((PlatformCursor(WebCursor::SIZENS))); + static const Cursor c(PlatformCursor::typeNorthSouthResize); return c; } const Cursor& eastWestResizeCursor() { - static const Cursor c((PlatformCursor(WebCursor::SIZEWE))); + static const Cursor c(PlatformCursor::typeEastWestResize); return c; } const Cursor& northEastSouthWestResizeCursor() { - static const Cursor c((PlatformCursor(WebCursor::SIZENESW))); + static const Cursor c(PlatformCursor::typeNorthEastSouthWestResize); return c; } const Cursor& northWestSouthEastResizeCursor() { - static const Cursor c((PlatformCursor(WebCursor::SIZENWSE))); + static const Cursor c(PlatformCursor::typeNorthWestSouthEastResize); return c; } const Cursor& columnResizeCursor() { - static const Cursor c((PlatformCursor(WebCursor::COLRESIZE))); + static const Cursor c(PlatformCursor::typeColumnResize); return c; } const Cursor& rowResizeCursor() { - static const Cursor c((PlatformCursor(WebCursor::ROWRESIZE))); + static const Cursor c(PlatformCursor::typeRowResize); return c; } const Cursor& middlePanningCursor() { - GlueBitmap bitmap = webkit_glue::GetBitmapResource(IDC_PAN_MIDDLE); - static const Cursor c((PlatformCursor(WebCursor(bitmap, 7, 7)))); + static const Cursor c(PlatformCursor::typeMiddlePanning); return c; } const Cursor& eastPanningCursor() { - GlueBitmap bitmap = webkit_glue::GetBitmapResource(IDC_PAN_EAST); - static const Cursor c((PlatformCursor(WebCursor(bitmap, 7, 7)))); + static const Cursor c(PlatformCursor::typeEastPanning); return c; } const Cursor& northPanningCursor() { - GlueBitmap bitmap = webkit_glue::GetBitmapResource(IDC_PAN_NORTH); - static const Cursor c((PlatformCursor(WebCursor(bitmap, 7, 7)))); + static const Cursor c(PlatformCursor::typeNorthPanning); return c; } const Cursor& northEastPanningCursor() { - GlueBitmap bitmap = webkit_glue::GetBitmapResource(IDC_PAN_NORTH_EAST); - static const Cursor c((PlatformCursor(WebCursor(bitmap, 7, 7)))); + static const Cursor c(PlatformCursor::typeNorthEastPanning); return c; } const Cursor& northWestPanningCursor() { - GlueBitmap bitmap = webkit_glue::GetBitmapResource(IDC_PAN_NORTH_WEST); - static const Cursor c((PlatformCursor(WebCursor(bitmap, 7, 7)))); + static const Cursor c(PlatformCursor::typeNorthWestPanning); return c; } const Cursor& southPanningCursor() { - GlueBitmap bitmap = webkit_glue::GetBitmapResource(IDC_PAN_SOUTH); - static const Cursor c((PlatformCursor(WebCursor(bitmap, 7, 7)))); + static const Cursor c(PlatformCursor::typeSouthPanning); return c; } const Cursor& southEastPanningCursor() { - GlueBitmap bitmap = webkit_glue::GetBitmapResource(IDC_PAN_SOUTH_EAST); - static const Cursor c((PlatformCursor(WebCursor(bitmap, 7, 7)))); + static const Cursor c(PlatformCursor::typeSouthEastPanning); return c; } const Cursor& southWestPanningCursor() { - GlueBitmap bitmap = webkit_glue::GetBitmapResource(IDC_PAN_SOUTH_WEST); - static const Cursor c((PlatformCursor(WebCursor(bitmap, 7, 7)))); + static const Cursor c(PlatformCursor::typeSouthWestPanning); return c; } const Cursor& westPanningCursor() { - GlueBitmap bitmap = webkit_glue::GetBitmapResource(IDC_PAN_WEST); - static const Cursor c((PlatformCursor(WebCursor(bitmap, 7, 7)))); + static const Cursor c(PlatformCursor::typeWestPanning); return c; } const Cursor& moveCursor() { - static const Cursor c((PlatformCursor(WebCursor::SIZEALL))); + static const Cursor c(PlatformCursor::typeMove); return c; } const Cursor& verticalTextCursor() { - static const Cursor c((PlatformCursor(WebCursor::VERTICALTEXT))); + static const Cursor c(PlatformCursor::typeVerticalText); return c; } const Cursor& cellCursor() { - static const Cursor c((PlatformCursor(WebCursor::CELL))); + static const Cursor c(PlatformCursor::typeCell); return c; } const Cursor& contextMenuCursor() { - return pointerCursor(); + static const Cursor c(PlatformCursor::typeContextMenu); + return c; } const Cursor& aliasCursor() { - static const Cursor c((PlatformCursor(WebCursor::ALIAS))); + static const Cursor c(PlatformCursor::typeAlias); return c; } const Cursor& progressCursor() { - static const Cursor c((PlatformCursor(WebCursor::APPSTARTING))); + static const Cursor c(PlatformCursor::typeProgress); return c; } const Cursor& noDropCursor() { - return notAllowedCursor(); + static const Cursor c(PlatformCursor::typeNoDrop); + return c; } const Cursor& copyCursor() { - static const Cursor c((PlatformCursor(WebCursor::COPYCUR))); + static const Cursor c(PlatformCursor::typeCopy); return c; } const Cursor& noneCursor() { - return pointerCursor(); + static const Cursor c(PlatformCursor::typeNone); + return c; } const Cursor& notAllowedCursor() { - static const Cursor c((PlatformCursor(WebCursor::NO))); + static const Cursor c(PlatformCursor::typeNotAllowed); return c; } const Cursor& zoomInCursor() { - static const Cursor c((PlatformCursor(WebCursor::ZOOMIN))); + static const Cursor c(PlatformCursor::typeZoomIn); return c; } const Cursor& zoomOutCursor() { - static const Cursor c((PlatformCursor(WebCursor::ZOOMOUT))); + static const Cursor c(PlatformCursor::typeZoomOut); return c; } diff --git a/webkit/port/platform/chromium/PlatformCursor.h b/webkit/port/platform/chromium/PlatformCursor.h index 05507cf..8d5bd04 100644 --- a/webkit/port/platform/chromium/PlatformCursor.h +++ b/webkit/port/platform/chromium/PlatformCursor.h @@ -27,22 +27,80 @@ // (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 PlatformCursor_h__ -#define PlatformCursor_h__ +#ifndef PlatformCursor_h +#define PlatformCursor_h -#include "webkit/glue/webcursor.h" +#include "Image.h" +#include "IntPoint.h" +#include "RefPtr.h" namespace WebCore { + class PlatformCursor { + public: + enum Type { + typePointer, + typeCross, + typeHand, + typeIBeam, + typeWait, + typeHelp, + typeEastResize, + typeNorthResize, + typeNorthEastResize, + typeNorthWestResize, + typeSouthResize, + typeSouthEastResize, + typeSouthWestResize, + typeWestResize, + typeNorthSouthResize, + typeEastWestResize, + typeNorthEastSouthWestResize, + typeNorthWestSouthEastResize, + typeColumnResize, + typeRowResize, + typeMiddlePanning, + typeEastPanning, + typeNorthPanning, + typeNorthEastPanning, + typeNorthWestPanning, + typeSouthPanning, + typeSouthEastPanning, + typeSouthWestPanning, + typeWestPanning, + typeMove, + typeVerticalText, + typeCell, + typeContextMenu, + typeAlias, + typeProgress, + typeNoDrop, + typeCopy, + typeNone, + typeNotAllowed, + typeZoomIn, + typeZoomOut, + typeCustom + }; -struct PlatformCursor : WebCursor { - explicit PlatformCursor(int type = 0) - : WebCursor(static_cast<WebCursor::Type>(type)) { - } - explicit PlatformCursor(const WebCursor& c) - : WebCursor(c) { - } -}; + // Cursor.h assumes that it can initialize us to 0. + explicit PlatformCursor(int type = 0) : m_type(typePointer) {} + + PlatformCursor(Type type) : m_type(type) {} + PlatformCursor(Image* image, const IntPoint& hotSpot) + : m_image(image) + , m_hotSpot(hotSpot) + , m_type(typeCustom) {} + + PassRefPtr<Image> customImage() const { return m_image; } + const IntPoint& hotSpot() const { return m_hotSpot; } + Type type() const { return m_type; } + + private: + RefPtr<Image> m_image; + IntPoint m_hotSpot; + Type m_type; + }; } #endif diff --git a/webkit/port/platform/chromium/WidgetChromium.cpp b/webkit/port/platform/chromium/WidgetChromium.cpp index 9b84698..e980370 100644 --- a/webkit/port/platform/chromium/WidgetChromium.cpp +++ b/webkit/port/platform/chromium/WidgetChromium.cpp @@ -26,33 +26,12 @@ #include "config.h" #include "Widget.h" +#include "ChromiumBridge.h" #include "Assertions.h" -#include "ChromeClientChromium.h" -#include "Frame.h" -#include "FrameView.h" -#include "Page.h" #include "NotImplemented.h" namespace WebCore { -ChromeClientChromium* chromeClientChromium(Widget* widget) -{ - FrameView* view; - if (widget->isFrameView()) { - view = static_cast<FrameView*>(widget); - } else if (widget->parent() && widget->parent()->isFrameView()) { - view = static_cast<FrameView*>(widget->parent()); - } else { - return 0; - } - - Page* page = view->frame() ? view->frame()->page() : 0; - if (!page) - return 0; - - return static_cast<ChromeClientChromium*>(page->chrome()->client()); -} - Widget::Widget(PlatformWidget widget) { init(widget); @@ -73,9 +52,7 @@ void Widget::hide() void Widget::setCursor(const Cursor& cursor) { - ChromeClientChromium* client = chromeClientChromium(this); - if (client) - client->setCursor(cursor); + ChromiumBridge::widgetSetCursor(this, cursor); } void Widget::paint(GraphicsContext*, const IntRect&) @@ -84,9 +61,7 @@ void Widget::paint(GraphicsContext*, const IntRect&) void Widget::setFocus() { - ChromeClientChromium* client = chromeClientChromium(this); - if (client) - client->focus(); + ChromiumBridge::widgetSetFocus(this); } void Widget::setIsSelected(bool) diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 7e21c6f..475289ca 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -714,7 +714,7 @@ void TestWebViewDelegate::SetCursor(WebWidget* webwidget, DestroyIcon(custom_cursor_); custom_cursor_ = NULL; } - if (cursor.type() == WebCursor::CUSTOM) { + if (cursor.IsCustom()) { custom_cursor_ = cursor.GetCustomCursor(); host->SetCursor(custom_cursor_); } else { |