diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-06 00:36:52 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-06 00:36:52 +0000 |
commit | 4c870b4013b3cf658c40e2c7b98e0a419ae7236f (patch) | |
tree | e701a8ab7b093e04367a0956e7ff94a702806e6c /webkit/port | |
parent | 983f7bd3fa88bbdac942dbfaf0269b1684a5c1ee (diff) | |
download | chromium_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 'webkit/port')
-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 |
5 files changed, 124 insertions, 123 deletions
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) |