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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_win.cc

Issue 11360144: Converts some of the omnibox related classes to support multiple (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win_initialized Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/views/omnibox/omnibox_view_win.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <locale> 8 #include <locale>
9 #include <string> 9 #include <string>
10 10
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 double_click_time_(0), 467 double_click_time_(0),
468 can_discard_mousemove_(false), 468 can_discard_mousemove_(false),
469 ignore_ime_messages_(false), 469 ignore_ime_messages_(false),
470 delete_at_end_pressed_(false), 470 delete_at_end_pressed_(false),
471 font_(parent_view->font()), 471 font_(parent_view->font()),
472 possible_drag_(false), 472 possible_drag_(false),
473 in_drag_(false), 473 in_drag_(false),
474 initiated_drag_(false), 474 initiated_drag_(false),
475 drop_highlight_position_(-1), 475 drop_highlight_position_(-1),
476 ime_candidate_window_open_(false), 476 ime_candidate_window_open_(false),
477 background_color_(skia::SkColorToCOLORREF(LocationBarView::GetColor( 477 background_color_(skia::SkColorToCOLORREF(parent_view->GetColor(
478 ToolbarModel::NONE, LocationBarView::BACKGROUND))), 478 ToolbarModel::NONE, LocationBarView::BACKGROUND))),
479 security_level_(ToolbarModel::NONE), 479 security_level_(ToolbarModel::NONE),
480 text_object_model_(NULL), 480 text_object_model_(NULL),
481 ALLOW_THIS_IN_INITIALIZER_LIST( 481 ALLOW_THIS_IN_INITIALIZER_LIST(
482 tsf_event_router_(base::win::IsTSFAwareRequired() ? 482 tsf_event_router_(base::win::IsTSFAwareRequired() ?
483 new ui::TSFEventRouter(this) : NULL)) { 483 new ui::TSFEventRouter(this) : NULL)) {
484 if (!loaded_library_module_) 484 if (!loaded_library_module_)
485 loaded_library_module_ = LoadLibrary(kRichEditDLLName); 485 loaded_library_module_ = LoadLibrary(kRichEditDLLName);
486 486
487 saved_selection_for_focus_change_.cpMin = -1; 487 saved_selection_for_focus_change_.cpMin = -1;
(...skipping 1874 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 2362
2363 bool instant_extended_api_enabled = 2363 bool instant_extended_api_enabled =
2364 chrome::search::IsInstantExtendedAPIEnabled(parent_view_->profile()); 2364 chrome::search::IsInstantExtendedAPIEnabled(parent_view_->profile());
2365 2365
2366 // Set the baseline emphasis. 2366 // Set the baseline emphasis.
2367 CHARFORMAT cf = {0}; 2367 CHARFORMAT cf = {0};
2368 cf.dwMask = CFM_COLOR; 2368 cf.dwMask = CFM_COLOR;
2369 // If we're going to emphasize parts of the text, then the baseline state 2369 // If we're going to emphasize parts of the text, then the baseline state
2370 // should be "de-emphasized". If not, then everything should be rendered in 2370 // should be "de-emphasized". If not, then everything should be rendered in
2371 // the standard text color. 2371 // the standard text color.
2372 cf.crTextColor = skia::SkColorToCOLORREF(LocationBarView::GetColor( 2372 cf.crTextColor = skia::SkColorToCOLORREF(parent_view_->GetColor(
2373 security_level_, 2373 security_level_,
2374 emphasize ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT)); 2374 emphasize ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT));
2375 // NOTE: Don't use SetDefaultCharFormat() instead of the below; that sets the 2375 // NOTE: Don't use SetDefaultCharFormat() instead of the below; that sets the
2376 // format that will get applied to text added in the future, not to text 2376 // format that will get applied to text added in the future, not to text
2377 // already in the edit. 2377 // already in the edit.
2378 SelectAll(false); 2378 SelectAll(false);
2379 SetSelectionCharFormat(cf); 2379 SetSelectionCharFormat(cf);
2380 2380
2381 if (emphasize) { 2381 if (emphasize) {
2382 // We've found a host name, give it more emphasis. 2382 // We've found a host name, give it more emphasis.
2383 cf.crTextColor = skia::SkColorToCOLORREF(LocationBarView::GetColor( 2383 cf.crTextColor = skia::SkColorToCOLORREF(parent_view_->GetColor(
2384 security_level_, LocationBarView::TEXT)); 2384 security_level_, LocationBarView::TEXT));
2385 SetSelection(host.begin, host.end()); 2385 SetSelection(host.begin, host.end());
2386 SetSelectionCharFormat(cf); 2386 SetSelectionCharFormat(cf);
2387 } 2387 }
2388 2388
2389 // Emphasize the scheme for security UI display purposes (if necessary). 2389 // Emphasize the scheme for security UI display purposes (if necessary).
2390 insecure_scheme_component_.reset(); 2390 insecure_scheme_component_.reset();
2391 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && 2391 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() &&
2392 scheme.is_nonempty() && (security_level_ != ToolbarModel::NONE)) { 2392 scheme.is_nonempty() && (security_level_ != ToolbarModel::NONE)) {
2393 if (security_level_ == ToolbarModel::SECURITY_ERROR) { 2393 if (security_level_ == ToolbarModel::SECURITY_ERROR) {
2394 insecure_scheme_component_.begin = scheme.begin; 2394 insecure_scheme_component_.begin = scheme.begin;
2395 insecure_scheme_component_.len = scheme.len; 2395 insecure_scheme_component_.len = scheme.len;
2396 } 2396 }
2397 cf.crTextColor = skia::SkColorToCOLORREF(LocationBarView::GetColor( 2397 cf.crTextColor = skia::SkColorToCOLORREF(parent_view_->GetColor(
2398 security_level_, LocationBarView::SECURITY_TEXT)); 2398 security_level_, LocationBarView::SECURITY_TEXT));
2399 SetSelection(scheme.begin, scheme.end()); 2399 SetSelection(scheme.begin, scheme.end());
2400 SetSelectionCharFormat(cf); 2400 SetSelectionCharFormat(cf);
2401 } 2401 }
2402 2402
2403 // Restore the selection. 2403 // Restore the selection.
2404 SetSelectionRange(saved_sel); 2404 SetSelectionRange(saved_sel);
2405 } 2405 }
2406 2406
2407 void OmniboxViewWin::EraseTopOfSelection(CDC* dc, 2407 void OmniboxViewWin::EraseTopOfSelection(CDC* dc,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2487 SkIntToScalar(PosFromChar(sel.cpMax).x - scheme_rect.left), 2487 SkIntToScalar(PosFromChar(sel.cpMax).x - scheme_rect.left),
2488 SkIntToScalar(scheme_rect.Height()) }; 2488 SkIntToScalar(scheme_rect.Height()) };
2489 2489
2490 bool instant_extended_api_enabled = 2490 bool instant_extended_api_enabled =
2491 chrome::search::IsInstantExtendedAPIEnabled(parent_view_->profile()); 2491 chrome::search::IsInstantExtendedAPIEnabled(parent_view_->profile());
2492 2492
2493 // Draw the unselected portion of the stroke. 2493 // Draw the unselected portion of the stroke.
2494 sk_canvas->save(); 2494 sk_canvas->save();
2495 if (selection_rect.isEmpty() || 2495 if (selection_rect.isEmpty() ||
2496 sk_canvas->clipRect(selection_rect, SkRegion::kDifference_Op)) { 2496 sk_canvas->clipRect(selection_rect, SkRegion::kDifference_Op)) {
2497 paint.setColor(LocationBarView::GetColor(security_level_, 2497 paint.setColor(parent_view_->GetColor(security_level_,
2498 LocationBarView::SECURITY_TEXT)); 2498 LocationBarView::SECURITY_TEXT));
2499 sk_canvas->drawLine(start_point.fX, start_point.fY, 2499 sk_canvas->drawLine(start_point.fX, start_point.fY,
2500 end_point.fX, end_point.fY, paint); 2500 end_point.fX, end_point.fY, paint);
2501 } 2501 }
2502 sk_canvas->restore(); 2502 sk_canvas->restore();
2503 2503
2504 // Draw the selected portion of the stroke. 2504 // Draw the selected portion of the stroke.
2505 if (!selection_rect.isEmpty() && sk_canvas->clipRect(selection_rect)) { 2505 if (!selection_rect.isEmpty() && sk_canvas->clipRect(selection_rect)) {
2506 paint.setColor(LocationBarView::GetColor(security_level_, 2506 paint.setColor(parent_view_->GetColor(security_level_,
2507 LocationBarView::SELECTED_TEXT)); 2507 LocationBarView::SELECTED_TEXT));
2508 sk_canvas->drawLine(start_point.fX, start_point.fY, 2508 sk_canvas->drawLine(start_point.fX, start_point.fY,
2509 end_point.fX, end_point.fY, paint); 2509 end_point.fX, end_point.fY, paint);
2510 } 2510 }
2511 2511
2512 // Now copy what we drew to the target HDC. 2512 // Now copy what we drew to the target HDC.
2513 skia::DrawToNativeContext(sk_canvas, hdc, 2513 skia::DrawToNativeContext(sk_canvas, hdc,
2514 scheme_rect.left + canvas_paint_clip_rect.left - canvas_clip_rect.left, 2514 scheme_rect.left + canvas_paint_clip_rect.left - canvas_clip_rect.left,
2515 std::max(scheme_rect.top, client_rect.top) + canvas_paint_clip_rect.top - 2515 std::max(scheme_rect.top, client_rect.top) + canvas_paint_clip_rect.top -
2516 canvas_clip_rect.top, &canvas_paint_clip_rect); 2516 canvas_clip_rect.top, &canvas_paint_clip_rect);
2517 } 2517 }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2745 return (rect.left - client_rect.left) + (client_rect.right - rect.right); 2745 return (rect.left - client_rect.left) + (client_rect.right - rect.right);
2746 } 2746 }
2747 2747
2748 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { 2748 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const {
2749 // Use font_.GetStringWidth() instead of 2749 // Use font_.GetStringWidth() instead of
2750 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is 2750 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is
2751 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, 2751 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout,
2752 // PosFromChar(i) might return 0 when i is greater than 1. 2752 // PosFromChar(i) might return 0 when i is greater than 1.
2753 return font_.GetStringWidth(text) + GetHorizontalMargin(); 2753 return font_.GetStringWidth(text) + GetHorizontalMargin();
2754 } 2754 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698