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 | |
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')
-rw-r--r-- | chrome/renderer/print_web_view_helper.cc | 37 | ||||
-rw-r--r-- | chrome/renderer/print_web_view_helper.h | 35 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 55 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 27 | ||||
-rw-r--r-- | chrome/renderer/render_view_unittest.cc | 30 | ||||
-rw-r--r-- | chrome/renderer/render_widget.cc | 131 | ||||
-rw-r--r-- | chrome/renderer/render_widget.h | 57 |
7 files changed, 180 insertions, 192 deletions
diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc index 115fc12..aac98ac 100644 --- a/chrome/renderer/print_web_view_helper.cc +++ b/chrome/renderer/print_web_view_helper.cc @@ -13,7 +13,6 @@ #include "printing/native_metafile.h" #include "printing/units.h" #include "webkit/api/public/WebConsoleMessage.h" -#include "webkit/api/public/WebRect.h" #include "webkit/api/public/WebScreenInfo.h" #include "webkit/api/public/WebSize.h" #include "webkit/api/public/WebURL.h" @@ -25,8 +24,6 @@ #endif using WebKit::WebConsoleMessage; -using WebKit::WebRect; -using WebKit::WebScreenInfo; using WebKit::WebString; using WebKit::WebURLRequest; @@ -65,9 +62,9 @@ class PrepareFrameAndViewForPrint { print_layout_size.set_height(static_cast<int>( static_cast<double>(print_layout_size.height()) * 1.25)); - prev_view_size_ = web_view->size(); + prev_view_size_ = web_view->GetSize(); - web_view->resize(print_layout_size); + web_view->Resize(print_layout_size); expected_pages_count_ = frame->PrintBegin(print_canvas_size_); } @@ -82,7 +79,7 @@ class PrepareFrameAndViewForPrint { ~PrepareFrameAndViewForPrint() { frame_->PrintEnd(); - web_view_->resize(prev_view_size_); + web_view_->Resize(prev_view_size_); } private: @@ -233,7 +230,7 @@ void PrintWebViewHelper::DidFinishPrinting(bool success) { } if (print_web_view_.get()) { - print_web_view_->close(); + print_web_view_->Close(); print_web_view_.release(); // Close deletes object. print_pages_params_.reset(); } @@ -414,28 +411,24 @@ int32 PrintWebViewHelper::routing_id() { return render_view_->routing_id(); } -WebRect PrintWebViewHelper::windowRect() { - NOTREACHED(); - return WebRect(); +void PrintWebViewHelper::DidStopLoading(WebView* webview) { + DCHECK(print_pages_params_.get() != NULL); + DCHECK_EQ(webview, print_web_view_.get()); + PrintPages(*print_pages_params_.get(), print_web_view_->GetMainFrame()); } -WebRect PrintWebViewHelper::windowResizerRect() { +void PrintWebViewHelper::GetWindowRect(WebWidget* webwidget, + WebKit::WebRect* rect) { NOTREACHED(); - return WebRect(); } -WebRect PrintWebViewHelper::rootWindowRect() { +WebKit::WebScreenInfo PrintWebViewHelper::GetScreenInfo(WebWidget* webwidget) { + WebKit::WebScreenInfo info; NOTREACHED(); - return WebRect(); + return info; } -WebScreenInfo PrintWebViewHelper::screenInfo() { +bool PrintWebViewHelper::IsHidden(WebWidget* webwidget) { NOTREACHED(); - return WebScreenInfo(); -} - -void PrintWebViewHelper::DidStopLoading(WebView* webview) { - DCHECK(print_pages_params_.get() != NULL); - DCHECK_EQ(webview, print_web_view_.get()); - PrintPages(*print_pages_params_.get(), print_web_view_->GetMainFrame()); + return true; } diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h index 13d0747..11e16fd 100644 --- a/chrome/renderer/print_web_view_helper.h +++ b/chrome/renderer/print_web_view_helper.h @@ -66,20 +66,29 @@ class PrintWebViewHelper : public WebViewDelegate { int32 routing_id(); // WebViewDeletegate - virtual void didInvalidateRect(const WebKit::WebRect&) {} - virtual void didScrollRect(int dx, int dy, const WebKit::WebRect& clipRect) {} - virtual void didFocus() {} - virtual void didBlur() {} - virtual void didChangeCursor(const WebKit::WebCursorInfo&) {} - virtual void closeWidgetSoon() {} - virtual void show(WebKit::WebNavigationPolicy) {} - virtual void runModal() {} - virtual WebKit::WebRect windowRect(); - virtual void setWindowRect(const WebKit::WebRect&) {} - virtual WebKit::WebRect windowResizerRect(); - virtual WebKit::WebRect rootWindowRect(); - virtual WebKit::WebScreenInfo screenInfo(); virtual void DidStopLoading(WebView* webview); + virtual void DidInvalidateRect(WebWidget* webwidget, + const WebKit::WebRect& rect) {} + virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy, + const WebKit::WebRect& clip_rect) {} + virtual void Show(WebWidget* webwidget, WindowOpenDisposition disposition) {} + virtual void CloseWidgetSoon(WebWidget* webwidget) {} + virtual void Focus(WebWidget* webwidget) {} + virtual void Blur(WebWidget* webwidget) {} + virtual void SetCursor(WebWidget* webwidget, + const WebKit::WebCursorInfo& cursor) {} + virtual void GetWindowRect(WebWidget* webwidget, WebKit::WebRect* rect); + virtual void SetWindowRect(WebWidget* webwidget, + const WebKit::WebRect& rect) {} + virtual void GetRootWindowRect(WebWidget* webwidget, WebKit::WebRect* rect) {} + virtual void GetRootWindowResizerRect(WebWidget* webwidget, + WebKit::WebRect* rect) {} + virtual void DidMove(WebWidget* webwidget, const WebPluginGeometry& move) {} + virtual void RunModal(WebWidget* webwidget) {} + virtual void AddRef() {} + virtual void Release() {} + virtual bool IsHidden(WebWidget* webwidget); + virtual WebKit::WebScreenInfo GetScreenInfo(WebWidget* webwidget); private: RenderView* render_view_; diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 96cf524a..15d7771 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -106,7 +106,6 @@ using WebKit::WebDataSource; using WebKit::WebDragData; using WebKit::WebForm; using WebKit::WebHistoryItem; -using WebKit::WebNavigationPolicy; using WebKit::WebNavigationType; using WebKit::WebPopupMenuInfo; using WebKit::WebRect; @@ -117,10 +116,9 @@ using WebKit::WebURL; using WebKit::WebURLError; using WebKit::WebURLRequest; using WebKit::WebURLResponse; -using WebKit::WebVector; -using WebKit::WebWidget; using WebKit::WebWorker; using WebKit::WebWorkerClient; +using WebKit::WebVector; //----------------------------------------------------------------------------- @@ -562,13 +560,13 @@ bool RenderView::CaptureThumbnail(WebView* view, double begin = time_util::GetHighResolutionTimeNow(); #endif - view->layout(); - const WebSize& size = view->size(); + view->Layout(); + const WebSize& size = view->GetSize(); skia::PlatformCanvas canvas; if (!canvas.initialize(size.width, size.height, true)) return false; - view->paint(&canvas, WebRect(0, 0, size.width, size.height)); + view->Paint(&canvas, WebRect(0, 0, size.width, size.height)); skia::BitmapPlatformDevice& device = static_cast<skia::BitmapPlatformDevice&>(canvas.getTopPlatformDevice()); @@ -1476,12 +1474,12 @@ void RenderView::DidCreateIsolatedScriptContext(WebFrame* webframe) { EventBindings::HandleContextCreated(webframe); } -WebNavigationPolicy RenderView::PolicyForNavigationAction( +WindowOpenDisposition RenderView::DispositionForNavigationAction( WebView* webview, WebFrame* frame, const WebURLRequest& request, WebNavigationType type, - WebNavigationPolicy default_policy, + WindowOpenDisposition disposition, bool is_redirect) { // A content initiated navigation may have originated from a link-click, // script, drag-n-drop operation, etc. @@ -1498,9 +1496,8 @@ WebNavigationPolicy RenderView::PolicyForNavigationAction( // to, for example, opening a new window). // But we sometimes navigate to about:blank to clear a tab, and we want to // still allow that. - if (default_policy == WebKit::WebNavigationPolicyCurrentTab && - is_content_initiated && frame->GetParent() == NULL && - !url.SchemeIs(chrome::kAboutScheme)) { + if (disposition == CURRENT_TAB && is_content_initiated && + frame->GetParent() == NULL && !url.SchemeIs(chrome::kAboutScheme)) { // When we received such unsolicited navigations, we sometimes want to // punt them up to the browser to handle. if (BindingsPolicy::is_dom_ui_enabled(enabled_bindings_) || @@ -1508,8 +1505,8 @@ WebNavigationPolicy RenderView::PolicyForNavigationAction( frame->GetInViewSourceMode() || url.SchemeIs(chrome::kViewSourceScheme) || url.SchemeIs(chrome::kPrintScheme)) { - OpenURL(webview, url, GURL(), default_policy); - return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. + OpenURL(webview, url, GURL(), disposition); + return IGNORE_ACTION; // Suppress the load here. } } @@ -1538,16 +1535,16 @@ WebNavigationPolicy RenderView::PolicyForNavigationAction( // Must not have issued the request from this page. is_content_initiated && // Must be targeted at the current tab. - default_policy == WebKit::WebNavigationPolicyCurrentTab && + disposition == CURRENT_TAB && // Must be a JavaScript navigation, which appears as "other". type == WebKit::WebNavigationTypeOther; if (is_fork) { // Open the URL via the browser, not via WebKit. - OpenURL(webview, url, GURL(), default_policy); - return WebKit::WebNavigationPolicyIgnore; + OpenURL(webview, url, GURL(), disposition); + return IGNORE_ACTION; } - return default_policy; + return disposition; } void RenderView::RunJavaScriptAlert(WebFrame* webframe, @@ -1887,9 +1884,8 @@ WebWorker* RenderView::CreateWebWorker(WebWorkerClient* client) { void RenderView::OpenURL(WebView* webview, const GURL& url, const GURL& referrer, - WebNavigationPolicy policy) { - Send(new ViewHostMsg_OpenURL( - routing_id_, url, referrer, NavigationPolicyToDisposition(policy))); + WindowOpenDisposition disposition) { + Send(new ViewHostMsg_OpenURL(routing_id_, url, referrer, disposition)); } void RenderView::DidContentsSizeChange(WebWidget* webwidget, @@ -1922,7 +1918,7 @@ void RenderView::DidContentsSizeChange(WebWidget* webwidget, // This method provides us with the information about how to display the newly // created RenderView (i.e., as a constrained popup or as a new tab). // -void RenderView::show(WebNavigationPolicy policy) { +void RenderView::Show(WebWidget* webwidget, WindowOpenDisposition disposition) { DCHECK(!did_show_) << "received extraneous Show call"; DCHECK(opener_id_ != MSG_ROUTING_NONE); @@ -1933,18 +1929,17 @@ void RenderView::show(WebNavigationPolicy policy) { // NOTE: initial_pos_ may still have its default values at this point, but // that's okay. It'll be ignored if disposition is not NEW_POPUP, or the // browser process will impose a default position otherwise. - Send(new ViewHostMsg_ShowView(opener_id_, routing_id_, - NavigationPolicyToDisposition(policy), initial_pos_, - opened_by_user_gesture_, creator_url_)); + Send(new ViewHostMsg_ShowView(opener_id_, routing_id_, disposition, + initial_pos_, opened_by_user_gesture_, creator_url_)); SetPendingWindowRect(initial_pos_); } -void RenderView::closeWidgetSoon() { +void RenderView::CloseWidgetSoon(WebWidget* webwidget) { if (!popup_notification_visible_) - RenderWidget::closeWidgetSoon(); + RenderWidget::CloseWidgetSoon(webwidget); } -void RenderView::runModal() { +void RenderView::RunModal(WebWidget* webwidget) { DCHECK(did_show_) << "should already have shown the view"; IPC::SyncMessage* msg = new ViewHostMsg_RunModal(routing_id_); @@ -2737,7 +2732,7 @@ void RenderView::OnThemeChanged() { #if defined(OS_WIN) gfx::NativeTheme::instance()->CloseHandles(); gfx::Rect view_rect(0, 0, size_.width(), size_.height()); - didInvalidateRect(view_rect); + DidInvalidateRect(webwidget_, view_rect); #else // defined(OS_WIN) // TODO(port): we don't support theming on non-Windows platforms yet NOTIMPLEMENTED(); @@ -3023,10 +3018,6 @@ void RenderView::FocusAccessibilityObject( #endif } -void RenderView::DidMovePlugin(const WebPluginGeometry& move) { - SchedulePluginMove(move); -} - void RenderView::SendPasswordForms(WebFrame* frame) { std::vector<WebForm> forms; frame->GetForms(&forms); diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index c8afcd2..0b1a38a 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -35,8 +35,8 @@ #include "webkit/glue/webview.h" #if defined(OS_WIN) -// RenderView is a diamond-shaped hierarchy, with WebWidgetClient at the root. -// VS warns when we inherit the WebWidgetClient method implementations from +// RenderView is a diamond-shaped hierarchy, with WebWidgetDelegate at the root. +// VS warns when we inherit the WebWidgetDelegate method implementations from // RenderWidget. It's safe to ignore that warning. #pragma warning(disable: 4250) #endif @@ -202,7 +202,7 @@ class RenderView : public RenderWidget, virtual void DidChangeLocationWithinPageForFrame(WebView* webview, WebFrame* frame, bool is_new_navigation); - virtual void DidContentsSizeChange(WebKit::WebWidget* webwidget, + virtual void DidContentsSizeChange(WebWidget* webwidget, int new_width, int new_height); @@ -222,21 +222,19 @@ class RenderView : public RenderWidget, virtual void DidDestroyScriptContextForFrame(WebFrame* webframe); virtual void DidCreateIsolatedScriptContext(WebFrame* webframe); - virtual WebKit::WebNavigationPolicy PolicyForNavigationAction( + virtual WindowOpenDisposition DispositionForNavigationAction( WebView* webview, WebFrame* frame, const WebKit::WebURLRequest& request, WebKit::WebNavigationType type, - WebKit::WebNavigationPolicy default_policy, + WindowOpenDisposition disposition, bool is_redirect); virtual WebView* CreateWebView(WebView* webview, bool user_gesture, const GURL& creator_url); - virtual WebKit::WebWidget* CreatePopupWidget( - WebView* webview, - bool activatable); - virtual WebKit::WebWidget* CreatePopupWidgetWithInfo( + virtual WebWidget* CreatePopupWidget(WebView* webview, bool activatable); + virtual WebWidget* CreatePopupWidgetWithInfo( WebView* webview, const WebKit::WebPopupMenuInfo& info); virtual WebPluginDelegate* CreatePluginDelegate( @@ -251,7 +249,7 @@ class RenderView : public RenderWidget, virtual void OnMissingPluginStatus(WebPluginDelegate* delegate, int status); virtual void OpenURL(WebView* webview, const GURL& url, const GURL& referrer, - WebKit::WebNavigationPolicy policy); + WindowOpenDisposition disposition); virtual void DidDownloadImage(int id, const GURL& image_url, bool errored, @@ -303,7 +301,6 @@ class RenderView : public RenderWidget, const WebKit::WebRect& selection); virtual bool WasOpenedByUserGesture() const; virtual void FocusAccessibilityObject(WebCore::AccessibilityObject* acc_obj); - virtual void DidMovePlugin(const WebPluginGeometry& move); virtual void SpellCheck(const std::wstring& word, int* misspell_location, int* misspell_length); virtual std::wstring GetAutoCorrectWord(const std::wstring& word); @@ -316,11 +313,11 @@ class RenderView : public RenderWidget, virtual void DidSerializeDataForFrame(const GURL& frame_url, const std::string& data, PageSavingSerializationStatus status); - // WebKit::WebWidgetClient + // WebWidgetDelegate // Most methods are handled by RenderWidget. - virtual void show(WebKit::WebNavigationPolicy policy); - virtual void closeWidgetSoon(); - virtual void runModal(); + virtual void Show(WebWidget* webwidget, WindowOpenDisposition disposition); + virtual void CloseWidgetSoon(WebWidget* webwidget); + virtual void RunModal(WebWidget* webwidget); // Do not delete directly. This class is reference counted. virtual ~RenderView(); diff --git a/chrome/renderer/render_view_unittest.cc b/chrome/renderer/render_view_unittest.cc index 4b4ed60..ab27ec0 100644 --- a/chrome/renderer/render_view_unittest.cc +++ b/chrome/renderer/render_view_unittest.cc @@ -10,23 +10,8 @@ #include "testing/gtest/include/gtest/gtest.h" #include "webkit/api/public/WebURLError.h" -using WebKit::WebCompositionCommand; -using WebKit::WebTextDirection; using WebKit::WebURLError; -static WebCompositionCommand ToCompositionCommand(int string_type) { - switch (string_type) { - default: - NOTREACHED(); - case -1: - return WebKit::WebCompositionCommandDiscard; - case 0: - return WebKit::WebCompositionCommandSet; - case 1: - return WebKit::WebCompositionCommandConfirm; - } -} - TEST_F(RenderViewTest, OnLoadAlternateHTMLText) { // Test a new navigation. GURL test_url("http://www.google.com/some_test_url"); @@ -225,12 +210,11 @@ TEST_F(RenderViewTest, ImeComposition) { break; case IME_SETCOMPOSITION: - view_->OnImeSetComposition( - ToCompositionCommand(ime_message->string_type), - ime_message->cursor_position, - ime_message->target_start, - ime_message->target_end, - WideToUTF16Hack(ime_message->ime_string)); + view_->OnImeSetComposition(ime_message->string_type, + ime_message->cursor_position, + ime_message->target_start, + ime_message->target_end, + ime_message->ime_string); break; } @@ -273,8 +257,8 @@ TEST_F(RenderViewTest, OnSetTextDirection) { WebTextDirection direction; const wchar_t* expected_result; } kTextDirection[] = { - { WebKit::WebTextDirectionRightToLeft, L"\x000A" L"rtl,rtl" }, - { WebKit::WebTextDirectionLeftToRight, L"\x000A" L"ltr,ltr" }, + {WEB_TEXT_DIRECTION_RTL, L"\x000A" L"rtl,rtl"}, + {WEB_TEXT_DIRECTION_LTR, L"\x000A" L"ltr,ltr"}, }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTextDirection); ++i) { // Set the text direction of the <textarea> element. 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; +} diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h index 005b4b6..f1fa069 100644 --- a/chrome/renderer/render_widget.h +++ b/chrome/renderer/render_widget.h @@ -17,10 +17,9 @@ #include "chrome/renderer/render_process.h" #include "skia/ext/platform_canvas.h" #include "third_party/skia/include/core/SkBitmap.h" -#include "webkit/api/public/WebCompositionCommand.h" + #include "webkit/api/public/WebRect.h" -#include "webkit/api/public/WebTextDirection.h" -#include "webkit/api/public/WebWidgetClient.h" +#include "webkit/glue/webwidget_delegate.h" #include "webkit/glue/webcursor.h" class RenderThreadBase; @@ -35,7 +34,7 @@ struct WebPopupMenuInfo; // a RenderWidgetHost, the latter of which lives in a different process. class RenderWidget : public IPC::Channel::Listener, public IPC::Message::Sender, - virtual public WebKit::WebWidgetClient, + virtual public WebWidgetDelegate, public base::RefCounted<RenderWidget> { public: // Creates a new RenderWidget. The opener_id is the routing ID of the @@ -57,7 +56,7 @@ class RenderWidget : public IPC::Channel::Listener, } // May return NULL when the window is closing. - WebKit::WebWidget* webwidget() const { + WebWidget* webwidget() const { return webwidget_; } @@ -67,24 +66,27 @@ class RenderWidget : public IPC::Channel::Listener, // IPC::Message::Sender virtual bool Send(IPC::Message* msg); - // WebKit::WebWidgetClient - virtual void didInvalidateRect(const WebKit::WebRect&); - virtual void didScrollRect(int dx, int dy, const WebKit::WebRect& clipRect); - virtual void didFocus(); - virtual void didBlur(); - virtual void didChangeCursor(const WebKit::WebCursorInfo&); - virtual void closeWidgetSoon(); - virtual void show(WebKit::WebNavigationPolicy); - virtual void runModal() {} - virtual WebKit::WebRect windowRect(); - virtual void setWindowRect(const WebKit::WebRect&); - virtual WebKit::WebRect windowResizerRect(); - virtual WebKit::WebRect rootWindowRect(); - virtual WebKit::WebScreenInfo screenInfo(); - - // Called when a plugin is moved. These events are queued up and sent with - // the next paint or scroll message to the host. - void SchedulePluginMove(const WebPluginGeometry& move); + // WebWidgetDelegate + virtual void DidInvalidateRect(WebWidget* webwidget, + const WebKit::WebRect& rect); + virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy, + const WebKit::WebRect& clip_rect); + virtual void Show(WebWidget* webwidget, WindowOpenDisposition disposition); + virtual void CloseWidgetSoon(WebWidget* webwidget); + virtual void Focus(WebWidget* webwidget); + virtual void Blur(WebWidget* webwidget); + virtual void SetCursor(WebWidget* webwidget, + const WebKit::WebCursorInfo& cursor); + virtual void GetWindowRect(WebWidget* webwidget, WebKit::WebRect* rect); + virtual void SetWindowRect(WebWidget* webwidget, + const WebKit::WebRect& rect); + virtual void GetRootWindowRect(WebWidget* webwidget, WebKit::WebRect* rect); + virtual void GetRootWindowResizerRect(WebWidget* webwidget, + WebKit::WebRect* rect); + virtual void DidMove(WebWidget* webwidget, const WebPluginGeometry& move); + virtual void RunModal(WebWidget* webwidget) {} + virtual bool IsHidden(WebWidget* webwidget) { return is_hidden_; } + virtual WebKit::WebScreenInfo GetScreenInfo(WebWidget* webwidget); // Invalidates entire widget rect to generate a full repaint. void GenerateFullRepaint(); @@ -136,12 +138,11 @@ class RenderWidget : public IPC::Channel::Listener, void OnMouseCaptureLost(); void OnSetFocus(bool enable); void OnImeSetInputMode(bool is_active); - void OnImeSetComposition(WebKit::WebCompositionCommand command, - int cursor_position, + void OnImeSetComposition(int string_type, int cursor_position, int target_start, int target_end, - const string16& ime_string); + const std::wstring& ime_string); void OnMsgRepaint(const gfx::Size& size_to_paint); - void OnSetTextDirection(WebKit::WebTextDirection direction); + void OnSetTextDirection(int direction); // Override point to notify that a paint has happened. This fires after the // browser side has updated the screen for a newly painted region. @@ -187,7 +188,7 @@ class RenderWidget : public IPC::Channel::Listener, int32 routing_id_; // We are responsible for destroying this object via its Close method. - WebKit::WebWidget* webwidget_; + WebWidget* webwidget_; // Set to the ID of the view that initiated creating this view, if any. When // the view was initiated by the browser (the common case), this will be |