| OLD | NEW |
| 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 "content/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 #include "third_party/WebKit/public/web/WebAXObject.h" | 128 #include "third_party/WebKit/public/web/WebAXObject.h" |
| 129 #include "third_party/WebKit/public/web/WebColorSuggestion.h" | 129 #include "third_party/WebKit/public/web/WebColorSuggestion.h" |
| 130 #include "third_party/WebKit/public/web/WebDOMEvent.h" | 130 #include "third_party/WebKit/public/web/WebDOMEvent.h" |
| 131 #include "third_party/WebKit/public/web/WebDOMMessageEvent.h" | 131 #include "third_party/WebKit/public/web/WebDOMMessageEvent.h" |
| 132 #include "third_party/WebKit/public/web/WebDataSource.h" | 132 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 133 #include "third_party/WebKit/public/web/WebDateTimeChooserCompletion.h" | 133 #include "third_party/WebKit/public/web/WebDateTimeChooserCompletion.h" |
| 134 #include "third_party/WebKit/public/web/WebDateTimeChooserParams.h" | 134 #include "third_party/WebKit/public/web/WebDateTimeChooserParams.h" |
| 135 #include "third_party/WebKit/public/web/WebDocument.h" | 135 #include "third_party/WebKit/public/web/WebDocument.h" |
| 136 #include "third_party/WebKit/public/web/WebElement.h" | 136 #include "third_party/WebKit/public/web/WebElement.h" |
| 137 #include "third_party/WebKit/public/web/WebFileChooserParams.h" | 137 #include "third_party/WebKit/public/web/WebFileChooserParams.h" |
| 138 #include "third_party/WebKit/public/web/WebFindOptions.h" | |
| 139 #include "third_party/WebKit/public/web/WebFormControlElement.h" | 138 #include "third_party/WebKit/public/web/WebFormControlElement.h" |
| 140 #include "third_party/WebKit/public/web/WebFormElement.h" | 139 #include "third_party/WebKit/public/web/WebFormElement.h" |
| 141 #include "third_party/WebKit/public/web/WebFrame.h" | 140 #include "third_party/WebKit/public/web/WebFrame.h" |
| 142 #include "third_party/WebKit/public/web/WebHistoryItem.h" | 141 #include "third_party/WebKit/public/web/WebHistoryItem.h" |
| 143 #include "third_party/WebKit/public/web/WebHitTestResult.h" | 142 #include "third_party/WebKit/public/web/WebHitTestResult.h" |
| 144 #include "third_party/WebKit/public/web/WebInputElement.h" | 143 #include "third_party/WebKit/public/web/WebInputElement.h" |
| 145 #include "third_party/WebKit/public/web/WebInputEvent.h" | 144 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 146 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 145 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 147 #include "third_party/WebKit/public/web/WebMediaPlayerAction.h" | 146 #include "third_party/WebKit/public/web/WebMediaPlayerAction.h" |
| 148 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" | 147 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" |
| 149 #include "third_party/WebKit/public/web/WebPageImportanceSignals.h" | 148 #include "third_party/WebKit/public/web/WebPageImportanceSignals.h" |
| 150 #include "third_party/WebKit/public/web/WebPlugin.h" | 149 #include "third_party/WebKit/public/web/WebPlugin.h" |
| 151 #include "third_party/WebKit/public/web/WebPluginAction.h" | 150 #include "third_party/WebKit/public/web/WebPluginAction.h" |
| 152 #include "third_party/WebKit/public/web/WebPluginContainer.h" | |
| 153 #include "third_party/WebKit/public/web/WebPluginDocument.h" | |
| 154 #include "third_party/WebKit/public/web/WebRange.h" | 151 #include "third_party/WebKit/public/web/WebRange.h" |
| 155 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 152 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 156 #include "third_party/WebKit/public/web/WebScriptSource.h" | 153 #include "third_party/WebKit/public/web/WebScriptSource.h" |
| 157 #include "third_party/WebKit/public/web/WebSearchableFormData.h" | 154 #include "third_party/WebKit/public/web/WebSearchableFormData.h" |
| 158 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 155 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| 159 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 156 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
| 160 #include "third_party/WebKit/public/web/WebSettings.h" | 157 #include "third_party/WebKit/public/web/WebSettings.h" |
| 161 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 158 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
| 162 #include "third_party/WebKit/public/web/WebView.h" | 159 #include "third_party/WebKit/public/web/WebView.h" |
| 163 #include "third_party/WebKit/public/web/WebWindowFeatures.h" | 160 #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 174 #include "ui/gfx/native_widget_types.h" | 171 #include "ui/gfx/native_widget_types.h" |
| 175 #include "v8/include/v8.h" | 172 #include "v8/include/v8.h" |
| 176 | 173 |
| 177 #if defined(OS_ANDROID) | 174 #if defined(OS_ANDROID) |
| 178 #include <cpu-features.h> | 175 #include <cpu-features.h> |
| 179 | 176 |
| 180 #include "content/renderer/android/address_detector.h" | 177 #include "content/renderer/android/address_detector.h" |
| 181 #include "content/renderer/android/content_detector.h" | 178 #include "content/renderer/android/content_detector.h" |
| 182 #include "content/renderer/android/email_detector.h" | 179 #include "content/renderer/android/email_detector.h" |
| 183 #include "content/renderer/android/phone_number_detector.h" | 180 #include "content/renderer/android/phone_number_detector.h" |
| 184 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | |
| 185 #include "third_party/WebKit/public/platform/WebFloatRect.h" | |
| 186 #include "ui/gfx/geometry/rect_f.h" | 181 #include "ui/gfx/geometry/rect_f.h" |
| 187 | 182 |
| 188 #elif defined(OS_WIN) | 183 #elif defined(OS_WIN) |
| 189 // TODO(port): these files are currently Windows only because they concern: | 184 // TODO(port): these files are currently Windows only because they concern: |
| 190 // * theming | 185 // * theming |
| 191 #include "ui/native_theme/native_theme_win.h" | 186 #include "ui/native_theme/native_theme_win.h" |
| 192 #elif defined(USE_X11) | 187 #elif defined(USE_X11) |
| 193 #include "ui/native_theme/native_theme.h" | 188 #include "ui/native_theme/native_theme.h" |
| 194 #elif defined(OS_MACOSX) | 189 #elif defined(OS_MACOSX) |
| 195 #include "skia/ext/skia_utils_mac.h" | 190 #include "skia/ext/skia_utils_mac.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 213 using blink::WebColor; | 208 using blink::WebColor; |
| 214 using blink::WebConsoleMessage; | 209 using blink::WebConsoleMessage; |
| 215 using blink::WebData; | 210 using blink::WebData; |
| 216 using blink::WebDataSource; | 211 using blink::WebDataSource; |
| 217 using blink::WebDocument; | 212 using blink::WebDocument; |
| 218 using blink::WebDragData; | 213 using blink::WebDragData; |
| 219 using blink::WebDragOperation; | 214 using blink::WebDragOperation; |
| 220 using blink::WebDragOperationsMask; | 215 using blink::WebDragOperationsMask; |
| 221 using blink::WebElement; | 216 using blink::WebElement; |
| 222 using blink::WebFileChooserCompletion; | 217 using blink::WebFileChooserCompletion; |
| 223 using blink::WebFindOptions; | |
| 224 using blink::WebFormControlElement; | 218 using blink::WebFormControlElement; |
| 225 using blink::WebFormElement; | 219 using blink::WebFormElement; |
| 226 using blink::WebFrame; | 220 using blink::WebFrame; |
| 227 using blink::WebGestureEvent; | 221 using blink::WebGestureEvent; |
| 228 using blink::WebHistoryItem; | 222 using blink::WebHistoryItem; |
| 229 using blink::WebHTTPBody; | 223 using blink::WebHTTPBody; |
| 230 using blink::WebIconURL; | 224 using blink::WebIconURL; |
| 231 using blink::WebImage; | 225 using blink::WebImage; |
| 232 using blink::WebInputElement; | 226 using blink::WebInputElement; |
| 233 using blink::WebInputEvent; | 227 using blink::WebInputEvent; |
| 234 using blink::WebLocalFrame; | 228 using blink::WebLocalFrame; |
| 235 using blink::WebMediaPlayerAction; | 229 using blink::WebMediaPlayerAction; |
| 236 using blink::WebMouseEvent; | 230 using blink::WebMouseEvent; |
| 237 using blink::WebNavigationPolicy; | 231 using blink::WebNavigationPolicy; |
| 238 using blink::WebNavigationType; | 232 using blink::WebNavigationType; |
| 239 using blink::WebNode; | 233 using blink::WebNode; |
| 240 using blink::WebPeerConnection00Handler; | 234 using blink::WebPeerConnection00Handler; |
| 241 using blink::WebPeerConnection00HandlerClient; | 235 using blink::WebPeerConnection00HandlerClient; |
| 242 using blink::WebPeerConnectionHandler; | 236 using blink::WebPeerConnectionHandler; |
| 243 using blink::WebPeerConnectionHandlerClient; | 237 using blink::WebPeerConnectionHandlerClient; |
| 244 using blink::WebPluginAction; | 238 using blink::WebPluginAction; |
| 245 using blink::WebPluginContainer; | |
| 246 using blink::WebPluginDocument; | |
| 247 using blink::WebPoint; | 239 using blink::WebPoint; |
| 248 using blink::WebRange; | 240 using blink::WebRange; |
| 249 using blink::WebRect; | 241 using blink::WebRect; |
| 250 using blink::WebReferrerPolicy; | 242 using blink::WebReferrerPolicy; |
| 251 using blink::WebScriptSource; | 243 using blink::WebScriptSource; |
| 252 using blink::WebSearchableFormData; | 244 using blink::WebSearchableFormData; |
| 253 using blink::WebSecurityOrigin; | 245 using blink::WebSecurityOrigin; |
| 254 using blink::WebSecurityPolicy; | 246 using blink::WebSecurityPolicy; |
| 255 using blink::WebSettings; | 247 using blink::WebSettings; |
| 256 using blink::WebSize; | 248 using blink::WebSize; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 269 using blink::WebVector; | 261 using blink::WebVector; |
| 270 using blink::WebView; | 262 using blink::WebView; |
| 271 using blink::WebWidget; | 263 using blink::WebWidget; |
| 272 using blink::WebWindowFeatures; | 264 using blink::WebWindowFeatures; |
| 273 using blink::WebRuntimeFeatures; | 265 using blink::WebRuntimeFeatures; |
| 274 using base::Time; | 266 using base::Time; |
| 275 using base::TimeDelta; | 267 using base::TimeDelta; |
| 276 | 268 |
| 277 #if defined(OS_ANDROID) | 269 #if defined(OS_ANDROID) |
| 278 using blink::WebContentDetectionResult; | 270 using blink::WebContentDetectionResult; |
| 279 using blink::WebFloatPoint; | |
| 280 using blink::WebFloatRect; | |
| 281 using blink::WebHitTestResult; | 271 using blink::WebHitTestResult; |
| 282 #endif | 272 #endif |
| 283 | 273 |
| 284 namespace content { | 274 namespace content { |
| 285 | 275 |
| 286 //----------------------------------------------------------------------------- | 276 //----------------------------------------------------------------------------- |
| 287 | 277 |
| 288 typedef std::map<blink::WebView*, RenderViewImpl*> ViewMap; | 278 typedef std::map<blink::WebView*, RenderViewImpl*> ViewMap; |
| 289 static base::LazyInstance<ViewMap> g_view_map = LAZY_INSTANCE_INITIALIZER; | 279 static base::LazyInstance<ViewMap> g_view_map = LAZY_INSTANCE_INITIALIZER; |
| 290 typedef std::map<int32_t, RenderViewImpl*> RoutingIDViewMap; | 280 typedef std::map<int32_t, RenderViewImpl*> RoutingIDViewMap; |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 frame_widget_(nullptr), | 627 frame_widget_(nullptr), |
| 638 speech_recognition_dispatcher_(NULL), | 628 speech_recognition_dispatcher_(NULL), |
| 639 mouse_lock_dispatcher_(NULL), | 629 mouse_lock_dispatcher_(NULL), |
| 640 #if defined(OS_ANDROID) | 630 #if defined(OS_ANDROID) |
| 641 expected_content_intent_id_(0), | 631 expected_content_intent_id_(0), |
| 642 #endif | 632 #endif |
| 643 #if defined(OS_WIN) | 633 #if defined(OS_WIN) |
| 644 focused_plugin_id_(-1), | 634 focused_plugin_id_(-1), |
| 645 #endif | 635 #endif |
| 646 #if defined(ENABLE_PLUGINS) | 636 #if defined(ENABLE_PLUGINS) |
| 647 plugin_find_handler_(NULL), | |
| 648 focused_pepper_plugin_(NULL), | 637 focused_pepper_plugin_(NULL), |
| 649 pepper_last_mouse_event_target_(NULL), | 638 pepper_last_mouse_event_target_(NULL), |
| 650 #endif | 639 #endif |
| 651 enumeration_completion_id_(0), | 640 enumeration_completion_id_(0), |
| 652 session_storage_namespace_id_(params.session_storage_namespace_id) { | 641 session_storage_namespace_id_(params.session_storage_namespace_id) { |
| 653 } | 642 } |
| 654 | 643 |
| 655 void RenderViewImpl::Initialize(const ViewMsg_New_Params& params, | 644 void RenderViewImpl::Initialize(const ViewMsg_New_Params& params, |
| 656 bool was_created_by_renderer) { | 645 bool was_created_by_renderer) { |
| 657 SetRoutingID(params.view_id); | 646 SetRoutingID(params.view_id); |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 bool handled = true; | 1309 bool handled = true; |
| 1321 IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message) | 1310 IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message) |
| 1322 IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand) | 1311 IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand) |
| 1323 IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret) | 1312 IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret) |
| 1324 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, | 1313 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, |
| 1325 OnScrollFocusedEditableNodeIntoRect) | 1314 OnScrollFocusedEditableNodeIntoRect) |
| 1326 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, | 1315 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, |
| 1327 OnSetEditCommandsForNextKeyEvent) | 1316 OnSetEditCommandsForNextKeyEvent) |
| 1328 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) | 1317 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
| 1329 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt) | 1318 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt) |
| 1330 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) | |
| 1331 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) | |
| 1332 IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale) | 1319 IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale) |
| 1333 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) | 1320 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
| 1334 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, | 1321 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
| 1335 OnSetZoomLevelForLoadingURL) | 1322 OnSetZoomLevelForLoadingURL) |
| 1336 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForView, | 1323 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForView, |
| 1337 OnSetZoomLevelForView) | 1324 OnSetZoomLevelForView) |
| 1338 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) | 1325 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) |
| 1339 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, | 1326 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, |
| 1340 OnResetPageEncodingToDefault) | 1327 OnResetPageEncodingToDefault) |
| 1341 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) | 1328 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1372 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) | 1359 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) |
| 1373 // TODO(viettrungluu): Move to a separate message filter. | 1360 // TODO(viettrungluu): Move to a separate message filter. |
| 1374 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryOffsetAndLength, | 1361 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryOffsetAndLength, |
| 1375 OnSetHistoryOffsetAndLength) | 1362 OnSetHistoryOffsetAndLength) |
| 1376 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 1363 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
| 1377 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, | 1364 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, |
| 1378 OnReleaseDisambiguationPopupBitmap) | 1365 OnReleaseDisambiguationPopupBitmap) |
| 1379 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) | 1366 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) |
| 1380 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) | 1367 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) |
| 1381 #if defined(OS_ANDROID) | 1368 #if defined(OS_ANDROID) |
| 1382 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, | |
| 1383 OnActivateNearestFindResult) | |
| 1384 IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects) | |
| 1385 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, | 1369 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, |
| 1386 OnUpdateTopControlsState) | 1370 OnUpdateTopControlsState) |
| 1387 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) | 1371 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) |
| 1388 #elif defined(OS_MACOSX) | 1372 #elif defined(OS_MACOSX) |
| 1389 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText, | 1373 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText, |
| 1390 OnGetRenderedText) | 1374 OnGetRenderedText) |
| 1391 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted, | 1375 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted, |
| 1392 OnPluginImeCompositionCompleted) | 1376 OnPluginImeCompositionCompleted) |
| 1393 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) | 1377 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) |
| 1394 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) | 1378 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
| (...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2208 | 2192 |
| 2209 gfx::Size size = webview()->contentsPreferredMinimumSize(); | 2193 gfx::Size size = webview()->contentsPreferredMinimumSize(); |
| 2210 if (size == preferred_size_) | 2194 if (size == preferred_size_) |
| 2211 return; | 2195 return; |
| 2212 | 2196 |
| 2213 preferred_size_ = size; | 2197 preferred_size_ = size; |
| 2214 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id(), | 2198 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id(), |
| 2215 preferred_size_)); | 2199 preferred_size_)); |
| 2216 } | 2200 } |
| 2217 | 2201 |
| 2218 void RenderViewImpl::SendFindReply(int request_id, | |
| 2219 int match_count, | |
| 2220 int ordinal, | |
| 2221 const WebRect& selection_rect, | |
| 2222 bool final_status_update) { | |
| 2223 Send(new ViewHostMsg_Find_Reply(routing_id(), request_id, match_count, | |
| 2224 selection_rect, ordinal, | |
| 2225 final_status_update)); | |
| 2226 } | |
| 2227 | |
| 2228 blink::WebString RenderViewImpl::acceptLanguages() { | 2202 blink::WebString RenderViewImpl::acceptLanguages() { |
| 2229 return WebString::fromUTF8(renderer_preferences_.accept_languages); | 2203 return WebString::fromUTF8(renderer_preferences_.accept_languages); |
| 2230 } | 2204 } |
| 2231 | 2205 |
| 2232 // RenderView implementation --------------------------------------------------- | 2206 // RenderView implementation --------------------------------------------------- |
| 2233 | 2207 |
| 2234 bool RenderViewImpl::Send(IPC::Message* message) { | 2208 bool RenderViewImpl::Send(IPC::Message* message) { |
| 2235 return RenderWidget::Send(message); | 2209 return RenderWidget::Send(message); |
| 2236 } | 2210 } |
| 2237 | 2211 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2295 WebFrame* focused_frame = webview()->focusedFrame(); | 2269 WebFrame* focused_frame = webview()->focusedFrame(); |
| 2296 if (focused_frame) { | 2270 if (focused_frame) { |
| 2297 WebDocument doc = focused_frame->document(); | 2271 WebDocument doc = focused_frame->document(); |
| 2298 if (!doc.isNull()) | 2272 if (!doc.isNull()) |
| 2299 return doc.focusedElement(); | 2273 return doc.focusedElement(); |
| 2300 } | 2274 } |
| 2301 | 2275 |
| 2302 return WebElement(); | 2276 return WebElement(); |
| 2303 } | 2277 } |
| 2304 | 2278 |
| 2305 blink::WebPlugin* RenderViewImpl::GetWebPluginForFind() { | |
| 2306 if (!webview()) | |
| 2307 return NULL; | |
| 2308 | |
| 2309 WebFrame* main_frame = webview()->mainFrame(); | |
| 2310 if (main_frame->isWebLocalFrame() && | |
| 2311 main_frame->document().isPluginDocument()) | |
| 2312 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); | |
| 2313 | |
| 2314 #if defined(ENABLE_PLUGINS) | |
| 2315 if (plugin_find_handler_) | |
| 2316 return plugin_find_handler_->container()->plugin(); | |
| 2317 #endif | |
| 2318 | |
| 2319 return NULL; | |
| 2320 } | |
| 2321 | |
| 2322 void RenderViewImpl::OnFind(int request_id, | |
| 2323 const base::string16& search_text, | |
| 2324 const WebFindOptions& options) { | |
| 2325 DCHECK(!search_text.empty()); | |
| 2326 | |
| 2327 WebFrame* main_frame = webview()->mainFrame(); | |
| 2328 blink::WebPlugin* plugin = GetWebPluginForFind(); | |
| 2329 // Check if the plugin still exists in the document. | |
| 2330 if (plugin) { | |
| 2331 if (options.findNext) { | |
| 2332 // Just navigate back/forward. | |
| 2333 plugin->selectFindResult(options.forward); | |
| 2334 } else { | |
| 2335 if (!plugin->startFind( | |
| 2336 search_text, options.matchCase, request_id)) { | |
| 2337 // Send "no results". | |
| 2338 SendFindReply(request_id, 0, 0, gfx::Rect(), true); | |
| 2339 } | |
| 2340 } | |
| 2341 return; | |
| 2342 } | |
| 2343 | |
| 2344 WebFrame* frame_after_main = main_frame->traverseNext(true); | |
| 2345 WebFrame* focused_frame = webview()->focusedFrame(); | |
| 2346 WebFrame* search_frame = focused_frame; // start searching focused frame. | |
| 2347 | |
| 2348 bool multi_frame = (frame_after_main != main_frame); | |
| 2349 | |
| 2350 // If we have multiple frames, we don't want to wrap the search within the | |
| 2351 // frame, so we check here if we only have main_frame in the chain. | |
| 2352 bool wrap_within_frame = !multi_frame; | |
| 2353 | |
| 2354 WebRect selection_rect; | |
| 2355 bool result = false; | |
| 2356 | |
| 2357 // If something is selected when we start searching it means we cannot just | |
| 2358 // increment the current match ordinal; we need to re-generate it. | |
| 2359 WebRange current_selection = focused_frame->selectionRange(); | |
| 2360 | |
| 2361 do { | |
| 2362 result = search_frame->find( | |
| 2363 request_id, search_text, options, wrap_within_frame, &selection_rect); | |
| 2364 | |
| 2365 if (!result) { | |
| 2366 // don't leave text selected as you move to the next frame. | |
| 2367 search_frame->executeCommand(WebString::fromUTF8("Unselect"), | |
| 2368 GetFocusedElement()); | |
| 2369 | |
| 2370 // Find the next frame, but skip the invisible ones. | |
| 2371 do { | |
| 2372 // What is the next frame to search? (we might be going backwards). Note | |
| 2373 // that we specify wrap=true so that search_frame never becomes NULL. | |
| 2374 search_frame = options.forward ? | |
| 2375 search_frame->traverseNext(true) : | |
| 2376 search_frame->traversePrevious(true); | |
| 2377 } while (!search_frame->hasVisibleContent() && | |
| 2378 search_frame != focused_frame); | |
| 2379 | |
| 2380 // Make sure selection doesn't affect the search operation in new frame. | |
| 2381 search_frame->executeCommand(WebString::fromUTF8("Unselect"), | |
| 2382 GetFocusedElement()); | |
| 2383 | |
| 2384 // If we have multiple frames and we have wrapped back around to the | |
| 2385 // focused frame, we need to search it once more allowing wrap within | |
| 2386 // the frame, otherwise it will report 'no match' if the focused frame has | |
| 2387 // reported matches, but no frames after the focused_frame contain a | |
| 2388 // match for the search word(s). | |
| 2389 if (multi_frame && search_frame == focused_frame) { | |
| 2390 result = search_frame->find( | |
| 2391 request_id, search_text, options, true, // Force wrapping. | |
| 2392 &selection_rect); | |
| 2393 } | |
| 2394 } | |
| 2395 | |
| 2396 webview()->setFocusedFrame(search_frame); | |
| 2397 } while (!result && search_frame != focused_frame); | |
| 2398 | |
| 2399 if (options.findNext && current_selection.isNull()) { | |
| 2400 // Force the main_frame to report the actual count. | |
| 2401 main_frame->increaseMatchCount(0, request_id); | |
| 2402 } else { | |
| 2403 // If nothing is found, set result to "0 of 0", otherwise, set it to | |
| 2404 // "-1 of 1" to indicate that we found at least one item, but we don't know | |
| 2405 // yet what is active. | |
| 2406 int ordinal = result ? -1 : 0; // -1 here means, we might know more later. | |
| 2407 int match_count = result ? 1 : 0; // 1 here means possibly more coming. | |
| 2408 | |
| 2409 // If we find no matches then this will be our last status update. | |
| 2410 // Otherwise the scoping effort will send more results. | |
| 2411 bool final_status_update = !result; | |
| 2412 | |
| 2413 SendFindReply(request_id, match_count, ordinal, selection_rect, | |
| 2414 final_status_update); | |
| 2415 | |
| 2416 // Scoping effort begins, starting with the mainframe. | |
| 2417 search_frame = main_frame; | |
| 2418 | |
| 2419 main_frame->resetMatchCount(); | |
| 2420 | |
| 2421 do { | |
| 2422 // Cancel all old scoping requests before starting a new one. | |
| 2423 search_frame->cancelPendingScopingEffort(); | |
| 2424 | |
| 2425 // We don't start another scoping effort unless at least one match has | |
| 2426 // been found. | |
| 2427 if (result) { | |
| 2428 // Start new scoping request. If the scoping function determines that it | |
| 2429 // needs to scope, it will defer until later. | |
| 2430 search_frame->scopeStringMatches(request_id, | |
| 2431 search_text, | |
| 2432 options, | |
| 2433 true); // reset the tickmarks | |
| 2434 } | |
| 2435 | |
| 2436 // Iterate to the next frame. The frame will not necessarily scope, for | |
| 2437 // example if it is not visible. | |
| 2438 search_frame = search_frame->traverseNext(true); | |
| 2439 } while (search_frame != main_frame); | |
| 2440 } | |
| 2441 } | |
| 2442 | |
| 2443 void RenderViewImpl::OnStopFinding(StopFindAction action) { | |
| 2444 WebView* view = webview(); | |
| 2445 if (!view) | |
| 2446 return; | |
| 2447 | |
| 2448 blink::WebPlugin* plugin = GetWebPluginForFind(); | |
| 2449 if (plugin) { | |
| 2450 plugin->stopFind(); | |
| 2451 return; | |
| 2452 } | |
| 2453 | |
| 2454 bool clear_selection = action == STOP_FIND_ACTION_CLEAR_SELECTION; | |
| 2455 if (clear_selection) { | |
| 2456 view->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect"), | |
| 2457 GetFocusedElement()); | |
| 2458 } | |
| 2459 | |
| 2460 WebFrame* frame = view->mainFrame(); | |
| 2461 while (frame) { | |
| 2462 frame->stopFinding(clear_selection); | |
| 2463 frame = frame->traverseNext(false); | |
| 2464 } | |
| 2465 | |
| 2466 if (action == STOP_FIND_ACTION_ACTIVATE_SELECTION) { | |
| 2467 WebFrame* focused_frame = view->focusedFrame(); | |
| 2468 if (focused_frame) { | |
| 2469 WebDocument doc = focused_frame->document(); | |
| 2470 if (!doc.isNull()) { | |
| 2471 WebElement element = doc.focusedElement(); | |
| 2472 if (!element.isNull()) | |
| 2473 element.simulateClick(); | |
| 2474 } | |
| 2475 } | |
| 2476 } | |
| 2477 } | |
| 2478 | |
| 2479 #if defined(OS_ANDROID) | |
| 2480 void RenderViewImpl::OnActivateNearestFindResult(int request_id, | |
| 2481 float x, float y) { | |
| 2482 if (!webview()) | |
| 2483 return; | |
| 2484 | |
| 2485 WebFrame* main_frame = webview()->mainFrame(); | |
| 2486 WebRect selection_rect; | |
| 2487 int ordinal = main_frame->selectNearestFindMatch(WebFloatPoint(x, y), | |
| 2488 &selection_rect); | |
| 2489 if (ordinal == -1) { | |
| 2490 // Something went wrong, so send a no-op reply (force the main_frame to | |
| 2491 // report the current match count) in case the host is waiting for a | |
| 2492 // response due to rate-limiting). | |
| 2493 main_frame->increaseMatchCount(0, request_id); | |
| 2494 return; | |
| 2495 } | |
| 2496 | |
| 2497 SendFindReply(request_id, | |
| 2498 -1 /* number_of_matches */, | |
| 2499 ordinal, | |
| 2500 selection_rect, | |
| 2501 true /* final_update */); | |
| 2502 } | |
| 2503 | |
| 2504 void RenderViewImpl::OnFindMatchRects(int current_version) { | |
| 2505 if (!webview()) | |
| 2506 return; | |
| 2507 | |
| 2508 WebFrame* main_frame = webview()->mainFrame(); | |
| 2509 std::vector<gfx::RectF> match_rects; | |
| 2510 | |
| 2511 int rects_version = main_frame->findMatchMarkersVersion(); | |
| 2512 if (current_version != rects_version) { | |
| 2513 WebVector<WebFloatRect> web_match_rects; | |
| 2514 main_frame->findMatchRects(web_match_rects); | |
| 2515 match_rects.reserve(web_match_rects.size()); | |
| 2516 for (size_t i = 0; i < web_match_rects.size(); ++i) | |
| 2517 match_rects.push_back(gfx::RectF(web_match_rects[i])); | |
| 2518 } | |
| 2519 | |
| 2520 gfx::RectF active_rect = main_frame->activeFindMatchRect(); | |
| 2521 Send(new ViewHostMsg_FindMatchRects_Reply(routing_id(), rects_version, | |
| 2522 match_rects, active_rect)); | |
| 2523 } | |
| 2524 #endif | |
| 2525 | |
| 2526 void RenderViewImpl::OnSetPageScale(float page_scale_factor) { | 2279 void RenderViewImpl::OnSetPageScale(float page_scale_factor) { |
| 2527 if (!webview()) | 2280 if (!webview()) |
| 2528 return; | 2281 return; |
| 2529 webview()->setPageScaleFactor(page_scale_factor); | 2282 webview()->setPageScaleFactor(page_scale_factor); |
| 2530 } | 2283 } |
| 2531 | 2284 |
| 2532 void RenderViewImpl::OnZoom(PageZoom zoom) { | 2285 void RenderViewImpl::OnZoom(PageZoom zoom) { |
| 2533 if (!webview()) // Not sure if this can happen, but no harm in being safe. | 2286 if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| 2534 return; | 2287 return; |
| 2535 | 2288 |
| (...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3721 if (IsUseZoomForDSFEnabled()) { | 3474 if (IsUseZoomForDSFEnabled()) { |
| 3722 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); | 3475 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); |
| 3723 } else { | 3476 } else { |
| 3724 webview()->setDeviceScaleFactor(device_scale_factor_); | 3477 webview()->setDeviceScaleFactor(device_scale_factor_); |
| 3725 } | 3478 } |
| 3726 webview()->settings()->setPreferCompositingToLCDTextEnabled( | 3479 webview()->settings()->setPreferCompositingToLCDTextEnabled( |
| 3727 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); | 3480 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
| 3728 } | 3481 } |
| 3729 | 3482 |
| 3730 } // namespace content | 3483 } // namespace content |
| OLD | NEW |