Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Unified Diff: webkit/glue/webpopupmenu_impl.cc

Issue 149620: Use WebWidget from the WebKit API. This change also makes... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/webpopupmenu_impl.h ('k') | webkit/glue/webtextdirection.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webpopupmenu_impl.cc
===================================================================
--- webkit/glue/webpopupmenu_impl.cc (revision 20363)
+++ webkit/glue/webpopupmenu_impl.cc (working copy)
@@ -4,9 +4,6 @@
#include "config.h"
-#include "base/compiler_specific.h"
-
-MSVC_PUSH_WARNING_LEVEL(0);
#include "Cursor.h"
#include "FramelessScrollView.h"
#include "FrameView.h"
@@ -16,75 +13,70 @@
#include "PlatformMouseEvent.h"
#include "PlatformWheelEvent.h"
#include "SkiaUtils.h"
-MSVC_POP_WARNING();
-
#undef LOG
+
#include "base/logging.h"
#include "skia/ext/platform_canvas.h"
#include "webkit/api/public/WebInputEvent.h"
#include "webkit/api/public/WebRect.h"
+#include "webkit/api/public/WebWidgetClient.h"
#include "webkit/glue/event_conversion.h"
#include "webkit/glue/glue_util.h"
-#include "webkit/glue/webwidget_delegate.h"
-#include "webkit/glue/webwidget_impl.h"
+#include "webkit/glue/webpopupmenu_impl.h"
using namespace WebCore;
+using WebKit::WebCanvas;
+using WebKit::WebCompositionCommand;
using WebKit::WebInputEvent;
using WebKit::WebKeyboardEvent;
using WebKit::WebMouseEvent;
using WebKit::WebMouseWheelEvent;
+using WebKit::WebNavigationPolicy;
using WebKit::WebPoint;
+using WebKit::WebPopupMenu;
using WebKit::WebRect;
using WebKit::WebSize;
+using WebKit::WebString;
+using WebKit::WebTextDirection;
+using WebKit::WebWidget;
+using WebKit::WebWidgetClient;
-// WebWidget ----------------------------------------------------------------
+// WebPopupMenu ---------------------------------------------------------------
-/*static*/
-WebWidget* WebWidget::Create(WebWidgetDelegate* delegate) {
- WebWidgetImpl* instance = new WebWidgetImpl(delegate);
+// static
+WebPopupMenu* WebPopupMenu::create(WebWidgetClient* client) {
+ WebPopupMenuImpl* instance = new WebPopupMenuImpl(client);
instance->AddRef();
return instance;
}
-WebWidgetImpl::WebWidgetImpl(WebWidgetDelegate* delegate)
- : delegate_(delegate),
+// WebWidget ------------------------------------------------------------------
+
+WebPopupMenuImpl::WebPopupMenuImpl(WebWidgetClient* client)
+ : client_(client),
widget_(NULL) {
// set to impossible point so we always get the first mouse pos
last_mouse_position_ = WebPoint(-1, -1);
}
-WebWidgetImpl::~WebWidgetImpl() {
+WebPopupMenuImpl::~WebPopupMenuImpl() {
if (widget_)
widget_->setClient(NULL);
}
-void WebWidgetImpl::Init(WebCore::FramelessScrollView* widget,
- const WebRect& bounds) {
+void WebPopupMenuImpl::Init(WebCore::FramelessScrollView* widget,
+ const WebRect& bounds) {
widget_ = widget;
widget_->setClient(this);
- if (delegate_) {
- delegate_->SetWindowRect(this, bounds);
- delegate_->Show(this, WindowOpenDisposition());
+ if (client_) {
+ client_->setWindowRect(bounds);
+ client_->show(WebNavigationPolicy()); // Policy is ignored
}
}
-void WebWidgetImpl::InitWithItems(WebCore::FramelessScrollView* widget,
- const WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<WebMenuItem>& items) {
- widget_ = widget;
- widget_->setClient(this);
-
- if (delegate_) {
- delegate_->ShowAsPopupWithItems(this, bounds, item_height,
- selected_index, items);
- }
-}
-
-void WebWidgetImpl::MouseMove(const WebMouseEvent& event) {
+void WebPopupMenuImpl::MouseMove(const WebMouseEvent& event) {
// don't send mouse move messages if the mouse hasn't moved.
if (event.x != last_mouse_position_.x ||
event.y != last_mouse_position_.y) {
@@ -93,39 +85,39 @@
}
}
-void WebWidgetImpl::MouseLeave(const WebMouseEvent& event) {
+void WebPopupMenuImpl::MouseLeave(const WebMouseEvent& event) {
widget_->handleMouseMoveEvent(MakePlatformMouseEvent(widget_, event));
}
-void WebWidgetImpl::MouseDown(const WebMouseEvent& event) {
+void WebPopupMenuImpl::MouseDown(const WebMouseEvent& event) {
widget_->handleMouseDownEvent(MakePlatformMouseEvent(widget_, event));
}
-void WebWidgetImpl::MouseUp(const WebMouseEvent& event) {
- MouseCaptureLost();
+void WebPopupMenuImpl::MouseUp(const WebMouseEvent& event) {
+ mouseCaptureLost();
widget_->handleMouseReleaseEvent(MakePlatformMouseEvent(widget_, event));
}
-void WebWidgetImpl::MouseWheel(const WebMouseWheelEvent& event) {
+void WebPopupMenuImpl::MouseWheel(const WebMouseWheelEvent& event) {
widget_->handleWheelEvent(MakePlatformWheelEvent(widget_, event));
}
-bool WebWidgetImpl::KeyEvent(const WebKeyboardEvent& event) {
+bool WebPopupMenuImpl::KeyEvent(const WebKeyboardEvent& event) {
return widget_->handleKeyEvent(MakePlatformKeyboardEvent(event));
}
// WebWidget -------------------------------------------------------------------
-void WebWidgetImpl::Close() {
+void WebPopupMenuImpl::close() {
if (widget_)
widget_->hide();
- delegate_ = NULL;
+ client_ = NULL;
Release(); // Balances AddRef from WebWidget::Create
}
-void WebWidgetImpl::Resize(const WebSize& new_size) {
+void WebPopupMenuImpl::resize(const WebSize& new_size) {
if (size_ == new_size)
return;
size_ = new_size;
@@ -135,16 +127,16 @@
widget_->setFrameRect(new_geometry);
}
- if (delegate_) {
+ if (client_) {
WebRect damaged_rect(0, 0, size_.width, size_.height);
- delegate_->DidInvalidateRect(this, damaged_rect);
+ client_->didInvalidateRect(damaged_rect);
}
}
-void WebWidgetImpl::Layout() {
+void WebPopupMenuImpl::layout() {
}
-void WebWidgetImpl::Paint(skia::PlatformCanvas* canvas, const WebRect& rect) {
+void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect) {
if (!widget_)
return;
@@ -162,32 +154,32 @@
}
}
-bool WebWidgetImpl::HandleInputEvent(const WebInputEvent* input_event) {
+bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& input_event) {
if (!widget_)
return false;
// TODO (jcampan): WebKit seems to always return false on mouse events
// methods. For now we'll assume it has processed them (as we are only
// interested in whether keyboard events are processed).
- switch (input_event->type) {
+ switch (input_event.type) {
case WebInputEvent::MouseMove:
- MouseMove(*static_cast<const WebMouseEvent*>(input_event));
+ MouseMove(*static_cast<const WebMouseEvent*>(&input_event));
return true;
case WebInputEvent::MouseLeave:
- MouseLeave(*static_cast<const WebMouseEvent*>(input_event));
+ MouseLeave(*static_cast<const WebMouseEvent*>(&input_event));
return true;
case WebInputEvent::MouseWheel:
- MouseWheel(*static_cast<const WebMouseWheelEvent*>(input_event));
+ MouseWheel(*static_cast<const WebMouseWheelEvent*>(&input_event));
return true;
case WebInputEvent::MouseDown:
- MouseDown(*static_cast<const WebMouseEvent*>(input_event));
+ MouseDown(*static_cast<const WebMouseEvent*>(&input_event));
return true;
case WebInputEvent::MouseUp:
- MouseUp(*static_cast<const WebMouseEvent*>(input_event));
+ MouseUp(*static_cast<const WebMouseEvent*>(&input_event));
return true;
// In Windows, RawKeyDown only has information about the physical key, but
@@ -202,7 +194,7 @@
case WebInputEvent::KeyDown:
case WebInputEvent::KeyUp:
case WebInputEvent::Char:
- return KeyEvent(*static_cast<const WebKeyboardEvent*>(input_event));
+ return KeyEvent(*static_cast<const WebKeyboardEvent*>(&input_event));
default:
break;
@@ -210,71 +202,70 @@
return false;
}
-void WebWidgetImpl::MouseCaptureLost() {
+void WebPopupMenuImpl::mouseCaptureLost() {
}
-void WebWidgetImpl::SetFocus(bool enable) {
+void WebPopupMenuImpl::setFocus(bool enable) {
}
-bool WebWidgetImpl::ImeSetComposition(int string_type,
- int cursor_position,
- int target_start,
- int target_end,
- const std::wstring& ime_string) {
+bool WebPopupMenuImpl::handleCompositionEvent(
+ WebCompositionCommand command,
+ int cursor_position,
+ int target_start,
+ int target_end,
+ const WebString& ime_string) {
return false;
}
-bool WebWidgetImpl::ImeUpdateStatus(bool* enable_ime,
- WebRect* caret_rect) {
+bool WebPopupMenuImpl::queryCompositionStatus(bool* enabled,
+ WebRect* caret_rect) {
return false;
}
-void WebWidgetImpl::SetTextDirection(WebTextDirection direction) {
+void WebPopupMenuImpl::setTextDirection(WebTextDirection direction) {
}
//-----------------------------------------------------------------------------
// WebCore::HostWindow
-void WebWidgetImpl::repaint(const WebCore::IntRect& paint_rect,
+void WebPopupMenuImpl::repaint(const WebCore::IntRect& paint_rect,
bool content_changed,
bool immediate,
bool repaint_content_only) {
// Ignore spurious calls.
if (!content_changed || paint_rect.isEmpty())
return;
- if (delegate_)
- delegate_->DidInvalidateRect(this,
- webkit_glue::IntRectToWebRect(paint_rect));
+ if (client_)
+ client_->didInvalidateRect(webkit_glue::IntRectToWebRect(paint_rect));
}
-void WebWidgetImpl::scroll(const WebCore::IntSize& scroll_delta,
+void WebPopupMenuImpl::scroll(const WebCore::IntSize& scroll_delta,
const WebCore::IntRect& scroll_rect,
const WebCore::IntRect& clip_rect) {
- if (delegate_) {
+ if (client_) {
int dx = scroll_delta.width();
int dy = scroll_delta.height();
- delegate_->DidScrollRect(this, dx, dy,
- webkit_glue::IntRectToWebRect(clip_rect));
+ client_->didScrollRect(dx, dy, webkit_glue::IntRectToWebRect(clip_rect));
}
}
-WebCore::IntPoint WebWidgetImpl::screenToWindow(
+WebCore::IntPoint WebPopupMenuImpl::screenToWindow(
const WebCore::IntPoint& point) const {
NOTIMPLEMENTED();
return WebCore::IntPoint();
}
-WebCore::IntRect WebWidgetImpl::windowToScreen(
+WebCore::IntRect WebPopupMenuImpl::windowToScreen(
const WebCore::IntRect& rect) const {
NOTIMPLEMENTED();
return WebCore::IntRect();
}
-PlatformWidget WebWidgetImpl::platformWindow() const {
+PlatformWidget WebPopupMenuImpl::platformWindow() const {
return NULL;
}
-void WebWidgetImpl::scrollRectIntoView(
+void WebPopupMenuImpl::scrollRectIntoView(
const WebCore::IntRect&, const WebCore::ScrollView*) const {
// Nothing to be done here since we do not have the concept of a container
// that implements its own scrolling.
@@ -283,11 +274,11 @@
//-----------------------------------------------------------------------------
// WebCore::FramelessScrollViewClient
-void WebWidgetImpl::popupClosed(WebCore::FramelessScrollView* widget) {
+void WebPopupMenuImpl::popupClosed(WebCore::FramelessScrollView* widget) {
DCHECK(widget == widget_);
if (widget_) {
widget_->setClient(NULL);
widget_ = NULL;
}
- delegate_->CloseWidgetSoon(this);
+ client_->closeWidgetSoon();
}
« no previous file with comments | « webkit/glue/webpopupmenu_impl.h ('k') | webkit/glue/webtextdirection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698