Commit 848c1835 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Use base::Optional in content::PepperPluginInstanceImpl.

Replace two rects and a bool with a struct of two rects inside
base::Optional.

Change-Id: Ie0fe4353809d6d22eafdfc5ae9d488cb1af092ea
Reviewed-on: https://chromium-review.googlesource.com/1013258Reviewed-by: default avatarBill Budge <bbudge@chromium.org>
Reviewed-by: default avatarKazuhiro Inaba <kinaba@chromium.org>
Reviewed-by: default avatarTakayoshi Kochi <kochi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551051}
parent b096dcaa
...@@ -542,9 +542,6 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl( ...@@ -542,9 +542,6 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl(
input_event_mask_(0), input_event_mask_(0),
filtered_input_event_mask_(0), filtered_input_event_mask_(0),
text_input_type_(kPluginDefaultTextInputType), text_input_type_(kPluginDefaultTextInputType),
text_input_caret_(0, 0, 0, 0),
text_input_caret_bounds_(0, 0, 0, 0),
text_input_caret_set_(false),
selection_caret_(0), selection_caret_(0),
selection_anchor_(0), selection_anchor_(0),
pending_user_gesture_(0.0), pending_user_gesture_(0.0),
...@@ -1103,7 +1100,7 @@ bool PepperPluginInstanceImpl::IsPluginAcceptingCompositionEvents() const { ...@@ -1103,7 +1100,7 @@ bool PepperPluginInstanceImpl::IsPluginAcceptingCompositionEvents() const {
} }
gfx::Rect PepperPluginInstanceImpl::GetCaretBounds() const { gfx::Rect PepperPluginInstanceImpl::GetCaretBounds() const {
if (!text_input_caret_set_) { if (!text_input_caret_info_) {
// If it is never set by the plugin, use the bottom left corner. // If it is never set by the plugin, use the bottom left corner.
gfx::Rect rect(view_data_.rect.point.x, gfx::Rect rect(view_data_.rect.point.x,
view_data_.rect.point.y + view_data_.rect.size.height, view_data_.rect.point.y + view_data_.rect.size.height,
...@@ -1113,12 +1110,12 @@ gfx::Rect PepperPluginInstanceImpl::GetCaretBounds() const { ...@@ -1113,12 +1110,12 @@ gfx::Rect PepperPluginInstanceImpl::GetCaretBounds() const {
} }
// TODO(kinaba) Take CSS transformation into account. // TODO(kinaba) Take CSS transformation into account.
// TODO(kinaba) Take |text_input_caret_bounds_| into account. On // TODO(kinaba) Take |text_input_caret_info_->caret_bounds| into account. On
// some platforms, an "exclude rectangle" where candidate window // some platforms, an "exclude rectangle" where candidate window must avoid
// must avoid the region can be passed to IME. Currently, we pass // the region can be passed to IME. Currently, we pass only the caret
// only the caret rectangle because it is the only information // rectangle because it is the only information supported uniformly in
// supported uniformly in Chromium. // Chromium.
gfx::Rect caret(text_input_caret_); gfx::Rect caret = text_input_caret_info_->caret;
caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y); caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y);
ConvertDIPToViewport(&caret); ConvertDIPToViewport(&caret);
return caret; return caret;
...@@ -2804,9 +2801,8 @@ void PepperPluginInstanceImpl::UpdateCaretPosition( ...@@ -2804,9 +2801,8 @@ void PepperPluginInstanceImpl::UpdateCaretPosition(
const PP_Rect& bounding_box) { const PP_Rect& bounding_box) {
if (!render_frame_) if (!render_frame_)
return; return;
text_input_caret_ = PP_ToGfxRect(caret); TextInputCaretInfo info = {PP_ToGfxRect(caret), PP_ToGfxRect(bounding_box)};
text_input_caret_bounds_ = PP_ToGfxRect(bounding_box); text_input_caret_info_ = std::move(info);
text_input_caret_set_ = true;
render_frame_->PepperCaretPositionChanged(this); render_frame_->PepperCaretPositionChanged(this);
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "cc/layers/content_layer_client.h" #include "cc/layers/content_layer_client.h"
...@@ -857,10 +858,12 @@ class CONTENT_EXPORT PepperPluginInstanceImpl ...@@ -857,10 +858,12 @@ class CONTENT_EXPORT PepperPluginInstanceImpl
uint32_t filtered_input_event_mask_; uint32_t filtered_input_event_mask_;
// Text composition status. // Text composition status.
struct TextInputCaretInfo {
gfx::Rect caret;
gfx::Rect caret_bounds;
};
base::Optional<TextInputCaretInfo> text_input_caret_info_;
ui::TextInputType text_input_type_; ui::TextInputType text_input_type_;
gfx::Rect text_input_caret_;
gfx::Rect text_input_caret_bounds_;
bool text_input_caret_set_;
// Text selection status. // Text selection status.
std::string surrounding_text_; std::string surrounding_text_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment