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

Side by Side Diff: chrome/browser/views/find_bar_win.cc

Issue 67135: Fix: Find box forwarding scroll messages to the page when it shouldn't (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/views/find_bar_win.h ('k') | no next file » | 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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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/views/find_bar_win.h" 5 #include "chrome/browser/views/find_bar_win.h"
6 6
7 #include "chrome/browser/browser.h" 7 #include "chrome/browser/browser.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/find_bar_controller.h" 9 #include "chrome/browser/find_bar_controller.h"
10 #include "chrome/browser/renderer_host/render_view_host.h" 10 #include "chrome/browser/renderer_host/render_view_host.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 return; 225 return;
226 } 226 }
227 227
228 gfx::Rect new_pos = GetDialogPosition(selection_rect); 228 gfx::Rect new_pos = GetDialogPosition(selection_rect);
229 SetDialogPosition(new_pos, no_redraw); 229 SetDialogPosition(new_pos, no_redraw);
230 230
231 // May need to redraw our frame to accommodate bookmark bar styles. 231 // May need to redraw our frame to accommodate bookmark bar styles.
232 view_->SchedulePaint(); 232 view_->SchedulePaint();
233 } 233 }
234 234
235 void FindBarWin::ForwardKeystrokeToWebpage(TCHAR key) { 235 bool FindBarWin::MaybeForwardKeystrokeToWebpage(
236 UINT message, TCHAR key, UINT flags) {
237 // We specifically ignore WM_CHAR. See http://crbug.com/10509.
238 if (message != WM_KEYDOWN && message != WM_KEYUP)
239 return false;
240
241 switch (key) {
242 case VK_HOME:
243 case VK_END:
244 // Ctrl+Home and Ctrl+End should be forwarded to the page.
245 if (GetKeyState(VK_CONTROL) >= 0)
246 return false; // Ctrl not pressed: Abort. Otherwise fall through.
247 case VK_UP:
248 case VK_DOWN:
249 case VK_PRIOR: // Page up
250 case VK_NEXT: // Page down
251 break; // The keys above are the ones we want to forward to the page.
252 default:
253 return false;
254 }
255
236 WebContents* contents = find_bar_controller_->web_contents(); 256 WebContents* contents = find_bar_controller_->web_contents();
237 if (!contents) 257 if (!contents)
238 return; 258 return false;
239 259
240 RenderViewHost* render_view_host = contents->render_view_host(); 260 RenderViewHost* render_view_host = contents->render_view_host();
241 261
242 // Make sure we don't have a text field element interfering with keyboard 262 // Make sure we don't have a text field element interfering with keyboard
243 // input. Otherwise Up and Down arrow key strokes get eaten. "Nom Nom Nom". 263 // input. Otherwise Up and Down arrow key strokes get eaten. "Nom Nom Nom".
244 render_view_host->ClearFocusedNode(); 264 render_view_host->ClearFocusedNode();
245 265
246 HWND hwnd = contents->GetContentNativeView(); 266 HWND hwnd = contents->GetContentNativeView();
247 render_view_host->ForwardKeyboardEvent( 267 render_view_host->ForwardKeyboardEvent(
248 NativeWebKeyboardEvent(hwnd, WM_KEYDOWN, key, 0)); 268 NativeWebKeyboardEvent(hwnd, message, key, 0));
249 render_view_host->ForwardKeyboardEvent( 269 return true;
250 NativeWebKeyboardEvent(hwnd, WM_KEYUP, key, 0));
251 } 270 }
252 271
253 //////////////////////////////////////////////////////////////////////////////// 272 ////////////////////////////////////////////////////////////////////////////////
254 // FindBarWin, views::WidgetWin implementation: 273 // FindBarWin, views::WidgetWin implementation:
255 274
256 void FindBarWin::OnFinalMessage(HWND window) { 275 void FindBarWin::OnFinalMessage(HWND window) {
257 // TODO(beng): Destroy the RootView before destroying the Focus Manager will 276 // TODO(beng): Destroy the RootView before destroying the Focus Manager will
258 // allow us to remove this method. 277 // allow us to remove this method.
259 278
260 // We are exiting, so we no longer need to monitor focus changes. 279 // We are exiting, so we no longer need to monitor focus changes.
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 542
524 // We now need to check if the window is obscuring the search results. 543 // We now need to check if the window is obscuring the search results.
525 if (!result.selection_rect().IsEmpty()) 544 if (!result.selection_rect().IsEmpty())
526 MoveWindowIfNecessary(result.selection_rect(), false); 545 MoveWindowIfNecessary(result.selection_rect(), false);
527 546
528 // Once we find a match we no longer want to keep track of what had 547 // Once we find a match we no longer want to keep track of what had
529 // focus. EndFindSession will then set the focus to the page content. 548 // focus. EndFindSession will then set the focus to the page content.
530 if (result.number_of_matches() > 0) 549 if (result.number_of_matches() > 0)
531 focus_tracker_.reset(NULL); 550 focus_tracker_.reset(NULL);
532 } 551 }
OLDNEW
« no previous file with comments | « chrome/browser/views/find_bar_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698