Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/animation/ink_drop_host_view.h" | 5 #include "ui/views/animation/ink_drop_host_view.h" |
| 6 | 6 |
| 7 #include "ui/events/event.h" | 7 #include "ui/events/event.h" |
| 8 #include "ui/events/scoped_target_handler.h" | 8 #include "ui/events/scoped_target_handler.h" |
| 9 #include "ui/gfx/color_palette.h" | 9 #include "ui/gfx/color_palette.h" |
| 10 #include "ui/gfx/geometry/size_conversions.h" | 10 #include "ui/gfx/geometry/size_conversions.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 } | 165 } |
| 166 | 166 |
| 167 gfx::Point InkDropHostView::GetInkDropCenterBasedOnLastEvent() const { | 167 gfx::Point InkDropHostView::GetInkDropCenterBasedOnLastEvent() const { |
| 168 return last_ripple_triggering_event_ | 168 return last_ripple_triggering_event_ |
| 169 ? last_ripple_triggering_event_->location() | 169 ? last_ripple_triggering_event_->location() |
| 170 : GetLocalBounds().CenterPoint(); | 170 : GetLocalBounds().CenterPoint(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void InkDropHostView::AnimateInkDrop(InkDropState state, | 173 void InkDropHostView::AnimateInkDrop(InkDropState state, |
| 174 const ui::LocatedEvent* event) { | 174 const ui::LocatedEvent* event) { |
| 175 #if defined(OS_WIN) | |
| 176 // The reason for this code is to ensure the ink-drop never gets "stuck" | |
|
Evan Stade
2016/06/27 15:19:46
I think you're skipping ahead a bit here, imo the
| |
| 177 // because of mismatched events or states. | |
| 178 // | |
| 179 // The ink-drop should never transition to a "pending" state from a touch | |
| 180 // event. This is the first part of the conditional: | |
| 181 // | |
| 182 // state == InkDropState::ACTION_PENDING || | |
| 183 // state == InkDropState::ALTERNATE_ACTION_PENDING | |
| 184 // | |
| 185 // If the state is already "pending", presumably, from a non-touch event such | |
| 186 // as mouse or keyboard, then a triggered action state should be allowed. The | |
| 187 // second part of the conditional: | |
| 188 // | |
| 189 // (state == InkDropState::ACTION_TRIGGERED || | |
| 190 // state == InkDropState::ALTERNATE_ACTION_TRIGGERED) && | |
| 191 // ink_drop_->GetTargetInkDropState() == InkDropState::HIDDEN | |
| 192 // | |
| 193 // Finally, all of the above is predicated on the event itself being a | |
| 194 // gesture/touch event: | |
| 195 // | |
| 196 // event && event->IsGestureEvent() | |
| 197 // | |
| 198 if ((state == InkDropState::ACTION_PENDING || | |
| 199 state == InkDropState::ALTERNATE_ACTION_PENDING || | |
| 200 ((state == InkDropState::ACTION_TRIGGERED || | |
| 201 state == InkDropState::ALTERNATE_ACTION_TRIGGERED) && | |
| 202 ink_drop_->GetTargetInkDropState() == InkDropState::HIDDEN)) && | |
| 203 event && event->IsGestureEvent()) | |
| 204 return; | |
| 205 #endif | |
| 175 last_ripple_triggering_event_.reset( | 206 last_ripple_triggering_event_.reset( |
| 176 event ? ui::Event::Clone(*event).release()->AsLocatedEvent() : nullptr); | 207 event ? ui::Event::Clone(*event).release()->AsLocatedEvent() : nullptr); |
| 177 ink_drop_->AnimateToState(state); | 208 ink_drop_->AnimateToState(state); |
| 178 } | 209 } |
| 179 | 210 |
| 180 void InkDropHostView::VisibilityChanged(View* starting_from, bool is_visible) { | 211 void InkDropHostView::VisibilityChanged(View* starting_from, bool is_visible) { |
| 181 View::VisibilityChanged(starting_from, is_visible); | 212 View::VisibilityChanged(starting_from, is_visible); |
| 182 if (GetWidget() && !is_visible) { | 213 if (GetWidget() && !is_visible) { |
| 183 ink_drop()->AnimateToState(InkDropState::HIDDEN); | 214 ink_drop()->AnimateToState(InkDropState::HIDDEN); |
| 184 ink_drop()->SetHovered(false); | 215 ink_drop()->SetHovered(false); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 if (has_an_ink_drop) { | 255 if (has_an_ink_drop) { |
| 225 ink_drop_.reset(new InkDropImpl(this)); | 256 ink_drop_.reset(new InkDropImpl(this)); |
| 226 gesture_handler_.reset(new InkDropGestureHandler(this, ink_drop_.get())); | 257 gesture_handler_.reset(new InkDropGestureHandler(this, ink_drop_.get())); |
| 227 } else { | 258 } else { |
| 228 gesture_handler_.reset(); | 259 gesture_handler_.reset(); |
| 229 ink_drop_.reset(new InkDropStub()); | 260 ink_drop_.reset(new InkDropStub()); |
| 230 } | 261 } |
| 231 } | 262 } |
| 232 | 263 |
| 233 } // namespace views | 264 } // namespace views |
| OLD | NEW |