Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_win.cc

Issue 24012002: Move Range code to gfx. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: d Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_win.h" 5 #include "content/browser/renderer_host/render_widget_host_view_win.h"
6 6
7 #include <InputScope.h> 7 #include <InputScope.h>
8 #include <wtsapi32.h> 8 #include <wtsapi32.h>
9 #pragma comment(lib, "wtsapi32.lib") 9 #pragma comment(lib, "wtsapi32.lib")
10 10
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 being_destroyed_(false), 402 being_destroyed_(false),
403 tooltip_hwnd_(NULL), 403 tooltip_hwnd_(NULL),
404 tooltip_showing_(false), 404 tooltip_showing_(false),
405 weak_factory_(this), 405 weak_factory_(this),
406 is_loading_(false), 406 is_loading_(false),
407 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 407 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
408 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), 408 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
409 can_compose_inline_(true), 409 can_compose_inline_(true),
410 is_fullscreen_(false), 410 is_fullscreen_(false),
411 ignore_mouse_movement_(true), 411 ignore_mouse_movement_(true),
412 composition_range_(ui::Range::InvalidRange()), 412 composition_range_(gfx::Range::InvalidRange()),
413 touch_state_(new WebTouchState(this)), 413 touch_state_(new WebTouchState(this)),
414 pointer_down_context_(false), 414 pointer_down_context_(false),
415 last_touch_location_(-1, -1), 415 last_touch_location_(-1, -1),
416 touch_events_enabled_(ui::AreTouchEventsEnabled()), 416 touch_events_enabled_(ui::AreTouchEventsEnabled()),
417 gesture_recognizer_(ui::GestureRecognizer::Create(this)) { 417 gesture_recognizer_(ui::GestureRecognizer::Create(this)) {
418 render_widget_host_->SetView(this); 418 render_widget_host_->SetView(this);
419 registrar_.Add(this, 419 registrar_.Add(this,
420 NOTIFICATION_RENDERER_PROCESS_TERMINATED, 420 NOTIFICATION_RENDERER_PROCESS_TERMINATED,
421 NotificationService::AllBrowserContextsAndSources()); 421 NotificationService::AllBrowserContextsAndSources());
422 } 422 }
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 } 719 }
720 720
721 void RenderWidgetHostViewWin::ScrollOffsetChanged() { 721 void RenderWidgetHostViewWin::ScrollOffsetChanged() {
722 } 722 }
723 723
724 void RenderWidgetHostViewWin::ImeCancelComposition() { 724 void RenderWidgetHostViewWin::ImeCancelComposition() {
725 imm32_manager_->CancelIME(m_hWnd); 725 imm32_manager_->CancelIME(m_hWnd);
726 } 726 }
727 727
728 void RenderWidgetHostViewWin::ImeCompositionRangeChanged( 728 void RenderWidgetHostViewWin::ImeCompositionRangeChanged(
729 const ui::Range& range, 729 const gfx::Range& range,
730 const std::vector<gfx::Rect>& character_bounds) { 730 const std::vector<gfx::Rect>& character_bounds) {
731 composition_range_ = range; 731 composition_range_ = range;
732 composition_character_bounds_ = character_bounds; 732 composition_character_bounds_ = character_bounds;
733 } 733 }
734 734
735 void RenderWidgetHostViewWin::Redraw() { 735 void RenderWidgetHostViewWin::Redraw() {
736 RECT damage_bounds; 736 RECT damage_bounds;
737 GetUpdateRect(&damage_bounds, FALSE); 737 GetUpdateRect(&damage_bounds, FALSE);
738 738
739 base::win::ScopedGDIObject<HRGN> damage_region(CreateRectRgn(0, 0, 0, 0)); 739 base::win::ScopedGDIObject<HRGN> damage_region(CreateRectRgn(0, 0, 0, 0));
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 NOTIMPLEMENTED(); 1014 NOTIMPLEMENTED();
1015 } 1015 }
1016 1016
1017 void RenderWidgetHostViewWin::InsertText(const string16& text) { 1017 void RenderWidgetHostViewWin::InsertText(const string16& text) {
1018 if (!base::win::IsTSFAwareRequired()) { 1018 if (!base::win::IsTSFAwareRequired()) {
1019 NOTREACHED(); 1019 NOTREACHED();
1020 return; 1020 return;
1021 } 1021 }
1022 if (render_widget_host_) 1022 if (render_widget_host_)
1023 render_widget_host_->ImeConfirmComposition(text, 1023 render_widget_host_->ImeConfirmComposition(text,
1024 ui::Range::InvalidRange(), 1024 gfx::Range::InvalidRange(),
1025 false); 1025 false);
1026 } 1026 }
1027 1027
1028 void RenderWidgetHostViewWin::InsertChar(char16 ch, int flags) { 1028 void RenderWidgetHostViewWin::InsertChar(char16 ch, int flags) {
1029 if (!base::win::IsTSFAwareRequired()) { 1029 if (!base::win::IsTSFAwareRequired()) {
1030 NOTREACHED(); 1030 NOTREACHED();
1031 return; 1031 return;
1032 } 1032 }
1033 // TODO(nona): Implement this function. 1033 // TODO(nona): Implement this function.
1034 NOTIMPLEMENTED(); 1034 NOTIMPLEMENTED();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 bool RenderWidgetHostViewWin::HasCompositionText() { 1092 bool RenderWidgetHostViewWin::HasCompositionText() {
1093 if (!base::win::IsTSFAwareRequired()) { 1093 if (!base::win::IsTSFAwareRequired()) {
1094 NOTREACHED(); 1094 NOTREACHED();
1095 return false; 1095 return false;
1096 } 1096 }
1097 // TODO(nona): Implement this function. 1097 // TODO(nona): Implement this function.
1098 NOTIMPLEMENTED(); 1098 NOTIMPLEMENTED();
1099 return false; 1099 return false;
1100 } 1100 }
1101 1101
1102 bool RenderWidgetHostViewWin::GetTextRange(ui::Range* range) { 1102 bool RenderWidgetHostViewWin::GetTextRange(gfx::Range* range) {
1103 if (!base::win::IsTSFAwareRequired()) { 1103 if (!base::win::IsTSFAwareRequired()) {
1104 NOTREACHED(); 1104 NOTREACHED();
1105 return false; 1105 return false;
1106 } 1106 }
1107 range->set_start(selection_text_offset_); 1107 range->set_start(selection_text_offset_);
1108 range->set_end(selection_text_offset_ + selection_text_.length()); 1108 range->set_end(selection_text_offset_ + selection_text_.length());
1109 return false; 1109 return false;
1110 } 1110 }
1111 1111
1112 bool RenderWidgetHostViewWin::GetCompositionTextRange(ui::Range* range) { 1112 bool RenderWidgetHostViewWin::GetCompositionTextRange(gfx::Range* range) {
1113 if (!base::win::IsTSFAwareRequired()) { 1113 if (!base::win::IsTSFAwareRequired()) {
1114 NOTREACHED(); 1114 NOTREACHED();
1115 return false; 1115 return false;
1116 } 1116 }
1117 // TODO(nona): Implement this function. 1117 // TODO(nona): Implement this function.
1118 NOTIMPLEMENTED(); 1118 NOTIMPLEMENTED();
1119 return false; 1119 return false;
1120 } 1120 }
1121 1121
1122 bool RenderWidgetHostViewWin::GetSelectionRange(ui::Range* range) { 1122 bool RenderWidgetHostViewWin::GetSelectionRange(gfx::Range* range) {
1123 if (!base::win::IsTSFAwareRequired()) { 1123 if (!base::win::IsTSFAwareRequired()) {
1124 NOTREACHED(); 1124 NOTREACHED();
1125 return false; 1125 return false;
1126 } 1126 }
1127 range->set_start(selection_range_.start()); 1127 range->set_start(selection_range_.start());
1128 range->set_end(selection_range_.end()); 1128 range->set_end(selection_range_.end());
1129 return false; 1129 return false;
1130 } 1130 }
1131 1131
1132 bool RenderWidgetHostViewWin::SetSelectionRange(const ui::Range& range) { 1132 bool RenderWidgetHostViewWin::SetSelectionRange(const gfx::Range& range) {
1133 if (!base::win::IsTSFAwareRequired()) { 1133 if (!base::win::IsTSFAwareRequired()) {
1134 NOTREACHED(); 1134 NOTREACHED();
1135 return false; 1135 return false;
1136 } 1136 }
1137 // TODO(nona): Implement this function. 1137 // TODO(nona): Implement this function.
1138 NOTIMPLEMENTED(); 1138 NOTIMPLEMENTED();
1139 return false; 1139 return false;
1140 } 1140 }
1141 1141
1142 bool RenderWidgetHostViewWin::DeleteRange(const ui::Range& range) { 1142 bool RenderWidgetHostViewWin::DeleteRange(const gfx::Range& range) {
1143 if (!base::win::IsTSFAwareRequired()) { 1143 if (!base::win::IsTSFAwareRequired()) {
1144 NOTREACHED(); 1144 NOTREACHED();
1145 return false; 1145 return false;
1146 } 1146 }
1147 // TODO(nona): Implement this function. 1147 // TODO(nona): Implement this function.
1148 NOTIMPLEMENTED(); 1148 NOTIMPLEMENTED();
1149 return false; 1149 return false;
1150 } 1150 }
1151 1151
1152 bool RenderWidgetHostViewWin::GetTextFromRange(const ui::Range& range, 1152 bool RenderWidgetHostViewWin::GetTextFromRange(const gfx::Range& range,
1153 string16* text) { 1153 string16* text) {
1154 if (!base::win::IsTSFAwareRequired()) { 1154 if (!base::win::IsTSFAwareRequired()) {
1155 NOTREACHED(); 1155 NOTREACHED();
1156 return false; 1156 return false;
1157 } 1157 }
1158 ui::Range selection_text_range(selection_text_offset_, 1158 gfx::Range selection_text_range(selection_text_offset_,
1159 selection_text_offset_ + selection_text_.length()); 1159 selection_text_offset_ + selection_text_.length());
1160 if (!selection_text_range.Contains(range)) { 1160 if (!selection_text_range.Contains(range)) {
1161 text->clear(); 1161 text->clear();
1162 return false; 1162 return false;
1163 } 1163 }
1164 if (selection_text_range.EqualsIgnoringDirection(range)) { 1164 if (selection_text_range.EqualsIgnoringDirection(range)) {
1165 *text = selection_text_; 1165 *text = selection_text_;
1166 } else { 1166 } else {
1167 *text = selection_text_.substr( 1167 *text = selection_text_.substr(
1168 range.GetMin() - selection_text_offset_, 1168 range.GetMin() - selection_text_offset_,
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1663 // WebKit::WebCompositionUnderline, so that we can do reinterpret_cast safely. 1663 // WebKit::WebCompositionUnderline, so that we can do reinterpret_cast safely.
1664 COMPILE_ASSERT(sizeof(ui::CompositionUnderline) == 1664 COMPILE_ASSERT(sizeof(ui::CompositionUnderline) ==
1665 sizeof(WebKit::WebCompositionUnderline), 1665 sizeof(WebKit::WebCompositionUnderline),
1666 ui_CompositionUnderline__WebKit_WebCompositionUnderline_diff); 1666 ui_CompositionUnderline__WebKit_WebCompositionUnderline_diff);
1667 1667
1668 // Retrieve the result string and its attributes of the ongoing composition 1668 // Retrieve the result string and its attributes of the ongoing composition
1669 // and send it to a renderer process. 1669 // and send it to a renderer process.
1670 ui::CompositionText composition; 1670 ui::CompositionText composition;
1671 if (imm32_manager_->GetResult(m_hWnd, lparam, &composition.text)) { 1671 if (imm32_manager_->GetResult(m_hWnd, lparam, &composition.text)) {
1672 render_widget_host_->ImeConfirmComposition( 1672 render_widget_host_->ImeConfirmComposition(
1673 composition.text, ui::Range::InvalidRange(), false); 1673 composition.text, gfx::Range::InvalidRange(), false);
1674 imm32_manager_->ResetComposition(m_hWnd); 1674 imm32_manager_->ResetComposition(m_hWnd);
1675 // Fall though and try reading the composition string. 1675 // Fall though and try reading the composition string.
1676 // Japanese IMEs send a message containing both GCS_RESULTSTR and 1676 // Japanese IMEs send a message containing both GCS_RESULTSTR and
1677 // GCS_COMPSTR, which means an ongoing composition has been finished 1677 // GCS_COMPSTR, which means an ongoing composition has been finished
1678 // by the start of another composition. 1678 // by the start of another composition.
1679 } 1679 }
1680 // Retrieve the composition string and its attributes of the ongoing 1680 // Retrieve the composition string and its attributes of the ongoing
1681 // composition and send it to a renderer process. 1681 // composition and send it to a renderer process.
1682 if (imm32_manager_->GetComposition(m_hWnd, lparam, &composition)) { 1682 if (imm32_manager_->GetComposition(m_hWnd, lparam, &composition)) {
1683 // TODO(suzhe): due to a bug of webkit, we can't use selection range with 1683 // TODO(suzhe): due to a bug of webkit, we can't use selection range with
1684 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788 1684 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788
1685 composition.selection = ui::Range(composition.selection.end()); 1685 composition.selection = gfx::Range(composition.selection.end());
1686 1686
1687 // TODO(suzhe): convert both renderer_host and renderer to use 1687 // TODO(suzhe): convert both renderer_host and renderer to use
1688 // ui::CompositionText. 1688 // ui::CompositionText.
1689 const std::vector<WebKit::WebCompositionUnderline>& underlines = 1689 const std::vector<WebKit::WebCompositionUnderline>& underlines =
1690 reinterpret_cast<const std::vector<WebKit::WebCompositionUnderline>&>( 1690 reinterpret_cast<const std::vector<WebKit::WebCompositionUnderline>&>(
1691 composition.underlines); 1691 composition.underlines);
1692 render_widget_host_->ImeSetComposition( 1692 render_widget_host_->ImeSetComposition(
1693 composition.text, underlines, 1693 composition.text, underlines,
1694 composition.selection.start(), composition.selection.end()); 1694 composition.selection.start(), composition.selection.end());
1695 } 1695 }
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after
3199 return new RenderWidgetHostViewWin(widget); 3199 return new RenderWidgetHostViewWin(widget);
3200 } 3200 }
3201 3201
3202 // static 3202 // static
3203 void RenderWidgetHostViewPort::GetDefaultScreenInfo( 3203 void RenderWidgetHostViewPort::GetDefaultScreenInfo(
3204 WebKit::WebScreenInfo* results) { 3204 WebKit::WebScreenInfo* results) {
3205 GetScreenInfoForWindow(0, results); 3205 GetScreenInfoForWindow(0, results);
3206 } 3206 }
3207 3207
3208 } // namespace content 3208 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_win.h ('k') | content/browser/renderer_host/test_render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698