summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-14 17:46:15 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-14 17:46:15 +0000
commit655750cba246a2e3049867c3b200ca478f883230 (patch)
tree581ae4bdfb37aa3673619c021ca5796348dcb70e
parent87373acb051a898a2b6cbb56be05fc3f4d3a75bc (diff)
downloadchromium_src-655750cba246a2e3049867c3b200ca478f883230.zip
chromium_src-655750cba246a2e3049867c3b200ca478f883230.tar.gz
chromium_src-655750cba246a2e3049867c3b200ca478f883230.tar.bz2
Remove code doing a no-op due to float -> int rounding.
Make implicit float -> int/long conversions explicit. (Implicit float -> int conversions can be found by compiling with -Wconversion in gcc [versions 4.1.1 and 4.2.4, and surely many others].) Landing the patch for Jacob Mandelson, original review: http://codereview.chromium.org/201091 BUG=none TEST=app_unittests & base_unittests Review URL: http://codereview.chromium.org/200122 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26119 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/process_util_linux.cc11
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc8
-rw-r--r--chrome/browser/gtk/back_forward_button_gtk.cc2
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.cc5
-rw-r--r--chrome/browser/gtk/bookmark_manager_gtk.cc12
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc20
-rw-r--r--chrome/browser/gtk/download_item_gtk.cc6
-rw-r--r--chrome/browser/gtk/slide_animator_gtk.cc4
-rw-r--r--chrome/browser/gtk/tab_contents_drag_source.cc4
-rw-r--r--chrome/browser/gtk/tabs/dragged_tab_gtk.cc11
-rw-r--r--chrome/browser/gtk/tabs/tab_gtk.cc12
-rw-r--r--chrome/renderer/print_web_view_helper_linux.cc6
12 files changed, 59 insertions, 42 deletions
diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc
index 53e7d02..8342414 100644
--- a/base/process_util_linux.cc
+++ b/base/process_util_linux.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -259,7 +259,6 @@ bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const {
int private_kb = 0;
int pss_kb = 0;
bool have_pss = false;
- const int kPssAdjust = 0.5;
if (!file_util::ReadFileToString(stat_file, &smaps))
return false;
@@ -278,12 +277,12 @@ bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const {
return false;
}
if (StartsWithASCII(last_key_name, "Shared_", 1)) {
- shared_kb += StringToInt(tokenizer.token());
+ shared_kb += StringToInt(tokenizer.token());
} else if (StartsWithASCII(last_key_name, "Private_", 1)) {
- private_kb += StringToInt(tokenizer.token());
+ private_kb += StringToInt(tokenizer.token());
} else if (StartsWithASCII(last_key_name, "Pss", 1)) {
- have_pss = true;
- pss_kb += StringToInt(tokenizer.token()) + kPssAdjust;
+ have_pss = true;
+ pss_kb += StringToInt(tokenizer.token());
}
state = KEY_NAME;
break;
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
index d459775..fac4fcd 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
@@ -341,7 +341,7 @@ void AutocompletePopupViewGtk::AcceptLine(size_t line,
gboolean AutocompletePopupViewGtk::HandleMotion(GtkWidget* widget,
GdkEventMotion* event) {
// TODO(deanm): Windows has a bunch of complicated logic here.
- size_t line = LineFromY(event->y);
+ size_t line = LineFromY(static_cast<int>(event->y));
// There is both a hovered and selected line, hovered just means your mouse
// is over it, but selected is what's showing in the location edit.
model_->SetHoveredLine(line);
@@ -354,7 +354,7 @@ gboolean AutocompletePopupViewGtk::HandleMotion(GtkWidget* widget,
gboolean AutocompletePopupViewGtk::HandleButtonPress(GtkWidget* widget,
GdkEventButton* event) {
// Very similar to HandleMotion.
- size_t line = LineFromY(event->y);
+ size_t line = LineFromY(static_cast<int>(event->y));
model_->SetHoveredLine(line);
if (event->button == 1)
model_->SetSelectedLine(line, false);
@@ -363,7 +363,7 @@ gboolean AutocompletePopupViewGtk::HandleButtonPress(GtkWidget* widget,
gboolean AutocompletePopupViewGtk::HandleButtonRelease(GtkWidget* widget,
GdkEventButton* event) {
- size_t line = LineFromY(event->y);
+ size_t line = LineFromY(static_cast<int>(event->y));
switch (event->button) {
case 1: // Left click.
AcceptLine(line, CURRENT_TAB);
@@ -430,7 +430,7 @@ gboolean AutocompletePopupViewGtk::HandleExpose(GtkWidget* widget,
bool has_description = !match.description.empty();
int text_width = window_rect.width() - (kIconAreaWidth + kRightPadding);
int allocated_content_width = has_description ?
- text_width * kContentWidthPercentage : text_width;
+ static_cast<int>(text_width * kContentWidthPercentage) : text_width;
pango_layout_set_width(layout_, allocated_content_width * PANGO_SCALE);
// Note: We force to URL to LTR for all text directions.
diff --git a/chrome/browser/gtk/back_forward_button_gtk.cc b/chrome/browser/gtk/back_forward_button_gtk.cc
index 7f4bd69..e5f6125 100644
--- a/chrome/browser/gtk/back_forward_button_gtk.cc
+++ b/chrome/browser/gtk/back_forward_button_gtk.cc
@@ -110,7 +110,7 @@ gboolean BackForwardButtonGtk::OnButtonPress(GtkWidget* widget,
if (event->button != 1)
return FALSE;
- button->y_position_of_last_press_ = event->y;
+ button->y_position_of_last_press_ = static_cast<int>(event->y);
MessageLoop::current()->PostDelayedTask(FROM_HERE,
button->show_menu_factory_.NewRunnableMethod(
&BackForwardButtonGtk::ShowBackForwardMenu),
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc
index 32b26e0..275b8e6 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.cc
+++ b/chrome/browser/gtk/bookmark_bar_gtk.cc
@@ -482,8 +482,9 @@ bool BookmarkBarGtk::IsAlwaysShown() {
void BookmarkBarGtk::AnimationProgressed(const Animation* animation) {
DCHECK_EQ(animation, slide_animation_.get());
- gint height = animation->GetCurrentValue() *
- (kBookmarkBarHeight - kBookmarkBarMinimumHeight) +
+ gint height =
+ static_cast<gint>(animation->GetCurrentValue() *
+ (kBookmarkBarHeight - kBookmarkBarMinimumHeight)) +
kBookmarkBarMinimumHeight;
gtk_widget_set_size_request(event_box_.get(), -1, height);
}
diff --git a/chrome/browser/gtk/bookmark_manager_gtk.cc b/chrome/browser/gtk/bookmark_manager_gtk.cc
index 7c89476..390fda2 100644
--- a/chrome/browser/gtk/bookmark_manager_gtk.cc
+++ b/chrome/browser/gtk/bookmark_manager_gtk.cc
@@ -1185,7 +1185,9 @@ gboolean BookmarkManagerGtk::OnRightTreeViewButtonPress(
GtkTreePath* path;
gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tree_view),
- event->x, event->y, &path, NULL, NULL, NULL);
+ static_cast<gint>(event->x),
+ static_cast<gint>(event->y),
+ &path, NULL, NULL, NULL);
if (path == NULL)
return TRUE;
@@ -1209,10 +1211,10 @@ gboolean BookmarkManagerGtk::OnRightTreeViewMotion(
return FALSE;
if (gtk_drag_check_threshold(tree_view,
- bm->mousedown_event_.x,
- bm->mousedown_event_.y,
- event->x,
- event->y)) {
+ static_cast<gint>(bm->mousedown_event_.x),
+ static_cast<gint>(bm->mousedown_event_.y),
+ static_cast<gint>(event->x),
+ static_cast<gint>(event->y))) {
bm->delaying_mousedown_ = false;
GtkTargetList* targets = GtkDndUtil::GetTargetListFromCodeMask(
GtkDndUtil::CHROME_BOOKMARK_ITEM |
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index e0aa335..72e0123 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -671,7 +671,7 @@ gboolean BrowserWindowGtk::OnCustomFrameExpose(GtkWidget* widget,
IDR_WINDOW_TOP_CENTER,
IDR_WINDOW_TOP_RIGHT_CORNER,
IDR_WINDOW_LEFT_SIDE,
- NULL,
+ 0,
IDR_WINDOW_RIGHT_SIDE,
IDR_WINDOW_BOTTOM_LEFT_CORNER,
IDR_WINDOW_BOTTOM_CENTER,
@@ -1937,7 +1937,8 @@ gboolean BrowserWindowGtk::OnButtonPressEvent(GtkWidget* widget,
gdk_window_get_origin(GTK_WIDGET(browser->window_)->window, &win_x, &win_y);
GdkWindowEdge edge;
- gfx::Point point(event->x_root - win_x, event->y_root - win_y);
+ gfx::Point point(static_cast<int>(event->x_root - win_x),
+ static_cast<int>(event->y_root - win_y));
bool has_hit_edge = browser->GetWindowEdge(point.x(), point.y(), &edge);
// Ignore clicks that are in/below the browser toolbar.
@@ -1956,7 +1957,8 @@ gboolean BrowserWindowGtk::OnButtonPressEvent(GtkWidget* widget,
guint32 last_click_time = browser->last_click_time_;
gfx::Point last_click_position = browser->last_click_position_;
browser->last_click_time_ = event->time;
- browser->last_click_position_ = gfx::Point(event->x, event->y);
+ browser->last_click_position_ = gfx::Point(static_cast<int>(event->x),
+ static_cast<int>(event->y));
if (has_hit_titlebar) {
// We want to start a move when the user single clicks, but not start a
@@ -1976,19 +1978,23 @@ gboolean BrowserWindowGtk::OnButtonPressEvent(GtkWidget* widget,
NULL);
guint32 click_time = event->time - last_click_time;
- int click_move_x = event->x - last_click_position.x();
- int click_move_y = event->y - last_click_position.y();
+ int click_move_x = static_cast<int>(event->x - last_click_position.x());
+ int click_move_y = static_cast<int>(event->y - last_click_position.y());
if (click_time > static_cast<guint32>(double_click_time) ||
click_move_x > double_click_distance ||
click_move_y > double_click_distance) {
gtk_window_begin_move_drag(browser->window_, event->button,
- event->x_root, event->y_root, event->time);
+ static_cast<gint>(event->x_root),
+ static_cast<gint>(event->y_root),
+ event->time);
return TRUE;
}
} else if (has_hit_edge) {
gtk_window_begin_resize_drag(browser->window_, edge, event->button,
- event->x_root, event->y_root, event->time);
+ static_cast<gint>(event->x_root),
+ static_cast<gint>(event->y_root),
+ event->time);
return TRUE;
}
} else if (GDK_2BUTTON_PRESS == event->type) {
diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc
index 74e15f8..b2a13eb 100644
--- a/chrome/browser/gtk/download_item_gtk.cc
+++ b/chrome/browser/gtk/download_item_gtk.cc
@@ -424,9 +424,9 @@ void DownloadItemGtk::AnimationProgressed(const Animation* animation) {
gtk_widget_queue_draw(progress_area_.get());
} else {
if (IsDangerous()) {
- int progress = (dangerous_hbox_full_width_ -
- dangerous_hbox_start_width_) *
- new_item_animation_->GetCurrentValue();
+ int progress = static_cast<int>((dangerous_hbox_full_width_ -
+ dangerous_hbox_start_width_) *
+ new_item_animation_->GetCurrentValue());
int showing_width = dangerous_hbox_start_width_ + progress;
gtk_widget_set_size_request(dangerous_hbox_, showing_width, -1);
} else {
diff --git a/chrome/browser/gtk/slide_animator_gtk.cc b/chrome/browser/gtk/slide_animator_gtk.cc
index 0508f6f..b6837fc 100644
--- a/chrome/browser/gtk/slide_animator_gtk.cc
+++ b/chrome/browser/gtk/slide_animator_gtk.cc
@@ -111,8 +111,8 @@ bool SlideAnimatorGtk::IsAnimating() {
}
void SlideAnimatorGtk::AnimationProgressed(const Animation* animation) {
- int showing_height = child_->allocation.height *
- animation_->GetCurrentValue();
+ int showing_height = static_cast<int>(child_->allocation.height *
+ animation_->GetCurrentValue());
if (direction_ == DOWN) {
gtk_fixed_move(GTK_FIXED(widget_.get()), child_, 0,
showing_height - child_->allocation.height);
diff --git a/chrome/browser/gtk/tab_contents_drag_source.cc b/chrome/browser/gtk/tab_contents_drag_source.cc
index 146cbd7..1b6b94c 100644
--- a/chrome/browser/gtk/tab_contents_drag_source.cc
+++ b/chrome/browser/gtk/tab_contents_drag_source.cc
@@ -115,7 +115,9 @@ void TabContentsDragSource::DidProcessEvent(GdkEvent* event) {
if (tab_contents()->render_view_host()) {
tab_contents()->render_view_host()->DragSourceMovedTo(
- client.x(), client.y(), event_motion->x_root, event_motion->y_root);
+ client.x(), client.y(),
+ static_cast<int>(event_motion->x_root),
+ static_cast<int>(event_motion->y_root));
}
}
diff --git a/chrome/browser/gtk/tabs/dragged_tab_gtk.cc b/chrome/browser/gtk/tabs/dragged_tab_gtk.cc
index 2ddb607..5809cd1 100644
--- a/chrome/browser/gtk/tabs/dragged_tab_gtk.cc
+++ b/chrome/browser/gtk/tabs/dragged_tab_gtk.cc
@@ -263,8 +263,9 @@ void DraggedTabGtk::SetContainerShapeMask(GdkPixbuf* pixbuf) {
// border).
cairo_identity_matrix(cairo_context);
cairo_set_source_rgba(cairo_context, 1.0f, 1.0f, 1.0f, 1.0f);
- int tab_height = kScalingFactor * gdk_pixbuf_get_height(pixbuf) -
- kDragFrameBorderSize;
+ int tab_height = static_cast<int>(kScalingFactor *
+ gdk_pixbuf_get_height(pixbuf) -
+ kDragFrameBorderSize);
cairo_rectangle(cairo_context,
0, tab_height,
size.width(), size.height() - tab_height);
@@ -295,8 +296,10 @@ gboolean DraggedTabGtk::OnExposeEvent(GtkWidget* widget,
}
// Only used when not attached.
- int tab_height = kScalingFactor * gdk_pixbuf_get_height(pixbuf);
- int tab_width = kScalingFactor * gdk_pixbuf_get_width(pixbuf);
+ int tab_height = static_cast<int>(kScalingFactor *
+ gdk_pixbuf_get_height(pixbuf));
+ int tab_width = static_cast<int>(kScalingFactor *
+ gdk_pixbuf_get_width(pixbuf));
// Draw the render area.
if (dragged_tab->backing_store_ && !dragged_tab->attached_) {
diff --git a/chrome/browser/gtk/tabs/tab_gtk.cc b/chrome/browser/gtk/tabs/tab_gtk.cc
index 667cd8a..ca9b93d 100644
--- a/chrome/browser/gtk/tabs/tab_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_gtk.cc
@@ -227,10 +227,14 @@ void TabGtk::DidProcessEvent(GdkEvent* event) {
GdkEventMotion* motion = reinterpret_cast<GdkEventMotion*>(event);
GdkEventButton* button = reinterpret_cast<GdkEventButton*>(last_mouse_down_);
bool dragging = gtk_drag_check_threshold(widget(),
- button->x, button->y,
- motion->x, motion->y);
- if (dragging)
- StartDragging(gfx::Point(button->x, button->y));
+ static_cast<gint>(button->x),
+ static_cast<gint>(button->y),
+ static_cast<gint>(motion->x),
+ static_cast<gint>(motion->y));
+ if (dragging) {
+ StartDragging(gfx::Point(static_cast<int>(button->x),
+ static_cast<int>(button->y)));
+ }
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/renderer/print_web_view_helper_linux.cc b/chrome/renderer/print_web_view_helper_linux.cc
index b16b05e..211eb6f 100644
--- a/chrome/renderer/print_web_view_helper_linux.cc
+++ b/chrome/renderer/print_web_view_helper_linux.cc
@@ -27,15 +27,15 @@ void PrintWebViewHelper::Print(WebFrame* frame, bool script_initiated) {
// Top = 0.25 in.
// Bottom = 0.56 in.
const int kDPI = 72;
- const int kWidth = (8.5-0.25-0.25) * kDPI;
- const int kHeight = (11-0.25-0.56) * kDPI;
+ const int kWidth = static_cast<int>((8.5-0.25-0.25) * kDPI);
+ const int kHeight = static_cast<int>((11-0.25-0.56) * kDPI);
ViewMsg_Print_Params default_settings;
default_settings.printable_size = gfx::Size(kWidth, kHeight);
default_settings.dpi = kDPI;
default_settings.min_shrink = 1.25;
default_settings.max_shrink = 2.0;
default_settings.desired_dpi = kDPI;
- default_settings.document_cookie = NULL;
+ default_settings.document_cookie = 0;
default_settings.selection_only = false;
ViewMsg_PrintPages_Params print_settings;