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

Side by Side Diff: chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc

Issue 8800029: GTK: Add TRACE_EVENTs around gtk ui events. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase again for ANOTHER conflict Created 9 years 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
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/ui/gtk/tabs/tab_strip_gtk.h" 5 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/debug/trace_event.h"
11 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
12 #include "base/string_util.h" 13 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/autocomplete/autocomplete.h" 15 #include "chrome/browser/autocomplete/autocomplete.h"
15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 16 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
16 #include "chrome/browser/autocomplete/autocomplete_match.h" 17 #include "chrome/browser/autocomplete/autocomplete_match.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/tabs/tab_strip_model_delegate.h" 19 #include "chrome/browser/tabs/tab_strip_model_delegate.h"
19 #include "chrome/browser/themes/theme_service.h" 20 #include "chrome/browser/themes/theme_service.h"
20 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 958
958 return NULL; 959 return NULL;
959 } 960 }
960 961
961 //////////////////////////////////////////////////////////////////////////////// 962 ////////////////////////////////////////////////////////////////////////////////
962 // TabStripGtk, TabStripModelObserver implementation: 963 // TabStripGtk, TabStripModelObserver implementation:
963 964
964 void TabStripGtk::TabInsertedAt(TabContentsWrapper* contents, 965 void TabStripGtk::TabInsertedAt(TabContentsWrapper* contents,
965 int index, 966 int index,
966 bool foreground) { 967 bool foreground) {
968 TRACE_EVENT0("ui::gtk", "TabStripGtk::TabInsertedAt");
969
967 DCHECK(contents); 970 DCHECK(contents);
968 DCHECK(index == TabStripModel::kNoTab || model_->ContainsIndex(index)); 971 DCHECK(index == TabStripModel::kNoTab || model_->ContainsIndex(index));
969 972
970 StopAnimation(); 973 StopAnimation();
971 974
972 bool contains_tab = false; 975 bool contains_tab = false;
973 TabGtk* tab = NULL; 976 TabGtk* tab = NULL;
974 // First see if this Tab is one that was dragged out of this TabStrip and is 977 // First see if this Tab is one that was dragged out of this TabStrip and is
975 // now being dragged back in. In this case, the DraggedTabController actually 978 // now being dragged back in. In this case, the DraggedTabController actually
976 // has the Tab already constructed and we can just insert it into our list 979 // has the Tab already constructed and we can just insert it into our list
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 // Have to do this _after_ calling StartRemoveTabAnimation, so that any 1033 // Have to do this _after_ calling StartRemoveTabAnimation, so that any
1031 // previous remove is completed fully and index is valid in sync with the 1034 // previous remove is completed fully and index is valid in sync with the
1032 // model index. 1035 // model index.
1033 GetTabAt(index)->set_closing(true); 1036 GetTabAt(index)->set_closing(true);
1034 } 1037 }
1035 1038
1036 void TabStripGtk::ActiveTabChanged(TabContentsWrapper* old_contents, 1039 void TabStripGtk::ActiveTabChanged(TabContentsWrapper* old_contents,
1037 TabContentsWrapper* new_contents, 1040 TabContentsWrapper* new_contents,
1038 int index, 1041 int index,
1039 bool user_gesture) { 1042 bool user_gesture) {
1043 TRACE_EVENT0("ui::gtk", "TabStripGtk::ActiveTabChanged");
1040 ReStack(); 1044 ReStack();
1041 } 1045 }
1042 1046
1043 void TabStripGtk::TabSelectionChanged(TabStripModel* tab_strip_model, 1047 void TabStripGtk::TabSelectionChanged(TabStripModel* tab_strip_model,
1044 const TabStripSelectionModel& old_model) { 1048 const TabStripSelectionModel& old_model) {
1045 // We have "tiny tabs" if the tabs are so tiny that the unselected ones are 1049 // We have "tiny tabs" if the tabs are so tiny that the unselected ones are
1046 // a different size to the selected ones. 1050 // a different size to the selected ones.
1047 bool tiny_tabs = current_unselected_width_ != current_selected_width_; 1051 bool tiny_tabs = current_unselected_width_ != current_selected_width_;
1048 if (!IsAnimating() && (!needs_resize_layout_ || tiny_tabs)) 1052 if (!IsAnimating() && (!needs_resize_layout_ || tiny_tabs))
1049 Layout(); 1053 Layout();
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 GdkScreen* screen = gdk_screen_get_default(); 1604 GdkScreen* screen = gdk_screen_get_default();
1601 GdkDisplay* display = gdk_screen_get_display(screen); 1605 GdkDisplay* display = gdk_screen_get_display(screen);
1602 gint x, y; 1606 gint x, y;
1603 gdk_display_get_pointer(display, NULL, &x, &y, NULL); 1607 gdk_display_get_pointer(display, NULL, &x, &y, NULL);
1604 gfx::Point cursor_point(x, y); 1608 gfx::Point cursor_point(x, y);
1605 1609
1606 return bds.Contains(cursor_point); 1610 return bds.Contains(cursor_point);
1607 } 1611 }
1608 1612
1609 void TabStripGtk::ReStack() { 1613 void TabStripGtk::ReStack() {
1614 TRACE_EVENT0("ui::gtk", "TabStripGtk::ReStack");
1615
1610 if (!gtk_widget_get_realized(tabstrip_.get())) { 1616 if (!gtk_widget_get_realized(tabstrip_.get())) {
1611 // If the window isn't realized yet, we can't stack them yet. It will be 1617 // If the window isn't realized yet, we can't stack them yet. It will be
1612 // done by the OnMap signal handler. 1618 // done by the OnMap signal handler.
1613 return; 1619 return;
1614 } 1620 }
1615 int tab_count = GetTabCount(); 1621 int tab_count = GetTabCount();
1616 TabGtk* active_tab = NULL; 1622 TabGtk* active_tab = NULL;
1617 for (int i = tab_count - 1; i >= 0; --i) { 1623 for (int i = tab_count - 1; i >= 0; --i) {
1618 TabGtk* tab = GetTabAt(i); 1624 TabGtk* tab = GetTabAt(i);
1619 if (tab->IsActive()) 1625 if (tab->IsActive())
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 CreateContainer(); 1802 CreateContainer();
1797 drop_arrow = GetDropArrowImage(point_down); 1803 drop_arrow = GetDropArrowImage(point_down);
1798 } 1804 }
1799 1805
1800 TabStripGtk::DropInfo::~DropInfo() { 1806 TabStripGtk::DropInfo::~DropInfo() {
1801 DestroyContainer(); 1807 DestroyContainer();
1802 } 1808 }
1803 1809
1804 gboolean TabStripGtk::DropInfo::OnExposeEvent(GtkWidget* widget, 1810 gboolean TabStripGtk::DropInfo::OnExposeEvent(GtkWidget* widget,
1805 GdkEventExpose* event) { 1811 GdkEventExpose* event) {
1812 TRACE_EVENT0("ui::gtk", "TabStripGtk::DropInfo::OnExposeEvent");
1813
1806 if (ui::IsScreenComposited()) { 1814 if (ui::IsScreenComposited()) {
1807 SetContainerTransparency(); 1815 SetContainerTransparency();
1808 } else { 1816 } else {
1809 SetContainerShapeMask(); 1817 SetContainerShapeMask();
1810 } 1818 }
1811 1819
1812 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); 1820 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window));
1813 gdk_cairo_rectangle(cr, &event->area); 1821 gdk_cairo_rectangle(cr, &event->area);
1814 cairo_clip(cr); 1822 cairo_clip(cr);
1815 1823
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 1991
1984 if (layout) 1992 if (layout)
1985 Layout(); 1993 Layout();
1986 } 1994 }
1987 1995
1988 void TabStripGtk::OnMap(GtkWidget* widget) { 1996 void TabStripGtk::OnMap(GtkWidget* widget) {
1989 ReStack(); 1997 ReStack();
1990 } 1998 }
1991 1999
1992 gboolean TabStripGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event) { 2000 gboolean TabStripGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event) {
2001 TRACE_EVENT0("ui::gtk", "TabStripGtk::OnExpose");
2002
1993 if (gdk_region_empty(event->region)) 2003 if (gdk_region_empty(event->region))
1994 return TRUE; 2004 return TRUE;
1995 2005
1996 // If we're only repainting favicons, optimize the paint path and only draw 2006 // If we're only repainting favicons, optimize the paint path and only draw
1997 // the favicons. 2007 // the favicons.
1998 GdkRectangle* rects; 2008 GdkRectangle* rects;
1999 gint num_rects; 2009 gint num_rects;
2000 gdk_region_get_rectangles(event->region, &rects, &num_rects); 2010 gdk_region_get_rectangles(event->region, &rects, &num_rects);
2001 qsort(rects, num_rects, sizeof(GdkRectangle), CompareGdkRectangles); 2011 qsort(rects, num_rects, sizeof(GdkRectangle), CompareGdkRectangles);
2002 std::vector<int> tabs_to_repaint; 2012 std::vector<int> tabs_to_repaint;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2062 // Paint the selected tab last, so it overlaps all the others. 2072 // Paint the selected tab last, so it overlaps all the others.
2063 if (selected_tab) { 2073 if (selected_tab) {
2064 gtk_container_propagate_expose(GTK_CONTAINER(tabstrip_.get()), 2074 gtk_container_propagate_expose(GTK_CONTAINER(tabstrip_.get()),
2065 selected_tab->widget(), event); 2075 selected_tab->widget(), event);
2066 } 2076 }
2067 2077
2068 return TRUE; 2078 return TRUE;
2069 } 2079 }
2070 2080
2071 void TabStripGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) { 2081 void TabStripGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) {
2082 TRACE_EVENT0("ui::gtk", "TabStripGtk::OnSizeAllocate");
2083
2072 gfx::Rect bounds = gfx::Rect(allocation->x, allocation->y, 2084 gfx::Rect bounds = gfx::Rect(allocation->x, allocation->y,
2073 allocation->width, allocation->height); 2085 allocation->width, allocation->height);
2074 2086
2075 // Nothing to do if the bounds are the same. If we don't catch this, we'll 2087 // Nothing to do if the bounds are the same. If we don't catch this, we'll
2076 // get an infinite loop of size-allocate signals. 2088 // get an infinite loop of size-allocate signals.
2077 if (bounds_ == bounds) 2089 if (bounds_ == bounds)
2078 return; 2090 return;
2079 2091
2080 SetBounds(bounds); 2092 SetBounds(bounds);
2081 2093
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2228 } 2240 }
2229 2241
2230 void TabStripGtk::SetNewTabButtonBackground() { 2242 void TabStripGtk::SetNewTabButtonBackground() {
2231 SkColor color = theme_service_->GetColor( 2243 SkColor color = theme_service_->GetColor(
2232 ThemeService::COLOR_BUTTON_BACKGROUND); 2244 ThemeService::COLOR_BUTTON_BACKGROUND);
2233 SkBitmap* background = theme_service_->GetBitmapNamed( 2245 SkBitmap* background = theme_service_->GetBitmapNamed(
2234 IDR_THEME_WINDOW_CONTROL_BACKGROUND); 2246 IDR_THEME_WINDOW_CONTROL_BACKGROUND);
2235 SkBitmap* mask = theme_service_->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK); 2247 SkBitmap* mask = theme_service_->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK);
2236 newtab_button_->SetBackground(color, background, mask); 2248 newtab_button_->SetBackground(color, background, mask);
2237 } 2249 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc ('k') | content/browser/renderer_host/render_widget_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698