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 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1399 } | 1399 } |
1400 | 1400 |
1401 void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( | 1401 void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( |
1402 const gfx::Rect& rect) { | 1402 const gfx::Rect& rect) { |
1403 if (has_scrolled_focused_editable_node_into_rect_ && | 1403 if (has_scrolled_focused_editable_node_into_rect_ && |
1404 rect == rect_for_scrolled_focused_editable_node_) { | 1404 rect == rect_for_scrolled_focused_editable_node_) { |
1405 GetWidget()->FocusChangeComplete(); | 1405 GetWidget()->FocusChangeComplete(); |
1406 return; | 1406 return; |
1407 } | 1407 } |
1408 | 1408 |
1409 blink::WebElement element = GetFocusedElement(); | 1409 if (!webview()->scrollFocusedEditableElementIntoRect(rect)) |
1410 bool will_animate = false; | 1410 return; |
1411 if (!element.isNull() && element.isEditable()) { | |
1412 rect_for_scrolled_focused_editable_node_ = rect; | |
1413 has_scrolled_focused_editable_node_into_rect_ = true; | |
1414 will_animate = webview()->scrollFocusedNodeIntoRect(rect); | |
1415 } | |
1416 | 1411 |
1417 if (!will_animate) | 1412 rect_for_scrolled_focused_editable_node_ = rect; |
| 1413 has_scrolled_focused_editable_node_into_rect_ = true; |
| 1414 if (!compositor()->hasPendingPageScaleAnimation()) |
1418 GetWidget()->FocusChangeComplete(); | 1415 GetWidget()->FocusChangeComplete(); |
1419 } | 1416 } |
1420 | 1417 |
1421 void RenderViewImpl::OnSetEditCommandsForNextKeyEvent( | 1418 void RenderViewImpl::OnSetEditCommandsForNextKeyEvent( |
1422 const EditCommands& edit_commands) { | 1419 const EditCommands& edit_commands) { |
1423 edit_commands_ = edit_commands; | 1420 edit_commands_ = edit_commands; |
1424 } | 1421 } |
1425 | 1422 |
1426 void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset, | 1423 void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset, |
1427 int history_length) { | 1424 int history_length) { |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2316 } | 2313 } |
2317 | 2314 |
2318 void RenderViewImpl::DidStartLoading() { | 2315 void RenderViewImpl::DidStartLoading() { |
2319 main_render_frame_->didStartLoading(true); | 2316 main_render_frame_->didStartLoading(true); |
2320 } | 2317 } |
2321 | 2318 |
2322 void RenderViewImpl::DidStopLoading() { | 2319 void RenderViewImpl::DidStopLoading() { |
2323 main_render_frame_->didStopLoading(); | 2320 main_render_frame_->didStopLoading(); |
2324 } | 2321 } |
2325 | 2322 |
2326 blink::WebElement RenderViewImpl::GetFocusedElement() const { | |
2327 if (!webview()) | |
2328 return WebElement(); | |
2329 WebFrame* focused_frame = webview()->focusedFrame(); | |
2330 if (focused_frame) { | |
2331 WebDocument doc = focused_frame->document(); | |
2332 if (!doc.isNull()) | |
2333 return doc.focusedElement(); | |
2334 } | |
2335 | |
2336 return WebElement(); | |
2337 } | |
2338 | |
2339 void RenderViewImpl::OnSetPageScale(float page_scale_factor) { | 2323 void RenderViewImpl::OnSetPageScale(float page_scale_factor) { |
2340 if (!webview()) | 2324 if (!webview()) |
2341 return; | 2325 return; |
2342 webview()->setPageScaleFactor(page_scale_factor); | 2326 webview()->setPageScaleFactor(page_scale_factor); |
2343 } | 2327 } |
2344 | 2328 |
2345 void RenderViewImpl::OnZoom(PageZoom zoom) { | 2329 void RenderViewImpl::OnZoom(PageZoom zoom) { |
2346 if (!webview()) // Not sure if this can happen, but no harm in being safe. | 2330 if (!webview()) // Not sure if this can happen, but no harm in being safe. |
2347 return; | 2331 return; |
2348 | 2332 |
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3385 return render_frame->focused_pepper_plugin(); | 3369 return render_frame->focused_pepper_plugin(); |
3386 } | 3370 } |
3387 frame = frame->traverseNext(false); | 3371 frame = frame->traverseNext(false); |
3388 } | 3372 } |
3389 | 3373 |
3390 return nullptr; | 3374 return nullptr; |
3391 } | 3375 } |
3392 #endif | 3376 #endif |
3393 | 3377 |
3394 } // namespace content | 3378 } // namespace content |
OLD | NEW |