Reviewed by Adele.
authoraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Oct 2006 23:02:08 +0000 (23:02 +0000)
committeraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Oct 2006 23:02:08 +0000 (23:02 +0000)
        Move popup menu code out of rendering/ and into platform/.
        RenderPopupMenu becomes PopupMenu, the
        RenderPopupMenuMac/RenderPopupMenuWin subclasses and all the associated
        virtual methods go away, RenderTheme gets to stop worrying about popup
        menus, PopupMenu becomes ref-counted, and everyone becomes happy.

        * WebCore.vcproj/WebCore/WebCore.vcproj: Move files within project.
        * WebCore.xcodeproj/project.pbxproj: Ditto.
        * html/HTMLSelectElement.cpp: Remove unnecessary #include.
        * platform/PopupMenu.cpp: Moved from rendering/RenderPopupMenu.cpp.
        Also renamed showPopup()/hidePopup() to show()/hide() to disambiguate
        from RenderMenuList::showPopup/hidePopup.
        (WebCore::PopupMenu::create): New static creation method to hand back a
        PassRefPtr<PopupMenu>.
        (WebCore::PopupMenu::addItems): This platform-independent method should
        be called by PopupMenu::populate when the platform-specific
        implementation is ready to receive the menu items. Fixed an ASSERT
        while I was at it.
        * platform/PopupMenu.h: Moved from rendering/RenderPopupMenu.h. No more
        need for virtual methods.
        (WebCore::PopupMenu::wasClicked):
        (WebCore::PopupMenu::setWasClicked):
        (WebCore::PopupMenu::popupHandle):
        * platform/mac/PopupMenuMac.mm: Moved from
        rendering/RenderPopupMenuMac.mm. Much renaming ensues.
        (WebCore::PopupMenu::PopupMenu):
        (WebCore::PopupMenu::~PopupMenu):
        (WebCore::PopupMenu::clear):
        (WebCore::PopupMenu::populate):
        (WebCore::PopupMenu::show):
        (WebCore::PopupMenu::hide):
        (WebCore::PopupMenu::addSeparator):
        (WebCore::PopupMenu::addGroupLabel): Since we don't have our own
        RenderStyle anymore, just pick up the style from our RenderMenuList.
        (WebCore::PopupMenu::addOption): Ditto.
        * platform/win/TemporaryLinkStubs.cpp: Rename-fest.
        (PopupMenu::PopupMenu):
        (PopupMenu::~PopupMenu):
        (PopupMenu::clear):
        (PopupMenu::populate):
        (PopupMenu::show):
        (PopupMenu::hide):
        (PopupMenu::addSeparator):
        (PopupMenu::addGroupLabel):
        (PopupMenu::addOption):
        * rendering/RenderMenuList.cpp:
        (WebCore::RenderMenuList::~RenderMenuList):
        (WebCore::RenderMenuList::showPopup): Use nice new simple
        PopupMenu::create to make the popup.
        (WebCore::RenderMenuList::hidePopup):
        * rendering/RenderMenuList.h: Hold a RefPtr<PopupMenu> instead of a
        RenderPopupMenu*.
        (WebCore::RenderMenuList::popup):
        * rendering/RenderPopupMenu.cpp: Removed.
        * rendering/RenderPopupMenu.h: Removed.
        * rendering/RenderPopupMenuMac.h: Removed.
        * rendering/RenderPopupMenuMac.mm: Removed.
        * rendering/RenderPopupMenuWin.h: Removed.
        * rendering/RenderTheme.cpp: Get rid of createPopupMenu() method.
        * rendering/RenderTheme.h: Ditto.
        * rendering/RenderThemeMac.h: Ditto.
        * rendering/RenderThemeMac.mm: Ditto.
        * rendering/RenderThemeWin.cpp: Ditto.
        * rendering/RenderThemeWin.h: Ditto.

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

19 files changed:
WebCore/ChangeLog
WebCore/WebCore.vcproj/WebCore/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/html/HTMLSelectElement.cpp
WebCore/platform/PopupMenu.cpp [moved from WebCore/rendering/RenderPopupMenu.cpp with 87% similarity]
WebCore/platform/PopupMenu.h [new file with mode: 0644]
WebCore/platform/mac/PopupMenuMac.mm [moved from WebCore/rendering/RenderPopupMenuMac.mm with 86% similarity]
WebCore/platform/win/TemporaryLinkStubs.cpp
WebCore/rendering/RenderMenuList.cpp
WebCore/rendering/RenderMenuList.h
WebCore/rendering/RenderPopupMenu.h [deleted file]
WebCore/rendering/RenderPopupMenuMac.h [deleted file]
WebCore/rendering/RenderPopupMenuWin.h [deleted file]
WebCore/rendering/RenderTheme.cpp
WebCore/rendering/RenderTheme.h
WebCore/rendering/RenderThemeMac.h
WebCore/rendering/RenderThemeMac.mm
WebCore/rendering/RenderThemeWin.cpp
WebCore/rendering/RenderThemeWin.h

