| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
| 9 #include <gdk/gdkx.h> | 9 #include <gdk/gdkx.h> |
| 10 #include <cairo/cairo.h> | 10 #include <cairo/cairo.h> |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 RenderWidgetHost* widget) { | 152 RenderWidgetHost* widget) { |
| 153 return new RenderWidgetHostViewGtk(widget); | 153 return new RenderWidgetHostViewGtk(widget); |
| 154 } | 154 } |
| 155 | 155 |
| 156 RenderWidgetHostViewGtk::RenderWidgetHostViewGtk(RenderWidgetHost* widget_host) | 156 RenderWidgetHostViewGtk::RenderWidgetHostViewGtk(RenderWidgetHost* widget_host) |
| 157 : host_(widget_host), | 157 : host_(widget_host), |
| 158 parent_host_view_(NULL), | 158 parent_host_view_(NULL), |
| 159 parent_(NULL), | 159 parent_(NULL), |
| 160 popup_signal_id_(0), | 160 popup_signal_id_(0), |
| 161 activatable_(true), | 161 activatable_(true), |
| 162 about_to_validate_and_paint_(false), |
| 162 is_loading_(false) { | 163 is_loading_(false) { |
| 163 host_->set_view(this); | 164 host_->set_view(this); |
| 164 } | 165 } |
| 165 | 166 |
| 166 RenderWidgetHostViewGtk::~RenderWidgetHostViewGtk() { | 167 RenderWidgetHostViewGtk::~RenderWidgetHostViewGtk() { |
| 167 } | 168 } |
| 168 | 169 |
| 169 void RenderWidgetHostViewGtk::InitAsChild() { | 170 void RenderWidgetHostViewGtk::InitAsChild() { |
| 170 view_.Own(RenderWidgetHostViewGtkWidget::CreateNewWidget(this)); | 171 view_.Own(RenderWidgetHostViewGtkWidget::CreateNewWidget(this)); |
| 171 gtk_widget_show(view_.get()); | 172 gtk_widget_show(view_.get()); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 if (current_cursor_.GetCursorType() == GDK_LAST_CURSOR) | 271 if (current_cursor_.GetCursorType() == GDK_LAST_CURSOR) |
| 271 ShowCurrentCursor(); | 272 ShowCurrentCursor(); |
| 272 } | 273 } |
| 273 | 274 |
| 274 void RenderWidgetHostViewGtk::IMEUpdateStatus(int control, | 275 void RenderWidgetHostViewGtk::IMEUpdateStatus(int control, |
| 275 const gfx::Rect& caret_rect) { | 276 const gfx::Rect& caret_rect) { |
| 276 NOTIMPLEMENTED(); | 277 NOTIMPLEMENTED(); |
| 277 } | 278 } |
| 278 | 279 |
| 279 void RenderWidgetHostViewGtk::DidPaintRect(const gfx::Rect& rect) { | 280 void RenderWidgetHostViewGtk::DidPaintRect(const gfx::Rect& rect) { |
| 280 Paint(rect); | 281 if (about_to_validate_and_paint_) |
| 282 invalid_rect_ = invalid_rect_.Union(rect); |
| 283 else |
| 284 Paint(rect); |
| 281 } | 285 } |
| 282 | 286 |
| 283 void RenderWidgetHostViewGtk::DidScrollRect(const gfx::Rect& rect, int dx, | 287 void RenderWidgetHostViewGtk::DidScrollRect(const gfx::Rect& rect, int dx, |
| 284 int dy) { | 288 int dy) { |
| 285 Paint(rect); | 289 Paint(rect); |
| 286 } | 290 } |
| 287 | 291 |
| 288 void RenderWidgetHostViewGtk::RenderViewGone() { | 292 void RenderWidgetHostViewGtk::RenderViewGone() { |
| 289 NOTIMPLEMENTED(); | 293 NOTIMPLEMENTED(); |
| 290 } | 294 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 return new BackingStore(size, display, depth, visual, root_window, | 335 return new BackingStore(size, display, depth, visual, root_window, |
| 332 use_render, use_shared_memory); | 336 use_render, use_shared_memory); |
| 333 } | 337 } |
| 334 | 338 |
| 335 void RenderWidgetHostViewGtk::PasteFromSelectionClipboard() { | 339 void RenderWidgetHostViewGtk::PasteFromSelectionClipboard() { |
| 336 GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); | 340 GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); |
| 337 gtk_clipboard_request_text(x_clipboard, ReceivedSelectionText, this); | 341 gtk_clipboard_request_text(x_clipboard, ReceivedSelectionText, this); |
| 338 } | 342 } |
| 339 | 343 |
| 340 void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { | 344 void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { |
| 345 DCHECK(!about_to_validate_and_paint_); |
| 346 |
| 347 invalid_rect_ = damage_rect; |
| 348 about_to_validate_and_paint_ = true; |
| 341 BackingStore* backing_store = host_->GetBackingStore(); | 349 BackingStore* backing_store = host_->GetBackingStore(); |
| 350 // Calling GetBackingStore maybe have changed |invalid_rect_|... |
| 351 about_to_validate_and_paint_ = false; |
| 342 | 352 |
| 343 GdkWindow* window = view_.get()->window; | 353 GdkWindow* window = view_.get()->window; |
| 344 if (backing_store) { | 354 if (backing_store) { |
| 345 // Only render the widget if it is attached to a window; there's a short | 355 // Only render the widget if it is attached to a window; there's a short |
| 346 // period where this object isn't attached to a window but hasn't been | 356 // period where this object isn't attached to a window but hasn't been |
| 347 // Destroy()ed yet and it receives paint messages... | 357 // Destroy()ed yet and it receives paint messages... |
| 348 if (window) { | 358 if (window) { |
| 349 backing_store->ShowRect( | 359 backing_store->ShowRect( |
| 350 damage_rect, x11_util::GetX11WindowFromGtkWidget(view_.get())); | 360 invalid_rect_, x11_util::GetX11WindowFromGtkWidget(view_.get())); |
| 351 } | 361 } |
| 352 } else { | 362 } else { |
| 353 if (window) | 363 if (window) |
| 354 gdk_window_clear(window); | 364 gdk_window_clear(window); |
| 355 NOTIMPLEMENTED(); | 365 NOTIMPLEMENTED(); |
| 356 } | 366 } |
| 357 } | 367 } |
| 358 | 368 |
| 359 void RenderWidgetHostViewGtk::ShowCurrentCursor() { | 369 void RenderWidgetHostViewGtk::ShowCurrentCursor() { |
| 360 // The widget may not have a window. If that's the case, abort mission. This | 370 // The widget may not have a window. If that's the case, abort mission. This |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 void RenderWidgetHostViewGtk::ReceivedSelectionText(GtkClipboard* clipboard, | 411 void RenderWidgetHostViewGtk::ReceivedSelectionText(GtkClipboard* clipboard, |
| 402 const gchar* text, gpointer userdata) { | 412 const gchar* text, gpointer userdata) { |
| 403 // If there's nothing to paste (|text| is NULL), do nothing. | 413 // If there's nothing to paste (|text| is NULL), do nothing. |
| 404 if (!text) | 414 if (!text) |
| 405 return; | 415 return; |
| 406 RenderWidgetHostViewGtk* host_view = | 416 RenderWidgetHostViewGtk* host_view = |
| 407 reinterpret_cast<RenderWidgetHostViewGtk*>(userdata); | 417 reinterpret_cast<RenderWidgetHostViewGtk*>(userdata); |
| 408 host_view->host_->Send(new ViewMsg_InsertText(host_view->host_->routing_id(), | 418 host_view->host_->Send(new ViewMsg_InsertText(host_view->host_->routing_id(), |
| 409 UTF8ToUTF16(text))); | 419 UTF8ToUTF16(text))); |
| 410 } | 420 } |
| OLD | NEW |