2007-09-12 Oliver Hunt <oliver@apple.com>
authoroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2007 05:33:15 +0000 (05:33 +0000)
committeroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2007 05:33:15 +0000 (05:33 +0000)
        Reviewed by Adam.

WebKit:
        Fixing
            <rdar://problem/5018591> Windows doesn't have a standard vertical text cursor
            <rdar://problem/5224996> Add zoom in and zoom out cursors

        Add images for vertical text and zoom in and out cursors to WebKit resources.

        * WebKit.vcproj/verticalTextCursor.png: Added.
        * WebKit.vcproj/WebKit.rc:
        * WebKit.vcproj/WebKit.vcproj:
        * WebKit.vcproj/resource.h:
        * WebKit.vcproj/zoomInCursor.png: Added.
        * WebKit.vcproj/zoomOutCursor.png: Added.
        * WebKitDLL.cpp:
        (loadResourceIntoBuffer):

WebCore:
        Fixing
            <rdar://problem/5018591> Windows doesn't have a standard vertical text cursor
            <rdar://problem/5224996> Add zoom in and zoom out cursors

        Added SharedCursor for CursorWin so we can correctly track lifetime of custom/image
        based cursors, such as the vertical text and zooming cursors.

        * platform/Cursor.h:
        (WebCore::SharedCursor::SharedCursor):
        (WebCore::SharedCursor::~SharedCursor):
        (WebCore::SharedCursor::nativeCursor):
        * platform/win/CursorWin.cpp:
        (WebCore::Cursor::Cursor):
        (WebCore::loadCursorByName):
        (WebCore::loadSharedCursor):
        (WebCore::pointerCursor):
        (WebCore::crossCursor):
        (WebCore::handCursor):
        (WebCore::iBeamCursor):
        (WebCore::waitCursor):
        (WebCore::helpCursor):
        (WebCore::eastResizeCursor):
        (WebCore::northResizeCursor):
        (WebCore::northEastResizeCursor):
        (WebCore::northWestResizeCursor):
        (WebCore::southResizeCursor):
        (WebCore::southEastResizeCursor):
        (WebCore::southWestResizeCursor):
        (WebCore::westResizeCursor):
        (WebCore::northSouthResizeCursor):
        (WebCore::eastWestResizeCursor):
        (WebCore::northEastSouthWestResizeCursor):
        (WebCore::northWestSouthEastResizeCursor):
        (WebCore::columnResizeCursor):
        (WebCore::rowResizeCursor):
        (WebCore::moveCursor):
        (WebCore::verticalTextCursor):
        (WebCore::progressCursor):
        (WebCore::notAllowedCursor):
        (WebCore::zoomInCursor):
        (WebCore::zoomOutCursor):
        * platform/win/WidgetWin.cpp:
        (WebCore::Widget::setCursor):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@25530 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
WebCore/ChangeLog
WebCore/platform/Cursor.h
WebCore/platform/win/CursorWin.cpp
WebCore/platform/win/WidgetWin.cpp
WebKit/win/ChangeLog
WebKit/win/WebKit.vcproj/WebKit.rc
WebKit/win/WebKit.vcproj/WebKit.vcproj
WebKit/win/WebKit.vcproj/resource.h
WebKit/win/WebKit.vcproj/verticalTextCursor.png [new file with mode: 0644]
WebKit/win/WebKit.vcproj/zoomInCursor.png [new file with mode: 0644]
WebKit/win/WebKit.vcproj/zoomOutCursor.png [new file with mode: 0644]
WebKit/win/WebKitDLL.cpp

index 1776aee..4662cd0 100644 (file)
@@ -1,3 +1,51 @@
+2007-09-12  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Adam.
+
+        Fixing 
+            <rdar://problem/5018591> Windows doesn't have a standard vertical text cursor
+            <rdar://problem/5224996> Add zoom in and zoom out cursors
+
+        Added SharedCursor for CursorWin so we can correctly track lifetime of custom/image
+        based cursors, such as the vertical text and zooming cursors.
+
+        * platform/Cursor.h:
+        (WebCore::SharedCursor::SharedCursor):
+        (WebCore::SharedCursor::~SharedCursor):
+        (WebCore::SharedCursor::nativeCursor):
+        * platform/win/CursorWin.cpp:
+        (WebCore::Cursor::Cursor):
+        (WebCore::loadCursorByName):
+        (WebCore::loadSharedCursor):
+        (WebCore::pointerCursor):
+        (WebCore::crossCursor):
+        (WebCore::handCursor):
+        (WebCore::iBeamCursor):
+        (WebCore::waitCursor):
+        (WebCore::helpCursor):
+        (WebCore::eastResizeCursor):
+        (WebCore::northResizeCursor):
+        (WebCore::northEastResizeCursor):
+        (WebCore::northWestResizeCursor):
+        (WebCore::southResizeCursor):
+        (WebCore::southEastResizeCursor):
+        (WebCore::southWestResizeCursor):
+        (WebCore::westResizeCursor):
+        (WebCore::northSouthResizeCursor):
+        (WebCore::eastWestResizeCursor):
+        (WebCore::northEastSouthWestResizeCursor):
+        (WebCore::northWestSouthEastResizeCursor):
+        (WebCore::columnResizeCursor):
+        (WebCore::rowResizeCursor):
+        (WebCore::moveCursor):
+        (WebCore::verticalTextCursor):
+        (WebCore::progressCursor):
+        (WebCore::notAllowedCursor):
+        (WebCore::zoomInCursor):
+        (WebCore::zoomOutCursor):
+        * platform/win/WidgetWin.cpp:
+        (WebCore::Widget::setCursor):
+
 2007-09-12  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Geoff Garen
