Commit b382e98f authored by Jinho Bang's avatar Jinho Bang Committed by Commit Bot

WebXR: Make public member variables in XRInputSource private

Bug: 955567
Change-Id: I09e6c053620e8b07eaf16d7ea534276309e98dec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1630131Reviewed-by: default avatarBrandon Jones <bajones@chromium.org>
Commit-Queue: Jinho Bang <jinho.bang@samsung.com>
Cr-Commit-Position: refs/heads/master@{#664358}
parent ac3456bd
...@@ -134,9 +134,9 @@ XRInputSource::XRInputSource( ...@@ -134,9 +134,9 @@ XRInputSource::XRInputSource(
// Deep copy because of the unique_ptrs // Deep copy because of the unique_ptrs
XRInputSource::XRInputSource(const XRInputSource& other) XRInputSource::XRInputSource(const XRInputSource& other)
: active_frame_id(other.active_frame_id), : active_frame_id_(other.active_frame_id_),
primary_input_pressed(other.primary_input_pressed), primary_input_pressed_(other.primary_input_pressed_),
selection_cancelled(other.selection_cancelled), selection_cancelled_(other.selection_cancelled_),
session_(other.session_), session_(other.session_),
source_id_(other.source_id_), source_id_(other.source_id_),
target_ray_space_(other.target_ray_space_), target_ray_space_(other.target_ray_space_),
......
...@@ -49,6 +49,15 @@ class XRInputSource : public ScriptWrappable, public Gamepad::Client { ...@@ -49,6 +49,15 @@ class XRInputSource : public ScriptWrappable, public Gamepad::Client {
XRInputSource(const XRInputSource& other); XRInputSource(const XRInputSource& other);
~XRInputSource() override = default; ~XRInputSource() override = default;
int16_t activeFrameId() const { return active_frame_id_; }
void setActiveFrameId(int16_t id) { active_frame_id_ = id; }
bool primaryInputPressed() const { return primary_input_pressed_; }
void setPrimaryInputPressed(bool value) { primary_input_pressed_ = value; }
bool selectionCancelled() const { return selection_cancelled_; }
void setSelectionCancelled(bool value) { selection_cancelled_ = value; }
XRSession* session() const { return session_; } XRSession* session() const { return session_; }
const String& handedness() const { return handedness_string_; } const String& handedness() const { return handedness_string_; }
...@@ -74,10 +83,6 @@ class XRInputSource : public ScriptWrappable, public Gamepad::Client { ...@@ -74,10 +83,6 @@ class XRInputSource : public ScriptWrappable, public Gamepad::Client {
void Trace(blink::Visitor*) override; void Trace(blink::Visitor*) override;
int16_t active_frame_id = -1;
bool primary_input_pressed = false;
bool selection_cancelled = false;
private: private:
friend class XRGripSpace; friend class XRGripSpace;
friend class XRTargetRaySpace; friend class XRTargetRaySpace;
...@@ -94,6 +99,9 @@ class XRInputSource : public ScriptWrappable, public Gamepad::Client { ...@@ -94,6 +99,9 @@ class XRInputSource : public ScriptWrappable, public Gamepad::Client {
const device::mojom::blink::XRInputSourceStatePtr& state); const device::mojom::blink::XRInputSourceStatePtr& state);
void UpdateGamepad(const device::Gamepad& gamepad); void UpdateGamepad(const device::Gamepad& gamepad);
int16_t active_frame_id_ = -1;
bool primary_input_pressed_ = false;
bool selection_cancelled_ = false;
const Member<XRSession> session_; const Member<XRSession> session_;
const uint32_t source_id_; const uint32_t source_id_;
Member<XRTargetRaySpace> target_ray_space_; Member<XRTargetRaySpace> target_ray_space_;
......
...@@ -783,7 +783,7 @@ void XRSession::OnInputStateChange( ...@@ -783,7 +783,7 @@ void XRSession::OnInputStateChange(
} }
} }
input_source->active_frame_id = frame_id; input_source->setActiveFrameId(frame_id);
} }
// Remove any input sources that are inactive, and disconnect their gamepad. // Remove any input sources that are inactive, and disconnect their gamepad.
...@@ -794,7 +794,7 @@ void XRSession::OnInputStateChange( ...@@ -794,7 +794,7 @@ void XRSession::OnInputStateChange(
// also be in removed, and we'd remove our newly added source. // also be in removed, and we'd remove our newly added source.
std::vector<uint32_t> inactive_sources; std::vector<uint32_t> inactive_sources;
for (const auto& input_source : input_sources_.Values()) { for (const auto& input_source : input_sources_.Values()) {
if (input_source->active_frame_id != frame_id) { if (input_source->activeFrameId() != frame_id) {
inactive_sources.push_back(input_source->source_id()); inactive_sources.push_back(input_source->source_id());
input_source->SetGamepadConnected(false); input_source->SetGamepadConnected(false);
removed.push_back(input_source); removed.push_back(input_source);
...@@ -822,18 +822,18 @@ void XRSession::OnInputStateChange( ...@@ -822,18 +822,18 @@ void XRSession::OnInputStateChange(
void XRSession::OnSelectStart(XRInputSource* input_source) { void XRSession::OnSelectStart(XRInputSource* input_source) {
// Discard duplicate events // Discard duplicate events
if (input_source->primary_input_pressed) if (input_source->primaryInputPressed())
return; return;
input_source->primary_input_pressed = true; input_source->setPrimaryInputPressed(true);
input_source->selection_cancelled = false; input_source->setSelectionCancelled(false);
XRInputSourceEvent* event = XRInputSourceEvent* event =
CreateInputSourceEvent(event_type_names::kSelectstart, input_source); CreateInputSourceEvent(event_type_names::kSelectstart, input_source);
DispatchEvent(*event); DispatchEvent(*event);
if (event->defaultPrevented()) if (event->defaultPrevented())
input_source->selection_cancelled = true; input_source->setSelectionCancelled(true);
// Ensure the frame cannot be used outside of the event handler. // Ensure the frame cannot be used outside of the event handler.
event->frame()->Deactivate(); event->frame()->Deactivate();
...@@ -841,10 +841,10 @@ void XRSession::OnSelectStart(XRInputSource* input_source) { ...@@ -841,10 +841,10 @@ void XRSession::OnSelectStart(XRInputSource* input_source) {
void XRSession::OnSelectEnd(XRInputSource* input_source) { void XRSession::OnSelectEnd(XRInputSource* input_source) {
// Discard duplicate events // Discard duplicate events
if (!input_source->primary_input_pressed) if (!input_source->primaryInputPressed())
return; return;
input_source->primary_input_pressed = false; input_source->setPrimaryInputPressed(false);
LocalFrame* frame = xr_->GetFrame(); LocalFrame* frame = xr_->GetFrame();
if (!frame) if (!frame)
...@@ -858,7 +858,7 @@ void XRSession::OnSelectEnd(XRInputSource* input_source) { ...@@ -858,7 +858,7 @@ void XRSession::OnSelectEnd(XRInputSource* input_source) {
DispatchEvent(*event); DispatchEvent(*event);
if (event->defaultPrevented()) if (event->defaultPrevented())
input_source->selection_cancelled = true; input_source->setSelectionCancelled(true);
// Ensure the frame cannot be used outside of the event handler. // Ensure the frame cannot be used outside of the event handler.
event->frame()->Deactivate(); event->frame()->Deactivate();
...@@ -868,11 +868,11 @@ void XRSession::OnSelect(XRInputSource* input_source) { ...@@ -868,11 +868,11 @@ void XRSession::OnSelect(XRInputSource* input_source) {
// If a select was fired but we had not previously started the selection it // If a select was fired but we had not previously started the selection it
// indictes a sub-frame or instantanous select event, and we should fire a // indictes a sub-frame or instantanous select event, and we should fire a
// selectstart prior to the selectend. // selectstart prior to the selectend.
if (!input_source->primary_input_pressed) { if (!input_source->primaryInputPressed()) {
OnSelectStart(input_source); OnSelectStart(input_source);
} }
if (!input_source->selection_cancelled) { if (!input_source->selectionCancelled()) {
XRInputSourceEvent* event = XRInputSourceEvent* event =
CreateInputSourceEvent(event_type_names::kSelect, input_source); CreateInputSourceEvent(event_type_names::kSelect, input_source);
DispatchEvent(*event); DispatchEvent(*event);
...@@ -902,7 +902,7 @@ void XRSession::UpdateSelectState( ...@@ -902,7 +902,7 @@ void XRSession::UpdateSelectState(
if (state->primary_input_pressed) { if (state->primary_input_pressed) {
OnSelectStart(input_source); OnSelectStart(input_source);
} else if (input_source->primary_input_pressed) { } else if (input_source->primaryInputPressed()) {
// May get here if the input source was previously pressed but now isn't, // May get here if the input source was previously pressed but now isn't,
// but the input source did not set primary_input_clicked to true. We will // but the input source did not set primary_input_clicked to true. We will
// treat this as a cancelled selection, firing the selectend event so the // treat this as a cancelled selection, firing the selectend event so the
......
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