Commit 6a2b36e9 authored by erg@chromium.org's avatar erg@chromium.org

GTK: Even more cleanup to access allocation through the accessor.

BUG=79722
TEST=none


Review URL: http://codereview.chromium.org/8921022

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114153 0039d316-1c4b-4281-b951-d872f2087c98
parent 2f18c44f
......@@ -1389,7 +1389,9 @@ gboolean LocationBarViewGtk::ContentSettingImageViewGtk::OnExpose(
if (!(animation_.IsShowing() || animation_.IsClosing()))
return FALSE;
const int height = sender->allocation.height;
GtkAllocation allocation;
gtk_widget_get_allocation(sender, &allocation);
const int height = allocation.height;
cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(sender->window));
gdk_cairo_rectangle(cr, &event->area);
......
......@@ -26,9 +26,12 @@ void PopulateSubmenus(GtkWidget* child, gpointer data) {
// Is the cursor over |menu| or one of its parent menus?
bool MotionIsOverMenu(GtkWidget* menu, GdkEventMotion* motion) {
GtkAllocation allocation;
gtk_widget_get_allocation(menu, &allocation);
if (motion->x >= 0 && motion->y >= 0 &&
motion->x < menu->allocation.width &&
motion->y < menu->allocation.height) {
motion->x < allocation.width &&
motion->y < allocation.height) {
return true;
}
......@@ -131,8 +134,10 @@ gboolean MenuBarHelper::OnMenuMotionNotify(GtkWidget* menu,
last_button = button;
if (x >= 0 && y >= 0 && x < button->allocation.width &&
y < button->allocation.height) {
GtkAllocation allocation;
gtk_widget_get_allocation(button, &allocation);
if (x >= 0 && y >= 0 && x < allocation.width && y < allocation.height) {
if (button != button_showing_menu_)
delegate_->PopupForButton(button);
return TRUE;
......
......@@ -344,7 +344,10 @@ void DraggedViewGtk::SetContainerShapeMask() {
cairo_set_operator(cairo_context, CAIRO_OPERATOR_SOURCE);
else
cairo_set_operator(cairo_context, CAIRO_OPERATOR_OVER);
PaintTab(i, container_, cairo_context, container_->allocation.width);
GtkAllocation allocation;
gtk_widget_get_allocation(container_, &allocation);
PaintTab(i, container_, cairo_context, allocation.width);
}
if (!attached_) {
......@@ -383,6 +386,9 @@ gboolean DraggedViewGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event) {
int tab_height = static_cast<int>(
kScalingFactor * renderers_[drag_data_->source_tab_index()]->height());
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
// Draw the render area.
BackingStore* backing_store = drag_data_->GetSourceTabContents()->
render_view_host()->GetBackingStore(false);
......@@ -390,8 +396,8 @@ gboolean DraggedViewGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event) {
// This leaves room for the border.
static_cast<BackingStoreGtk*>(backing_store)->PaintToRect(
gfx::Rect(kDragFrameBorderSize, tab_height,
widget->allocation.width - kTwiceDragFrameBorderSize,
widget->allocation.height - tab_height -
allocation.width - kTwiceDragFrameBorderSize,
allocation.height - tab_height -
kDragFrameBorderSize),
GDK_DRAWABLE(widget->window));
}
......@@ -408,8 +414,8 @@ gboolean DraggedViewGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event) {
double offset = kDragFrameBorderSize / 2.0 - 0.5;
double left_x = offset;
double top_y = tab_height - kDragFrameBorderSize + offset;
double right_x = widget->allocation.width - offset;
double bottom_y = widget->allocation.height - offset;
double right_x = allocation.width - offset;
double bottom_y = allocation.height - offset;
cairo_move_to(cr, left_x, top_y);
cairo_line_to(cr, left_x, bottom_y);
......@@ -426,11 +432,11 @@ gboolean DraggedViewGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event) {
for (int i = renderers_.size() - 1; i >= 0; i--) {
if (i == drag_data_->source_tab_index())
continue;
PaintTab(i, widget, cr, widget->allocation.width);
PaintTab(i, widget, cr, allocation.width);
}
// Painting the active tab last, so that it appears on top.
PaintTab(drag_data_->source_tab_index(), widget, cr,
widget->allocation.width);
allocation.width);
cairo_destroy(cr);
......
......@@ -157,12 +157,15 @@ gboolean TabGtk::OnButtonReleaseEvent(GtkWidget* widget,
}
}
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
// Middle mouse up means close the tab, but only if the mouse is over it
// (like a button).
if (event->button == 2 &&
event->x >= 0 && event->y >= 0 &&
event->x < widget->allocation.width &&
event->y < widget->allocation.height) {
event->x < allocation.width &&
event->y < allocation.height) {
// If the user is currently holding the left mouse button down but hasn't
// moved the mouse yet, a drag hasn't started yet. In that case, clean up
// some state before closing the tab to avoid a crash. Once the drag has
......
......@@ -99,9 +99,13 @@ gfx::Rect GetWidgetBoundsRelativeToParent(GtkWidget* parent,
GtkWidget* widget) {
gfx::Point parent_pos = gtk_util::GetWidgetScreenPosition(parent);
gfx::Point widget_pos = gtk_util::GetWidgetScreenPosition(widget);
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
return gfx::Rect(widget_pos.x() - parent_pos.x(),
widget_pos.y() - parent_pos.y(),
widget->allocation.width, widget->allocation.height);
allocation.width, allocation.height);
}
} // namespace
......
......@@ -78,15 +78,18 @@ static void gtk_preserve_window_realize(GtkWidget* widget) {
g_return_if_fail(GTK_IS_PRESERVE_WINDOW(widget));
if (widget->window) {
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
gdk_window_reparent(widget->window,
gtk_widget_get_parent_window(widget),
widget->allocation.x,
widget->allocation.y);
allocation.x,
allocation.y);
GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget);
if (!priv->delegate_resize) {
gdk_window_resize(widget->window,
widget->allocation.width,
widget->allocation.height);
gdk_window_resize(gtk_widget_get_window(widget),
allocation.width,
allocation.height);
}
widget->style = gtk_style_attach(widget->style, widget->window);
gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment