| 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_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1537 return false; | 1537 return false; |
| 1538 *rect = ConvertRectToScreen(composition_character_bounds_[index]); | 1538 *rect = ConvertRectToScreen(composition_character_bounds_[index]); |
| 1539 return true; | 1539 return true; |
| 1540 } | 1540 } |
| 1541 | 1541 |
| 1542 bool RenderWidgetHostViewAura::HasCompositionText() const { | 1542 bool RenderWidgetHostViewAura::HasCompositionText() const { |
| 1543 return has_composition_text_; | 1543 return has_composition_text_; |
| 1544 } | 1544 } |
| 1545 | 1545 |
| 1546 bool RenderWidgetHostViewAura::GetTextRange(gfx::Range* range) const { | 1546 bool RenderWidgetHostViewAura::GetTextRange(gfx::Range* range) const { |
| 1547 range->set_start(selection_text_offset_); | 1547 if (!text_input_manager_) |
| 1548 range->set_end(selection_text_offset_ + selection_text_.length()); | 1548 return false; |
| 1549 |
| 1550 const TextInputManager::TextSelection* selection = |
| 1551 text_input_manager_->GetTextSelection(); |
| 1552 if (!selection) |
| 1553 return false; |
| 1554 |
| 1555 range->set_start(selection->offset); |
| 1556 range->set_end(selection->offset + selection->text.length()); |
| 1549 return true; | 1557 return true; |
| 1550 } | 1558 } |
| 1551 | 1559 |
| 1552 bool RenderWidgetHostViewAura::GetCompositionTextRange( | 1560 bool RenderWidgetHostViewAura::GetCompositionTextRange( |
| 1553 gfx::Range* range) const { | 1561 gfx::Range* range) const { |
| 1554 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. | 1562 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. |
| 1555 NOTIMPLEMENTED(); | 1563 NOTIMPLEMENTED(); |
| 1556 return false; | 1564 return false; |
| 1557 } | 1565 } |
| 1558 | 1566 |
| 1559 bool RenderWidgetHostViewAura::GetSelectionRange(gfx::Range* range) const { | 1567 bool RenderWidgetHostViewAura::GetSelectionRange(gfx::Range* range) const { |
| 1560 range->set_start(selection_range_.start()); | 1568 if (!text_input_manager_) |
| 1561 range->set_end(selection_range_.end()); | 1569 return false; |
| 1570 |
| 1571 const TextInputManager::TextSelection* selection = |
| 1572 text_input_manager_->GetTextSelection(); |
| 1573 if (!selection) |
| 1574 return false; |
| 1575 |
| 1576 range->set_start(selection->range.start()); |
| 1577 range->set_end(selection->range.end()); |
| 1562 return true; | 1578 return true; |
| 1563 } | 1579 } |
| 1564 | 1580 |
| 1565 bool RenderWidgetHostViewAura::SetSelectionRange(const gfx::Range& range) { | 1581 bool RenderWidgetHostViewAura::SetSelectionRange(const gfx::Range& range) { |
| 1566 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. | 1582 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. |
| 1567 NOTIMPLEMENTED(); | 1583 NOTIMPLEMENTED(); |
| 1568 return false; | 1584 return false; |
| 1569 } | 1585 } |
| 1570 | 1586 |
| 1571 bool RenderWidgetHostViewAura::DeleteRange(const gfx::Range& range) { | 1587 bool RenderWidgetHostViewAura::DeleteRange(const gfx::Range& range) { |
| 1572 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. | 1588 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. |
| 1573 NOTIMPLEMENTED(); | 1589 NOTIMPLEMENTED(); |
| 1574 return false; | 1590 return false; |
| 1575 } | 1591 } |
| 1576 | 1592 |
| 1577 bool RenderWidgetHostViewAura::GetTextFromRange( | 1593 bool RenderWidgetHostViewAura::GetTextFromRange( |
| 1578 const gfx::Range& range, | 1594 const gfx::Range& range, |
| 1579 base::string16* text) const { | 1595 base::string16* text) const { |
| 1580 gfx::Range selection_text_range(selection_text_offset_, | 1596 if (!text_input_manager_) |
| 1581 selection_text_offset_ + selection_text_.length()); | 1597 return false; |
| 1598 |
| 1599 const TextInputManager::TextSelection* selection = |
| 1600 text_input_manager_->GetTextSelection(); |
| 1601 if (!selection) |
| 1602 return false; |
| 1603 |
| 1604 gfx::Range selection_text_range(selection->offset, |
| 1605 selection->offset + selection->text.length()); |
| 1582 | 1606 |
| 1583 if (!selection_text_range.Contains(range)) { | 1607 if (!selection_text_range.Contains(range)) { |
| 1584 text->clear(); | 1608 text->clear(); |
| 1585 return false; | 1609 return false; |
| 1586 } | 1610 } |
| 1587 if (selection_text_range.EqualsIgnoringDirection(range)) { | 1611 if (selection_text_range.EqualsIgnoringDirection(range)) { |
| 1588 // Avoid calling substr whose performance is low. | 1612 // Avoid calling substr whose performance is low. |
| 1589 *text = selection_text_; | 1613 *text = selection->text; |
| 1590 } else { | 1614 } else { |
| 1591 *text = selection_text_.substr( | 1615 *text = selection->text.substr(range.GetMin() - selection->offset, |
| 1592 range.GetMin() - selection_text_offset_, | 1616 range.length()); |
| 1593 range.length()); | |
| 1594 } | 1617 } |
| 1595 return true; | 1618 return true; |
| 1596 } | 1619 } |
| 1597 | 1620 |
| 1598 void RenderWidgetHostViewAura::OnInputMethodChanged() { | 1621 void RenderWidgetHostViewAura::OnInputMethodChanged() { |
| 1599 // TODO(wjmaclean): can host_ ever be null? | 1622 // TODO(wjmaclean): can host_ ever be null? |
| 1600 if (!host_) | 1623 if (!host_) |
| 1601 return; | 1624 return; |
| 1602 | 1625 |
| 1603 // TODO(suzhe): implement the newly added “locale” property of HTML DOM | 1626 // TODO(suzhe): implement the newly added “locale” property of HTML DOM |
| (...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3001 | 3024 |
| 3002 //////////////////////////////////////////////////////////////////////////////// | 3025 //////////////////////////////////////////////////////////////////////////////// |
| 3003 // RenderWidgetHostViewBase, public: | 3026 // RenderWidgetHostViewBase, public: |
| 3004 | 3027 |
| 3005 // static | 3028 // static |
| 3006 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 3029 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3007 GetScreenInfoForWindow(results, NULL); | 3030 GetScreenInfoForWindow(results, NULL); |
| 3008 } | 3031 } |
| 3009 | 3032 |
| 3010 } // namespace content | 3033 } // namespace content |
| OLD | NEW |