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

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

Issue 2393133004: reflow comments in core/html/shadow (Closed)
Patch Set: oops Created 4 years, 2 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
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 LayoutUnit closestPosition(trackSize * closestRatio); 160 LayoutUnit closestPosition(trackSize * closestRatio);
161 const LayoutUnit snappingThreshold(5); 161 const LayoutUnit snappingThreshold(5);
162 if ((closestPosition - position).abs() <= snappingThreshold) 162 if ((closestPosition - position).abs() <= snappingThreshold)
163 value = closest; 163 value = closest;
164 } 164 }
165 165
166 String valueString = serializeForNumberType(value); 166 String valueString = serializeForNumberType(value);
167 if (valueString == input->value()) 167 if (valueString == input->value())
168 return; 168 return;
169 169
170 // FIXME: This is no longer being set from renderer. Consider updating the met hod name. 170 // FIXME: This is no longer being set from renderer. Consider updating the
171 // method name.
171 input->setValueFromRenderer(valueString); 172 input->setValueFromRenderer(valueString);
172 if (layoutObject()) 173 if (layoutObject())
173 layoutObject()->setNeedsLayoutAndFullPaintInvalidation( 174 layoutObject()->setNeedsLayoutAndFullPaintInvalidation(
174 LayoutInvalidationReason::SliderValueChanged); 175 LayoutInvalidationReason::SliderValueChanged);
175 } 176 }
176 177
177 void SliderThumbElement::startDragging() { 178 void SliderThumbElement::startDragging() {
178 if (LocalFrame* frame = document().frame()) { 179 if (LocalFrame* frame = document().frame()) {
179 frame->eventHandler().setCapturingMouseEventsNode(this); 180 frame->eventHandler().setCapturingMouseEventsNode(this);
180 m_inDragMode = true; 181 m_inDragMode = true;
(...skipping 14 matching lines...) Expand all
195 hostInput()->dispatchFormControlChangeEvent(); 196 hostInput()->dispatchFormControlChangeEvent();
196 } 197 }
197 198
198 void SliderThumbElement::defaultEventHandler(Event* event) { 199 void SliderThumbElement::defaultEventHandler(Event* event) {
199 if (!event->isMouseEvent()) { 200 if (!event->isMouseEvent()) {
200 HTMLDivElement::defaultEventHandler(event); 201 HTMLDivElement::defaultEventHandler(event);
201 return; 202 return;
202 } 203 }
203 204
204 // FIXME: Should handle this readonly/disabled check in more general way. 205 // FIXME: Should handle this readonly/disabled check in more general way.
205 // Missing this kind of check is likely to occur elsewhere if adding it in eac h shadow element. 206 // Missing this kind of check is likely to occur elsewhere if adding it in
207 // each shadow element.
206 HTMLInputElement* input = hostInput(); 208 HTMLInputElement* input = hostInput();
207 if (!input || input->isDisabledOrReadOnly()) { 209 if (!input || input->isDisabledOrReadOnly()) {
208 stopDragging(); 210 stopDragging();
209 HTMLDivElement::defaultEventHandler(event); 211 HTMLDivElement::defaultEventHandler(event);
210 return; 212 return;
211 } 213 }
212 214
213 MouseEvent* mouseEvent = toMouseEvent(event); 215 MouseEvent* mouseEvent = toMouseEvent(event);
214 bool isLeftButton = mouseEvent->button() == 216 bool isLeftButton = mouseEvent->button() ==
215 static_cast<short>(WebPointerProperties::Button::Left); 217 static_cast<short>(WebPointerProperties::Button::Left);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 255
254 void SliderThumbElement::detachLayoutTree(const AttachContext& context) { 256 void SliderThumbElement::detachLayoutTree(const AttachContext& context) {
255 if (m_inDragMode) { 257 if (m_inDragMode) {
256 if (LocalFrame* frame = document().frame()) 258 if (LocalFrame* frame = document().frame())
257 frame->eventHandler().setCapturingMouseEventsNode(nullptr); 259 frame->eventHandler().setCapturingMouseEventsNode(nullptr);
258 } 260 }
259 HTMLDivElement::detachLayoutTree(context); 261 HTMLDivElement::detachLayoutTree(context);
260 } 262 }
261 263
262 HTMLInputElement* SliderThumbElement::hostInput() const { 264 HTMLInputElement* SliderThumbElement::hostInput() const {
263 // Only HTMLInputElement creates SliderThumbElement instances as its shadow no des. 265 // Only HTMLInputElement creates SliderThumbElement instances as its shadow
264 // So, ownerShadowHost() must be an HTMLInputElement. 266 // nodes. So, ownerShadowHost() must be an HTMLInputElement.
265 return toHTMLInputElement(ownerShadowHost()); 267 return toHTMLInputElement(ownerShadowHost());
266 } 268 }
267 269
268 static const AtomicString& sliderThumbShadowPartId() { 270 static const AtomicString& sliderThumbShadowPartId() {
269 DEFINE_STATIC_LOCAL(const AtomicString, sliderThumb, 271 DEFINE_STATIC_LOCAL(const AtomicString, sliderThumb,
270 ("-webkit-slider-thumb")); 272 ("-webkit-slider-thumb"));
271 return sliderThumb; 273 return sliderThumb;
272 } 274 }
273 275
274 static const AtomicString& mediaSliderThumbShadowPartId() { 276 static const AtomicString& mediaSliderThumbShadowPartId() {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 m_slidingDirection = NoMove; 353 m_slidingDirection = NoMove;
352 m_touchStarted = true; 354 m_touchStarted = true;
353 thumb->setPositionFromPoint(touches->item(0)->absoluteLocation()); 355 thumb->setPositionFromPoint(touches->item(0)->absoluteLocation());
354 } else if (m_touchStarted) { 356 } else if (m_touchStarted) {
355 LayoutPoint currentPoint = touches->item(0)->absoluteLocation(); 357 LayoutPoint currentPoint = touches->item(0)->absoluteLocation();
356 if (m_slidingDirection == 358 if (m_slidingDirection ==
357 NoMove) { // Still needs to update the direction. 359 NoMove) { // Still needs to update the direction.
358 m_slidingDirection = getDirection(currentPoint, m_startPoint); 360 m_slidingDirection = getDirection(currentPoint, m_startPoint);
359 } 361 }
360 362
361 // m_slidingDirection has been updated, so check whether it's okay to slid e again. 363 // m_slidingDirection has been updated, so check whether it's okay to
364 // slide again.
362 if (canSlide()) { 365 if (canSlide()) {
363 thumb->setPositionFromPoint(touches->item(0)->absoluteLocation()); 366 thumb->setPositionFromPoint(touches->item(0)->absoluteLocation());
364 event->setDefaultHandled(); 367 event->setDefaultHandled();
365 } 368 }
366 } 369 }
367 } 370 }
368 } 371 }
369 372
370 SliderContainerElement::Direction SliderContainerElement::getDirection( 373 SliderContainerElement::Direction SliderContainerElement::getDirection(
371 LayoutPoint& point1, 374 LayoutPoint& point1,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 updateTouchEventHandlerRegistry(); 448 updateTouchEventHandlerRegistry();
446 HTMLElement::didMoveToNewDocument(oldDocument); 449 HTMLElement::didMoveToNewDocument(oldDocument);
447 } 450 }
448 451
449 void SliderContainerElement::removeAllEventListeners() { 452 void SliderContainerElement::removeAllEventListeners() {
450 Node::removeAllEventListeners(); 453 Node::removeAllEventListeners();
451 m_hasTouchEventHandler = false; 454 m_hasTouchEventHandler = false;
452 } 455 }
453 456
454 } // namespace blink 457 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698