From 8fcb5e2e0da39588de5f2318e0a62a265f30c6bd Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 12 Jan 2017 10:58:54 +0100 Subject: Adapt to changes in selection API in Chromium 55 Aura now uses the TextInputManager for tracking selections. Change-Id: I86634b987b0184a90d3d7125e568fcdab0b2e930 Reviewed-by: Michal Klocek --- src/core/render_widget_host_view_qt.cpp | 45 ++++++++++----------------------- 1 file changed, 14 insertions(+), 31 deletions(-) (limited to 'src/core/render_widget_host_view_qt.cpp') diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 147fdb5bb..2b0539ac9 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -54,8 +54,8 @@ #include "base/command_line.h" #include "cc/output/compositor_frame_ack.h" #include "content/browser/accessibility/browser_accessibility_state_impl.h" -#include "content/browser/renderer_host/input/web_input_event_util.h" #include "content/browser/renderer_host/render_view_host_impl.h" +#include "content/browser/renderer_host/text_input_manager.h" #include "content/common/cursors/webcursor.h" #include "content/public/browser/browser_accessibility_state.h" #include "content/public/browser/browser_thread.h" @@ -240,8 +240,6 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost* widget , m_adapterClient(0) , m_imeInProgress(false) , m_receivedEmptyImeText(false) - , m_anchorPositionWithinSelection(0) - , m_cursorPositionWithinSelection(0) , m_initPending(false) { m_host->SetView(this); @@ -609,22 +607,6 @@ void RenderWidgetHostViewQt::SetTooltipText(const base::string16 &tooltip_text) m_adapterClient->setToolTip(toQt(tooltip_text)); } -void RenderWidgetHostViewQt::SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params ¶ms) -{ - if (selection_range_.IsValid()) { - if (params.is_anchor_first) { - m_anchorPositionWithinSelection = selection_range_.GetMin() - selection_text_offset_; - m_cursorPositionWithinSelection = selection_range_.GetMax() - selection_text_offset_; - } else { - m_anchorPositionWithinSelection = selection_range_.GetMax() - selection_text_offset_; - m_cursorPositionWithinSelection = selection_range_.GetMin() - selection_text_offset_; - } - } - - gfx::Rect caretRect = gfx::UnionRects(params.anchor_rect, params.focus_rect); - m_cursorRect = QRect(caretRect.x(), caretRect.y(), caretRect.width(), caretRect.height()); -} - void RenderWidgetHostViewQt::CopyFromCompositingSurface(const gfx::Rect& src_subrect, const gfx::Size& dst_size, const content::ReadbackRequestCallback& callback, const SkColorType color_type) { NOTIMPLEMENTED(); @@ -827,23 +809,26 @@ bool RenderWidgetHostViewQt::forwardEvent(QEvent *event) return true; } -QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query) const +QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query) { switch (query) { case Qt::ImEnabled: return QVariant(m_currentInputType != ui::TEXT_INPUT_TYPE_NONE); - case Qt::ImCursorRectangle: - return m_cursorRect; case Qt::ImFont: return QVariant(); + case Qt::ImCursorRectangle: + return toQt(GetTextInputManager()->GetSelectionRegion()->caret_rect); case Qt::ImCursorPosition: - return static_cast(m_cursorPositionWithinSelection); + return toQt(GetTextInputManager()->GetSelectionRegion()->focus.edge_top_rounded().x()); case Qt::ImAnchorPosition: - return static_cast(m_anchorPositionWithinSelection); + return toQt(GetTextInputManager()->GetSelectionRegion()->anchor.edge_top_rounded().x()); case Qt::ImSurroundingText: return m_surroundingText; - case Qt::ImCurrentSelection: - return toQt(GetSelectedText()); + case Qt::ImCurrentSelection: { + base::string16 text; + GetTextInputManager()->GetTextSelection()->GetSelectedText(&text); + return toQt(text); + } case Qt::ImMaximumTextLength: return QVariant(); // No limit. case Qt::ImHints: @@ -919,7 +904,7 @@ void RenderWidgetHostViewQt::handleMouseEvent(QMouseEvent* event) blink::WebMouseEvent webEvent = WebEventFactory::toWebMouseEvent(event, dpiScale()); if ((webEvent.type == blink::WebInputEvent::MouseDown || webEvent.type == blink::WebInputEvent::MouseUp) - && webEvent.button == blink::WebMouseEvent::ButtonNone) { + && webEvent.button == blink::WebMouseEvent::Button::NoButton) { // Blink can only handle the 3 main mouse-buttons and may assert when processing mouse-down for no button. return; } @@ -979,9 +964,7 @@ void RenderWidgetHostViewQt::handleKeyEvent(QKeyEvent *ev) gfx::Range::InvalidRange(), gfx::Range::InvalidRange().start(), gfx::Range::InvalidRange().end()); - m_host->ImeConfirmComposition(base::string16(), - gfx::Range::InvalidRange(), - false); + m_host->ImeFinishComposingText(false); m_imeInProgress = false; } return; @@ -1098,7 +1081,7 @@ void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev) if (!commitString.isEmpty() || replacementLength > 0) { setCompositionString(commitString); - m_host->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(), false); + m_host->ImeFinishComposingText(false); // We might get a commit string and a pre-edit string in a single event, which means // we need to confirm the怀last composition, and start a new composition. -- cgit v1.2.3