index 34818d9..d4f7c07 100644 (file)
@@ -31,6 +31,8 @@
 #if PLATFORM(WIN)
 typedef struct HICON__* HICON;
 typedef HICON HCURSOR;
+#include <Shared.h>
+#include <RefPtr.h>
 #elif PLATFORM(GDK)
 #include <gdk/gdk.h>
 #elif PLATFORM(QT)
@@ -51,7 +53,17 @@ namespace WebCore {
     class IntPoint;
 
 #if PLATFORM(WIN)
-    typedef HCURSOR PlatformCursor;
+    class SharedCursor : public Shared<SharedCursor> {
+    public:
+        SharedCursor(HCURSOR nativeCursor) : m_nativeCursor(nativeCursor) {}
+        ~SharedCursor() {
+            DestroyIcon(m_nativeCursor);
+        }
+        HCURSOR nativeCursor() { return m_nativeCursor; }
+    private:
+        HCURSOR m_nativeCursor;
+    };
+    typedef RefPtr<SharedCursor> PlatformCursor;
 #elif PLATFORM(MAC)
     typedef NSCursor* PlatformCursor;
 #elif PLATFORM(GDK)
index c50329c..5cafe11 100644 (file)
@@ -79,7 +79,7 @@ Cursor::Cursor(Image* img, const IntPoint& hotspot)
         ii.hbmMask = hMask;
         ii.hbmColor = hCursor;
 
-        m_impl = CreateIconIndirect(&ii);
+        m_impl = new SharedCursor(CreateIconIndirect(&ii));
       
         DeleteObject(hMask); 
         DeleteObject(hCursor); 
@@ -119,7 +119,7 @@ Cursor::Cursor(Image* img, const IntPoint& hotspot)
         icon.yHotspot = hotspot.y();
         icon.hbmMask = andMask;
         icon.hbmColor = xorMask;
-        m_impl = CreateIconIndirect(&icon);
+        m_impl = new SharedCursor(CreateIconIndirect(&icon));
 
         DeleteObject(andMask);
         DeleteObject(xorMask);
@@ -133,7 +133,6 @@ Cursor::Cursor(Image* img, const IntPoint& hotspot)
 
 Cursor::~Cursor()
 {
-    DestroyIcon(m_impl);
 }
 
 Cursor& Cursor::operator=(const Cursor& other)
@@ -142,143 +141,160 @@ Cursor& Cursor::operator=(const Cursor& other)
     return *this;
 }
 
-Cursor::Cursor(HCURSOR c)
+Cursor::Cursor(PlatformCursor c)
     : m_impl(c)
 {
 }
 
+static Cursor loadCursorByName(char *name, int x, int y) {
+    IntPoint hotSpot(x, y);
+    Cursor c;
+    Image *cursorImage = Image::loadPlatformResource(name);
+    if (cursorImage && !cursorImage->isNull()) {
+        c = Cursor(cursorImage, hotSpot);
+        delete cursorImage;
+    } else
+        c = pointerCursor();
+    return c;
+}
+
+static PassRefPtr<SharedCursor> loadSharedCursor(HINSTANCE hInstance, LPCTSTR lpCursorName)
+{
+    return new SharedCursor(LoadCursor(hInstance, lpCursorName));
+}
+
 const Cursor& pointerCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_ARROW);
+    static Cursor c = loadSharedCursor(0, IDC_ARROW);
     return c;
 }
 
 const Cursor& crossCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_CROSS);
+    static Cursor c = loadSharedCursor(0, IDC_CROSS);
     return c;
 }
 
 const Cursor& handCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_HAND);
+    static Cursor c = loadSharedCursor(0, IDC_HAND);
     return c;
 }
 
 const Cursor& iBeamCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_IBEAM);
