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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc

Issue 200122: Remove code doing a no-op due to float -> int rounding. (Closed)
Patch Set: Created 11 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
« no previous file with comments | « base/process_util_linux.cc ('k') | chrome/browser/gtk/back_forward_button_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/autocomplete/autocomplete_popup_view_gtk.h" 5 #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 const GURL url(match.destination_url); 334 const GURL url(match.destination_url);
335 std::wstring keyword; 335 std::wstring keyword;
336 const bool is_keyword_hint = model_->GetKeywordForMatch(match, &keyword); 336 const bool is_keyword_hint = model_->GetKeywordForMatch(match, &keyword);
337 edit_view_->OpenURL(url, disposition, match.transition, GURL(), line, 337 edit_view_->OpenURL(url, disposition, match.transition, GURL(), line,
338 is_keyword_hint ? std::wstring() : keyword); 338 is_keyword_hint ? std::wstring() : keyword);
339 } 339 }
340 340
341 gboolean AutocompletePopupViewGtk::HandleMotion(GtkWidget* widget, 341 gboolean AutocompletePopupViewGtk::HandleMotion(GtkWidget* widget,
342 GdkEventMotion* event) { 342 GdkEventMotion* event) {
343 // TODO(deanm): Windows has a bunch of complicated logic here. 343 // TODO(deanm): Windows has a bunch of complicated logic here.
344 size_t line = LineFromY(event->y); 344 size_t line = LineFromY(static_cast<int>(event->y));
345 // There is both a hovered and selected line, hovered just means your mouse 345 // There is both a hovered and selected line, hovered just means your mouse
346 // is over it, but selected is what's showing in the location edit. 346 // is over it, but selected is what's showing in the location edit.
347 model_->SetHoveredLine(line); 347 model_->SetHoveredLine(line);
348 // Select the line if the user has the left mouse button down. 348 // Select the line if the user has the left mouse button down.
349 if (event->state & GDK_BUTTON1_MASK) 349 if (event->state & GDK_BUTTON1_MASK)
350 model_->SetSelectedLine(line, false); 350 model_->SetSelectedLine(line, false);
351 return TRUE; 351 return TRUE;
352 } 352 }
353 353
354 gboolean AutocompletePopupViewGtk::HandleButtonPress(GtkWidget* widget, 354 gboolean AutocompletePopupViewGtk::HandleButtonPress(GtkWidget* widget,
355 GdkEventButton* event) { 355 GdkEventButton* event) {
356 // Very similar to HandleMotion. 356 // Very similar to HandleMotion.
357 size_t line = LineFromY(event->y); 357 size_t line = LineFromY(static_cast<int>(event->y));
358 model_->SetHoveredLine(line); 358 model_->SetHoveredLine(line);
359 if (event->button == 1) 359 if (event->button == 1)
360 model_->SetSelectedLine(line, false); 360 model_->SetSelectedLine(line, false);
361 return TRUE; 361 return TRUE;
362 } 362 }
363 363
364 gboolean AutocompletePopupViewGtk::HandleButtonRelease(GtkWidget* widget, 364 gboolean AutocompletePopupViewGtk::HandleButtonRelease(GtkWidget* widget,
365 GdkEventButton* event) { 365 GdkEventButton* event) {
366 size_t line = LineFromY(event->y); 366 size_t line = LineFromY(static_cast<int>(event->y));
367 switch (event->button) { 367 switch (event->button) {
368 case 1: // Left click. 368 case 1: // Left click.
369 AcceptLine(line, CURRENT_TAB); 369 AcceptLine(line, CURRENT_TAB);
370 break; 370 break;
371 case 2: // Middle click. 371 case 2: // Middle click.
372 AcceptLine(line, NEW_BACKGROUND_TAB); 372 AcceptLine(line, NEW_BACKGROUND_TAB);
373 break; 373 break;
374 default: 374 default:
375 // Don't open the result. 375 // Don't open the result.
376 break; 376 break;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 // Draw the icon for this result. 423 // Draw the icon for this result.
424 DrawFullPixbuf(drawable, gc, IconForMatch(match, is_selected), 424 DrawFullPixbuf(drawable, gc, IconForMatch(match, is_selected),
425 icon_start_x, line_rect.y() + kIconTopPadding); 425 icon_start_x, line_rect.y() + kIconTopPadding);
426 426
427 // Draw the results text vertically centered in the results space. 427 // Draw the results text vertically centered in the results space.
428 // First draw the contents / url, but don't let it take up the whole width 428 // First draw the contents / url, but don't let it take up the whole width
429 // if there is also a description to be shown. 429 // if there is also a description to be shown.
430 bool has_description = !match.description.empty(); 430 bool has_description = !match.description.empty();
431 int text_width = window_rect.width() - (kIconAreaWidth + kRightPadding); 431 int text_width = window_rect.width() - (kIconAreaWidth + kRightPadding);
432 int allocated_content_width = has_description ? 432 int allocated_content_width = has_description ?
433 text_width * kContentWidthPercentage : text_width; 433 static_cast<int>(text_width * kContentWidthPercentage) : text_width;
434 pango_layout_set_width(layout_, allocated_content_width * PANGO_SCALE); 434 pango_layout_set_width(layout_, allocated_content_width * PANGO_SCALE);
435 435
436 // Note: We force to URL to LTR for all text directions. 436 // Note: We force to URL to LTR for all text directions.
437 SetupLayoutForMatch(layout_, match.contents, match.contents_class, 437 SetupLayoutForMatch(layout_, match.contents, match.contents_class,
438 &kContentTextColor, std::string()); 438 &kContentTextColor, std::string());
439 439
440 int actual_content_width, actual_content_height; 440 int actual_content_width, actual_content_height;
441 pango_layout_get_size(layout_, 441 pango_layout_get_size(layout_,
442 &actual_content_width, &actual_content_height); 442 &actual_content_width, &actual_content_height);
443 actual_content_width /= PANGO_SCALE; 443 actual_content_width /= PANGO_SCALE;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 // static 477 // static
478 AutocompletePopupView* AutocompletePopupView::CreatePopupView( 478 AutocompletePopupView* AutocompletePopupView::CreatePopupView(
479 const gfx::Font& font, 479 const gfx::Font& font,
480 AutocompleteEditView* edit_view, 480 AutocompleteEditView* edit_view,
481 AutocompleteEditModel* edit_model, 481 AutocompleteEditModel* edit_model,
482 Profile* profile, 482 Profile* profile,
483 AutocompletePopupPositioner* popup_positioner) { 483 AutocompletePopupPositioner* popup_positioner) {
484 return new AutocompletePopupViewGtk(edit_view, edit_model, profile, 484 return new AutocompletePopupViewGtk(edit_view, edit_model, profile,
485 popup_positioner); 485 popup_positioner);
486 } 486 }
OLDNEW
« no previous file with comments | « base/process_util_linux.cc ('k') | chrome/browser/gtk/back_forward_button_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698