index 6dbcf6a..da3129a 100644 (file)
@@ -1,3 +1,72 @@
+2006-10-12  Adam Roben  <aroben@apple.com>
+
+        Reviewed by Adele.
+
+        Move popup menu code out of rendering/ and into platform/.
+        RenderPopupMenu becomes PopupMenu, the
+        RenderPopupMenuMac/RenderPopupMenuWin subclasses and all the associated
+        virtual methods go away, RenderTheme gets to stop worrying about popup
+        menus, PopupMenu becomes ref-counted, and everyone becomes happy.
+
+        * WebCore.vcproj/WebCore/WebCore.vcproj: Move files within project.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        * html/HTMLSelectElement.cpp: Remove unnecessary #include.
+        * platform/PopupMenu.cpp: Moved from rendering/RenderPopupMenu.cpp.
+        Also renamed showPopup()/hidePopup() to show()/hide() to disambiguate
+        from RenderMenuList::showPopup/hidePopup.
+        (WebCore::PopupMenu::create): New static creation method to hand back a
+        PassRefPtr<PopupMenu>.
+        (WebCore::PopupMenu::addItems): This platform-independent method should
+        be called by PopupMenu::populate when the platform-specific
+        implementation is ready to receive the menu items. Fixed an ASSERT
+        while I was at it.
+        * platform/PopupMenu.h: Moved from rendering/RenderPopupMenu.h. No more
+        need for virtual methods.
+        (WebCore::PopupMenu::wasClicked):
+        (WebCore::PopupMenu::setWasClicked):
+        (WebCore::PopupMenu::popupHandle):
+        * platform/mac/PopupMenuMac.mm: Moved from
+        rendering/RenderPopupMenuMac.mm. Much renaming ensues.
+        (WebCore::PopupMenu::PopupMenu):
+        (WebCore::PopupMenu::~PopupMenu):
+        (WebCore::PopupMenu::clear):
+        (WebCore::PopupMenu::populate):
+        (WebCore::PopupMenu::show):
+        (WebCore::PopupMenu::hide):
+        (WebCore::PopupMenu::addSeparator):
+        (WebCore::PopupMenu::addGroupLabel): Since we don't have our own
+        RenderStyle anymore, just pick up the style from our RenderMenuList.
+        (WebCore::PopupMenu::addOption): Ditto.
+        * platform/win/TemporaryLinkStubs.cpp: Rename-fest.
+        (PopupMenu::PopupMenu):
+        (PopupMenu::~PopupMenu):
+        (PopupMenu::clear):
+        (PopupMenu::populate):
+        (PopupMenu::show):
+        (PopupMenu::hide):
+        (PopupMenu::addSeparator):
+        (PopupMenu::addGroupLabel):
+        (PopupMenu::addOption):
+        * rendering/RenderMenuList.cpp:
+        (WebCore::RenderMenuList::~RenderMenuList):
+        (WebCore::RenderMenuList::showPopup): Use nice new simple
+        PopupMenu::create to make the popup.
+        (WebCore::RenderMenuList::hidePopup):
+        * rendering/RenderMenuList.h: Hold a RefPtr<PopupMenu> instead of a
+        RenderPopupMenu*.
+        (WebCore::RenderMenuList::popup):
+        * rendering/RenderPopupMenu.cpp: Removed.
+        * rendering/RenderPopupMenu.h: Removed.
+        * rendering/RenderPopupMenuMac.h: Removed.
+        * rendering/RenderPopupMenuMac.mm: Removed.
+        * rendering/RenderPopupMenuWin.h: Removed.
+        * rendering/RenderTheme.cpp: Get rid of createPopupMenu() method.
+        * rendering/RenderTheme.h: Ditto.
+        * rendering/RenderThemeMac.h: Ditto.
+        * rendering/RenderThemeMac.mm: Ditto.
+        * rendering/RenderThemeWin.cpp: Ditto.
+        * rendering/RenderThemeWin.h: Ditto.
+
 2006-10-12  Adele Peterson  <adele@apple.com>
 
         Reviewed by Dave Harrison.
index 169c816..3e8924a 100644 (file)
                                >
                        </File>
                        <File
+                               RelativePath="..\..\platform\PopupMenu.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\platform\PopupMenu.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\platform\RegularExpression.cpp"
                                >
                        </File>
                                        RelativePath="..\..\platform\win\MouseEventWin.cpp"
                                        >
                                </File>
-                                <File
-                                        RelativePath="..\..\platform\win\PlatformScrollBar.h"
-                                        >
-                                </File>
+                               <File
+                                       RelativePath="..\..\platform\win\PlatformScrollBar.h"
+                                       >
+                               </File>
                                <File
                                        RelativePath="..\..\platform\win\ResourceLoaderWin.cpp"
                                        >
                                >
                        </File>
                        <File
-                               RelativePath="..\..\rendering\RenderPopupMenu.cpp"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\rendering\RenderPopupMenu.h"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\rendering\RenderPopupMenuWin.h"
-                               >
-                       </File>
-                       <File
                                RelativePath="..\..\rendering\RenderReplaced.cpp"
                                >
                        </File>
