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_widget.h" | 5 #include "content/renderer/render_widget.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/debug/trace_event_synthetic_delay.h" | 10 #include "base/debug/trace_event_synthetic_delay.h" |
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1492 | 1492 |
1493 // Check for whether we need to track swap buffers. We need to do that after | 1493 // Check for whether we need to track swap buffers. We need to do that after |
1494 // layout() because it may have switched us to accelerated compositing. | 1494 // layout() because it may have switched us to accelerated compositing. |
1495 if (is_accelerated_compositing_active_) | 1495 if (is_accelerated_compositing_active_) |
1496 using_asynchronous_swapbuffers_ = SupportsAsynchronousSwapBuffers(); | 1496 using_asynchronous_swapbuffers_ = SupportsAsynchronousSwapBuffers(); |
1497 | 1497 |
1498 // The following two can result in further layout and possibly | 1498 // The following two can result in further layout and possibly |
1499 // enable GPU acceleration so they need to be called before any painting | 1499 // enable GPU acceleration so they need to be called before any painting |
1500 // is done. | 1500 // is done. |
1501 UpdateTextInputType(); | 1501 UpdateTextInputType(); |
1502 UpdateSelectionRootBounds(); | |
1502 UpdateSelectionBounds(); | 1503 UpdateSelectionBounds(); |
1503 | 1504 |
1504 // Suppress painting if nothing is dirty. This has to be done after updating | 1505 // Suppress painting if nothing is dirty. This has to be done after updating |
1505 // animations running layout as these may generate further invalidations. | 1506 // animations running layout as these may generate further invalidations. |
1506 if (!paint_aggregator_.HasPendingUpdate()) { | 1507 if (!paint_aggregator_.HasPendingUpdate()) { |
1507 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate"); | 1508 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate"); |
1508 InstrumentDidCancelFrame(); | 1509 InstrumentDidCancelFrame(); |
1509 return; | 1510 return; |
1510 } | 1511 } |
1511 | 1512 |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1878 | 1879 |
1879 DCHECK(RenderThreadImpl::current()->compositor_message_loop_proxy().get()); | 1880 DCHECK(RenderThreadImpl::current()->compositor_message_loop_proxy().get()); |
1880 | 1881 |
1881 // The following two can result in further layout and possibly | 1882 // The following two can result in further layout and possibly |
1882 // enable GPU acceleration so they need to be called before any painting | 1883 // enable GPU acceleration so they need to be called before any painting |
1883 // is done. | 1884 // is done. |
1884 UpdateTextInputType(); | 1885 UpdateTextInputType(); |
1885 #if defined(OS_ANDROID) | 1886 #if defined(OS_ANDROID) |
1886 UpdateTextInputState(false, true); | 1887 UpdateTextInputState(false, true); |
1887 #endif | 1888 #endif |
1889 UpdateSelectionRootBounds(); | |
1888 UpdateSelectionBounds(); | 1890 UpdateSelectionBounds(); |
1889 } | 1891 } |
1890 | 1892 |
1891 void RenderWidget::didBecomeReadyForAdditionalInput() { | 1893 void RenderWidget::didBecomeReadyForAdditionalInput() { |
1892 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); | 1894 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); |
1893 FlushPendingInputEventAck(); | 1895 FlushPendingInputEventAck(); |
1894 } | 1896 } |
1895 | 1897 |
1896 void RenderWidget::DidCommitCompositorFrame() { | 1898 void RenderWidget::DidCommitCompositorFrame() { |
1897 FOR_EACH_OBSERVER(RenderFrameImpl, swapped_out_frames_, | 1899 FOR_EACH_OBSERVER(RenderFrameImpl, swapped_out_frames_, |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2380 DCHECK(!handling_ime_event_); | 2382 DCHECK(!handling_ime_event_); |
2381 handling_ime_event_ = true; | 2383 handling_ime_event_ = true; |
2382 } | 2384 } |
2383 | 2385 |
2384 void RenderWidget::FinishHandlingImeEvent() { | 2386 void RenderWidget::FinishHandlingImeEvent() { |
2385 DCHECK(handling_ime_event_); | 2387 DCHECK(handling_ime_event_); |
2386 handling_ime_event_ = false; | 2388 handling_ime_event_ = false; |
2387 // While handling an ime event, text input state and selection bounds updates | 2389 // While handling an ime event, text input state and selection bounds updates |
2388 // are ignored. These must explicitly be updated once finished handling the | 2390 // are ignored. These must explicitly be updated once finished handling the |
2389 // ime event. | 2391 // ime event. |
2392 UpdateSelectionRootBounds(); | |
timvolodine
2014/03/05 19:50:46
Should this be android-only? Not sure if the selec
mlamouri (slow - plz ping)
2014/03/10 15:56:45
I was considering making it Android only but I the
| |
2390 UpdateSelectionBounds(); | 2393 UpdateSelectionBounds(); |
2391 #if defined(OS_ANDROID) | 2394 #if defined(OS_ANDROID) |
2392 UpdateTextInputState(false, false); | 2395 UpdateTextInputState(false, false); |
2393 #endif | 2396 #endif |
2394 } | 2397 } |
2395 | 2398 |
2396 void RenderWidget::UpdateTextInputType() { | 2399 void RenderWidget::UpdateTextInputType() { |
2397 // On Windows, not only an IME but also an on-screen keyboard relies on the | 2400 // On Windows, not only an IME but also an on-screen keyboard relies on the |
2398 // latest TextInputType to optimize its layout and functionality. Thus | 2401 // latest TextInputType to optimize its layout and functionality. Thus |
2399 // |input_method_is_active_| is no longer an appropriate condition to suppress | 2402 // |input_method_is_active_| is no longer an appropriate condition to suppress |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2499 selection_focus_rect_ = params.focus_rect; | 2502 selection_focus_rect_ = params.focus_rect; |
2500 webwidget_->selectionTextDirection(params.focus_dir, params.anchor_dir); | 2503 webwidget_->selectionTextDirection(params.focus_dir, params.anchor_dir); |
2501 params.is_anchor_first = webwidget_->isSelectionAnchorFirst(); | 2504 params.is_anchor_first = webwidget_->isSelectionAnchorFirst(); |
2502 Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_, params)); | 2505 Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_, params)); |
2503 } | 2506 } |
2504 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) | 2507 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) |
2505 UpdateCompositionInfo(false); | 2508 UpdateCompositionInfo(false); |
2506 #endif | 2509 #endif |
2507 } | 2510 } |
2508 | 2511 |
2512 void RenderWidget::GetSelectionRootBounds(gfx::Rect* bounds) { | |
2513 WebRect bounds_webrect; | |
2514 webwidget_->selectionRootBounds(bounds_webrect); | |
2515 *bounds = bounds_webrect; | |
2516 } | |
2517 | |
2518 void RenderWidget::UpdateSelectionRootBounds() { | |
timvolodine
2014/03/05 19:50:46
I think we need a better name for "UpdateSelection
mlamouri (slow - plz ping)
2014/03/10 15:56:45
I would prefer to have the name reflecting what th
| |
2519 if (!webwidget_ || handling_ime_event_) { | |
2520 return; | |
2521 } | |
2522 | |
2523 gfx::Rect bounds; | |
2524 GetSelectionRootBounds(&bounds); | |
2525 if (selection_root_rect_ != bounds) { | |
2526 selection_root_rect_ = bounds; | |
2527 Send(new ViewHostMsg_SelectionRootBoundsChanged(routing_id_, bounds)); | |
2528 } | |
2529 } | |
2530 | |
2509 // Check blink::WebTextInputType and ui::TextInputType is kept in sync. | 2531 // Check blink::WebTextInputType and ui::TextInputType is kept in sync. |
2510 COMPILE_ASSERT(int(blink::WebTextInputTypeNone) == \ | 2532 COMPILE_ASSERT(int(blink::WebTextInputTypeNone) == \ |
2511 int(ui::TEXT_INPUT_TYPE_NONE), mismatching_enums); | 2533 int(ui::TEXT_INPUT_TYPE_NONE), mismatching_enums); |
2512 COMPILE_ASSERT(int(blink::WebTextInputTypeText) == \ | 2534 COMPILE_ASSERT(int(blink::WebTextInputTypeText) == \ |
2513 int(ui::TEXT_INPUT_TYPE_TEXT), mismatching_enums); | 2535 int(ui::TEXT_INPUT_TYPE_TEXT), mismatching_enums); |
2514 COMPILE_ASSERT(int(blink::WebTextInputTypePassword) == \ | 2536 COMPILE_ASSERT(int(blink::WebTextInputTypePassword) == \ |
2515 int(ui::TEXT_INPUT_TYPE_PASSWORD), mismatching_enums); | 2537 int(ui::TEXT_INPUT_TYPE_PASSWORD), mismatching_enums); |
2516 COMPILE_ASSERT(int(blink::WebTextInputTypeSearch) == \ | 2538 COMPILE_ASSERT(int(blink::WebTextInputTypeSearch) == \ |
2517 int(ui::TEXT_INPUT_TYPE_SEARCH), mismatching_enums); | 2539 int(ui::TEXT_INPUT_TYPE_SEARCH), mismatching_enums); |
2518 COMPILE_ASSERT(int(blink::WebTextInputTypeEmail) == \ | 2540 COMPILE_ASSERT(int(blink::WebTextInputTypeEmail) == \ |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2784 | 2806 |
2785 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { | 2807 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { |
2786 swapped_out_frames_.AddObserver(frame); | 2808 swapped_out_frames_.AddObserver(frame); |
2787 } | 2809 } |
2788 | 2810 |
2789 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { | 2811 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { |
2790 swapped_out_frames_.RemoveObserver(frame); | 2812 swapped_out_frames_.RemoveObserver(frame); |
2791 } | 2813 } |
2792 | 2814 |
2793 } // namespace content | 2815 } // namespace content |
OLD | NEW |