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

Side by Side Diff: chrome/browser/renderer_host/render_widget_host_view_views.cc

Issue 7850026: Aura under Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge conflict resolved Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_views.h" 5 #include "chrome/browser/renderer_host/render_widget_host_view_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 20 matching lines...) Expand all
31 #include "views/events/event.h" 31 #include "views/events/event.h"
32 #include "views/ime/input_method.h" 32 #include "views/ime/input_method.h"
33 #include "views/views_delegate.h" 33 #include "views/views_delegate.h"
34 #include "views/widget/tooltip_manager.h" 34 #include "views/widget/tooltip_manager.h"
35 #include "views/widget/widget.h" 35 #include "views/widget/widget.h"
36 36
37 #if defined(TOOLKIT_USES_GTK) 37 #if defined(TOOLKIT_USES_GTK)
38 #include <gtk/gtk.h> 38 #include <gtk/gtk.h>
39 #include <gtk/gtkwindow.h> 39 #include <gtk/gtkwindow.h>
40 #include <gdk/gdkx.h> 40 #include <gdk/gdkx.h>
41 #include "content/browser/renderer_host/gtk_window_utils.h"
42 #include "views/widget/native_widget_gtk.h"
41 #endif 43 #endif
42 44
43 #if defined(TOUCH_UI) 45 #if defined(TOUCH_UI)
44 #include "chrome/browser/renderer_host/accelerated_surface_container_touch.h" 46 #include "chrome/browser/renderer_host/accelerated_surface_container_touch.h"
45 #endif 47 #endif
46 48
49 #if defined(OS_POSIX)
50 #include "content/browser/renderer_host/gtk_window_utils.h"
51 #endif
52
47 static const int kMaxWindowWidth = 4000; 53 static const int kMaxWindowWidth = 4000;
48 static const int kMaxWindowHeight = 4000; 54 static const int kMaxWindowHeight = 4000;
49 static const int kTouchControllerUpdateDelay = 150; 55 static const int kTouchControllerUpdateDelay = 150;
50 56
51 // static 57 // static
52 const char RenderWidgetHostViewViews::kViewClassName[] = 58 const char RenderWidgetHostViewViews::kViewClassName[] =
53 "browser/renderer_host/RenderWidgetHostViewViews"; 59 "browser/renderer_host/RenderWidgetHostViewViews";
54 60
55 using WebKit::WebInputEventFactory; 61 using WebKit::WebInputEventFactory;
56 using WebKit::WebMouseWheelEvent; 62 using WebKit::WebMouseWheelEvent;
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 742
737 about_to_validate_and_paint_ = true; 743 about_to_validate_and_paint_ = true;
738 BackingStore* backing_store = host_->GetBackingStore(true); 744 BackingStore* backing_store = host_->GetBackingStore(true);
739 // Calling GetBackingStore maybe have changed |invalid_rect_|... 745 // Calling GetBackingStore maybe have changed |invalid_rect_|...
740 about_to_validate_and_paint_ = false; 746 about_to_validate_and_paint_ = false;
741 747
742 gfx::Rect paint_rect = gfx::Rect(0, 0, kMaxWindowWidth, kMaxWindowHeight); 748 gfx::Rect paint_rect = gfx::Rect(0, 0, kMaxWindowWidth, kMaxWindowHeight);
743 paint_rect = paint_rect.Intersect(invalid_rect_); 749 paint_rect = paint_rect.Intersect(invalid_rect_);
744 750
745 if (backing_store) { 751 if (backing_store) {
746 #if defined(TOOLKIT_USES_GTK) 752 #if defined(TOOLKIT_USES_GTK) && !defined(USE_AURA)
747 // Only render the widget if it is attached to a window; there's a short 753 // Only render the widget if it is attached to a window; there's a short
748 // period where this object isn't attached to a window but hasn't been 754 // period where this object isn't attached to a window but hasn't been
749 // Destroy()ed yet and it receives paint messages... 755 // Destroy()ed yet and it receives paint messages...
750 if (GetInnerNativeView()->window) { 756 if (GetInnerNativeView()->window) {
751 #endif 757 #endif
752 if (!visually_deemphasized_) { 758 if (!visually_deemphasized_) {
753 // In the common case, use XCopyArea. We don't draw more than once, so 759 // In the common case, use XCopyArea. We don't draw more than once, so
754 // we don't need to double buffer. 760 // we don't need to double buffer.
755 if (IsPopup()) { 761 if (IsPopup()) {
756 origin.SetPoint(origin.x() + paint_rect.x(), 762 origin.SetPoint(origin.x() + paint_rect.x(),
757 origin.y() + paint_rect.y()); 763 origin.y() + paint_rect.y());
758 paint_rect.SetRect(0, 0, paint_rect.width(), paint_rect.height()); 764 paint_rect.SetRect(0, 0, paint_rect.width(), paint_rect.height());
759 } 765 }
760 static_cast<BackingStoreSkia*>(backing_store)->SkiaShowRect( 766 static_cast<BackingStoreSkia*>(backing_store)->SkiaShowRect(
761 gfx::Point(paint_rect.x(), paint_rect.y()), canvas); 767 gfx::Point(paint_rect.x(), paint_rect.y()), canvas);
762 } else { 768 } else {
763 // TODO(sad) 769 // TODO(sad)
764 NOTIMPLEMENTED(); 770 NOTIMPLEMENTED();
765 } 771 }
766 #if defined(TOOLKIT_USES_GTK) 772 #if defined(TOOLKIT_USES_GTK) && !defined(USE_AURA)
767 } 773 }
768 #endif 774 #endif
769 if (!whiteout_start_time_.is_null()) { 775 if (!whiteout_start_time_.is_null()) {
770 base::TimeDelta whiteout_duration = base::TimeTicks::Now() - 776 base::TimeDelta whiteout_duration = base::TimeTicks::Now() -
771 whiteout_start_time_; 777 whiteout_start_time_;
772 UMA_HISTOGRAM_TIMES("MPArch.RWHH_WhiteoutDuration", whiteout_duration); 778 UMA_HISTOGRAM_TIMES("MPArch.RWHH_WhiteoutDuration", whiteout_duration);
773 779
774 // Reset the start time to 0 so that we start recording again the next 780 // Reset the start time to 0 so that we start recording again the next
775 // time the backing store is NULL... 781 // time the backing store is NULL...
776 whiteout_start_time_ = base::TimeTicks(); 782 whiteout_start_time_ = base::TimeTicks();
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 DCHECK(GetInputMethod()); 873 DCHECK(GetInputMethod());
868 GetInputMethod()->CancelComposition(this); 874 GetInputMethod()->CancelComposition(this);
869 has_composition_text_ = false; 875 has_composition_text_ = false;
870 } 876 }
871 877
872 void RenderWidgetHostViewViews::UpdateTouchSelectionController() { 878 void RenderWidgetHostViewViews::UpdateTouchSelectionController() {
873 if (touch_selection_controller_.get()) 879 if (touch_selection_controller_.get())
874 touch_selection_controller_->SelectionChanged(selection_start_, 880 touch_selection_controller_->SelectionChanged(selection_start_,
875 selection_end_); 881 selection_end_);
876 } 882 }
883
884 #if !defined(OS_WIN)
885 void RenderWidgetHostViewViews::UpdateCursor(const WebCursor& cursor) {
886 // Optimize the common case, where the cursor hasn't changed.
887 // However, we can switch between different pixmaps, so only on the
888 // non-pixmap branch.
889 if (current_cursor_.GetCursorType() != GDK_CURSOR_IS_PIXMAP &&
890 current_cursor_.GetCursorType() == cursor.GetCursorType()) {
891 return;
892 }
893
894 current_cursor_ = cursor;
895 ShowCurrentCursor();
896 }
897
898 void RenderWidgetHostViewViews::ShowCurrentCursor() {
899 #if !defined(USE_AURA)
900 // The widget may not have a window. If that's the case, abort mission. This
901 // is the same issue as that explained above in Paint().
902 if (!GetInnerNativeView() || !GetInnerNativeView()->window)
903 return;
904 #endif
905
906 native_cursor_ = current_cursor_.GetNativeCursor();
907 }
908
909 gfx::NativeView RenderWidgetHostViewViews::GetInnerNativeView() const {
910 #if defined(USE_AURA)
911 return NULL;
912 #else
913 const views::View* view = NULL;
914 if (views::ViewsDelegate::views_delegate)
915 view = views::ViewsDelegate::views_delegate->GetDefaultParentView();
916 if (!view)
917 view = this;
918
919 // TODO(sad): Ideally this function should be equivalent to GetNativeView, and
920 // NativeWidgetGtk-specific function call should not be necessary.
921 const views::Widget* widget = view->GetWidget();
922 const views::NativeWidget* native = widget ? widget->native_widget() : NULL;
923 return native ? static_cast<const views::NativeWidgetGtk*>(native)->
924 window_contents() : NULL;
925 #endif
926 }
927 #endif // !OS_WIN
928
929 void RenderWidgetHostViewViews::CreatePluginContainer(
930 gfx::PluginWindowHandle id) {
931 // TODO(anicolao): plugin_container_manager_.CreatePluginContainer(id);
932 }
933
934 void RenderWidgetHostViewViews::DestroyPluginContainer(
935 gfx::PluginWindowHandle id) {
936 // TODO(anicolao): plugin_container_manager_.DestroyPluginContainer(id);
937 }
938
939 void RenderWidgetHostViewViews::AcceleratedCompositingActivated(
940 bool activated) {
941 // TODO(anicolao): figure out if we need something here
942 if (activated)
943 NOTIMPLEMENTED();
944 }
945
946 #if defined(OS_POSIX)
947 void RenderWidgetHostViewViews::GetDefaultScreenInfo(
948 WebKit::WebScreenInfo* results) {
949 NOTIMPLEMENTED();
950 }
951
952 void RenderWidgetHostViewViews::GetScreenInfo(WebKit::WebScreenInfo* results) {
953 #if !defined(USE_AURA)
954 views::Widget* widget = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL;
955 if (widget)
956 content::GetScreenInfoFromNativeWindow(widget->GetNativeView()->window,
957 results);
958 #endif
959 }
960
961 gfx::Rect RenderWidgetHostViewViews::GetRootWindowBounds() {
962 views::Widget* widget = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL;
963 return widget ? widget->GetWindowScreenBounds() : gfx::Rect();
964 }
965 #endif
966
967 #if !defined(TOUCH_UI)
968 gfx::PluginWindowHandle RenderWidgetHostViewViews::GetCompositingSurface() {
969 // TODO(oshima): The original implementation was broken as
970 // GtkNativeViewManager doesn't know about NativeWidgetGtk. Figure
971 // out if this makes sense without compositor. If it does, then find
972 // out the right way to handle.
973 NOTIMPLEMENTED();
974 return gfx::kNullPluginWindow;
975 }
976 #endif
977
978 #if defined(USE_AURA)
979 // static
980 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
981 RenderWidgetHost* widget) {
982 return new RenderWidgetHostViewViews(widget);
983 }
984 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698