diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-16 05:33:47 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-16 05:33:47 +0000 |
commit | cf13bb696f6a50b06930ed8fabb0984cd6af7be9 (patch) | |
tree | a883217d4a1eee49750954f851188c5ca6fa6308 /chrome/renderer/render_widget.cc | |
parent | 05158051ea881677c03a22ddf38a3e6779cebb9e (diff) | |
download | chromium_src-cf13bb696f6a50b06930ed8fabb0984cd6af7be9.zip chromium_src-cf13bb696f6a50b06930ed8fabb0984cd6af7be9.tar.gz chromium_src-cf13bb696f6a50b06930ed8fabb0984cd6af7be9.tar.bz2 |
Reverting 20854.
Review URL: http://codereview.chromium.org/155621
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20855 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_widget.cc')
-rw-r--r-- | chrome/renderer/render_widget.cc | 131 |
1 files changed, 72 insertions, 59 deletions
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc index e6ac408..7ff612f 100644 --- a/chrome/renderer/render_widget.cc +++ b/chrome/renderer/render_widget.cc @@ -16,7 +16,6 @@ #include "skia/ext/platform_canvas.h" #include "third_party/skia/include/core/SkShader.h" #include "webkit/api/public/WebCursorInfo.h" -#include "webkit/api/public/WebPopupMenu.h" #include "webkit/api/public/WebPopupMenuInfo.h" #include "webkit/api/public/WebRect.h" #include "webkit/api/public/WebScreenInfo.h" @@ -27,18 +26,15 @@ #include "third_party/skia/include/core/SkMallocPixelRef.h" #endif // defined(OS_POSIX) -#include "webkit/api/public/WebWidget.h" +#include "webkit/glue/webtextdirection.h" +#include "webkit/glue/webwidget.h" -using WebKit::WebCompositionCommand; using WebKit::WebCursorInfo; using WebKit::WebInputEvent; -using WebKit::WebNavigationPolicy; -using WebKit::WebPopupMenu; using WebKit::WebPopupMenuInfo; using WebKit::WebRect; using WebKit::WebScreenInfo; using WebKit::WebSize; -using WebKit::WebTextDirection; RenderWidget::RenderWidget(RenderThreadBase* render_thread, bool activatable) : routing_id_(MSG_ROUTING_NONE), @@ -106,7 +102,7 @@ void RenderWidget::Init(int32 opener_id) { if (opener_id != MSG_ROUTING_NONE) opener_id_ = opener_id; - webwidget_ = WebPopupMenu::create(this); + webwidget_ = WebWidget::Create(this); bool result = render_thread_->Send( new ViewHostMsg_CreateWidget(opener_id, activatable_, &routing_id_)); @@ -214,7 +210,7 @@ void RenderWidget::OnResize(const gfx::Size& new_size, // When resizing, we want to wait to paint before ACK'ing the resize. This // ensures that we only resize as fast as we can paint. We only need to send // an ACK if we are resized to a non-empty rect. - webwidget_->resize(new_size); + webwidget_->Resize(new_size); if (!new_size.IsEmpty()) { DCHECK(!paint_rect_.IsEmpty()); @@ -250,7 +246,7 @@ void RenderWidget::OnWasRestored(bool needs_repainting) { set_next_paint_is_restore_ack(); // Generate a full repaint. - didInvalidateRect(gfx::Rect(size_.width(), size_.height())); + DidInvalidateRect(webwidget_, gfx::Rect(size_.width(), size_.height())); } void RenderWidget::OnPaintRectAck() { @@ -299,7 +295,7 @@ void RenderWidget::OnHandleInputEvent(const IPC::Message& message) { reinterpret_cast<const WebInputEvent*>(data); bool processed = false; if (webwidget_) - processed = webwidget_->handleInputEvent(*input_event); + processed = webwidget_->HandleInputEvent(input_event); IPC::Message* response = new ViewHostMsg_HandleInputEvent_ACK(routing_id_); response->WriteInt(input_event->type); @@ -310,13 +306,13 @@ void RenderWidget::OnHandleInputEvent(const IPC::Message& message) { void RenderWidget::OnMouseCaptureLost() { if (webwidget_) - webwidget_->mouseCaptureLost(); + webwidget_->MouseCaptureLost(); } void RenderWidget::OnSetFocus(bool enable) { has_focus_ = enable; if (webwidget_) - webwidget_->setFocus(enable); + webwidget_->SetFocus(enable); if (enable) { // Force to retrieve the state of the focused widget to determine if we // should activate IMEs next time when this process calls the UpdateIME() @@ -330,7 +326,7 @@ void RenderWidget::ClearFocus() { // We may have got the focus from the browser before this gets processed, in // which case we do not want to unfocus ourself. if (!has_focus_ && webwidget_) - webwidget_->setFocus(false); + webwidget_->SetFocus(false); } void RenderWidget::PaintRect(const gfx::Rect& rect, @@ -351,7 +347,7 @@ void RenderWidget::PaintRect(const gfx::Rect& rect, canvas->drawPaint(paint); } - webwidget_->paint(canvas, rect); + webwidget_->Paint(canvas, rect); // Flush to underlying bitmap. TODO(darin): is this needed? canvas->getTopPlatformDevice().accessBitmap(false); @@ -370,7 +366,7 @@ void RenderWidget::DoDeferredPaint() { } // Layout may generate more invalidation... - webwidget_->layout(); + webwidget_->Layout(); // OK, save the current paint_rect to a local since painting may cause more // invalidation. Some WebCore rendering objects only layout when painted. @@ -424,7 +420,7 @@ void RenderWidget::DoDeferredScroll() { // Layout may generate more invalidation, so we might have to bail on // optimized scrolling... - webwidget_->layout(); + webwidget_->Layout(); if (scroll_rect_.IsEmpty()) return; @@ -497,7 +493,8 @@ void RenderWidget::DoDeferredScroll() { /////////////////////////////////////////////////////////////////////////////// // WebWidgetDelegate -void RenderWidget::didInvalidateRect(const WebRect& rect) { +void RenderWidget::DidInvalidateRect(WebWidget* webwidget, + const WebRect& rect) { // We only want one pending DoDeferredPaint call at any time... bool paint_pending = !paint_rect_.IsEmpty(); @@ -528,10 +525,11 @@ void RenderWidget::didInvalidateRect(const WebRect& rect) { this, &RenderWidget::DoDeferredPaint)); } -void RenderWidget::didScrollRect(int dx, int dy, const WebRect& clip_rect) { +void RenderWidget::DidScrollRect(WebWidget* webwidget, int dx, int dy, + const WebRect& clip_rect) { if (dx != 0 && dy != 0) { // We only support scrolling along one axis at a time. - didScrollRect(0, dy, clip_rect); + DidScrollRect(webwidget, 0, dy, clip_rect); dy = 0; } @@ -551,9 +549,9 @@ void RenderWidget::didScrollRect(int dx, int dy, const WebRect& clip_rect) { return; } } - didInvalidateRect(scroll_rect_); + DidInvalidateRect(webwidget_, scroll_rect_); DCHECK(scroll_rect_.IsEmpty()); - didInvalidateRect(clip_rect); + DidInvalidateRect(webwidget_, clip_rect); return; } @@ -571,7 +569,8 @@ void RenderWidget::didScrollRect(int dx, int dy, const WebRect& clip_rect) { this, &RenderWidget::DoDeferredScroll)); } -void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) { +void RenderWidget::SetCursor(WebWidget* webwidget, + const WebCursorInfo& cursor_info) { // TODO(darin): Eliminate this temporary. WebCursor cursor(cursor_info); @@ -589,7 +588,8 @@ void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) { // This method provides us with the information about how to display the newly // created RenderWidget (i.e., as a constrained popup or as a new tab). // -void RenderWidget::show(WebNavigationPolicy) { +void RenderWidget::Show(WebWidget* webwidget, + WindowOpenDisposition disposition) { DCHECK(!did_show_) << "received extraneous Show call"; DCHECK(routing_id_ != MSG_ROUTING_NONE); DCHECK(opener_id_ != MSG_ROUTING_NONE); @@ -610,7 +610,7 @@ void RenderWidget::show(WebNavigationPolicy) { } } -void RenderWidget::didFocus() { +void RenderWidget::Focus(WebWidget* webwidget) { // Prevent the widget from stealing the focus if it does not have focus // already. We do this by explicitely setting the focus to false again. // We only let the browser focus the renderer. @@ -620,7 +620,7 @@ void RenderWidget::didFocus() { } } -void RenderWidget::didBlur() { +void RenderWidget::Blur(WebWidget* webwidget) { Send(new ViewHostMsg_Blur(routing_id_)); } @@ -628,7 +628,7 @@ void RenderWidget::DoDeferredClose() { Send(new ViewHostMsg_Close(routing_id_)); } -void RenderWidget::closeWidgetSoon() { +void RenderWidget::CloseWidgetSoon(WebWidget* webwidget) { // If a page calls window.close() twice, we'll end up here twice, but that's // OK. It is safe to send multiple Close messages. @@ -642,26 +642,28 @@ void RenderWidget::closeWidgetSoon() { } void RenderWidget::GenerateFullRepaint() { - didInvalidateRect(gfx::Rect(size_.width(), size_.height())); + DidInvalidateRect(webwidget_, gfx::Rect(size_.width(), size_.height())); } void RenderWidget::Close() { if (webwidget_) { - webwidget_->close(); + webwidget_->Close(); webwidget_ = NULL; } } -WebRect RenderWidget::windowRect() { - if (pending_window_rect_count_) - return pending_window_rect_; +void RenderWidget::GetWindowRect(WebWidget* webwidget, WebRect* result) { + if (pending_window_rect_count_) { + *result = pending_window_rect_; + return; + } gfx::Rect rect; Send(new ViewHostMsg_GetWindowRect(routing_id_, host_window_, &rect)); - return rect; + *result = rect; } -void RenderWidget::setWindowRect(const WebRect& pos) { +void RenderWidget::SetWindowRect(WebWidget* webwidget, const WebRect& pos) { if (did_show_) { Send(new ViewHostMsg_RequestMove(routing_id_, pos)); SetPendingWindowRect(pos); @@ -675,23 +677,25 @@ void RenderWidget::SetPendingWindowRect(const WebRect& rect) { pending_window_rect_count_++; } -WebRect RenderWidget::rootWindowRect() { +void RenderWidget::GetRootWindowRect(WebWidget* webwidget, WebRect* result) { if (pending_window_rect_count_) { // NOTE(mbelshe): If there is a pending_window_rect_, then getting // the RootWindowRect is probably going to return wrong results since the // browser may not have processed the Move yet. There isn't really anything // good to do in this case, and it shouldn't happen - since this size is // only really needed for windowToScreen, which is only used for Popups. - return pending_window_rect_; + *result = pending_window_rect_; + return; } gfx::Rect rect; Send(new ViewHostMsg_GetRootWindowRect(routing_id_, host_window_, &rect)); - return rect; + *result = rect; } -WebRect RenderWidget::windowResizerRect() { - return resizer_rect_; +void RenderWidget::GetRootWindowResizerRect(WebWidget* webwidget, + WebRect* rect) { + *rect = resizer_rect_; } void RenderWidget::OnImeSetInputMode(bool is_active) { @@ -701,17 +705,17 @@ void RenderWidget::OnImeSetInputMode(bool is_active) { ime_is_active_ = is_active; } -void RenderWidget::OnImeSetComposition(WebCompositionCommand command, +void RenderWidget::OnImeSetComposition(int string_type, int cursor_position, int target_start, int target_end, - const string16& ime_string) { - if (!webwidget_) - return; - ime_control_busy_ = true; - webwidget_->handleCompositionEvent(command, cursor_position, - target_start, target_end, - ime_string); - ime_control_busy_ = false; + const std::wstring& ime_string) { + if (webwidget_) { + ime_control_busy_ = true; + webwidget_->ImeSetComposition(string_type, cursor_position, + target_start, target_end, + ime_string); + ime_control_busy_ = false; + } } void RenderWidget::OnMsgRepaint(const gfx::Size& size_to_paint) { @@ -721,19 +725,27 @@ void RenderWidget::OnMsgRepaint(const gfx::Size& size_to_paint) { set_next_paint_is_repaint_ack(); gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height()); - didInvalidateRect(repaint_rect); + DidInvalidateRect(webwidget_, repaint_rect); } -void RenderWidget::OnSetTextDirection(WebTextDirection direction) { +void RenderWidget::OnSetTextDirection(int direction) { if (!webwidget_) return; - webwidget_->setTextDirection(direction); + + WebTextDirection new_direction = static_cast<WebTextDirection>(direction); + if (new_direction == WEB_TEXT_DIRECTION_DEFAULT || + new_direction == WEB_TEXT_DIRECTION_LTR || + new_direction == WEB_TEXT_DIRECTION_RTL) { + webwidget_->SetTextDirection(new_direction); + } else { + NOTREACHED(); + } } void RenderWidget::SetBackground(const SkBitmap& background) { background_ = background; // Generate a full repaint. - didInvalidateRect(gfx::Rect(size_.width(), size_.height())); + DidInvalidateRect(webwidget_, gfx::Rect(size_.width(), size_.height())); } bool RenderWidget::next_paint_is_resize_ack() const { @@ -769,7 +781,7 @@ void RenderWidget::UpdateIME() { bool enable_ime = false; WebRect caret_rect; if (!webwidget_ || - !webwidget_->queryCompositionStatus(&enable_ime, &caret_rect)) { + !webwidget_->ImeUpdateStatus(&enable_ime, &caret_rect)) { // There are not any editable widgets attached to this process. // We should disable the IME to prevent it from sending CJK strings to // non-editable widgets. @@ -827,13 +839,8 @@ void RenderWidget::UpdateIME() { ime_control_y_ = caret_rect.y; } -WebScreenInfo RenderWidget::screenInfo() { - WebScreenInfo results; - Send(new ViewHostMsg_GetScreenInfo(routing_id_, host_window_, &results)); - return results; -} - -void RenderWidget::SchedulePluginMove(const WebPluginGeometry& move) { +void RenderWidget::DidMove(WebWidget* webwidget, + const WebPluginGeometry& move) { size_t i = 0; for (; i < plugin_window_moves_.size(); ++i) { if (plugin_window_moves_[i].window == move.window) { @@ -845,3 +852,9 @@ void RenderWidget::SchedulePluginMove(const WebPluginGeometry& move) { if (i == plugin_window_moves_.size()) plugin_window_moves_.push_back(move); } + +WebScreenInfo RenderWidget::GetScreenInfo(WebWidget* webwidget) { + WebScreenInfo results; + Send(new ViewHostMsg_GetScreenInfo(routing_id_, host_window_, &results)); + return results; +} |