index f69207f..600bc2a 100644 (file)
@@ -21,6 +21,9 @@
 /* End PBXAggregateTarget section */
 
 /* Begin PBXBuildFile section */
+               0668E18A0ADD9624004128E0 /* PopupMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0668E1880ADD9624004128E0 /* PopupMenu.cpp */; };
+               0668E18B0ADD9624004128E0 /* PopupMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = 0668E1890ADD9624004128E0 /* PopupMenu.h */; };
+               0668E1900ADD9640004128E0 /* PopupMenuMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0668E18E0ADD9640004128E0 /* PopupMenuMac.mm */; };
                066C772B0AB603B700238CC4 /* FileChooser.h in Headers */ = {isa = PBXBuildFile; fileRef = 066C772A0AB603B700238CC4 /* FileChooser.h */; };
                066C772D0AB603D200238CC4 /* FileChooserMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 066C772C0AB603D200238CC4 /* FileChooserMac.mm */; };
                066C77300AB603FD00238CC4 /* RenderFileUploadControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 066C772E0AB603FD00238CC4 /* RenderFileUploadControl.cpp */; };
                ABB5419F0ACDDFE4002820EB /* RenderListBox.h in Headers */ = {isa = PBXBuildFile; fileRef = ABB5419D0ACDDFE4002820EB /* RenderListBox.h */; };
                ABDDFE790A5C6E7000A3E11D /* RenderMenuList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABDDFE730A5C6E6F00A3E11D /* RenderMenuList.cpp */; };
                ABDDFE7A0A5C6E7000A3E11D /* RenderMenuList.h in Headers */ = {isa = PBXBuildFile; fileRef = ABDDFE740A5C6E7000A3E11D /* RenderMenuList.h */; };
-               ABDDFE7B0A5C6E7000A3E11D /* RenderPopupMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABDDFE750A5C6E7000A3E11D /* RenderPopupMenu.cpp */; };
-               ABDDFE7C0A5C6E7000A3E11D /* RenderPopupMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = ABDDFE760A5C6E7000A3E11D /* RenderPopupMenu.h */; };
-               ABDDFE7D0A5C6E7000A3E11D /* RenderPopupMenuMac.h in Headers */ = {isa = PBXBuildFile; fileRef = ABDDFE770A5C6E7000A3E11D /* RenderPopupMenuMac.h */; };
-               ABDDFE7E0A5C6E7000A3E11D /* RenderPopupMenuMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABDDFE780A5C6E7000A3E11D /* RenderPopupMenuMac.mm */; };
                ABE7B5230A489F830031881C /* DeprecatedRenderSelect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABE7B5210A489F830031881C /* DeprecatedRenderSelect.cpp */; };
                ABE7B5240A489F830031881C /* DeprecatedRenderSelect.h in Headers */ = {isa = PBXBuildFile; fileRef = ABE7B5220A489F830031881C /* DeprecatedRenderSelect.h */; };
                B20111070AB7740500DB0E68 /* JSSVGAElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B20111050AB7740500DB0E68 /* JSSVGAElement.cpp */; };
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
+               0668E1880ADD9624004128E0 /* PopupMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PopupMenu.cpp; sourceTree = "<group>"; };
+               0668E1890ADD9624004128E0 /* PopupMenu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PopupMenu.h; sourceTree = "<group>"; };
+               0668E18E0ADD9640004128E0 /* PopupMenuMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = PopupMenuMac.mm; sourceTree = "<group>"; };
                066C772A0AB603B700238CC4 /* FileChooser.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FileChooser.h; sourceTree = "<group>"; };
                066C772C0AB603D200238CC4 /* FileChooserMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FileChooserMac.mm; sourceTree = "<group>"; };
                066C772E0AB603FD00238CC4 /* RenderFileUploadControl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderFileUploadControl.cpp; sourceTree = "<group>"; };
                ABB5419D0ACDDFE4002820EB /* RenderListBox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderListBox.h; sourceTree = "<group>"; };
                ABDDFE730A5C6E6F00A3E11D /* RenderMenuList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMenuList.cpp; sourceTree = "<group>"; };
                ABDDFE740A5C6E7000A3E11D /* RenderMenuList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderMenuList.h; sourceTree = "<group>"; };
-               ABDDFE750A5C6E7000A3E11D /* RenderPopupMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderPopupMenu.cpp; sourceTree = "<group>"; };
-               ABDDFE760A5C6E7000A3E11D /* RenderPopupMenu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderPopupMenu.h; sourceTree = "<group>"; };
-               ABDDFE770A5C6E7000A3E11D /* RenderPopupMenuMac.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderPopupMenuMac.h; sourceTree = "<group>"; };
-               ABDDFE780A5C6E7000A3E11D /* RenderPopupMenuMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = RenderPopupMenuMac.mm; sourceTree = "<group>"; };
                ABE7B5210A489F830031881C /* DeprecatedRenderSelect.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = DeprecatedRenderSelect.cpp; sourceTree = "<group>"; };
                ABE7B5220A489F830031881C /* DeprecatedRenderSelect.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DeprecatedRenderSelect.h; sourceTree = "<group>"; };
                B20111050AB7740500DB0E68 /* JSSVGAElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGAElement.cpp; sourceTree = "<group>"; };
                                935C476F09AC4D7300A6AAB4 /* PlatformMouseEventMac.mm */,
                                BC3FCAA80AC3DB5800BA54AD /* PlatformScrollBar.h */,
                                A82398A709B3ACF500B60641 /* PlugInInfoStoreMac.mm */,
