| OLD | NEW |
| 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/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 DCHECK(!devtools_client_.get()); | 764 DCHECK(!devtools_client_.get()); |
| 765 devtools_client_.reset(new DevToolsClient(this)); | 765 devtools_client_.reset(new DevToolsClient(this)); |
| 766 } | 766 } |
| 767 | 767 |
| 768 void RenderView::OnStopFinding(bool clear_selection) { | 768 void RenderView::OnStopFinding(bool clear_selection) { |
| 769 WebView* view = webview(); | 769 WebView* view = webview(); |
| 770 if (!view) | 770 if (!view) |
| 771 return; | 771 return; |
| 772 | 772 |
| 773 if (clear_selection) | 773 if (clear_selection) |
| 774 view->GetFocusedFrame()->clearSelection(); | 774 view->GetFocusedFrame()->executeCommand(WebString::fromUTF8("Unselect")); |
| 775 | 775 |
| 776 WebFrame* frame = view->GetMainFrame(); | 776 WebFrame* frame = view->GetMainFrame(); |
| 777 while (frame) { | 777 while (frame) { |
| 778 frame->stopFinding(clear_selection); | 778 frame->stopFinding(clear_selection); |
| 779 frame = view->GetNextFrameAfter(frame, false); | 779 frame = view->GetNextFrameAfter(frame, false); |
| 780 } | 780 } |
| 781 } | 781 } |
| 782 | 782 |
| 783 void RenderView::OnFindReplyAck() { | 783 void RenderView::OnFindReplyAck() { |
| 784 // Check if there is any queued up request waiting to be sent. | 784 // Check if there is any queued up request waiting to be sent. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 return; | 860 return; |
| 861 | 861 |
| 862 webview()->GetFocusedFrame()->executeCommand(WebString::fromUTF8("Delete")); | 862 webview()->GetFocusedFrame()->executeCommand(WebString::fromUTF8("Delete")); |
| 863 UserMetricsRecordAction(L"DeleteSelection"); | 863 UserMetricsRecordAction(L"DeleteSelection"); |
| 864 } | 864 } |
| 865 | 865 |
| 866 void RenderView::OnSelectAll() { | 866 void RenderView::OnSelectAll() { |
| 867 if (!webview()) | 867 if (!webview()) |
| 868 return; | 868 return; |
| 869 | 869 |
| 870 webview()->GetFocusedFrame()->selectAll(); | 870 webview()->GetFocusedFrame()->executeCommand( |
| 871 WebString::fromUTF8("SelectAll")); |
| 872 UserMetricsRecordAction(L"SelectAll"); |
| 871 } | 873 } |
| 872 | 874 |
| 873 void RenderView::OnSetInitialFocus(bool reverse) { | 875 void RenderView::OnSetInitialFocus(bool reverse) { |
| 874 if (!webview()) | 876 if (!webview()) |
| 875 return; | 877 return; |
| 876 webview()->SetInitialFocus(reverse); | 878 webview()->SetInitialFocus(reverse); |
| 877 } | 879 } |
| 878 | 880 |
| 879 /////////////////////////////////////////////////////////////////////////////// | 881 /////////////////////////////////////////////////////////////////////////////// |
| 880 | 882 |
| (...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2272 | 2274 |
| 2273 WebRect selection_rect; | 2275 WebRect selection_rect; |
| 2274 bool result = false; | 2276 bool result = false; |
| 2275 | 2277 |
| 2276 do { | 2278 do { |
| 2277 result = search_frame->find( | 2279 result = search_frame->find( |
| 2278 request_id, search_text, options, wrap_within_frame, &selection_rect); | 2280 request_id, search_text, options, wrap_within_frame, &selection_rect); |
| 2279 | 2281 |
| 2280 if (!result) { | 2282 if (!result) { |
| 2281 // don't leave text selected as you move to the next frame. | 2283 // don't leave text selected as you move to the next frame. |
| 2282 search_frame->clearSelection(); | 2284 search_frame->executeCommand(WebString::fromUTF8("Unselect")); |
| 2283 | 2285 |
| 2284 // Find the next frame, but skip the invisible ones. | 2286 // Find the next frame, but skip the invisible ones. |
| 2285 do { | 2287 do { |
| 2286 // What is the next frame to search? (we might be going backwards). Note | 2288 // What is the next frame to search? (we might be going backwards). Note |
| 2287 // that we specify wrap=true so that search_frame never becomes NULL. | 2289 // that we specify wrap=true so that search_frame never becomes NULL. |
| 2288 search_frame = options.forward ? | 2290 search_frame = options.forward ? |
| 2289 webview()->GetNextFrameAfter(search_frame, true) : | 2291 webview()->GetNextFrameAfter(search_frame, true) : |
| 2290 webview()->GetPreviousFrameBefore(search_frame, true); | 2292 webview()->GetPreviousFrameBefore(search_frame, true); |
| 2291 } while (!search_frame->hasVisibleContent() && | 2293 } while (!search_frame->hasVisibleContent() && |
| 2292 search_frame != focused_frame); | 2294 search_frame != focused_frame); |
| 2293 | 2295 |
| 2294 // Make sure selection doesn't affect the search operation in new frame. | 2296 // Make sure selection doesn't affect the search operation in new frame. |
| 2295 search_frame->clearSelection(); | 2297 search_frame->executeCommand(WebString::fromUTF8("Unselect")); |
| 2296 | 2298 |
| 2297 // If we have multiple frames and we have wrapped back around to the | 2299 // If we have multiple frames and we have wrapped back around to the |
| 2298 // focused frame, we need to search it once more allowing wrap within | 2300 // focused frame, we need to search it once more allowing wrap within |
| 2299 // the frame, otherwise it will report 'no match' if the focused frame has | 2301 // the frame, otherwise it will report 'no match' if the focused frame has |
| 2300 // reported matches, but no frames after the focused_frame contain a | 2302 // reported matches, but no frames after the focused_frame contain a |
| 2301 // match for the search word(s). | 2303 // match for the search word(s). |
| 2302 if (multi_frame && search_frame == focused_frame) { | 2304 if (multi_frame && search_frame == focused_frame) { |
| 2303 result = search_frame->find( | 2305 result = search_frame->find( |
| 2304 request_id, search_text, options, true, // Force wrapping. | 2306 request_id, search_text, options, true, // Force wrapping. |
| 2305 &selection_rect); | 2307 &selection_rect); |
| (...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3316 Send(new ViewHostMsg_PasswordFormsSeen(routing_id_, password_forms)); | 3318 Send(new ViewHostMsg_PasswordFormsSeen(routing_id_, password_forms)); |
| 3317 } | 3319 } |
| 3318 | 3320 |
| 3319 void RenderView::Print(WebFrame* frame, bool script_initiated) { | 3321 void RenderView::Print(WebFrame* frame, bool script_initiated) { |
| 3320 DCHECK(frame); | 3322 DCHECK(frame); |
| 3321 if (print_helper_.get() == NULL) { | 3323 if (print_helper_.get() == NULL) { |
| 3322 print_helper_.reset(new PrintWebViewHelper(this)); | 3324 print_helper_.reset(new PrintWebViewHelper(this)); |
| 3323 } | 3325 } |
| 3324 print_helper_->Print(frame, script_initiated); | 3326 print_helper_->Print(frame, script_initiated); |
| 3325 } | 3327 } |
| OLD | NEW |