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

Side by Side Diff: webkit/glue/webframe_impl.cc

Issue 62032: Stop serializing WebString over IPC. The new rule is that only POD (plain ol... (Closed) Base URL: svn://svn.chromium.org/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 | « webkit/glue/webframe_impl.h ('k') | webkit/webkit.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
3 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 #include "base/basictypes.h" 129 #include "base/basictypes.h"
130 #include "base/gfx/rect.h" 130 #include "base/gfx/rect.h"
131 #include "base/logging.h" 131 #include "base/logging.h"
132 #include "base/message_loop.h" 132 #include "base/message_loop.h"
133 #include "base/stats_counters.h" 133 #include "base/stats_counters.h"
134 #include "base/string_util.h" 134 #include "base/string_util.h"
135 #include "net/base/net_errors.h" 135 #include "net/base/net_errors.h"
136 #include "skia/ext/bitmap_platform_device.h" 136 #include "skia/ext/bitmap_platform_device.h"
137 #include "skia/ext/platform_canvas.h" 137 #include "skia/ext/platform_canvas.h"
138 #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" 138 #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h"
139 #include "third_party/WebKit/WebKit/chromium/public/WebFindInPageRequest.h" 139 #include "third_party/WebKit/WebKit/chromium/public/WebFindOptions.h"
140 #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" 140 #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h"
141 #include "webkit/glue/alt_error_page_resource_fetcher.h" 141 #include "webkit/glue/alt_error_page_resource_fetcher.h"
142 #include "webkit/glue/dom_operations.h" 142 #include "webkit/glue/dom_operations.h"
143 #include "webkit/glue/dom_operations_private.h" 143 #include "webkit/glue/dom_operations_private.h"
144 #include "webkit/glue/feed.h" 144 #include "webkit/glue/feed.h"
145 #include "webkit/glue/glue_serialize.h" 145 #include "webkit/glue/glue_serialize.h"
146 #include "webkit/glue/glue_util.h" 146 #include "webkit/glue/glue_util.h"
147 #include "webkit/glue/webdatasource_impl.h" 147 #include "webkit/glue/webdatasource_impl.h"
148 #include "webkit/glue/weberror_impl.h" 148 #include "webkit/glue/weberror_impl.h"
149 #include "webkit/glue/webframe_impl.h" 149 #include "webkit/glue/webframe_impl.h"
150 #include "webkit/glue/webhistoryitem_impl.h" 150 #include "webkit/glue/webhistoryitem_impl.h"
151 #include "webkit/glue/weburlrequest_impl.h" 151 #include "webkit/glue/weburlrequest_impl.h"
152 #include "webkit/glue/webtextinput_impl.h" 152 #include "webkit/glue/webtextinput_impl.h"
153 #include "webkit/glue/webview_impl.h" 153 #include "webkit/glue/webview_impl.h"
154 154
155 #if defined(OS_LINUX) 155 #if defined(OS_LINUX)
156 #include <gdk/gdk.h> 156 #include <gdk/gdk.h>
157 #endif 157 #endif
158 158
159 #if USE(JSC) 159 #if USE(JSC)
160 #include "bridge/c/c_instance.h" 160 #include "bridge/c/c_instance.h"
161 #include "bridge/runtime_object.h" 161 #include "bridge/runtime_object.h"
162 #endif 162 #endif
163 163
164 using base::Time; 164 using base::Time;
165
165 using WebCore::ChromeClientChromium; 166 using WebCore::ChromeClientChromium;
166 using WebCore::Color; 167 using WebCore::Color;
167 using WebCore::Document; 168 using WebCore::Document;
168 using WebCore::DocumentFragment; 169 using WebCore::DocumentFragment;
169 using WebCore::DocumentLoader; 170 using WebCore::DocumentLoader;
170 using WebCore::ExceptionCode; 171 using WebCore::ExceptionCode;
171 using WebCore::GraphicsContext; 172 using WebCore::GraphicsContext;
172 using WebCore::HTMLFrameOwnerElement; 173 using WebCore::HTMLFrameOwnerElement;
173 using WebCore::Frame; 174 using WebCore::Frame;
174 using WebCore::FrameLoader; 175 using WebCore::FrameLoader;
(...skipping 12 matching lines...) Expand all
187 using WebCore::ResourceError; 188 using WebCore::ResourceError;
188 using WebCore::ResourceHandle; 189 using WebCore::ResourceHandle;
189 using WebCore::ResourceRequest; 190 using WebCore::ResourceRequest;
190 using WebCore::VisibleSelection; 191 using WebCore::VisibleSelection;
191 using WebCore::SharedBuffer; 192 using WebCore::SharedBuffer;
192 using WebCore::String; 193 using WebCore::String;
193 using WebCore::SubstituteData; 194 using WebCore::SubstituteData;
194 using WebCore::TextIterator; 195 using WebCore::TextIterator;
195 using WebCore::VisiblePosition; 196 using WebCore::VisiblePosition;
196 using WebCore::XPathResult; 197 using WebCore::XPathResult;
198
197 using WebKit::WebConsoleMessage; 199 using WebKit::WebConsoleMessage;
198 using WebKit::WebFindInPageRequest; 200 using WebKit::WebFindOptions;
199 using WebKit::WebScriptSource; 201 using WebKit::WebScriptSource;
200 202
201 // Key for a StatsCounter tracking how many WebFrames are active. 203 // Key for a StatsCounter tracking how many WebFrames are active.
202 static const char* const kWebFrameActiveCount = "WebFrameActiveCount"; 204 static const char* const kWebFrameActiveCount = "WebFrameActiveCount";
203 205
204 static const char* const kOSDType = "application/opensearchdescription+xml"; 206 static const char* const kOSDType = "application/opensearchdescription+xml";
205 static const char* const kOSDRel = "search"; 207 static const char* const kOSDRel = "search";
206 208
207 // The separator between frames when the frames are converted to plain text. 209 // The separator between frames when the frames are converted to plain text.
208 static const wchar_t kFrameSeparator[] = L"\n\n"; 210 static const wchar_t kFrameSeparator[] = L"\n\n";
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 OrdinalOfFirstMatchForFrame(this) + active_match_ordinal, 942 OrdinalOfFirstMatchForFrame(this) + active_match_ordinal,
941 selection_rect); 943 selection_rect);
942 } 944 }
943 } 945 }
944 946
945 void WebFrameImpl::ResetMatchCount() { 947 void WebFrameImpl::ResetMatchCount() {
946 total_matchcount_ = 0; 948 total_matchcount_ = 0;
947 frames_scoping_count_ = 0; 949 frames_scoping_count_ = 0;
948 } 950 }
949 951
950 bool WebFrameImpl::Find(const WebFindInPageRequest& request, 952 bool WebFrameImpl::Find(int request_id,
953 const string16& search_text,
954 const WebFindOptions& options,
951 bool wrap_within_frame, 955 bool wrap_within_frame,
952 gfx::Rect* selection_rect) { 956 gfx::Rect* selection_rect) {
953 WebCore::String webcore_string = 957 WebCore::String webcore_string = webkit_glue::String16ToString(search_text);
954 webkit_glue::WebStringToString(request.text);
955 958
956 WebFrameImpl* const main_frame_impl = 959 WebFrameImpl* const main_frame_impl =
957 static_cast<WebFrameImpl*>(GetView()->GetMainFrame()); 960 static_cast<WebFrameImpl*>(GetView()->GetMainFrame());
958 961
959 if (!request.findNext) 962 if (!options.findNext)
960 frame()->page()->unmarkAllTextMatches(); 963 frame()->page()->unmarkAllTextMatches();
961 964
962 // Starts the search from the current selection. 965 // Starts the search from the current selection.
963 bool start_in_selection = true; 966 bool start_in_selection = true;
964 967
965 DCHECK(frame() && frame()->view()); 968 DCHECK(frame() && frame()->view());
966 bool found = frame()->findString(webcore_string, request.forward, 969 bool found = frame()->findString(webcore_string, options.forward,
967 request.matchCase, wrap_within_frame, 970 options.matchCase, wrap_within_frame,
968 start_in_selection); 971 start_in_selection);
969 if (found) { 972 if (found) {
970 #if defined(OS_WIN) 973 #if defined(OS_WIN)
971 WebCore::RenderThemeChromiumWin::setFindInPageMode(true); 974 WebCore::RenderThemeChromiumWin::setFindInPageMode(true);
972 #endif 975 #endif
973 // Store which frame was active. This will come in handy later when we 976 // Store which frame was active. This will come in handy later when we
974 // change the active match ordinal below. 977 // change the active match ordinal below.
975 WebFrameImpl* old_active_frame = main_frame_impl->active_match_frame_; 978 WebFrameImpl* old_active_frame = main_frame_impl->active_match_frame_;
976 // Set this frame as the active frame (the one with the active highlight). 979 // Set this frame as the active frame (the one with the active highlight).
977 main_frame_impl->active_match_frame_ = this; 980 main_frame_impl->active_match_frame_ = this;
978 981
979 // We found something, so we can now query the selection for its position. 982 // We found something, so we can now query the selection for its position.
980 VisibleSelection new_selection(frame()->selection()->selection()); 983 VisibleSelection new_selection(frame()->selection()->selection());
981 IntRect curr_selection_rect; 984 IntRect curr_selection_rect;
982 985
983 // If we thought we found something, but it couldn't be selected (perhaps 986 // If we thought we found something, but it couldn't be selected (perhaps
984 // because it was marked -webkit-user-select: none), we can't set it to 987 // because it was marked -webkit-user-select: none), we can't set it to
985 // be active but we still continue searching. This matches Safari's 988 // be active but we still continue searching. This matches Safari's
986 // behavior, including some oddities when selectable and un-selectable text 989 // behavior, including some oddities when selectable and un-selectable text
987 // are mixed on a page: see https://bugs.webkit.org/show_bug.cgi?id=19127. 990 // are mixed on a page: see https://bugs.webkit.org/show_bug.cgi?id=19127.
988 if (new_selection.isNone() || 991 if (new_selection.isNone() ||
989 (new_selection.start() == new_selection.end())) { 992 (new_selection.start() == new_selection.end())) {
990 active_match_ = NULL; 993 active_match_ = NULL;
991 } else { 994 } else {
992 active_match_ = new_selection.toNormalizedRange(); 995 active_match_ = new_selection.toNormalizedRange();
993 curr_selection_rect = active_match_->boundingBox(); 996 curr_selection_rect = active_match_->boundingBox();
994 } 997 }
995 998
996 if (!request.findNext) { 999 if (!options.findNext) {
997 // This is a Find operation, so we set the flag to ask the scoping effort 1000 // This is a Find operation, so we set the flag to ask the scoping effort
998 // to find the active rect for us so we can update the ordinal (n of m). 1001 // to find the active rect for us so we can update the ordinal (n of m).
999 locating_active_rect_ = true; 1002 locating_active_rect_ = true;
1000 } else { 1003 } else {
1001 if (old_active_frame != this) { 1004 if (old_active_frame != this) {
1002 // If the active frame has changed it means that we have a multi-frame 1005 // If the active frame has changed it means that we have a multi-frame
1003 // page and we just switch to searching in a new frame. Then we just 1006 // page and we just switch to searching in a new frame. Then we just
1004 // want to reset the index. 1007 // want to reset the index.
1005 if (request.forward) 1008 if (options.forward)
1006 active_match_index_ = 0; 1009 active_match_index_ = 0;
1007 else 1010 else
1008 active_match_index_ = last_match_count_ - 1; 1011 active_match_index_ = last_match_count_ - 1;
1009 } else { 1012 } else {
1010 // We are still the active frame, so increment (or decrement) the 1013 // We are still the active frame, so increment (or decrement) the
1011 // |active_match_index|, wrapping if needed (on single frame pages). 1014 // |active_match_index|, wrapping if needed (on single frame pages).
1012 request.forward ? ++active_match_index_ : --active_match_index_; 1015 options.forward ? ++active_match_index_ : --active_match_index_;
1013 if (active_match_index_ + 1 > last_match_count_) 1016 if (active_match_index_ + 1 > last_match_count_)
1014 active_match_index_ = 0; 1017 active_match_index_ = 0;
1015 if (active_match_index_ + 1 == 0) 1018 if (active_match_index_ + 1 == 0)
1016 active_match_index_ = last_match_count_ - 1; 1019 active_match_index_ = last_match_count_ - 1;
1017 } 1020 }
1018 #if defined(OS_WIN) 1021 #if defined(OS_WIN)
1019 // TODO(pinkerton): Fix Mac scrolling to be more like Win ScrollView 1022 // TODO(pinkerton): Fix Mac scrolling to be more like Win ScrollView
1020 if (selection_rect) { 1023 if (selection_rect) {
1021 gfx::Rect rect = webkit_glue::FromIntRect( 1024 gfx::Rect rect = webkit_glue::FromIntRect(
1022 frame()->view()->convertToContainingWindow(curr_selection_rect)); 1025 frame()->view()->convertToContainingWindow(curr_selection_rect));
1023 rect.Offset(-frameview()->scrollOffset().width(), 1026 rect.Offset(-frameview()->scrollOffset().width(),
1024 -frameview()->scrollOffset().height()); 1027 -frameview()->scrollOffset().height());
1025 *selection_rect = rect; 1028 *selection_rect = rect;
1026 1029
1027 ReportFindInPageSelection(rect, 1030 ReportFindInPageSelection(rect,
1028 active_match_index_ + 1, 1031 active_match_index_ + 1,
1029 request.identifier); 1032 request_id);
1030 } 1033 }
1031 #endif 1034 #endif
1032 } 1035 }
1033 } else { 1036 } else {
1034 // Nothing was found in this frame. 1037 // Nothing was found in this frame.
1035 active_match_ = NULL; 1038 active_match_ = NULL;
1036 1039
1037 // Erase all previous tickmarks and highlighting. 1040 // Erase all previous tickmarks and highlighting.
1038 InvalidateArea(INVALIDATE_ALL); 1041 InvalidateArea(INVALIDATE_ALL);
1039 } 1042 }
(...skipping 11 matching lines...) Expand all
1051 it != frame; 1054 it != frame;
1052 it = static_cast<WebFrameImpl*>( 1055 it = static_cast<WebFrameImpl*>(
1053 webview_impl_->GetNextFrameAfter(it, true))) { 1056 webview_impl_->GetNextFrameAfter(it, true))) {
1054 if (it->last_match_count_ > 0) 1057 if (it->last_match_count_ > 0)
1055 ordinal += it->last_match_count_; 1058 ordinal += it->last_match_count_;
1056 } 1059 }
1057 1060
1058 return ordinal; 1061 return ordinal;
1059 } 1062 }
1060 1063
1061 bool WebFrameImpl::ShouldScopeMatches(const WebFindInPageRequest& request) { 1064 bool WebFrameImpl::ShouldScopeMatches(const string16& search_text) {
1062 // Don't scope if we can't find a frame or if the frame is not visible. 1065 // Don't scope if we can't find a frame or if the frame is not visible.
1063 // The user may have closed the tab/application, so abort. 1066 // The user may have closed the tab/application, so abort.
1064 if (!frame() || !Visible()) 1067 if (!frame() || !Visible())
1065 return false; 1068 return false;
1066 1069
1067 DCHECK(frame()->document() && frame()->view()); 1070 DCHECK(frame()->document() && frame()->view());
1068 1071
1069 // If the frame completed the scoping operation and found 0 matches the last 1072 // If the frame completed the scoping operation and found 0 matches the last
1070 // time it was searched, then we don't have to search it again if the user is 1073 // time it was searched, then we don't have to search it again if the user is
1071 // just adding to the search string or sending the same search string again. 1074 // just adding to the search string or sending the same search string again.
1072 if (scoping_complete_ && 1075 if (scoping_complete_ &&
1073 !last_search_string_.empty() && last_match_count_ == 0) { 1076 !last_search_string_.empty() && last_match_count_ == 0) {
1074 // Check to see if the search string prefixes match. 1077 // Check to see if the search string prefixes match.
1075 string16 previous_search_prefix = 1078 string16 previous_search_prefix =
1076 string16(request.text).substr(0, last_search_string_.length()); 1079 search_text.substr(0, last_search_string_.length());
1077 1080
1078 if (previous_search_prefix == last_search_string_) { 1081 if (previous_search_prefix == last_search_string_) {
1079 return false; // Don't search this frame, it will be fruitless. 1082 return false; // Don't search this frame, it will be fruitless.
1080 } 1083 }
1081 } 1084 }
1082 1085
1083 return true; 1086 return true;
1084 } 1087 }
1085 1088
1086 void WebFrameImpl::InvalidateIfNecessary() { 1089 void WebFrameImpl::InvalidateIfNecessary() {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 Vector<WebCore::DocumentMarker> markers = 1130 Vector<WebCore::DocumentMarker> markers =
1128 frame()->document()->markersForNode(node); 1131 frame()->document()->markersForNode(node);
1129 frame()->document()->setRenderedRectForMarker( 1132 frame()->document()->setRenderedRectForMarker(
1130 textPiece->startContainer(exception), 1133 textPiece->startContainer(exception),
1131 markers[markers.size() - 1], 1134 markers[markers.size() - 1],
1132 range->boundingBox()); 1135 range->boundingBox());
1133 } 1136 }
1134 } 1137 }
1135 } 1138 }
1136 1139
1137 void WebFrameImpl::ScopeStringMatches(const WebFindInPageRequest& request, 1140 void WebFrameImpl::ScopeStringMatches(int request_id,
1141 const string16& search_text,
1142 const WebFindOptions& options,
1138 bool reset) { 1143 bool reset) {
1139 if (!ShouldScopeMatches(request)) 1144 if (!ShouldScopeMatches(search_text))
1140 return; 1145 return;
1141 1146
1142 WebFrameImpl* main_frame_impl = 1147 WebFrameImpl* main_frame_impl =
1143 static_cast<WebFrameImpl*>(GetView()->GetMainFrame()); 1148 static_cast<WebFrameImpl*>(GetView()->GetMainFrame());
1144 1149
1145 if (reset) { 1150 if (reset) {
1146 // This is a brand new search, so we need to reset everything. 1151 // This is a brand new search, so we need to reset everything.
1147 // Scoping is just about to begin. 1152 // Scoping is just about to begin.
1148 scoping_complete_ = false; 1153 scoping_complete_ = false;
1149 // Clear highlighting for this frame. 1154 // Clear highlighting for this frame.
1150 if (frame()->markedTextMatchesAreHighlighted()) 1155 if (frame()->markedTextMatchesAreHighlighted())
1151 frame()->page()->unmarkAllTextMatches(); 1156 frame()->page()->unmarkAllTextMatches();
1152 // Clear the counters from last operation. 1157 // Clear the counters from last operation.
1153 last_match_count_ = 0; 1158 last_match_count_ = 0;
1154 next_invalidate_after_ = 0; 1159 next_invalidate_after_ = 0;
1155 1160
1156 resume_scoping_from_range_ = NULL; 1161 resume_scoping_from_range_ = NULL;
1157 1162
1158 main_frame_impl->frames_scoping_count_++; 1163 main_frame_impl->frames_scoping_count_++;
1159 1164
1160 // Now, defer scoping until later to allow find operation to finish quickly. 1165 // Now, defer scoping until later to allow find operation to finish quickly.
1161 MessageLoop::current()->PostTask(FROM_HERE, 1166 MessageLoop::current()->PostTask(FROM_HERE,
1162 scope_matches_factory_.NewRunnableMethod( 1167 scope_matches_factory_.NewRunnableMethod(
1163 &WebFrameImpl::ScopeStringMatches, 1168 &WebFrameImpl::ScopeStringMatches,
1164 request, 1169 request_id,
1170 search_text,
1171 options,
1165 false)); // false=we just reset, so don't do it again. 1172 false)); // false=we just reset, so don't do it again.
1166 return; 1173 return;
1167 } 1174 }
1168 1175
1169 WebCore::String webcore_string = 1176 WebCore::String webcore_string = webkit_glue::String16ToString(search_text);
1170 webkit_glue::WebStringToString(request.text);
1171 1177
1172 RefPtr<Range> search_range(rangeOfContents(frame()->document())); 1178 RefPtr<Range> search_range(rangeOfContents(frame()->document()));
1173 1179
1174 ExceptionCode ec = 0, ec2 = 0; 1180 ExceptionCode ec = 0, ec2 = 0;
1175 if (resume_scoping_from_range_.get()) { 1181 if (resume_scoping_from_range_.get()) {
1176 // This is a continuation of a scoping operation that timed out and didn't 1182 // This is a continuation of a scoping operation that timed out and didn't
1177 // complete last time around, so we should start from where we left off. 1183 // complete last time around, so we should start from where we left off.
1178 search_range->setStart(resume_scoping_from_range_->startContainer(), 1184 search_range->setStart(resume_scoping_from_range_->startContainer(),
1179 resume_scoping_from_range_->startOffset(ec2) + 1, 1185 resume_scoping_from_range_->startOffset(ec2) + 1,
1180 ec); 1186 ec);
(...skipping 14 matching lines...) Expand all
1195 Time start_time = Time::Now(); 1201 Time start_time = Time::Now();
1196 do { 1202 do {
1197 // Find next occurrence of the search string. 1203 // Find next occurrence of the search string.
1198 // TODO(finnur): (http://b/1088245) This WebKit operation may run 1204 // TODO(finnur): (http://b/1088245) This WebKit operation may run
1199 // for longer than the timeout value, and is not interruptible as it is 1205 // for longer than the timeout value, and is not interruptible as it is
1200 // currently written. We may need to rewrite it with interruptibility in 1206 // currently written. We may need to rewrite it with interruptibility in
1201 // mind, or find an alternative. 1207 // mind, or find an alternative.
1202 RefPtr<Range> result_range(findPlainText(search_range.get(), 1208 RefPtr<Range> result_range(findPlainText(search_range.get(),
1203 webcore_string, 1209 webcore_string,
1204 true, 1210 true,
1205 request.matchCase)); 1211 options.matchCase));
1206 if (result_range->collapsed(ec)) { 1212 if (result_range->collapsed(ec)) {
1207 if (!result_range->startContainer()->isInShadowTree()) 1213 if (!result_range->startContainer()->isInShadowTree())
1208 break; 1214 break;
1209 1215
1210 search_range = rangeOfContents(frame()->document()); 1216 search_range = rangeOfContents(frame()->document());
1211 search_range->setStartAfter( 1217 search_range->setStartAfter(
1212 result_range->startContainer()->shadowAncestorNode(), ec); 1218 result_range->startContainer()->shadowAncestorNode(), ec);
1213 continue; 1219 continue;
1214 } 1220 }
1215 1221
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 // find this rect during scoping it means we have found the active 1256 // find this rect during scoping it means we have found the active
1251 // tickmark. 1257 // tickmark.
1252 if (locating_active_rect_ && (active_selection_rect == result_bounds)) { 1258 if (locating_active_rect_ && (active_selection_rect == result_bounds)) {
1253 // We have found the active tickmark frame. 1259 // We have found the active tickmark frame.
1254 main_frame_impl->active_match_frame_ = this; 1260 main_frame_impl->active_match_frame_ = this;
1255 // We also know which tickmark is active now. 1261 // We also know which tickmark is active now.
1256 active_match_index_ = match_count - 1; 1262 active_match_index_ = match_count - 1;
1257 // To stop looking for the active tickmark, we set this flag. 1263 // To stop looking for the active tickmark, we set this flag.
1258 locating_active_rect_ = false; 1264 locating_active_rect_ = false;
1259 1265
1260 #if defined(OS_WIN) 1266 #if defined(OS_WIN)
1261 // TODO(pinkerton): Fix Mac invalidation to be more like Win ScrollView 1267 // TODO(pinkerton): Fix Mac invalidation to be more like Win ScrollView
1262 // Notify browser of new location for the selected rectangle. 1268 // Notify browser of new location for the selected rectangle.
1263 result_bounds.move(-frameview()->scrollOffset().width(), 1269 result_bounds.move(-frameview()->scrollOffset().width(),
1264 -frameview()->scrollOffset().height()); 1270 -frameview()->scrollOffset().height());
1265 ReportFindInPageSelection( 1271 ReportFindInPageSelection(
1266 webkit_glue::FromIntRect( 1272 webkit_glue::FromIntRect(
1267 frame()->view()->convertToContainingWindow(result_bounds)), 1273 frame()->view()->convertToContainingWindow(result_bounds)),
1268 active_match_index_ + 1, 1274 active_match_index_ + 1,
1269 request.identifier); 1275 request_id);
1270 #endif 1276 #endif
1271 } 1277 }
1272 } 1278 }
1273 1279
1274 resume_scoping_from_range_ = result_range; 1280 resume_scoping_from_range_ = result_range;
1275 timeout = (Time::Now() - start_time).InMilliseconds() >= kTimeout; 1281 timeout = (Time::Now() - start_time).InMilliseconds() >= kTimeout;
1276 } while (!timeout); 1282 } while (!timeout);
1277 1283
1278 // Remember what we search for last time, so we can skip searching if more 1284 // Remember what we search for last time, so we can skip searching if more
1279 // letters are added to the search string (and last outcome was 0). 1285 // letters are added to the search string (and last outcome was 0).
1280 last_search_string_ = request.text; 1286 last_search_string_ = search_text;
1281 1287
1282 if (match_count > 0) { 1288 if (match_count > 0) {
1283 frame()->setMarkedTextMatchesAreHighlighted(true); 1289 frame()->setMarkedTextMatchesAreHighlighted(true);
1284 1290
1285 last_match_count_ += match_count; 1291 last_match_count_ += match_count;
1286 1292
1287 // Let the mainframe know how much we found during this pass. 1293 // Let the mainframe know how much we found during this pass.
1288 main_frame_impl->IncreaseMatchCount(match_count, request.identifier); 1294 main_frame_impl->IncreaseMatchCount(match_count, request_id);
1289 } 1295 }
1290 1296
1291 if (timeout) { 1297 if (timeout) {
1292 // If we found anything during this pass, we should redraw. However, we 1298 // If we found anything during this pass, we should redraw. However, we
1293 // don't want to spam too much if the page is extremely long, so if we 1299 // don't want to spam too much if the page is extremely long, so if we
1294 // reach a certain point we start throttling the redraw requests. 1300 // reach a certain point we start throttling the redraw requests.
1295 if (match_count > 0) 1301 if (match_count > 0)
1296 InvalidateIfNecessary(); 1302 InvalidateIfNecessary();
1297 1303
1298 // Scoping effort ran out of time, lets ask for another time-slice. 1304 // Scoping effort ran out of time, lets ask for another time-slice.
1299 MessageLoop::current()->PostTask(FROM_HERE, 1305 MessageLoop::current()->PostTask(FROM_HERE,
1300 scope_matches_factory_.NewRunnableMethod( 1306 scope_matches_factory_.NewRunnableMethod(
1301 &WebFrameImpl::ScopeStringMatches, 1307 &WebFrameImpl::ScopeStringMatches,
1302 request, 1308 request_id,
1309 search_text,
1310 options,
1303 false)); // don't reset. 1311 false)); // don't reset.
1304 1312
1305 return; // Done for now, resume work later. 1313 return; // Done for now, resume work later.
1306 } 1314 }
1307 1315
1308 // This frame has no further scoping left, so it is done. Other frames might, 1316 // This frame has no further scoping left, so it is done. Other frames might,
1309 // of course, continue to scope matches. 1317 // of course, continue to scope matches.
1310 scoping_complete_ = true; 1318 scoping_complete_ = true;
1311 main_frame_impl->frames_scoping_count_--; 1319 main_frame_impl->frames_scoping_count_--;
1312 1320
1313 // If this is the last frame to finish scoping we need to trigger the final 1321 // If this is the last frame to finish scoping we need to trigger the final
1314 // update to be sent. 1322 // update to be sent.
1315 if (main_frame_impl->frames_scoping_count_ == 0) 1323 if (main_frame_impl->frames_scoping_count_ == 0)
1316 main_frame_impl->IncreaseMatchCount(0, request.identifier); 1324 main_frame_impl->IncreaseMatchCount(0, request_id);
1317 1325
1318 // This frame is done, so show any scrollbar tickmarks we haven't drawn yet. 1326 // This frame is done, so show any scrollbar tickmarks we haven't drawn yet.
1319 InvalidateArea(INVALIDATE_SCROLLBAR); 1327 InvalidateArea(INVALIDATE_SCROLLBAR);
1320
1321 return;
1322 } 1328 }
1323 1329
1324 void WebFrameImpl::CancelPendingScopingEffort() { 1330 void WebFrameImpl::CancelPendingScopingEffort() {
1325 scope_matches_factory_.RevokeAll(); 1331 scope_matches_factory_.RevokeAll();
1326 active_match_index_ = -1; 1332 active_match_index_ = -1;
1327 } 1333 }
1328 1334
1329 void WebFrameImpl::SetFindEndstateFocusAndSelection() { 1335 void WebFrameImpl::SetFindEndstateFocusAndSelection() {
1330 WebFrameImpl* main_frame_impl = 1336 WebFrameImpl* main_frame_impl =
1331 static_cast<WebFrameImpl*>(GetView()->GetMainFrame()); 1337 static_cast<WebFrameImpl*>(GetView()->GetMainFrame());
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 return password_listeners_.get(input_element); 1939 return password_listeners_.get(input_element);
1934 } 1940 }
1935 1941
1936 void WebFrameImpl::ClearPasswordListeners() { 1942 void WebFrameImpl::ClearPasswordListeners() {
1937 for (PasswordListenerMap::iterator iter = password_listeners_.begin(); 1943 for (PasswordListenerMap::iterator iter = password_listeners_.begin();
1938 iter != password_listeners_.end(); ++iter) { 1944 iter != password_listeners_.end(); ++iter) {
1939 delete iter->second; 1945 delete iter->second;
1940 } 1946 }
1941 password_listeners_.clear(); 1947 password_listeners_.clear();
1942 } 1948 }
OLDNEW
« no previous file with comments | « webkit/glue/webframe_impl.h ('k') | webkit/webkit.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698