+    static Cursor c = loadSharedCursor(0, IDC_IBEAM);
     return c;
 }
 
 const Cursor& waitCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_WAIT);
+    static Cursor c = loadSharedCursor(0, IDC_WAIT);
     return c;
 }
 
 const Cursor& helpCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_HELP);
+    static Cursor c = loadSharedCursor(0, IDC_HELP);
     return c;
 }
 
 const Cursor& eastResizeCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_SIZEWE);
+    static Cursor c = loadSharedCursor(0, IDC_SIZEWE);
     return c;
 }
 
 const Cursor& northResizeCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_SIZENS);
+    static Cursor c = loadSharedCursor(0, IDC_SIZENS);
     return c;
 }
 
 const Cursor& northEastResizeCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_SIZENESW);
+    static Cursor c = loadSharedCursor(0, IDC_SIZENESW);
     return c;
 }
 
 const Cursor& northWestResizeCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_SIZENWSE);
+    static Cursor c = loadSharedCursor(0, IDC_SIZENWSE);
     return c;
 }
 
 const Cursor& southResizeCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_SIZENS);
+    static Cursor c = loadSharedCursor(0, IDC_SIZENS);
     return c;
 }
 
 const Cursor& southEastResizeCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_SIZENWSE);
+    static Cursor c = loadSharedCursor(0, IDC_SIZENWSE);
     return c;
 }
 
 const Cursor& southWestResizeCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_SIZENESW);
+    static Cursor c = loadSharedCursor(0, IDC_SIZENESW);
     return c;
 }
 
 const Cursor& westResizeCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_SIZEWE);
+    static Cursor c = loadSharedCursor(0, IDC_SIZEWE);
     return c;
 }
 
 const Cursor& northSouthResizeCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_SIZENS);
+    static Cursor c = loadSharedCursor(0, IDC_SIZENS);
     return c;
 }
 
 const Cursor& eastWestResizeCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_SIZEWE);
+    static Cursor c = loadSharedCursor(0, IDC_SIZEWE);
     return c;
 }
 
 const Cursor& northEastSouthWestResizeCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_SIZENESW);
+    static Cursor c = loadSharedCursor(0, IDC_SIZENESW);
     return c;
 }
 
 const Cursor& northWestSouthEastResizeCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_SIZENWSE);
+    static Cursor c = loadSharedCursor(0, IDC_SIZENWSE);
     return c;
 }
 
 const Cursor& columnResizeCursor()
 {
     // FIXME: Windows does not have a standard column resize cursor <rdar://problem/5018591>
-    static Cursor c = LoadCursor(0, IDC_SIZEWE);
+    static Cursor c = loadSharedCursor(0, IDC_SIZEWE);
     return c;
 }
 
 const Cursor& rowResizeCursor()
 {
     // FIXME: Windows does not have a standard row resize cursor <rdar://problem/5018591>
-    static Cursor c = LoadCursor(0, IDC_SIZENS);
+    static Cursor c = loadSharedCursor(0, IDC_SIZENS);
     return c;
 }
 
 const Cursor& moveCursor() 
 {
-    static Cursor c = LoadCursor(0, IDC_SIZEALL);
+    static Cursor c = loadSharedCursor(0, IDC_SIZEALL);
     return c;
 }
 
 const Cursor& verticalTextCursor()
 {
-    //FIXME: Windows doesn't have a standard vertical text cursor <rdar://problem/5018591>
-    return pointerCursor();
+    static const Cursor c = loadCursorByName("verticalTextCursor", 7, 7);
+    return c;
 }
 
 const Cursor& cellCursor()
@@ -298,13 +314,13 @@ const Cursor& aliasCursor()
 
 const Cursor& progressCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_APPSTARTING);
+    static Cursor c = loadSharedCursor(0, IDC_APPSTARTING);
     return c;
 }
 
 const Cursor& noDropCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_NO);
+    static Cursor c = loadSharedCursor(0, IDC_NO);
     return c;
 }
 
@@ -320,19 +336,20 @@ const Cursor& noneCursor()
 
 const Cursor& notAllowedCursor()
 {
-    static Cursor c = LoadCursor(0, IDC_NO);
+    static Cursor c = loadSharedCursor(0, IDC_NO);
     return c;
 }
 
-// FIXME: <rdar://problem/5224996> Add zoom in and zoom out cursors
 const Cursor& zoomInCursor()
 {
-    return pointerCursor();
+    static const Cursor c = loadCursorByName("zoomInCursor", 7, 7);
+    return c;
 }
 
 const Cursor& zoomOutCursor()
 {
-    return pointerCursor();
+    static const Cursor c = loadCursorByName("zoomOutCursor", 7, 7);
+    return c;
 }
 
 }
