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

Unified Diff: webkit/api/src/WebPopupMenuImpl.cpp

Issue 338041: Move a bunch of files into webkit/api/src... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
Index: webkit/api/src/WebPopupMenuImpl.cpp
===================================================================
--- webkit/api/src/WebPopupMenuImpl.cpp (revision 30163)
+++ webkit/api/src/WebPopupMenuImpl.cpp (working copy)
@@ -1,9 +1,38 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
#include "config.h"
+#include "WebPopupMenuImpl.h"
+#include <skia/ext/platform_canvas.h>
+
#include "Cursor.h"
#include "FramelessScrollView.h"
#include "FrameView.h"
@@ -13,174 +42,164 @@
#include "PlatformMouseEvent.h"
#include "PlatformWheelEvent.h"
#include "SkiaUtils.h"
-#undef LOG
+#include "WebInputEvent.h"
+#include "WebRect.h"
+#include "WebWidgetClient.h"
+#include "WebInputEventConversion.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/api/src/WebInputEventConversion.h"
-#include "webkit/glue/glue_util.h"
-#include "webkit/glue/webpopupmenu_impl.h"
-
using namespace WebCore;
-using WebKit::PlatformKeyboardEventBuilder;
-using WebKit::PlatformMouseEventBuilder;
-using WebKit::PlatformWheelEventBuilder;
-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;
+namespace WebKit {
// WebPopupMenu ---------------------------------------------------------------
-// static
-WebPopupMenu* WebPopupMenu::create(WebWidgetClient* client) {
- return new WebPopupMenuImpl(client);
+WebPopupMenu* WebPopupMenu::create(WebWidgetClient* client)
+{
+ return new WebPopupMenuImpl(client);
}
// 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);
+ : m_client(client)
+ , m_widget(0)
+{
+ // set to impossible point so we always get the first mouse pos
+ m_lastMousePosition = WebPoint(-1, -1);
}
-WebPopupMenuImpl::~WebPopupMenuImpl() {
- if (widget_)
- widget_->setClient(NULL);
+WebPopupMenuImpl::~WebPopupMenuImpl()
+{
+ if (m_widget)
+ m_widget->setClient(0);
}
-void WebPopupMenuImpl::Init(WebCore::FramelessScrollView* widget,
- const WebRect& bounds) {
- widget_ = widget;
- widget_->setClient(this);
+void WebPopupMenuImpl::Init(FramelessScrollView* widget, const WebRect& bounds)
+{
+ m_widget = widget;
+ m_widget->setClient(this);
- if (client_) {
- client_->setWindowRect(bounds);
- client_->show(WebNavigationPolicy()); // Policy is ignored
- }
+ if (m_client) {
+ m_client->setWindowRect(bounds);
+ m_client->show(WebNavigationPolicy()); // Policy is ignored
+ }
}
-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) {
- last_mouse_position_ = WebPoint(event.x, event.y);
- widget_->handleMouseMoveEvent(PlatformMouseEventBuilder(widget_, event));
- }
+void WebPopupMenuImpl::MouseMove(const WebMouseEvent& event)
+{
+ // don't send mouse move messages if the mouse hasn't moved.
+ if (event.x != m_lastMousePosition.x || event.y != m_lastMousePosition.y) {
+ m_lastMousePosition = WebPoint(event.x, event.y);
+ m_widget->handleMouseMoveEvent(PlatformMouseEventBuilder(m_widget, event));
+ }
}
-void WebPopupMenuImpl::MouseLeave(const WebMouseEvent& event) {
- widget_->handleMouseMoveEvent(PlatformMouseEventBuilder(widget_, event));
+void WebPopupMenuImpl::MouseLeave(const WebMouseEvent& event)
+{
+ m_widget->handleMouseMoveEvent(PlatformMouseEventBuilder(m_widget, event));
}
-void WebPopupMenuImpl::MouseDown(const WebMouseEvent& event) {
- widget_->handleMouseDownEvent(PlatformMouseEventBuilder(widget_, event));
+void WebPopupMenuImpl::MouseDown(const WebMouseEvent& event)
+{
+ m_widget->handleMouseDownEvent(PlatformMouseEventBuilder(m_widget, event));
}
-void WebPopupMenuImpl::MouseUp(const WebMouseEvent& event) {
- mouseCaptureLost();
- widget_->handleMouseReleaseEvent(PlatformMouseEventBuilder(widget_, event));
+void WebPopupMenuImpl::MouseUp(const WebMouseEvent& event)
+{
+ mouseCaptureLost();
+ m_widget->handleMouseReleaseEvent(PlatformMouseEventBuilder(m_widget, event));
}
-void WebPopupMenuImpl::MouseWheel(const WebMouseWheelEvent& event) {
- widget_->handleWheelEvent(PlatformWheelEventBuilder(widget_, event));
+void WebPopupMenuImpl::MouseWheel(const WebMouseWheelEvent& event)
+{
+ m_widget->handleWheelEvent(PlatformWheelEventBuilder(m_widget, event));
}
-bool WebPopupMenuImpl::KeyEvent(const WebKeyboardEvent& event) {
- return widget_->handleKeyEvent(PlatformKeyboardEventBuilder(event));
+bool WebPopupMenuImpl::KeyEvent(const WebKeyboardEvent& event)
+{
+ return m_widget->handleKeyEvent(PlatformKeyboardEventBuilder(event));
}
// WebWidget -------------------------------------------------------------------
-void WebPopupMenuImpl::close() {
- if (widget_)
- widget_->hide();
+void WebPopupMenuImpl::close()
+{
+ if (m_widget)
+ m_widget->hide();
- client_ = NULL;
+ m_client = 0;
- deref(); // Balances ref() from WebWidget::Create
+ deref(); // Balances ref() from WebWidget::Create
}
-void WebPopupMenuImpl::resize(const WebSize& new_size) {
- if (size_ == new_size)
- return;
- size_ = new_size;
+void WebPopupMenuImpl::resize(const WebSize& newSize)
+{
+ if (m_size == newSize)
+ return;
+ m_size = newSize;
- if (widget_) {
- IntRect new_geometry(0, 0, size_.width, size_.height);
- widget_->setFrameRect(new_geometry);
- }
+ if (m_widget) {
+ IntRect newGeometry(0, 0, m_size.width, m_size.height);
+ m_widget->setFrameRect(newGeometry);
+ }
- if (client_) {
- WebRect damaged_rect(0, 0, size_.width, size_.height);
- client_->didInvalidateRect(damaged_rect);
- }
+ if (m_client) {
+ WebRect damagedRect(0, 0, m_size.width, m_size.height);
+ m_client->didInvalidateRect(damagedRect);
+ }
}
-void WebPopupMenuImpl::layout() {
+void WebPopupMenuImpl::layout()
+{
}
-void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect) {
- if (!widget_)
- return;
+void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect)
+{
+ if (!m_widget)
+ return;
- if (!rect.isEmpty()) {
+ if (!rect.isEmpty()) {
#if WEBKIT_USING_CG
- GraphicsContext gc(canvas);
+ GraphicsContext gc(canvas);
#elif WEBKIT_USING_SKIA
- PlatformContextSkia context(canvas);
- // PlatformGraphicsContext is actually a pointer to PlatformContextSkia.
- GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
+ PlatformContextSkia context(canvas);
+ // PlatformGraphicsContext is actually a pointer to PlatformContextSkia.
+ GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
#else
- notImplemented();
+ notImplemented();
#endif
- widget_->paint(&gc, webkit_glue::WebRectToIntRect(rect));
- }
+ m_widget->paint(&gc, rect);
+ }
}
-bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& input_event) {
- if (!widget_)
- return false;
+bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& inputEvent)
+{
+ if (!m_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) {
+ // 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 (inputEvent.type) {
case WebInputEvent::MouseMove:
- MouseMove(*static_cast<const WebMouseEvent*>(&input_event));
- return true;
+ MouseMove(*static_cast<const WebMouseEvent*>(&inputEvent));
+ return true;
case WebInputEvent::MouseLeave:
- MouseLeave(*static_cast<const WebMouseEvent*>(&input_event));
- return true;
+ MouseLeave(*static_cast<const WebMouseEvent*>(&inputEvent));
+ return true;
case WebInputEvent::MouseWheel:
- MouseWheel(*static_cast<const WebMouseWheelEvent*>(&input_event));
- return true;
+ MouseWheel(*static_cast<const WebMouseWheelEvent*>(&inputEvent));
+ return true;
case WebInputEvent::MouseDown:
- MouseDown(*static_cast<const WebMouseEvent*>(&input_event));
- return true;
+ MouseDown(*static_cast<const WebMouseEvent*>(&inputEvent));
+ return true;
case WebInputEvent::MouseUp:
- MouseUp(*static_cast<const WebMouseEvent*>(&input_event));
- return true;
+ MouseUp(*static_cast<const WebMouseEvent*>(&inputEvent));
+ return true;
// In Windows, RawKeyDown only has information about the physical key, but
// for "selection", we need the information about the character the key
@@ -194,91 +213,99 @@
case WebInputEvent::KeyDown:
case WebInputEvent::KeyUp:
case WebInputEvent::Char:
- return KeyEvent(*static_cast<const WebKeyboardEvent*>(&input_event));
+ return KeyEvent(*static_cast<const WebKeyboardEvent*>(&inputEvent));
default:
- break;
- }
- return false;
+ break;
+ }
+ return false;
}
-void WebPopupMenuImpl::mouseCaptureLost() {
+void WebPopupMenuImpl::mouseCaptureLost()
+{
}
-void WebPopupMenuImpl::setFocus(bool enable) {
+void WebPopupMenuImpl::setFocus(bool enable)
+{
}
bool WebPopupMenuImpl::handleCompositionEvent(
- WebCompositionCommand command,
- int cursor_position,
- int target_start,
- int target_end,
- const WebString& ime_string) {
- return false;
+ WebCompositionCommand command, int cursorPosition, int targetStart,
+ int targetEnd, const WebString& imeString)
+{
+ return false;
}
-bool WebPopupMenuImpl::queryCompositionStatus(bool* enabled,
- WebRect* caret_rect) {
- return false;
+bool WebPopupMenuImpl::queryCompositionStatus(bool* enabled, WebRect* caretRect)
+{
+ return false;
}
-void WebPopupMenuImpl::setTextDirection(WebTextDirection direction) {
+void WebPopupMenuImpl::setTextDirection(WebTextDirection direction)
+{
}
+
//-----------------------------------------------------------------------------
// WebCore::HostWindow
-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 (client_)
- client_->didInvalidateRect(webkit_glue::IntRectToWebRect(paint_rect));
+void WebPopupMenuImpl::repaint(const IntRect& paintRect,
+ bool contentChanged,
+ bool immediate,
+ bool repaintContentOnly)
+{
+ // Ignore spurious calls.
+ if (!contentChanged || paintRect.isEmpty())
+ return;
+ if (m_client)
+ m_client->didInvalidateRect(paintRect);
}
-void WebPopupMenuImpl::scroll(const WebCore::IntSize& scroll_delta,
- const WebCore::IntRect& scroll_rect,
- const WebCore::IntRect& clip_rect) {
- if (client_) {
- int dx = scroll_delta.width();
- int dy = scroll_delta.height();
- client_->didScrollRect(dx, dy, webkit_glue::IntRectToWebRect(clip_rect));
- }
+void WebPopupMenuImpl::scroll(const IntSize& scrollDelta,
+ const IntRect& scrollRect,
+ const IntRect& clipRect)
+{
+ if (m_client) {
+ int dx = scrollDelta.width();
+ int dy = scrollDelta.height();
+ m_client->didScrollRect(dx, dy, clipRect);
+ }
}
-WebCore::IntPoint WebPopupMenuImpl::screenToWindow(
- const WebCore::IntPoint& point) const {
- notImplemented();
- return WebCore::IntPoint();
+IntPoint WebPopupMenuImpl::screenToWindow(const IntPoint& point) const
+{
+ notImplemented();
+ return IntPoint();
}
-WebCore::IntRect WebPopupMenuImpl::windowToScreen(
- const WebCore::IntRect& rect) const {
- notImplemented();
- return WebCore::IntRect();
+IntRect WebPopupMenuImpl::windowToScreen(const IntRect& rect) const
+{
+ notImplemented();
+ return IntRect();
}
-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.
+void WebPopupMenuImpl::scrollRectIntoView(const IntRect&, const ScrollView*) const
+{
+ // Nothing to be done here since we do not have the concept of a container
+ // that implements its own scrolling.
}
-void WebPopupMenuImpl::scrollbarsModeDidChange() const {
- // Nothing to be done since we have no concept of different scrollbar modes.
+void WebPopupMenuImpl::scrollbarsModeDidChange() const
+{
+ // Nothing to be done since we have no concept of different scrollbar modes.
}
//-----------------------------------------------------------------------------
// WebCore::FramelessScrollViewClient
-void WebPopupMenuImpl::popupClosed(WebCore::FramelessScrollView* widget) {
- ASSERT(widget == widget_);
- if (widget_) {
- widget_->setClient(NULL);
- widget_ = NULL;
- }
- client_->closeWidgetSoon();
+void WebPopupMenuImpl::popupClosed(FramelessScrollView* widget)
+{
+ ASSERT(widget == m_widget);
+ if (m_widget) {
+ m_widget->setClient(0);
+ m_widget = 0;
+ }
+ m_client->closeWidgetSoon();
}
+
+} // namespace WebKit

Powered by Google App Engine
This is Rietveld 408576698