summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authoraurimas@chromium.org <aurimas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-09 17:03:29 +0000
committeraurimas@chromium.org <aurimas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-09 17:03:29 +0000
commit501ea13dbca4eb47fa93410e45482abda0ef9ff3 (patch)
tree8e6ce40cc65a4b2bfd6dea0826d97e268cf4b1fe /content
parent493434d08ef4454db95496507e3ac2f443fafb32 (diff)
downloadchromium_src-501ea13dbca4eb47fa93410e45482abda0ef9ff3.zip
chromium_src-501ea13dbca4eb47fa93410e45482abda0ef9ff3.tar.gz
chromium_src-501ea13dbca4eb47fa93410e45482abda0ef9ff3.tar.bz2
ifdef CompositionBounds related calls on to OSes that use it.
Composition bounds are only used by OSX, Win, and Aura so ifdefing the update to limit to only these OSes. The main reason for this is because getCompositionCharacterBounds is really slow on Android. BUG=252803 Review URL: https://chromiumcodereview.appspot.com/17288016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210577 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/renderer_host/render_widget_host_impl.cc8
-rw-r--r--content/browser/renderer_host/render_widget_host_impl.h2
-rw-r--r--content/browser/renderer_host/render_widget_host_view_android.cc5
-rw-r--r--content/browser/renderer_host/render_widget_host_view_android.h3
-rw-r--r--content/browser/renderer_host/render_widget_host_view_gtk.cc5
-rw-r--r--content/browser/renderer_host/render_widget_host_view_gtk.h3
-rw-r--r--content/browser/renderer_host/render_widget_host_view_guest.cc2
-rw-r--r--content/browser/renderer_host/render_widget_host_view_guest.h2
-rw-r--r--content/browser/renderer_host/test_render_view_host.h2
-rw-r--r--content/common/view_messages.h14
-rw-r--r--content/port/browser/render_widget_host_view_port.h2
-rw-r--r--content/renderer/render_view_browsertest.cc2
-rw-r--r--content/renderer/render_view_impl.cc4
-rw-r--r--content/renderer/render_view_impl.h2
-rw-r--r--content/renderer/render_widget.cc75
-rw-r--r--content/renderer/render_widget.h12
16 files changed, 82 insertions, 61 deletions
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index 7cd8d8d..5460b50 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -469,8 +469,6 @@ bool RenderWidgetHostImpl::OnMessageReceived(const IPC::Message &msg) {
IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor)
IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged,
OnTextInputTypeChanged)
- IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCompositionRangeChanged,
- OnImeCompositionRangeChanged)
IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition,
OnImeCancelComposition)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidActivateAcceleratedCompositing,
@@ -486,6 +484,10 @@ bool RenderWidgetHostImpl::OnMessageReceived(const IPC::Message &msg) {
OnWindowlessPluginDummyWindowDestroyed)
#endif
IPC_MESSAGE_HANDLER(ViewHostMsg_Snapshot, OnSnapshot)
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCompositionRangeChanged,
+ OnImeCompositionRangeChanged)
+#endif
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
@@ -2137,12 +2139,14 @@ void RenderWidgetHostImpl::OnTextInputTypeChanged(ui::TextInputType type,
view_->TextInputTypeChanged(type, can_compose_inline);
}
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
void RenderWidgetHostImpl::OnImeCompositionRangeChanged(
const ui::Range& range,
const std::vector<gfx::Rect>& character_bounds) {
if (view_)
view_->ImeCompositionRangeChanged(range, character_bounds);
}
+#endif
void RenderWidgetHostImpl::OnImeCancelComposition() {
if (view_)
diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h
index c5933f5..759114e 100644
--- a/content/browser/renderer_host/render_widget_host_impl.h
+++ b/content/browser/renderer_host/render_widget_host_impl.h
@@ -659,9 +659,11 @@ class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost,
void OnHasTouchEventHandlers(bool has_handlers);
void OnSetCursor(const WebCursor& cursor);
void OnTextInputTypeChanged(ui::TextInputType type, bool can_compose_inline);
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
void OnImeCompositionRangeChanged(
const ui::Range& range,
const std::vector<gfx::Rect>& character_bounds);
+#endif
void OnImeCancelComposition();
void OnDidActivateAcceleratedCompositing(bool activated);
void OnLockMouse(bool user_gesture,
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc
index 9c45d7c..719943b 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -446,11 +446,6 @@ void RenderWidgetHostViewAndroid::ImeCancelComposition() {
ime_adapter_android_.CancelComposition();
}
-void RenderWidgetHostViewAndroid::ImeCompositionRangeChanged(
- const ui::Range& range,
- const std::vector<gfx::Rect>& character_bounds) {
-}
-
void RenderWidgetHostViewAndroid::DidUpdateBackingStore(
const gfx::Rect& scroll_rect,
const gfx::Vector2d& scroll_delta,
diff --git a/content/browser/renderer_host/render_widget_host_view_android.h b/content/browser/renderer_host/render_widget_host_view_android.h
index ce4e263..9631a63 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.h
+++ b/content/browser/renderer_host/render_widget_host_view_android.h
@@ -97,9 +97,6 @@ class RenderWidgetHostViewAndroid
virtual void TextInputTypeChanged(ui::TextInputType type,
bool can_compose_inline) OVERRIDE;
virtual void ImeCancelComposition() OVERRIDE;
- virtual void ImeCompositionRangeChanged(
- const ui::Range& range,
- const std::vector<gfx::Rect>& character_bounds) OVERRIDE;
virtual void DidUpdateBackingStore(
const gfx::Rect& scroll_rect,
const gfx::Vector2d& scroll_delta,
diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.cc b/content/browser/renderer_host/render_widget_host_view_gtk.cc
index 5dde072..146ec83 100644
--- a/content/browser/renderer_host/render_widget_host_view_gtk.cc
+++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc
@@ -844,11 +844,6 @@ void RenderWidgetHostViewGtk::ImeCancelComposition() {
im_context_->CancelComposition();
}
-void RenderWidgetHostViewGtk::ImeCompositionRangeChanged(
- const ui::Range& range,
- const std::vector<gfx::Rect>& character_bounds) {
-}
-
void RenderWidgetHostViewGtk::DidUpdateBackingStore(
const gfx::Rect& scroll_rect,
const gfx::Vector2d& scroll_delta,
diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.h b/content/browser/renderer_host/render_widget_host_view_gtk.h
index 0c30682..a7723ee 100644
--- a/content/browser/renderer_host/render_widget_host_view_gtk.h
+++ b/content/browser/renderer_host/render_widget_host_view_gtk.h
@@ -85,9 +85,6 @@ class CONTENT_EXPORT RenderWidgetHostViewGtk
virtual void TextInputTypeChanged(ui::TextInputType type,
bool can_compose_inline) OVERRIDE;
virtual void ImeCancelComposition() OVERRIDE;
- virtual void ImeCompositionRangeChanged(
- const ui::Range& range,
- const std::vector<gfx::Rect>& character_bounds) OVERRIDE;
virtual void DidUpdateBackingStore(
const gfx::Rect& scroll_rect,
const gfx::Vector2d& scroll_delta,
diff --git a/content/browser/renderer_host/render_widget_host_view_guest.cc b/content/browser/renderer_host/render_widget_host_view_guest.cc
index 2602e32..86adae9 100644
--- a/content/browser/renderer_host/render_widget_host_view_guest.cc
+++ b/content/browser/renderer_host/render_widget_host_view_guest.cc
@@ -281,10 +281,12 @@ void RenderWidgetHostViewGuest::ImeCancelComposition() {
platform_view_->ImeCancelComposition();
}
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
void RenderWidgetHostViewGuest::ImeCompositionRangeChanged(
const ui::Range& range,
const std::vector<gfx::Rect>& character_bounds) {
}
+#endif
void RenderWidgetHostViewGuest::DidUpdateBackingStore(
const gfx::Rect& scroll_rect,
diff --git a/content/browser/renderer_host/render_widget_host_view_guest.h b/content/browser/renderer_host/render_widget_host_view_guest.h
index 448ea3e..29a3486 100644
--- a/content/browser/renderer_host/render_widget_host_view_guest.h
+++ b/content/browser/renderer_host/render_widget_host_view_guest.h
@@ -87,9 +87,11 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest
virtual void TextInputTypeChanged(ui::TextInputType type,
bool can_compose_inline) OVERRIDE;
virtual void ImeCancelComposition() OVERRIDE;
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
virtual void ImeCompositionRangeChanged(
const ui::Range& range,
const std::vector<gfx::Rect>& character_bounds) OVERRIDE;
+#endif
virtual void DidUpdateBackingStore(
const gfx::Rect& scroll_rect,
const gfx::Vector2d& scroll_delta,
diff --git a/content/browser/renderer_host/test_render_view_host.h b/content/browser/renderer_host/test_render_view_host.h
index 9de121d..bdafb36 100644
--- a/content/browser/renderer_host/test_render_view_host.h
+++ b/content/browser/renderer_host/test_render_view_host.h
@@ -100,9 +100,11 @@ class TestRenderWidgetHostView : public RenderWidgetHostViewBase {
virtual void TextInputTypeChanged(ui::TextInputType type,
bool can_compose_inline) OVERRIDE {}
virtual void ImeCancelComposition() OVERRIDE {}
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
virtual void ImeCompositionRangeChanged(
const ui::Range& range,
const std::vector<gfx::Rect>& character_bounds) OVERRIDE {}
+#endif
virtual void DidUpdateBackingStore(
const gfx::Rect& scroll_rect,
const gfx::Vector2d& scroll_delta,
diff --git a/content/common/view_messages.h b/content/common/view_messages.h
index b4074bf..6ebe1d8 100644
--- a/content/common/view_messages.h
+++ b/content/common/view_messages.h
@@ -1964,11 +1964,6 @@ IPC_MESSAGE_ROUTED2(ViewHostMsg_TextInputTypeChanged,
IPC_MESSAGE_ROUTED1(ViewHostMsg_TextInputStateChanged,
ViewHostMsg_TextInputState_Params /* input state params */)
-// Message sent when the IME text composition range changes.
-IPC_MESSAGE_ROUTED2(ViewHostMsg_ImeCompositionRangeChanged,
- ui::Range /* composition range */,
- std::vector<gfx::Rect> /* character bounds */)
-
// Required for cancelling an ongoing input method composition.
IPC_MESSAGE_ROUTED0(ViewHostMsg_ImeCancelComposition)
@@ -2329,6 +2324,15 @@ IPC_MESSAGE_CONTROL1(ViewHostMsg_FreeTransportDIB,
TransportDIB::Id /* DIB id */)
#endif
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
+// On MACOSX, WIN and AURA IME can request composition character bounds
+// synchronously (see crbug.com/120597). This IPC message sends the character
+// bounds after every composition change to always have correct bound info.
+IPC_MESSAGE_ROUTED2(ViewHostMsg_ImeCompositionRangeChanged,
+ ui::Range /* composition range */,
+ std::vector<gfx::Rect> /* character bounds */)
+#endif
+
// Adding a new message? Stick to the sort order above: first platform
// independent ViewMsg, then ifdefs for platform specific ViewMsg, then platform
// independent ViewHostMsg, then ifdefs for platform specific ViewHostMsg.
diff --git a/content/port/browser/render_widget_host_view_port.h b/content/port/browser/render_widget_host_view_port.h
index 3028a70..6aa03de 100644
--- a/content/port/browser/render_widget_host_view_port.h
+++ b/content/port/browser/render_widget_host_view_port.h
@@ -106,10 +106,12 @@ class CONTENT_EXPORT RenderWidgetHostViewPort : public RenderWidgetHostView,
// Cancel the ongoing composition of the input method attached to the view.
virtual void ImeCancelComposition() = 0;
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
// Updates the range of the marked text in an IME composition.
virtual void ImeCompositionRangeChanged(
const ui::Range& range,
const std::vector<gfx::Rect>& character_bounds) = 0;
+#endif
// Informs the view that a portion of the widget's backing store was scrolled
// and/or painted. The view should ensure this gets copied to the screen.
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index 4831c6a..44bd173 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -1670,6 +1670,7 @@ TEST_F(RenderViewImplTest, TestBackForward) {
EXPECT_EQ(1, was_page_b);
}
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
TEST_F(RenderViewImplTest, GetCompositionCharacterBoundsTest) {
LoadHTML("<textarea id=\"test\"></textarea>");
ExecuteJavaScript("document.getElementById('test').focus();");
@@ -1733,6 +1734,7 @@ TEST_F(RenderViewImplTest, GetCompositionCharacterBoundsTest) {
}
view()->OnImeConfirmComposition(empty_string, ui::Range::InvalidRange());
}
+#endif
TEST_F(RenderViewImplTest, ZoomLimit) {
const double kMinZoomLevel =
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 035bc11..64ba322 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -6164,7 +6164,9 @@ void RenderViewImpl::SimulateImeConfirmComposition(
void RenderViewImpl::PpapiPluginCancelComposition() {
Send(new ViewHostMsg_ImeCancelComposition(routing_id()));;
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
UpdateCompositionInfo(true);
+#endif
}
void RenderViewImpl::PpapiPluginSelectionChanged() {
@@ -6295,6 +6297,7 @@ void RenderViewImpl::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) {
RenderWidget::GetSelectionBounds(start, end);
}
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
void RenderViewImpl::GetCompositionCharacterBounds(
std::vector<gfx::Rect>* bounds) {
DCHECK(bounds);
@@ -6334,6 +6337,7 @@ void RenderViewImpl::GetCompositionRange(ui::Range* range) {
}
RenderWidget::GetCompositionRange(range);
}
+#endif
bool RenderViewImpl::CanComposeInline() {
return pepper_helper_->IsPluginFocused() ?
diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
index 603c80ed..743923e 100644
--- a/content/renderer/render_view_impl.h
+++ b/content/renderer/render_view_impl.h
@@ -813,9 +813,11 @@ class CONTENT_EXPORT RenderViewImpl
virtual void SetDeviceScaleFactor(float device_scale_factor) OVERRIDE;
virtual ui::TextInputType GetTextInputType() OVERRIDE;
virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) OVERRIDE;
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
virtual void GetCompositionCharacterBounds(
std::vector<gfx::Rect>* character_bounds) OVERRIDE;
virtual void GetCompositionRange(ui::Range* range) OVERRIDE;
+#endif
virtual bool CanComposeInline() OVERRIDE;
virtual void DidCommitCompositorFrame() OVERRIDE;
virtual void InstrumentWillBeginFrame() OVERRIDE;
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index f0a1e6d..28b6077 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -1747,24 +1747,6 @@ void RenderWidget::OnSetInputMethodActive(bool is_active) {
input_method_is_active_ = is_active;
}
-void RenderWidget::UpdateCompositionInfo(bool should_update_range) {
- ui::Range range = ui::Range();
- if (should_update_range) {
- GetCompositionRange(&range);
- } else {
- range = composition_range_;
- }
- std::vector<gfx::Rect> character_bounds;
- GetCompositionCharacterBounds(&character_bounds);
-
- if (!ShouldUpdateCompositionInfo(range, character_bounds))
- return;
- composition_character_bounds_ = character_bounds;
- composition_range_ = range;
- Send(new ViewHostMsg_ImeCompositionRangeChanged(
- routing_id(), composition_range_, composition_character_bounds_));
-}
-
void RenderWidget::OnImeSetComposition(
const string16& text,
const std::vector<WebCompositionUnderline>& underlines,
@@ -1780,7 +1762,9 @@ void RenderWidget::OnImeSetComposition(
// sure we are in a consistent state.
Send(new ViewHostMsg_ImeCancelComposition(routing_id()));
}
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
UpdateCompositionInfo(true);
+#endif
}
void RenderWidget::OnImeConfirmComposition(
@@ -1791,7 +1775,9 @@ void RenderWidget::OnImeConfirmComposition(
handling_input_event_ = true;
webwidget_->confirmComposition(text);
handling_input_event_ = false;
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
UpdateCompositionInfo(true);
+#endif
}
// This message causes the renderer to render an image of the
@@ -2165,22 +2151,9 @@ void RenderWidget::UpdateSelectionBounds() {
params.is_anchor_first = webwidget_->isSelectionAnchorFirst();
Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_, params));
}
-
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
UpdateCompositionInfo(false);
-}
-
-bool RenderWidget::ShouldUpdateCompositionInfo(
- const ui::Range& range,
- const std::vector<gfx::Rect>& bounds) {
- if (composition_range_ != range)
- return true;
- if (bounds.size() != composition_character_bounds_.size())
- return true;
- for (size_t i = 0; i < bounds.size(); ++i) {
- if (bounds[i] != composition_character_bounds_[i])
- return true;
- }
- return false;
+#endif
}
// Check WebKit::WebTextInputType and ui::TextInputType is kept in sync.
@@ -2233,6 +2206,25 @@ ui::TextInputType RenderWidget::GetTextInputType() {
return ui::TEXT_INPUT_TYPE_NONE;
}
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
+void RenderWidget::UpdateCompositionInfo(bool should_update_range) {
+ ui::Range range = ui::Range();
+ if (should_update_range) {
+ GetCompositionRange(&range);
+ } else {
+ range = composition_range_;
+ }
+ std::vector<gfx::Rect> character_bounds;
+ GetCompositionCharacterBounds(&character_bounds);
+
+ if (!ShouldUpdateCompositionInfo(range, character_bounds))
+ return;
+ composition_character_bounds_ = character_bounds;
+ composition_range_ = range;
+ Send(new ViewHostMsg_ImeCompositionRangeChanged(
+ routing_id(), composition_range_, composition_character_bounds_));
+}
+
void RenderWidget::GetCompositionCharacterBounds(
std::vector<gfx::Rect>* bounds) {
DCHECK(bounds);
@@ -2252,6 +2244,21 @@ void RenderWidget::GetCompositionRange(ui::Range* range) {
}
}
+bool RenderWidget::ShouldUpdateCompositionInfo(
+ const ui::Range& range,
+ const std::vector<gfx::Rect>& bounds) {
+ if (composition_range_ != range)
+ return true;
+ if (bounds.size() != composition_character_bounds_.size())
+ return true;
+ for (size_t i = 0; i < bounds.size(); ++i) {
+ if (bounds[i] != composition_character_bounds_[i])
+ return true;
+ }
+ return false;
+}
+#endif
+
bool RenderWidget::CanComposeInline() {
return true;
}
@@ -2277,7 +2284,9 @@ void RenderWidget::resetInputMethod() {
Send(new ViewHostMsg_ImeCancelComposition(routing_id()));
}
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
UpdateCompositionInfo(true);
+#endif
}
void RenderWidget::didHandleGestureEvent(
diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h
index e5ab989..f014aff 100644
--- a/content/renderer/render_widget.h
+++ b/content/renderer/render_widget.h
@@ -420,11 +420,6 @@ class CONTENT_EXPORT RenderWidget
// the new value will be sent to the browser process.
virtual void UpdateSelectionBounds();
- // Checks if the composition range or composition character bounds have been
- // changed. If they are changed, the new value will be sent to the browser
- // process.
- virtual void UpdateCompositionInfo(bool should_update_range);
-
// Override point to obtain that the current input method state and caret
// position.
virtual ui::TextInputType GetTextInputType();
@@ -432,6 +427,12 @@ class CONTENT_EXPORT RenderWidget
virtual ui::TextInputType WebKitToUiTextInputType(
WebKit::WebTextInputType type);
+#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
+ // Checks if the composition range or composition character bounds have been
+ // changed. If they are changed, the new value will be sent to the browser
+ // process.
+ void UpdateCompositionInfo(bool should_update_range);
+
// Override point to obtain that the current composition character bounds.
// In the case of surrogate pairs, the character is treated as two characters:
// the bounds for first character is actual one, and the bounds for second
@@ -448,6 +449,7 @@ class CONTENT_EXPORT RenderWidget
bool ShouldUpdateCompositionInfo(
const ui::Range& range,
const std::vector<gfx::Rect>& bounds);
+#endif
// Override point to obtain that the current input method state about
// composition text.