index 098efde..31a38e6 100644 (file)
@@ -134,7 +134,7 @@ void Widget::setCursor(const Cursor& cursor)
         return;
     }
 
-    if (HCURSOR c = cursor.impl()) {
+    if (HCURSOR c = cursor.impl()->nativeCursor()) {
         lastSetCursor = c;
         SetCursor(c);
     }
index 617b99f..1abc21d 100644 (file)
@@ -1,3 +1,22 @@
+2007-09-12  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Adam.
+        
+        Fixing 
+            <rdar://problem/5018591> Windows doesn't have a standard vertical text cursor
+            <rdar://problem/5224996> Add zoom in and zoom out cursors
+            
+        Add images for vertical text and zoom in and out cursors to WebKit resources.
+            
+        * WebKit.vcproj/verticalTextCursor.png: Added.
+        * WebKit.vcproj/WebKit.rc:
+        * WebKit.vcproj/WebKit.vcproj:
+        * WebKit.vcproj/resource.h:
+        * WebKit.vcproj/zoomInCursor.png: Added.
+        * WebKit.vcproj/zoomOutCursor.png: Added.
+        * WebKitDLL.cpp:
+        (loadResourceIntoBuffer):
+
 2007-09-12  Adam Roben  <aroben@apple.com>
 
         Initialize SafariTheme early in WebKit's instantiation
index 032919b..20d0d2a 100644 (file)
@@ -66,3 +66,6 @@ IDR_URL_ICON                     PNG                     "urlIcon.png"
 IDR_NULL_PLUGIN                  PNG                     "nullplugin.png"
 IDR_DELETE_BUTTON                PNG                     "deleteButton.png"
 IDR_DELETE_BUTTON_PRESSED        PNG                     "deleteButtonPressed.png"
+IDR_ZOOM_IN_CURSOR               PNG                     "zoomInCursor.png"
+IDR_ZOOM_OUT_CURSOR              PNG                     "zoomOutCursor.png"
+IDR_VERTICAL_TEXT_CURSOR         PNG                     "verticalTextCursor.png"
index 6b0646b..459ff34 100644 (file)
                                >
                        </File>
                        <File
+                               RelativePath=".\verticalTextCursor.png"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\WebKit.rc"
                                >
                        </File>
                                RelativePath=".\WebKit.tlb"
                                >
                        </File>
+                       <File
+                               RelativePath=".\zoomInCursor.png"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\zoomOutCursor.png"
+                               >
+                       </File>
                </Filter>
                <Filter
                        Name="JSStringRefCF Hack"
index 0874d6b..696dad8 100644 (file)
@@ -7,6 +7,9 @@
 #define IDR_MISSING_IMAGE               3
 #define IDR_URL_ICON                    4
 #define IDR_NULL_PLUGIN                 5
+#define IDR_ZOOM_IN_CURSOR              6
+#define IDR_ZOOM_OUT_CURSOR             7
+#define IDR_VERTICAL_TEXT_CURSOR        8
 
 #define BUILD_NUMBER                    1
 
diff --git a/WebKit/win/WebKit.vcproj/verticalTextCursor.png b/WebKit/win/WebKit.vcproj/verticalTextCursor.png
new file mode 100644 (file)
index 0000000..0f2877c
Binary files /dev/null and b/WebKit/win/WebKit.vcproj/verticalTextCursor.png differ
diff --git a/WebKit/win/WebKit.vcproj/zoomInCursor.png b/WebKit/win/WebKit.vcproj/zoomInCursor.png
new file mode 100644 (file)
index 0000000..feec9bc
Binary files /dev/null and b/WebKit/win/WebKit.vcproj/zoomInCursor.png differ
diff --git a/WebKit/win/WebKit.vcproj/zoomOutCursor.png b/WebKit/win/WebKit.vcproj/zoomOutCursor.png
new file mode 100644 (file)
index 0000000..f4a954e
Binary files /dev/null and b/WebKit/win/WebKit.vcproj/zoomOutCursor.png differ
index 610dffb..661161c 100644 (file)
@@ -292,6 +292,12 @@ PassRefPtr<WebCore::SharedBuffer> loadResourceIntoBuffer(const char* name)
         idr = IDR_URL_ICON;
     else if (!strcmp(name, "nullPlugin"))
         idr = IDR_NULL_PLUGIN;
+    else if (!strcmp(name, "zoomInCursor"))
+        idr = IDR_ZOOM_IN_CURSOR;
+    else if (!strcmp(name, "zoomOutCursor"))
+        idr = IDR_ZOOM_OUT_CURSOR;
+    else if (!strcmp(name, "verticalTextCursor"))
+        idr = IDR_VERTICAL_TEXT_CURSOR;
     else
         return 0;