+                               0668E18E0ADD9640004128E0 /* PopupMenuMac.mm */,
                                6582A15409999D6D00BEEB6D /* ScreenMac.mm */,
                                BC7B2AF90450824100A8000F /* PlatformScrollBarMac.mm */,
                                BCAA90C20A7EBA60008B1229 /* ScrollBar.cpp */,
                                93CD4FEB0995FD2A007ECC97 /* PlatformString.h */,
                                935C476A09AC4D4F00A6AAB4 /* PlatformWheelEvent.h */,
                                A82398A509B3ACDB00B60641 /* PlugInInfoStore.h */,
+                               0668E1890ADD9624004128E0 /* PopupMenu.h */,
+                               0668E1880ADD9624004128E0 /* PopupMenu.cpp */,
                                F587852B02DE375901EA4122 /* RegularExpression.cpp */,
                                F58786B302DE3B8601EA4122 /* RegularExpression.h */,
                                6545F66C09B82FED0013006F /* ResourceLoader.cpp */,
                                A871DECF0A1530C700B12A68 /* RenderPart.h */,
                                A871DECE0A1530C700B12A68 /* RenderPartObject.cpp */,
                                A871DECD0A1530C700B12A68 /* RenderPartObject.h */,
-                               ABDDFE750A5C6E7000A3E11D /* RenderPopupMenu.cpp */,
-                               ABDDFE760A5C6E7000A3E11D /* RenderPopupMenu.h */,
-                               ABDDFE770A5C6E7000A3E11D /* RenderPopupMenuMac.h */,
-                               ABDDFE780A5C6E7000A3E11D /* RenderPopupMenuMac.mm */,
                                A871DFDE0A15376B00B12A68 /* RenderReplaced.cpp */,
                                A871DFDF0A15376B00B12A68 /* RenderReplaced.h */,
                                BCEA4844097D93020094C9E4 /* RenderStyle.cpp */,
                                1A0D57370A5C77FE007EDD4C /* OverflowEvent.h in Headers */,
                                1A0D57410A5C7867007EDD4C /* JSOverflowEvent.h in Headers */,
                                ABDDFE7A0A5C6E7000A3E11D /* RenderMenuList.h in Headers */,
-                               ABDDFE7C0A5C6E7000A3E11D /* RenderPopupMenu.h in Headers */,
-                               ABDDFE7D0A5C6E7000A3E11D /* RenderPopupMenuMac.h in Headers */,
                                85217E030A5ECD4700DB8D00 /* XSLImportRule.h in Headers */,
                                E14842DE0A674934007E4D39 /* StreamingTextDecoderICU.h in Headers */,
                                E148432F0A674FC2007E4D39 /* StreamingTextDecoderMac.h in Headers */,
                                656D37460ADBA5DE00A4554D /* WebPolicyDecider.h in Headers */,
                                656D37480ADBA5DE00A4554D /* WebSubresourceLoader.h in Headers */,
                                65BAAABE0ADCA015005BB5A4 /* RetainPtr.h in Headers */,
+                               0668E18B0ADD9624004128E0 /* PopupMenu.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
+                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
                        mainGroup = 0867D691FE84028FC02AAC07 /* WebKit */;
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
                        projectDirPath = "";
+                       projectRoot = "";
+                       shouldCheckCompatibility = 1;
                        targets = (
                                93F198A508245E59001E9ABC /* WebCore */,
                                DD041FBE09D9DDBE0010AF2A /* Derived Sources */,
                                1A0D57360A5C77FE007EDD4C /* OverflowEvent.cpp in Sources */,
                                1A0D57400A5C7867007EDD4C /* JSOverflowEvent.cpp in Sources */,
                                ABDDFE790A5C6E7000A3E11D /* RenderMenuList.cpp in Sources */,
-                               ABDDFE7B0A5C6E7000A3E11D /* RenderPopupMenu.cpp in Sources */,
-                               ABDDFE7E0A5C6E7000A3E11D /* RenderPopupMenuMac.mm in Sources */,
                                85217E020A5ECD4700DB8D00 /* XSLImportRule.cpp in Sources */,
                                93CF35AA0A6169F700543E52 /* AffineTransformCG.cpp in Sources */,
                                E14842FF0A674A31007E4D39 /* StreamingTextDecoderICU.cpp in Sources */,
                                656D37440ADBA5DE00A4554D /* WebNetscapePlugInStreamLoader.mm in Sources */,
                                656D37470ADBA5DE00A4554D /* WebPolicyDecider.mm in Sources */,
                                656D37490ADBA5DE00A4554D /* WebSubresourceLoader.mm in Sources */,
+                               0668E18A0ADD9624004128E0 /* PopupMenu.cpp in Sources */,
+                               0668E1900ADD9640004128E0 /* PopupMenuMac.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 03e6977..d4735b6 100644 (file)
@@ -42,7 +42,6 @@
 #include "MouseEvent.h"
 #include "RenderListBox.h"
 #include "RenderMenuList.h"
-#include "RenderPopupMenu.h"
 #include "cssstyleselector.h"
 #include <wtf/Vector.h>
 #include <math.h>
similarity index 87%
rename from WebCore/rendering/RenderPopupMenu.cpp
rename to WebCore/platform/PopupMenu.cpp
index 80c69f3..ed7396e 100644 (file)
  */
 
 #include "config.h"
-#include "RenderPopupMenu.h"
+#include "PopupMenu.h"
 
 #include "HTMLNames.h"
 #include "HTMLOptionElement.h"
 #include "HTMLOptGroupElement.h"
 #include "HTMLSelectElement.h"
+#include "RenderMenuList.h"
+#include <wtf/Assertions.h>
 
 namespace WebCore {
 
 using namespace HTMLNames;
-
-RenderPopupMenu::RenderPopupMenu(Node* element, RenderMenuList* menuList)
-    : RenderBlock(element)
-    , m_menuList(menuList)
+    
+PassRefPtr<PopupMenu> PopupMenu::create(RenderMenuList* menuList)
 {
+    return new PopupMenu(menuList);
 }
 
-void RenderPopupMenu::populate()
+void PopupMenu::addItems()
 {
     ASSERT(menuList());
     HTMLSelectElement* select = static_cast<HTMLSelectElement*>(menuList()->node());
@@ -54,7 +55,7 @@ void RenderPopupMenu::populate()
         else if (element->hasTagName(hrTag))
             addSeparator();
         else
-            ASSERT(0);
+            ASSERT_NOT_REACHED();
     }
 }
 
diff --git a/WebCore/platform/PopupMenu.h b/WebCore/platform/PopupMenu.h
new file mode 100644 (file)
index 0000000..2f58223
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef POPUPMENU_H
+#define POPUPMENU_H
+
+#include "Shared.h"
+#include <wtf/PassRefPtr.h>
+
+#if PLATFORM(MAC)
+#ifdef __OBJC__
+@class NSPopUpButtonCell;
+#else
+class NSPopUpButtonCell;
+#endif
+#elif PLATFORM(WIN)
+typedef struct HWND__* HWND;
+#endif
+
+namespace WebCore {
+
+class FrameView;
+class IntRect;
+class HTMLOptionElement;
+class HTMLOptGroupElement;
+class RenderMenuList;
+
+class PopupMenu : public Shared<PopupMenu> {
+public:
+    static PassRefPtr<PopupMenu> create(RenderMenuList* menuList);
+    ~PopupMenu();
+    
+    void clear();
+    void populate();
+    void show(const IntRect&, FrameView*, int index);
+    void hide();
+    
+    bool up();
+    bool down();
+    
+    bool wasClicked() const { return m_wasClicked; }
+    void setWasClicked(bool b) { m_wasClicked = b; }
+
+    int focusedIndex() const;
+    
+    RenderMenuList* menuList() { return m_menuList; }
+
+#if PLATFORM(WIN)
+    HWND popupHandle() const { return m_popup; }
+#endif
+
+protected:
+    void addItems();
+    void addSeparator();
+    void addGroupLabel(HTMLOptGroupElement*);
+    void addOption(HTMLOptionElement*);
+
+    void setPositionAndSize(const IntRect&, FrameView*);
+    
+ private:
+    PopupMenu(RenderMenuList* menuList);
+    
+    RenderMenuList* m_menuList;
+    bool m_wasClicked;
+    
+#if PLATFORM(MAC)
+    NSPopUpButtonCell* popup;
+#elif PLATFORM(WIN)
+    HWND m_popup;
+    HWND m_container;
+#endif
+};
+
+}
+
+#endif
similarity index 86%
rename from WebCore/rendering/RenderPopupMenuMac.mm
rename to WebCore/platform/mac/PopupMenuMac.mm
index 6748819..9ea4e9a 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * This file is part of the popup menu implementation for <select> elements in WebCore.
- *
  * Copyright (C) 2006 Apple Computer, Inc.
  *
  * This library is free software; you can redistribute it and/or
@@ -20,7 +18,7 @@
  */
 
 #import "config.h"
-#import "RenderPopupMenuMac.h"
+#import "PopupMenu.h"
 
 #import "FontData.h"
 #import "FrameMac.h"
@@ -35,13 +33,13 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
-RenderPopupMenuMac::RenderPopupMenuMac(Node* element, RenderMenuList* menuList)
-    : RenderPopupMenu(element, menuList)
+PopupMenu::PopupMenu(RenderMenuList* menuList)
+    : m_menuList(menuList)
     , popup(nil)
 {
 }
 
-RenderPopupMenuMac::~RenderPopupMenuMac()
+PopupMenu::~PopupMenu()
 {
     if (popup) {
         [popup setControlView:nil];
@@ -49,13 +47,13 @@ RenderPopupMenuMac::~RenderPopupMenuMac()
     }
 }
 
-void RenderPopupMenuMac::clear()
+void PopupMenu::clear()
 {
     if (popup)
         [popup removeAllItems];
 }
 
-void RenderPopupMenuMac::populate()
+void PopupMenu::populate()
 {
     if (popup)
         [popup removeAllItems];
@@ -66,11 +64,11 @@ void RenderPopupMenuMac::populate()
     }
     BOOL messagesEnabled = [[popup menu] menuChangedMessagesEnabled];
     [[popup menu] setMenuChangedMessagesEnabled:NO];
-    RenderPopupMenu::populate();
+    PopupMenu::addItems();
     [[popup menu] setMenuChangedMessagesEnabled:messagesEnabled];
 }
 
-void RenderPopupMenuMac::showPopup(const IntRect& r, FrameView* v, int index)
+void PopupMenu::show(const IntRect& r, FrameView* v, int index)
 {
     populate();
     if ([popup numberOfItems] <= 0)
@@ -82,7 +80,7 @@ void RenderPopupMenuMac::showPopup(const IntRect& r, FrameView* v, int index)
     [popup attachPopUpWithFrame:r inView:view];
     [popup selectItemAtIndex:index];
     
-    NSFont* font = style()->font().primaryFont()->getNSFont();
+    NSFont* font = menuList()->style()->font().primaryFont()->getNSFont();
 
     NSRect titleFrame = [popup titleRectForBounds:r];
     if (titleFrame.size.width <= 0 || titleFrame.size.height <= 0)
@@ -116,23 +114,23 @@ void RenderPopupMenuMac::showPopup(const IntRect& r, FrameView* v, int index)
     [event release];
 }
 
-void RenderPopupMenuMac::hidePopup()
+void PopupMenu::hide()
 {
     [popup dismissPopUp];
 }
 
-void RenderPopupMenuMac::addSeparator()
+void PopupMenu::addSeparator()
 {
     [[popup menu] addItem:[NSMenuItem separatorItem]];
 }
 
-void RenderPopupMenuMac::addGroupLabel(HTMLOptGroupElement* element)
+void PopupMenu::addGroupLabel(HTMLOptGroupElement* element)
 {
     String text = element->groupLabelText();
 
     RenderStyle* s = element->renderStyle();
     if (!s)
-        s = style();
+        s = menuList()->style();
 
     NSMutableDictionary* attributes = [[NSMutableDictionary alloc] init];
     if (s->font() != Font())
@@ -149,7 +147,7 @@ void RenderPopupMenuMac::addGroupLabel(HTMLOptGroupElement* element)
     [string release];
 }
 
