Fix <rdar://5395835> REGRESSION (r24527): Context menu for edit fields is...
authoraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 19 Aug 2007 22:07:28 +0000 (22:07 +0000)
committeraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 19 Aug 2007 22:07:28 +0000 (22:07 +0000)
        The problem was that ContextMenuItem::setSubMenu was just copying the
        HMENU from the ContextMenu passed in on Windows, but that HMENU was
        later getting destroyed when the ContextMenu went out of scope.

        I added a new ContextMenu::releasePlatformDescription method that is
        used in setSubMenu instead. I think an ultimately better design would
        be for setSubMenu to take ownership of the ContextMenu that's passed in
        (as should insertItem and appendItem), but I decided to be conservative
        and just make the changes needed to fix the bug.

        Reviewed by Darin.

        No test possible.

        * platform/ContextMenu.h: Added releasePlatformDescription.
        * platform/gdk/TemporaryLinkStubs.cpp: Added stub implementation.
        * platform/mac/ContextMenuMac.mm:
        (WebCore::ContextMenu::releasePlatformDescription): Implemented, though
        it's never called on this platform.
        * platform/qt/ContextMenuQt.cpp:
        (WebCore::ContextMenu::releasePlatformDescription): Ditto.
        * platform/win/ContextMenuItemWin.cpp:
        (WebCore::ContextMenuItem::setSubMenu): Call releasePlatformDescription
        since we need to take ownership of the HMENU.
        * platform/win/ContextMenuWin.cpp:
        (WebCore::ContextMenu::releasePlatformDescription): Implemented.

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

WebCore/ChangeLog
WebCore/platform/ContextMenu.h
WebCore/platform/gdk/TemporaryLinkStubs.cpp
WebCore/platform/mac/ContextMenuMac.mm
WebCore/platform/qt/ContextMenuQt.cpp
WebCore/platform/win/ContextMenuItemWin.cpp
WebCore/platform/win/ContextMenuWin.cpp

index fc3b32d7fc3fc5a35247ef89acf69ffd1bf0af97..5be264205d0c903b1cf2d1294b00a0eacf7882ec 100644 (file)
@@ -1,3 +1,34 @@
+2007-08-19  Adam Roben  <aroben@apple.com>
+
+        Fix <rdar://5395835> REGRESSION (r24527): Context menu for edit fields is missing "Font & Writing Direction"
+
+        The problem was that ContextMenuItem::setSubMenu was just copying the
+        HMENU from the ContextMenu passed in on Windows, but that HMENU was
+        later getting destroyed when the ContextMenu went out of scope.
+
+        I added a new ContextMenu::releasePlatformDescription method that is
+        used in setSubMenu instead. I think an ultimately better design would
+        be for setSubMenu to take ownership of the ContextMenu that's passed in
+        (as should insertItem and appendItem), but I decided to be conservative
+        and just make the changes needed to fix the bug.
+
+        Reviewed by Darin.
+
+        No test possible.
+
+        * platform/ContextMenu.h: Added releasePlatformDescription.
+        * platform/gdk/TemporaryLinkStubs.cpp: Added stub implementation.
+        * platform/mac/ContextMenuMac.mm:
+        (WebCore::ContextMenu::releasePlatformDescription): Implemented, though
+        it's never called on this platform.
+        * platform/qt/ContextMenuQt.cpp:
+        (WebCore::ContextMenu::releasePlatformDescription): Ditto.
+        * platform/win/ContextMenuItemWin.cpp:
+        (WebCore::ContextMenuItem::setSubMenu): Call releasePlatformDescription
+        since we need to take ownership of the HMENU.
+        * platform/win/ContextMenuWin.cpp:
+        (WebCore::ContextMenu::releasePlatformDescription): Implemented.
+
 2007-08-18  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Darin.
index 6ba27a9901b25148cf7c5a5fd7998df2fac60834..e6b0e70c5f6b4fdb5226b75c104d3d6e1d1e53c1 100644 (file)
@@ -67,6 +67,8 @@ class MenuEventProxy;
         PlatformMenuDescription platformDescription() const;
         void setPlatformDescription(PlatformMenuDescription);
 
+        PlatformMenuDescription releasePlatformDescription();
+
     private:
         HitTestResult m_hitTestResult;
 
index 7d8b4e402899e47f3ca54cb69fbcc41c11afd157..46ab72527da113967b202973c49b589340930a6e 100644 (file)
@@ -210,6 +210,7 @@ ContextMenu::~ContextMenu() { notImplemented(); }
 void ContextMenu::appendItem(ContextMenuItem&) { notImplemented(); }
 void ContextMenu::setPlatformDescription(PlatformMenuDescription menu) { m_platformDescription = menu; }
 PlatformMenuDescription ContextMenu::platformDescription() const  { return m_platformDescription; }
+PlatformMenuDescription ContextMenu::releasePlatformDescription() const  { notImplemented(); return 0; }
 
 ContextMenuItem::ContextMenuItem(PlatformMenuItemDescription) { notImplemented(); }
 ContextMenuItem::ContextMenuItem(ContextMenu*) { notImplemented(); }
index 957b9ed33c630155f50b4429440b64fcd77f984e..b56d0b9ebf6935fe334838c7537deb524fb8a684 100644 (file)
@@ -146,4 +146,9 @@ NSMutableArray* ContextMenu::platformDescription() const
     return m_platformDescription.get();
 }
 
+NSMutableArray* ContextMenu::releasePlatformDescription()
+{
+    return m_platformDescription.releaseRef();
+}
+
 }
index e7d319bdd56846e40ce712c91569eddd6082f40c..08a0b90f5ac4eaf66992a790af0ec0a13e9b0d37 100644 (file)
@@ -136,6 +136,13 @@ PlatformMenuDescription ContextMenu::platformDescription() const
     return m_menu;
 }
 
+PlatformMenuDescription ContextMenu::releasePlatformDescription()
+{
+    QMenu* tmp = m_menu;
+    m_menu = 0;
+    return tmp;
+}
+
 
 }
 // vim: ts=4 sw=4 et
index 8d73696c976eb87e0f711ea11a71ff2356c3d0f8..75d8a2b8db4bb7613d8ac37e7adaa9812e7fb59a 100644 (file)
@@ -160,7 +160,7 @@ void ContextMenuItem::setSubMenu(ContextMenu* subMenu)
         ::DestroyMenu(m_platformDescription->hSubMenu);
 
     m_platformDescription->fMask |= MIIM_SUBMENU;
-    m_platformDescription->hSubMenu = subMenu->platformDescription();
+    m_platformDescription->hSubMenu = subMenu->releasePlatformDescription();
 }
 
 void ContextMenuItem::setChecked(bool checked)
index c785b4888504ab972000c5c4c986faade9d07e90..83606b9eb1af49471be9ddbb2945438e9face6ed 100644 (file)
@@ -123,4 +123,11 @@ HMENU ContextMenu::platformDescription() const
     return m_platformDescription;
 }
 
+HMENU ContextMenu::releasePlatformDescription()
+{
+    HMENU description = m_platformDescription;
+    m_platformDescription = 0;
+    return description;
+}
+
 }