Commit 7bf11286 authored by Shimi Zhang's avatar Shimi Zhang Committed by Commit Bot

Rename WidgetBaseInputHandler::HandlingState member variables

- Make all the member variables to be private.
- Rename all the member variables to have a trailing '_'
- Make necessary changes to the callsites where uses these variables
  directly.

Test: No logic change, should be covered by the current tests.
Bug: 1103886
Change-Id: I05bd46765899f464352264e74e70168d3cd25915
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2294339Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: Shimi Zhang <ctzsm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#787780}
parent 8853dad1
...@@ -200,57 +200,80 @@ class WidgetBaseInputHandler::HandlingState { ...@@ -200,57 +200,80 @@ class WidgetBaseInputHandler::HandlingState {
public: public:
HandlingState(base::WeakPtr<WidgetBaseInputHandler> input_handler_param, HandlingState(base::WeakPtr<WidgetBaseInputHandler> input_handler_param,
bool is_touch_start_or_move) bool is_touch_start_or_move)
: touch_start_or_move(is_touch_start_or_move), : touch_start_or_move_(is_touch_start_or_move),
input_handler(std::move(input_handler_param)) { input_handler_(std::move(input_handler_param)) {
previous_was_handling_input = input_handler->handling_input_event_; previous_was_handling_input_ = input_handler_->handling_input_event_;
previous_state = input_handler->handling_input_state_; previous_state_ = input_handler_->handling_input_state_;
input_handler->handling_input_event_ = true; input_handler_->handling_input_event_ = true;
input_handler->handling_input_state_ = this; input_handler_->handling_input_state_ = this;
} }
~HandlingState() { ~HandlingState() {
// Unwinding the HandlingState on the stack might result in an // Unwinding the HandlingState on the stack might result in an
// input_handler_ that got destroyed. i.e. via a nested event loop. // input_handler_ that got destroyed. i.e. via a nested event loop.
if (!input_handler) if (!input_handler_)
return; return;
input_handler->handling_input_event_ = previous_was_handling_input; input_handler_->handling_input_event_ = previous_was_handling_input_;
DCHECK_EQ(input_handler->handling_input_state_, this); DCHECK_EQ(input_handler_->handling_input_state_, this);
input_handler->handling_input_state_ = previous_state; input_handler_->handling_input_state_ = previous_state_;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
if (show_virtual_keyboard) if (show_virtual_keyboard_)
input_handler->ShowVirtualKeyboard(); input_handler_->ShowVirtualKeyboard();
else else
input_handler->UpdateTextInputState(); input_handler_->UpdateTextInputState();
#endif #endif
} }
std::unique_ptr<InputHandlerProxy::DidOverscrollParams>& event_overscroll() {
return event_overscroll_;
}
void set_event_overscroll(
std::unique_ptr<InputHandlerProxy::DidOverscrollParams> params) {
event_overscroll_ = std::move(params);
}
base::Optional<WebTouchAction>& touch_action() { return touch_action_; }
std::vector<WidgetBaseInputHandler::InjectScrollGestureParams>&
injected_scroll_params() {
return injected_scroll_params_;
}
bool touch_start_or_move() { return touch_start_or_move_; }
#if defined(OS_ANDROID)
void set_show_virtual_keyboard(bool show_virtual_keyboard) {
show_virtual_keyboard_ = show_virtual_keyboard;
}
#endif // defined(OS_ANDROID)
private:
// Used to intercept overscroll notifications while an event is being // Used to intercept overscroll notifications while an event is being
// handled. If the event causes overscroll, the overscroll metadata can be // handled. If the event causes overscroll, the overscroll metadata can be
// bundled in the event ack, saving an IPC. Note that we must continue // bundled in the event ack, saving an IPC. Note that we must continue
// supporting overscroll IPC notifications due to fling animation updates. // supporting overscroll IPC notifications due to fling animation updates.
std::unique_ptr<InputHandlerProxy::DidOverscrollParams> event_overscroll; std::unique_ptr<InputHandlerProxy::DidOverscrollParams> event_overscroll_;
base::Optional<WebTouchAction> touch_action; base::Optional<WebTouchAction> touch_action_;
// Used to hold a sequence of parameters corresponding to scroll gesture // Used to hold a sequence of parameters corresponding to scroll gesture
// events that should be injected once the current input event is done // events that should be injected once the current input event is done
// being processed. // being processed.
std::vector<WidgetBaseInputHandler::InjectScrollGestureParams> std::vector<WidgetBaseInputHandler::InjectScrollGestureParams>
injected_scroll_params; injected_scroll_params_;
// Whether the event we are handling is a touch start or move. // Whether the event we are handling is a touch start or move.
bool touch_start_or_move; bool touch_start_or_move_;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// Whether to show the virtual keyboard or not at the end of processing. // Whether to show the virtual keyboard or not at the end of processing.
bool show_virtual_keyboard = false; bool show_virtual_keyboard_ = false;
#endif #endif
private: HandlingState* previous_state_;
HandlingState* previous_state; bool previous_was_handling_input_;
bool previous_was_handling_input; base::WeakPtr<WidgetBaseInputHandler> input_handler_;
base::WeakPtr<WidgetBaseInputHandler> input_handler;
}; };
WidgetBaseInputHandler::WidgetBaseInputHandler(WidgetBase* widget) WidgetBaseInputHandler::WidgetBaseInputHandler(WidgetBase* widget)
...@@ -412,8 +435,8 @@ void WidgetBaseInputHandler::HandleInputEvent( ...@@ -412,8 +435,8 @@ void WidgetBaseInputHandler::HandleInputEvent(
if (!weak_self) { if (!weak_self) {
if (callback) { if (callback) {
std::move(callback).Run(GetAckResult(processed), swap_latency_info, std::move(callback).Run(GetAckResult(processed), swap_latency_info,
std::move(handling_state.event_overscroll), std::move(handling_state.event_overscroll()),
handling_state.touch_action); std::move(handling_state.touch_action()));
} }
return; return;
} }
...@@ -439,9 +462,9 @@ void WidgetBaseInputHandler::HandleInputEvent( ...@@ -439,9 +462,9 @@ void WidgetBaseInputHandler::HandleInputEvent(
// scroll gestures back into blink, e.g., a mousedown on a scrollbar. We // scroll gestures back into blink, e.g., a mousedown on a scrollbar. We
// do this here so that we can attribute latency information from the mouse as // do this here so that we can attribute latency information from the mouse as
// a scroll interaction, instead of just classifying as mouse input. // a scroll interaction, instead of just classifying as mouse input.
if (handling_state.injected_scroll_params.size()) { if (handling_state.injected_scroll_params().size()) {
HandleInjectedScrollGestures( HandleInjectedScrollGestures(
std::move(handling_state.injected_scroll_params), input_event, std::move(handling_state.injected_scroll_params()), input_event,
coalesced_event.latency_info()); coalesced_event.latency_info());
} }
...@@ -455,12 +478,12 @@ void WidgetBaseInputHandler::HandleInputEvent( ...@@ -455,12 +478,12 @@ void WidgetBaseInputHandler::HandleInputEvent(
if (gesture_event.SourceDevice() == WebGestureDevice::kTouchpad || if (gesture_event.SourceDevice() == WebGestureDevice::kTouchpad ||
gesture_event.SourceDevice() == WebGestureDevice::kTouchscreen) { gesture_event.SourceDevice() == WebGestureDevice::kTouchscreen) {
gfx::Vector2dF latest_overscroll_delta = gfx::Vector2dF latest_overscroll_delta =
handling_state.event_overscroll handling_state.event_overscroll()
? handling_state.event_overscroll->latest_overscroll_delta ? handling_state.event_overscroll()->latest_overscroll_delta
: gfx::Vector2dF(); : gfx::Vector2dF();
cc::OverscrollBehavior overscroll_behavior = cc::OverscrollBehavior overscroll_behavior =
handling_state.event_overscroll handling_state.event_overscroll()
? handling_state.event_overscroll->overscroll_behavior ? handling_state.event_overscroll()->overscroll_behavior
: cc::OverscrollBehavior(); : cc::OverscrollBehavior();
widget_->client()->ObserveGestureEventAndResult( widget_->client()->ObserveGestureEventAndResult(
gesture_event, latest_overscroll_delta, overscroll_behavior, gesture_event, latest_overscroll_delta, overscroll_behavior,
...@@ -470,10 +493,10 @@ void WidgetBaseInputHandler::HandleInputEvent( ...@@ -470,10 +493,10 @@ void WidgetBaseInputHandler::HandleInputEvent(
if (callback) { if (callback) {
std::move(callback).Run(GetAckResult(processed), swap_latency_info, std::move(callback).Run(GetAckResult(processed), swap_latency_info,
std::move(handling_state.event_overscroll), std::move(handling_state.event_overscroll()),
handling_state.touch_action); std::move(handling_state.touch_action()));
} else { } else {
DCHECK(!handling_state.event_overscroll) DCHECK(!handling_state.event_overscroll())
<< "Unexpected overscroll for un-acked event"; << "Unexpected overscroll for un-acked event";
} }
...@@ -502,7 +525,7 @@ void WidgetBaseInputHandler::HandleInputEvent( ...@@ -502,7 +525,7 @@ void WidgetBaseInputHandler::HandleInputEvent(
// Ensure all injected scrolls were handled or queue up - any remaining // Ensure all injected scrolls were handled or queue up - any remaining
// injected scrolls at this point would not be processed. // injected scrolls at this point would not be processed.
DCHECK(handling_state.injected_scroll_params.empty()); DCHECK(handling_state.injected_scroll_params().empty());
} }
bool WidgetBaseInputHandler::DidOverscrollFromBlink( bool WidgetBaseInputHandler::DidOverscrollFromBlink(
...@@ -525,7 +548,7 @@ bool WidgetBaseInputHandler::DidOverscrollFromBlink( ...@@ -525,7 +548,7 @@ bool WidgetBaseInputHandler::DidOverscrollFromBlink(
params->current_fling_velocity = velocity; params->current_fling_velocity = velocity;
params->causal_event_viewport_point = position; params->causal_event_viewport_point = position;
params->overscroll_behavior = behavior; params->overscroll_behavior = behavior;
handling_input_state_->event_overscroll = std::move(params); handling_input_state_->set_event_overscroll(std::move(params));
return false; return false;
} }
...@@ -550,7 +573,7 @@ void WidgetBaseInputHandler::InjectGestureScrollEvent( ...@@ -550,7 +573,7 @@ void WidgetBaseInputHandler::InjectGestureScrollEvent(
if (handling_input_state_) { if (handling_input_state_) {
InjectScrollGestureParams params{device, delta, granularity, InjectScrollGestureParams params{device, delta, granularity,
scrollable_area_element_id, injected_type}; scrollable_area_element_id, injected_type};
handling_input_state_->injected_scroll_params.push_back(params); handling_input_state_->injected_scroll_params().push_back(params);
} else { } else {
base::TimeTicks now = base::TimeTicks::Now(); base::TimeTicks now = base::TimeTicks::Now();
std::unique_ptr<WebGestureEvent> gesture_event = std::unique_ptr<WebGestureEvent> gesture_event =
...@@ -660,16 +683,16 @@ bool WidgetBaseInputHandler::ProcessTouchAction(WebTouchAction touch_action) { ...@@ -660,16 +683,16 @@ bool WidgetBaseInputHandler::ProcessTouchAction(WebTouchAction touch_action) {
return false; return false;
// Ignore setTouchAction calls that result from synthetic touch events (eg. // Ignore setTouchAction calls that result from synthetic touch events (eg.
// when blink is emulating touch with mouse). // when blink is emulating touch with mouse).
if (!handling_input_state_->touch_start_or_move) if (!handling_input_state_->touch_start_or_move())
return false; return false;
handling_input_state_->touch_action = touch_action; handling_input_state_->touch_action() = touch_action;
return true; return true;
} }
void WidgetBaseInputHandler::ShowVirtualKeyboard() { void WidgetBaseInputHandler::ShowVirtualKeyboard() {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
if (handling_input_state_) { if (handling_input_state_) {
handling_input_state_->show_virtual_keyboard = true; handling_input_state_->set_show_virtual_keyboard(true);
return; return;
} }
#endif #endif
......
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