-void RenderPopupMenuMac::addOption(HTMLOptionElement* element)
+void PopupMenu::addOption(HTMLOptionElement* element)
 {
     String text = element->optionText();
     
@@ -159,7 +157,7 @@ void RenderPopupMenuMac::addOption(HTMLOptionElement* element)
 
     RenderStyle* s = element->renderStyle();
     if (!s)
-        s = style();
+        s = menuList()->style();
         
     NSMutableDictionary* attributes = [[NSMutableDictionary alloc] init];
     if (s->font() != Font())
index 48cdb56..42f5ab7 100644 (file)
@@ -61,7 +61,7 @@
 #include "RenderThemeWin.h"
 #include "TextBoundaries.h"
 #include "AXObjectCache.h"
-#include "RenderPopupMenuWin.h"
+#include "PopupMenu.h"
 #include "EditCommand.h"
 #include "Icon.h"
 #include "IconLoader.h"
@@ -365,14 +365,15 @@ void Frame::setNeedsReapplyStyles() { }
 
 void Image::drawTiled(GraphicsContext*, const FloatRect&, const FloatRect&, TileRule, TileRule, CompositeOperator) { }
 
-RenderPopupMenuWin::~RenderPopupMenuWin() { notImplemented(); }
-void RenderPopupMenuWin::clear() { notImplemented(); }
-void RenderPopupMenuWin::populate() { notImplemented(); }
-void RenderPopupMenuWin::showPopup(const IntRect&, FrameView*, int index) { notImplemented(); }
-void RenderPopupMenuWin::hidePopup() { notImplemented(); }
-void RenderPopupMenuWin::addSeparator() { notImplemented(); }
-void RenderPopupMenuWin::addGroupLabel(HTMLOptGroupElement*) { notImplemented(); }
-void RenderPopupMenuWin::addOption(HTMLOptionElement*) { notImplemented(); }
+PopupMenu::PopupMenu(RenderMenuList*) { notImplemented(); }
+PopupMenu::~PopupMenu() { notImplemented(); }
+void PopupMenu::clear() { notImplemented(); }
+void PopupMenu::populate() { notImplemented(); }
+void PopupMenu::show(const IntRect&, FrameView*, int index) { notImplemented(); }
+void PopupMenu::hide() { notImplemented(); }
+void PopupMenu::addSeparator() { notImplemented(); }
+void PopupMenu::addGroupLabel(HTMLOptGroupElement*) { notImplemented(); }
+void PopupMenu::addOption(HTMLOptionElement*) { notImplemented(); }
 
 void RenderThemeWin::systemFont(int propId, FontDescription& fontDescription) const {}
 bool RenderThemeWin::paintMenuList(RenderObject *, const RenderObject::PaintInfo&, const IntRect&) { return false; }
index 27bb4ab..165fa70 100644 (file)
@@ -29,7 +29,7 @@
 #include "HTMLNames.h"
 #include "HTMLOptionElement.h"
 #include "HTMLSelectElement.h"
-#include "RenderPopupMenu.h"
+#include "PopupMenu.h"
 #include "RenderText.h"
 #include "RenderTheme.h"
 #include "TextStyle.h"
@@ -54,8 +54,6 @@ RenderMenuList::RenderMenuList(HTMLSelectElement* element)
 
 RenderMenuList::~RenderMenuList()
 {
-    if (m_popup)
-        m_popup->destroy();
     m_popup = 0;
 }
 
@@ -227,20 +225,17 @@ void RenderMenuList::showPopup()
     // inside the showPopup call and it would fail.
     createInnerBlock();
     if (!m_popup)
-        m_popup = theme()->createPopupMenu(renderArena(), document(), this);
-    RenderStyle* newStyle = new (renderArena()) RenderStyle;
-    newStyle->inheritFrom(style());
-    m_popup->setStyle(newStyle);
+        m_popup = PopupMenu::create(this);
     HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node());
     m_popupIsVisible = true;
-    m_popup->showPopup(absoluteBoundingBoxRect(), document()->view(),
+    m_popup->show(absoluteBoundingBoxRect(), document()->view(),
         select->optionToListIndex(select->selectedIndex()));
 }
 
 void RenderMenuList::hidePopup()
 {
     if (m_popup)
-        m_popup->hidePopup();
+        m_popup->hide();
     m_popupIsVisible = false;
 }
 
index 34344f9..16a2781 100644 (file)
 #define RenderMenuList_H
 
 #include "RenderFlexibleBox.h"
