OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/tab_contents/tab_contents_view_gtk.h" | 5 #include "chrome/browser/tab_contents/tab_contents_view_gtk.h" |
6 | 6 |
7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 | 573 |
574 void TabContentsViewGtk::OnTabCrashed() { | 574 void TabContentsViewGtk::OnTabCrashed() { |
575 if (!sad_tab_.get()) { | 575 if (!sad_tab_.get()) { |
576 sad_tab_.reset(new SadTabGtk); | 576 sad_tab_.reset(new SadTabGtk); |
577 InsertIntoContentArea(sad_tab_->widget()); | 577 InsertIntoContentArea(sad_tab_->widget()); |
578 gtk_widget_show(sad_tab_->widget()); | 578 gtk_widget_show(sad_tab_->widget()); |
579 } | 579 } |
580 } | 580 } |
581 | 581 |
582 void TabContentsViewGtk::SizeContents(const gfx::Size& size) { | 582 void TabContentsViewGtk::SizeContents(const gfx::Size& size) { |
583 // This function is a hack and should go away. In any case we don't manually | 583 // We don't normally need to manually set the size of of widgets in GTK+, |
584 // control the size of the contents on linux, so do nothing. | 584 // but this is used when creating background tabs. When a tab is created in |
| 585 // the background, we need to set the size so WebKit can properly compute |
| 586 // the scrolling offset if a #ref is provided. |
| 587 if (tab_contents()->render_widget_host_view()) { |
| 588 GtkWidget* widget = |
| 589 tab_contents()->render_widget_host_view()->GetNativeView(); |
| 590 widget->allocation.width = size.width(); |
| 591 widget->allocation.height = size.height(); |
| 592 } |
585 } | 593 } |
586 | 594 |
587 void TabContentsViewGtk::Focus() { | 595 void TabContentsViewGtk::Focus() { |
588 if (tab_contents()->showing_interstitial_page()) { | 596 if (tab_contents()->showing_interstitial_page()) { |
589 tab_contents()->interstitial_page()->Focus(); | 597 tab_contents()->interstitial_page()->Focus(); |
590 } else { | 598 } else { |
591 GtkWidget* widget = GetContentNativeView(); | 599 GtkWidget* widget = GetContentNativeView(); |
592 if (widget) | 600 if (widget) |
593 gtk_widget_grab_focus(widget); | 601 gtk_widget_grab_focus(widget); |
594 } | 602 } |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 884 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
877 widget, "x", &value); | 885 widget, "x", &value); |
878 | 886 |
879 int child_y = std::max(half_view_height - (requisition.height / 2), 0); | 887 int child_y = std::max(half_view_height - (requisition.height / 2), 0); |
880 g_value_set_int(&value, child_y); | 888 g_value_set_int(&value, child_y); |
881 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 889 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
882 widget, "y", &value); | 890 widget, "y", &value); |
883 g_value_unset(&value); | 891 g_value_unset(&value); |
884 } | 892 } |
885 } | 893 } |
OLD | NEW |