Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: third_party/WebKit/Source/core/html/shadow/SliderThumbElement.cpp

Issue 2749313002: Move slider implemention to use pointer capture (Closed)
Patch Set: Add a note Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // FIXME: This is no longer being set from renderer. Consider updating the 170 // FIXME: This is no longer being set from renderer. Consider updating the
171 // method name. 171 // method name.
172 input->setValueFromRenderer(valueString); 172 input->setValueFromRenderer(valueString);
173 if (layoutObject()) 173 if (layoutObject())
174 layoutObject()->setNeedsLayoutAndFullPaintInvalidation( 174 layoutObject()->setNeedsLayoutAndFullPaintInvalidation(
175 LayoutInvalidationReason::SliderValueChanged); 175 LayoutInvalidationReason::SliderValueChanged);
176 } 176 }
177 177
178 void SliderThumbElement::startDragging() { 178 void SliderThumbElement::startDragging() {
179 if (LocalFrame* frame = document().frame()) { 179 if (LocalFrame* frame = document().frame()) {
180 frame->eventHandler().setCapturingMouseEventsNode(this); 180 // Note that we get to here only we through mouse event path. The touch
181 // events are implicitly captured to the starting element and will be
182 // handled in handleTouchEvent function.
183 frame->eventHandler().setPointerCapture(PointerEventFactory::s_mouseId,
184 this);
181 m_inDragMode = true; 185 m_inDragMode = true;
182 } 186 }
183 } 187 }
184 188
185 void SliderThumbElement::stopDragging() { 189 void SliderThumbElement::stopDragging() {
186 if (!m_inDragMode) 190 if (!m_inDragMode)
187 return; 191 return;
188 192
189 if (LocalFrame* frame = document().frame()) 193 if (LocalFrame* frame = document().frame()) {
190 frame->eventHandler().setCapturingMouseEventsNode(nullptr); 194 frame->eventHandler().releasePointerCapture(PointerEventFactory::s_mouseId,
195 this);
196 }
191 m_inDragMode = false; 197 m_inDragMode = false;
192 if (layoutObject()) 198 if (layoutObject())
193 layoutObject()->setNeedsLayoutAndFullPaintInvalidation( 199 layoutObject()->setNeedsLayoutAndFullPaintInvalidation(
194 LayoutInvalidationReason::SliderValueChanged); 200 LayoutInvalidationReason::SliderValueChanged);
195 if (hostInput()) 201 if (hostInput())
196 hostInput()->dispatchFormControlChangeEvent(); 202 hostInput()->dispatchFormControlChangeEvent();
197 } 203 }
198 204
199 void SliderThumbElement::defaultEventHandler(Event* event) { 205 void SliderThumbElement::defaultEventHandler(Event* event) {
206 if (event->isPointerEvent() &&
207 event->type() == EventTypeNames::lostpointercapture) {
208 stopDragging();
209 return;
210 }
211
200 if (!event->isMouseEvent()) { 212 if (!event->isMouseEvent()) {
201 HTMLDivElement::defaultEventHandler(event); 213 HTMLDivElement::defaultEventHandler(event);
202 return; 214 return;
203 } 215 }
204 216
205 // FIXME: Should handle this readonly/disabled check in more general way. 217 // FIXME: Should handle this readonly/disabled check in more general way.
206 // Missing this kind of check is likely to occur elsewhere if adding it in 218 // Missing this kind of check is likely to occur elsewhere if adding it in
207 // each shadow element. 219 // each shadow element.
208 HTMLInputElement* input = hostInput(); 220 HTMLInputElement* input = hostInput();
209 if (!input || input->isDisabledFormControl()) { 221 if (!input || input->isDisabledFormControl()) {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 updateTouchEventHandlerRegistry(); 459 updateTouchEventHandlerRegistry();
448 HTMLElement::didMoveToNewDocument(oldDocument); 460 HTMLElement::didMoveToNewDocument(oldDocument);
449 } 461 }
450 462
451 void SliderContainerElement::removeAllEventListeners() { 463 void SliderContainerElement::removeAllEventListeners() {
452 Node::removeAllEventListeners(); 464 Node::removeAllEventListeners();
453 m_hasTouchEventHandler = false; 465 m_hasTouchEventHandler = false;
454 } 466 }
455 467
456 } // namespace blink 468 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698