[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.22-985-g3c00f00
eric at webkit.org
eric at webkit.org
Wed Mar 17 17:56:40 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 6c9fd147fa27539634b26a6dc952f12c2f5b8206
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Feb 23 07:37:25 2010 +0000
2010-02-22 Stephan Aßmus <superstippi at gmx.de>
Reviewed by Eric Seidel.
[Haiku] Implemented PopupMenu support.
https://bugs.webkit.org/show_bug.cgi?id=35078
Covered by existing tests.
The implementation is currently very simple: Added a PopupMenuHaiku
class that derives from a native BPopUpMenu. It attaches a BHandler
derivative to the BApplication (WebCore main thread) which receives
the item invokation and menu hidden events and informs the PopupMenuClient
accordingly.
* platform/PopupMenu.h:
Changed type of m_menu for Haiku.
* platform/haiku/PopupMenuHaiku.cpp:
(WebCore::PopupMenuHandler::PopupMenuHandler):
(WebCore::PopupMenuHandler::MessageReceived):
(WebCore::PopupMenuHaiku::PopupMenuHaiku):
(WebCore::PopupMenuHaiku::~PopupMenuHaiku):
(WebCore::PopupMenuHaiku::show):
(WebCore::PopupMenuHaiku::hide):
(WebCore::PopupMenuHaiku::Hide):
(WebCore::PopupMenu::PopupMenu):
(WebCore::PopupMenu::~PopupMenu):
Removed bogus code.
(WebCore::PopupMenu::show):
Implemented using new PopupMenuHaiku class.
(WebCore::PopupMenu::hide):
Implemented using new PopupMenuHaiku class.
(WebCore::PopupMenu::updateFromElement):
Implemented.
(WebCore::PopupMenu::itemWritingDirectionIsNatural):
Implemented according to Gtk port.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55122 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 0954147..a0e4e75 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -2,6 +2,43 @@
Reviewed by Eric Seidel.
+ [Haiku] Implemented PopupMenu support.
+ https://bugs.webkit.org/show_bug.cgi?id=35078
+
+ Covered by existing tests.
+
+ The implementation is currently very simple: Added a PopupMenuHaiku
+ class that derives from a native BPopUpMenu. It attaches a BHandler
+ derivative to the BApplication (WebCore main thread) which receives
+ the item invokation and menu hidden events and informs the PopupMenuClient
+ accordingly.
+
+ * platform/PopupMenu.h:
+ Changed type of m_menu for Haiku.
+ * platform/haiku/PopupMenuHaiku.cpp:
+ (WebCore::PopupMenuHandler::PopupMenuHandler):
+ (WebCore::PopupMenuHandler::MessageReceived):
+ (WebCore::PopupMenuHaiku::PopupMenuHaiku):
+ (WebCore::PopupMenuHaiku::~PopupMenuHaiku):
+ (WebCore::PopupMenuHaiku::show):
+ (WebCore::PopupMenuHaiku::hide):
+ (WebCore::PopupMenuHaiku::Hide):
+ (WebCore::PopupMenu::PopupMenu):
+ (WebCore::PopupMenu::~PopupMenu):
+ Removed bogus code.
+ (WebCore::PopupMenu::show):
+ Implemented using new PopupMenuHaiku class.
+ (WebCore::PopupMenu::hide):
+ Implemented using new PopupMenuHaiku class.
+ (WebCore::PopupMenu::updateFromElement):
+ Implemented.
+ (WebCore::PopupMenu::itemWritingDirectionIsNatural):
+ Implemented according to Gtk port.
+
+2010-02-22 Stephan Aßmus <superstippi at gmx.de>
+
+ Reviewed by Eric Seidel.
+
Fix various issues in PlatformMouseEventHaiku.
https://bugs.webkit.org/show_bug.cgi?id=34685
diff --git a/WebCore/platform/PopupMenu.h b/WebCore/platform/PopupMenu.h
index 449d475..4df0dcd 100644
--- a/WebCore/platform/PopupMenu.h
+++ b/WebCore/platform/PopupMenu.h
@@ -61,7 +61,9 @@ class wxMenu;
#elif PLATFORM(CHROMIUM)
#include "PopupMenuPrivate.h"
#elif PLATFORM(HAIKU)
-class BMenu;
+namespace WebCore {
+class PopupMenuHaiku;
+}
#endif
namespace WebCore {
@@ -186,7 +188,7 @@ private:
#elif PLATFORM(CHROMIUM)
PopupMenuPrivate p;
#elif PLATFORM(HAIKU)
- BMenu* m_menu;
+ PopupMenuHaiku* m_menu;
#endif
};
diff --git a/WebCore/platform/haiku/PopupMenuHaiku.cpp b/WebCore/platform/haiku/PopupMenuHaiku.cpp
index 9d608c8..5adbc66 100644
--- a/WebCore/platform/haiku/PopupMenuHaiku.cpp
+++ b/WebCore/platform/haiku/PopupMenuHaiku.cpp
@@ -1,7 +1,7 @@
/*
* This file is part of the popup menu implementation for <select> elements in WebCore.
*
- * Copyright (C) 2007 Ryan Leavengood <leavengood at gmail.com>
+ * Copyright (C) 2010 Stephan Aßmus <superstippi at gmx.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -26,42 +26,165 @@
#include "FrameView.h"
#include "NotImplemented.h"
-#include <Menu.h>
-
+#include <Application.h>
+#include <Handler.h>
+#include <MenuItem.h>
+#include <Message.h>
+#include <PopUpMenu.h>
+#include <String.h>
+#include <Window.h>
+#include <support/Autolock.h>
+#include <support/Locker.h>
namespace WebCore {
+static const uint32 kPopupResult = 'pmrs';
+static const uint32 kPopupHidden = 'pmhd';
+
+// This BHandler is added to the application (main) thread, so that we
+// invoke methods on the PopupMenuClient within the main thread.
+class PopupMenuHandler : public BHandler {
+public:
+ PopupMenuHandler(PopupMenuClient* popupClient)
+ : m_popupClient(popupClient)
+ {
+ }
+
+ virtual void MessageReceived(BMessage* message)
+ {
+ switch (message->what) {
+ case kPopupResult: {
+ int32 index = 0;
+ message->FindInt32("index", &index);
+ m_popupClient->valueChanged(index);
+ break;
+ }
+ case kPopupHidden:
+ m_popupClient->popupDidHide();
+ break;
+
+ default:
+ BHandler::MessageReceived(message);
+ }
+ }
+
+private:
+ PopupMenuClient* m_popupClient;
+};
+
+class PopupMenuHaiku : public BPopUpMenu {
+public:
+ PopupMenuHaiku(PopupMenuClient* popupClient)
+ : BPopUpMenu("WebCore Popup", true, false)
+ , m_popupClient(popupClient)
+ , m_Handler(popupClient)
+ {
+ if (be_app->Lock()) {
+ be_app->AddHandler(&m_Handler);
+ be_app->Unlock();
+ }
+ SetAsyncAutoDestruct(false);
+ }
+
+ virtual ~PopupMenuHaiku()
+ {
+ if (be_app->Lock()) {
+ be_app->RemoveHandler(&m_Handler);
+ be_app->Unlock();
+ }
+ }
+
+ void show(const IntRect& rect, FrameView* view, int index)
+ {
+ // Clean out the menu first
+ for (int32 i = CountItems() - 1; i >= 0; i--)
+ delete RemoveItem(i);
+
+ // Popuplate the menu from the client
+ int itemCount = m_popupClient->listSize();
+ for (int i = 0; i < itemCount; i++) {
+ if (m_popupClient->itemIsSeparator(i))
+ AddSeparatorItem();
+ else {
+ // NOTE: WebCore distinguishes between "Group" and "Label"
+ // here, but both types of item (radio or check mark) currently
+ // look the same on Haiku.
+ BString label(m_popupClient->itemText(i));
+ BMessage* message = new BMessage(kPopupResult);
+ message->AddInt32("index", i);
+ BMenuItem* item = new BMenuItem(label.String(), message);
+ AddItem(item);
+ item->SetTarget(BMessenger(&m_Handler));
+ item->SetEnabled(m_popupClient->itemIsEnabled(i));
+ item->SetMarked(i == index);
+ }
+ }
+
+ // We need to force a layout now, or the item frames will not be
+ // computed yet, so we cannot move the current item under the mouse.
+ DoLayout();
+
+ // Account for frame of menu field
+ BRect screenRect(view->contentsToScreen(rect));
+ screenRect.OffsetBy(2, 2);
+ // Move currently selected item under the mouse.
+ if (BMenuItem* item = ItemAt(index))
+ screenRect.OffsetBy(0, -item->Frame().top);
+
+ BRect openRect = Bounds().OffsetToSelf(screenRect.LeftTop());
+
+ Go(screenRect.LeftTop(), true, true, openRect, true);
+ }
+
+ void hide()
+ {
+ if (!IsHidden())
+ Hide();
+ }
+
+private:
+ virtual void Hide()
+ {
+ BPopUpMenu::Hide();
+ be_app->PostMessage(kPopupHidden, &m_Handler);
+ }
+
+ PopupMenuClient* m_popupClient;
+ PopupMenuHandler m_Handler;
+};
+
PopupMenu::PopupMenu(PopupMenuClient* client)
: m_popupClient(client)
- , m_menu(0)
+ , m_menu(new PopupMenuHaiku(client))
{
+ // We don't need additional references to the client, since we completely
+ // control any sub-objects we create that need it as well.
}
PopupMenu::~PopupMenu()
{
delete m_menu;
- m_menu = 0;
}
void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
{
- notImplemented();
+ // The menu will update itself from the PopupMenuClient before showing.
+ m_menu->show(rect, view, index);
}
void PopupMenu::hide()
{
- notImplemented();
+ m_menu->hide();
}
void PopupMenu::updateFromElement()
{
- notImplemented();
+ client()->setTextFromItem(m_popupClient->selectedIndex());
}
bool PopupMenu::itemWritingDirectionIsNatural()
{
- notImplemented();
- return true;
+ return false;
}
} // namespace WebCore
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list