| 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/browser/renderer_host/render_widget_host_view_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 6 | 6 |
| 7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 // Do nothing. The UI notification is handled through ContentViewClient which | 504 // Do nothing. The UI notification is handled through ContentViewClient which |
| 505 // is TabContentsDelegate. | 505 // is TabContentsDelegate. |
| 506 } | 506 } |
| 507 | 507 |
| 508 long RenderWidgetHostViewAndroid::GetNativeImeAdapter() { | 508 long RenderWidgetHostViewAndroid::GetNativeImeAdapter() { |
| 509 return reinterpret_cast<intptr_t>(&ime_adapter_android_); | 509 return reinterpret_cast<intptr_t>(&ime_adapter_android_); |
| 510 } | 510 } |
| 511 | 511 |
| 512 void RenderWidgetHostViewAndroid::TextInputStateChanged( | 512 void RenderWidgetHostViewAndroid::TextInputStateChanged( |
| 513 const ViewHostMsg_TextInputState_Params& params) { | 513 const ViewHostMsg_TextInputState_Params& params) { |
| 514 if (selection_controller_) { |
| 515 // This call is semi-redundant with that in |OnFocusedNodeChanged|. The |
| 516 // latter is guaranteed to be called before |OnSelectionBoundsChanged|, |
| 517 // while this call is present to ensure consistency with IME after |
| 518 // navigation and tab focus changes |
| 519 const bool is_editable_node = params.type != ui::TEXT_INPUT_TYPE_NONE; |
| 520 selection_controller_->OnSelectionEditable(is_editable_node); |
| 521 } |
| 522 |
| 514 // If the change is not originated from IME (e.g. Javascript, autofill), | 523 // If the change is not originated from IME (e.g. Javascript, autofill), |
| 515 // send back the renderer an acknowledgement, regardless of how we exit from | 524 // send back the renderer an acknowledgement, regardless of how we exit from |
| 516 // this method. | 525 // this method. |
| 517 base::ScopedClosureRunner ack_caller; | 526 base::ScopedClosureRunner ack_caller; |
| 518 if (params.is_non_ime_change) | 527 if (params.is_non_ime_change) |
| 519 ack_caller.Reset(base::Bind(&SendImeEventAck, host_)); | 528 ack_caller.Reset(base::Bind(&SendImeEventAck, host_)); |
| 520 | 529 |
| 521 if (!IsShowing()) | 530 if (!IsShowing()) |
| 522 return; | 531 return; |
| 523 | 532 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 void RenderWidgetHostViewAndroid::SetTooltipText( | 660 void RenderWidgetHostViewAndroid::SetTooltipText( |
| 652 const base::string16& tooltip_text) { | 661 const base::string16& tooltip_text) { |
| 653 // Tooltips don't makes sense on Android. | 662 // Tooltips don't makes sense on Android. |
| 654 } | 663 } |
| 655 | 664 |
| 656 void RenderWidgetHostViewAndroid::SelectionChanged(const base::string16& text, | 665 void RenderWidgetHostViewAndroid::SelectionChanged(const base::string16& text, |
| 657 size_t offset, | 666 size_t offset, |
| 658 const gfx::Range& range) { | 667 const gfx::Range& range) { |
| 659 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); | 668 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); |
| 660 | 669 |
| 670 if (selection_controller_) |
| 671 selection_controller_->OnSelectionEmpty(text.empty()); |
| 672 |
| 661 if (text.empty() || range.is_empty() || !content_view_core_) | 673 if (text.empty() || range.is_empty() || !content_view_core_) |
| 662 return; | 674 return; |
| 663 size_t pos = range.GetMin() - offset; | 675 size_t pos = range.GetMin() - offset; |
| 664 size_t n = range.length(); | 676 size_t n = range.length(); |
| 665 | 677 |
| 666 DCHECK(pos + n <= text.length()) << "The text can not fully cover range."; | 678 DCHECK(pos + n <= text.length()) << "The text can not fully cover range."; |
| 667 if (pos >= text.length()) { | 679 if (pos >= text.length()) { |
| 668 NOTREACHED() << "The text can not cover range."; | 680 NOTREACHED() << "The text can not cover range."; |
| 669 return; | 681 return; |
| 670 } | 682 } |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 | 1250 |
| 1239 if (content_view_core_) | 1251 if (content_view_core_) |
| 1240 content_view_core_->OnGestureEventAck(event, ack_result); | 1252 content_view_core_->OnGestureEventAck(event, ack_result); |
| 1241 } | 1253 } |
| 1242 | 1254 |
| 1243 InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent( | 1255 InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent( |
| 1244 const blink::WebInputEvent& input_event) { | 1256 const blink::WebInputEvent& input_event) { |
| 1245 if (selection_controller_) { | 1257 if (selection_controller_) { |
| 1246 switch (input_event.type) { | 1258 switch (input_event.type) { |
| 1247 case blink::WebInputEvent::GestureLongPress: | 1259 case blink::WebInputEvent::GestureLongPress: |
| 1248 case blink::WebInputEvent::GestureLongTap: | 1260 selection_controller_->OnLongPressEvent(); |
| 1249 selection_controller_->ShowInsertionHandleAutomatically(); | |
| 1250 selection_controller_->ShowSelectionHandlesAutomatically(); | |
| 1251 break; | 1261 break; |
| 1252 case blink::WebInputEvent::GestureTap: | 1262 case blink::WebInputEvent::GestureTap: |
| 1253 selection_controller_->ShowInsertionHandleAutomatically(); | 1263 selection_controller_->OnTapEvent(); |
| 1254 break; | 1264 break; |
| 1255 default: | 1265 default: |
| 1256 break; | 1266 break; |
| 1257 } | 1267 } |
| 1258 } | 1268 } |
| 1259 | 1269 |
| 1260 if (content_view_core_ && | 1270 if (content_view_core_ && |
| 1261 content_view_core_->FilterInputEvent(input_event)) | 1271 content_view_core_->FilterInputEvent(input_event)) |
| 1262 return INPUT_EVENT_ACK_STATE_CONSUMED; | 1272 return INPUT_EVENT_ACK_STATE_CONSUMED; |
| 1263 | 1273 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 host_->ForwardGestureEventWithLatencyInfo(event, CreateLatencyInfo(event)); | 1365 host_->ForwardGestureEventWithLatencyInfo(event, CreateLatencyInfo(event)); |
| 1356 } | 1366 } |
| 1357 | 1367 |
| 1358 void RenderWidgetHostViewAndroid::MoveCaret(const gfx::Point& point) { | 1368 void RenderWidgetHostViewAndroid::MoveCaret(const gfx::Point& point) { |
| 1359 if (host_) | 1369 if (host_) |
| 1360 host_->MoveCaret(point); | 1370 host_->MoveCaret(point); |
| 1361 } | 1371 } |
| 1362 | 1372 |
| 1363 void RenderWidgetHostViewAndroid::HideTextHandles() { | 1373 void RenderWidgetHostViewAndroid::HideTextHandles() { |
| 1364 if (selection_controller_) | 1374 if (selection_controller_) |
| 1365 selection_controller_->HideAndDisallowAutomaticShowing(); | 1375 selection_controller_->HideAndDisallowShowingAutomatically(); |
| 1366 } | 1376 } |
| 1367 | 1377 |
| 1368 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { | 1378 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { |
| 1369 return cached_background_color_; | 1379 return cached_background_color_; |
| 1370 } | 1380 } |
| 1371 | 1381 |
| 1372 void RenderWidgetHostViewAndroid::DidOverscroll( | 1382 void RenderWidgetHostViewAndroid::DidOverscroll( |
| 1373 const DidOverscrollParams& params) { | 1383 const DidOverscrollParams& params) { |
| 1374 if (!content_view_core_ || !layer_ || !is_showing_) | 1384 if (!content_view_core_ || !layer_ || !is_showing_) |
| 1375 return; | 1385 return; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1596 // supported we should go with that (this degrades quality) | 1606 // supported we should go with that (this degrades quality) |
| 1597 // or stick back to the default format. | 1607 // or stick back to the default format. |
| 1598 if (base::SysInfo::IsLowEndDevice()) { | 1608 if (base::SysInfo::IsLowEndDevice()) { |
| 1599 if (IsReadbackConfigSupported(kRGB_565_SkColorType)) | 1609 if (IsReadbackConfigSupported(kRGB_565_SkColorType)) |
| 1600 return kRGB_565_SkColorType; | 1610 return kRGB_565_SkColorType; |
| 1601 } | 1611 } |
| 1602 return kN32_SkColorType; | 1612 return kN32_SkColorType; |
| 1603 } | 1613 } |
| 1604 | 1614 |
| 1605 void RenderWidgetHostViewAndroid::ShowSelectionHandlesAutomatically() { | 1615 void RenderWidgetHostViewAndroid::ShowSelectionHandlesAutomatically() { |
| 1616 // Fake a long press to allow automatic selection handle showing. |
| 1606 if (selection_controller_) | 1617 if (selection_controller_) |
| 1607 selection_controller_->ShowSelectionHandlesAutomatically(); | 1618 selection_controller_->OnLongPressEvent(); |
| 1608 } | 1619 } |
| 1609 | 1620 |
| 1610 void RenderWidgetHostViewAndroid::SelectRange( | 1621 void RenderWidgetHostViewAndroid::SelectRange( |
| 1611 float x1, float y1, float x2, float y2) { | 1622 float x1, float y1, float x2, float y2) { |
| 1612 if (content_view_core_) | 1623 if (content_view_core_) |
| 1613 static_cast<WebContentsImpl*>(content_view_core_->GetWebContents())-> | 1624 static_cast<WebContentsImpl*>(content_view_core_->GetWebContents())-> |
| 1614 SelectRange(gfx::Point(x1, y1), gfx::Point(x2, y2)); | 1625 SelectRange(gfx::Point(x1, y1), gfx::Point(x2, y2)); |
| 1615 } | 1626 } |
| 1616 | 1627 |
| 1617 void RenderWidgetHostViewAndroid::Unselect() { | 1628 void RenderWidgetHostViewAndroid::Unselect() { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1639 results->orientationAngle = display.RotationAsDegree(); | 1650 results->orientationAngle = display.RotationAsDegree(); |
| 1640 results->orientationType = | 1651 results->orientationType = |
| 1641 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 1652 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
| 1642 gfx::DeviceDisplayInfo info; | 1653 gfx::DeviceDisplayInfo info; |
| 1643 results->depth = info.GetBitsPerPixel(); | 1654 results->depth = info.GetBitsPerPixel(); |
| 1644 results->depthPerComponent = info.GetBitsPerComponent(); | 1655 results->depthPerComponent = info.GetBitsPerComponent(); |
| 1645 results->isMonochrome = (results->depthPerComponent == 0); | 1656 results->isMonochrome = (results->depthPerComponent == 0); |
| 1646 } | 1657 } |
| 1647 | 1658 |
| 1648 } // namespace content | 1659 } // namespace content |
| OLD | NEW |