+#include "PopupMenu.h"
 
 namespace WebCore {
 
 class HTMLSelectElement;
-class RenderPopupMenu;
 
 class RenderMenuList : public RenderFlexibleBox {
 public:
@@ -51,7 +51,7 @@ public:
 
     virtual void calcMinMaxWidth();
 
-    RenderPopupMenu* popup() const { return m_popup; }
+    RefPtr<PopupMenu> popup() const { return m_popup; }
     bool popupIsVisible() const { return m_popupIsVisible; }
     void showPopup();
     void hidePopup();
@@ -75,7 +75,7 @@ private:
     bool m_optionsChanged;
     int m_optionsWidth;
 
-    RenderPopupMenu* m_popup;
+    RefPtr<PopupMenu> m_popup;
     bool m_popupIsVisible;
 };
 
diff --git a/WebCore/rendering/RenderPopupMenu.h b/WebCore/rendering/RenderPopupMenu.h
deleted file mode 100644 (file)
index 02ed5c5..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * This file is part of the popup menu implementation for <select> elements in WebCore.
- *
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef RENDER_POPUPMENU_H
-#define RENDER_POPUPMENU_H
-
-#include "RenderBlock.h"
-#include "RenderMenuList.h"
-
-namespace WebCore {
-
-class HTMLOptionElement;
-class HTMLOptGroupElement;
-
-class RenderPopupMenu : public RenderBlock {
-public:
-    RenderPopupMenu(Node*, RenderMenuList* menuList);
-    
-    virtual const char* renderName() const { return "RenderPopupMenu"; }
-
-    virtual void clear() = 0;
-    virtual void populate();
-    virtual void showPopup(const IntRect&, FrameView*, int index) = 0;
-    virtual void hidePopup() = 0;
-
-    RenderMenuList* menuList() { return m_menuList; }
-
-protected:
-    virtual void addSeparator() = 0;
-    virtual void addGroupLabel(HTMLOptGroupElement*) = 0;
-    virtual void addOption(HTMLOptionElement*) = 0;
-
- private:
-    RenderMenuList* m_menuList;
-};
-
-}
-
-#endif
diff --git a/WebCore/rendering/RenderPopupMenuMac.h b/WebCore/rendering/RenderPopupMenuMac.h
deleted file mode 100644 (file)
index f273867..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * This file is part of the popup menu implementation for <select> elements in WebCore.
- *
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef RENDER_POPUPMENU_MAC_H
-#define RENDER_POPUPMENU_MAC_H
-
-#import "RenderPopupMenu.h"
-#import <AppKit/NSPopUpButtonCell.h>
-
-namespace WebCore {
-
-class RenderPopupMenuMac : public RenderPopupMenu {
-public:
-    RenderPopupMenuMac(Node*, RenderMenuList*);
-    ~RenderPopupMenuMac();
-    
-    virtual void clear();
-    virtual void showPopup(const IntRect&, FrameView*, int index);
-    virtual void hidePopup();
-    virtual void populate();
-    
-protected:
-    virtual void addSeparator();
-    virtual void addGroupLabel(HTMLOptGroupElement*);
-    virtual void addOption(HTMLOptionElement*);
-
-    NSPopUpButtonCell* popup;
-
-};
-
-}
-
-#endif
diff --git a/WebCore/rendering/RenderPopupMenuWin.h b/WebCore/rendering/RenderPopupMenuWin.h
deleted file mode 100644 (file)
index 7641d42..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * This file is part of the popup menu implementation for <select> elements in WebCore.
- *
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef RENDER_POPUPMENU_WIN_H
-#define RENDER_POPUPMENU_WIN_H
-
-#include "RenderPopupMenu.h"
-
-namespace WebCore {
-
-class HTMLOptionElement;
-class HTMLOptGroupElement;
-
-class RenderPopupMenuWin : public RenderPopupMenu {
-public:
-    RenderPopupMenuWin(Node* n, RenderMenuList* m) : RenderPopupMenu(n, m) {}
-    ~RenderPopupMenuWin();
-
-    virtual void clear();
-    virtual void populate();
-    virtual void showPopup(const IntRect&, FrameView*, int index);
-    virtual void hidePopup();
-
-protected:
-    virtual void addSeparator();
-    virtual void addGroupLabel(HTMLOptGroupElement*);
-    virtual void addOption(HTMLOptionElement*);
-
-};
-
-}
-
-#endif
index 655f46d..104b7d8 100644 (file)
@@ -27,7 +27,6 @@
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "RenderStyle.h"
-#include "RenderPopupMenu.h"
 
 // The methods in this file are shared by all themes on every platform.
 
index 17c1d3a..cd82c50 100644 (file)
@@ -114,7 +114,6 @@ public:
     virtual void systemFont(int propId, FontDescription&) const = 0;
 
     virtual int minimumMenuListSize(RenderStyle*) const { return 0; }
-    virtual RenderPopupMenu* createPopupMenu(RenderArena*, Document*, RenderMenuList*) = 0;
 
 protected:
     // Methods for state querying
index 1738199..b3498f7 100644 (file)
@@ -60,7 +60,6 @@ public:
     virtual void systemFont(int propId, FontDescription&) const;
 
     virtual int minimumMenuListSize(RenderStyle*) const;
-    virtual RenderPopupMenu* createPopupMenu(RenderArena*, Document*, RenderMenuList*);
 
 protected:
     // Methods for each appearance value.
index 03e3662..d096145 100644 (file)
@@ -30,7 +30,6 @@
 #import "GraphicsContext.h"
 #import "Image.h"
 #import "LocalCurrentGraphicsContext.h"
-#import "RenderPopupMenuMac.h"
 #import "RenderView.h"
 #import "WebCoreSystemInterface.h"
 
@@ -893,11 +892,6 @@ void RenderThemeMac::setPopupButtonCellState(const RenderObject* o, const IntRec
     updateFocusedState(popupButton, o);
 }
 
-RenderPopupMenu* RenderThemeMac::createPopupMenu(RenderArena* arena, Document* doc, RenderMenuList* menuList)
-{
-    return new (arena) RenderPopupMenuMac(doc, menuList);
-}
-
 int RenderThemeMac::minimumMenuListSize(RenderStyle* style) const
 {
     int fontSize = style->fontSize();
index f153955..516b9ac 100644 (file)
@@ -26,7 +26,6 @@
 #include <cairo-win32.h>
 #include "Document.h"
 #include "GraphicsContext.h"
-#include "RenderPopupMenuWin.h"
 
 /* 
  * The following constants are used to determine how a widget is drawn using
@@ -307,9 +306,4 @@ bool RenderThemeWin::paintTextArea(RenderObject* o, const RenderObject::PaintInf
     return paintTextField(o, i, r);
 }
 
-RenderPopupMenu* RenderThemeWin::createPopupMenu(RenderArena* arena, Document* doc, RenderMenuList* menuList)
-{
-    return new (arena) RenderPopupMenuWin(doc, menuList);
-}
-
 }
index 4b39769..4c57067 100644 (file)
@@ -75,7 +75,6 @@ public:
 
     virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
-    virtual RenderPopupMenu* createPopupMenu(RenderArena*, Document*, RenderMenuList*);
 
 private:
     void addIntrinsicMargins(RenderStyle*) const;