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

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

Issue 2209773002: Remove the blocking touch handlers for the input[type=range] and add touch-action instead (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: '==' -> '>=' and '==' -> Created 4 years, 4 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 position = offset.y() - layoutBox()->size().height() / 2 - trackBounding Box.y() + inputBoundingBox.y() - layoutBox()->marginBottom(); 136 position = offset.y() - layoutBox()->size().height() / 2 - trackBounding Box.y() + inputBoundingBox.y() - layoutBox()->marginBottom();
137 currentPosition = absoluteThumbOrigin.y() - absoluteSliderContentOrigin. y(); 137 currentPosition = absoluteThumbOrigin.y() - absoluteSliderContentOrigin. y();
138 } else { 138 } else {
139 trackSize = trackElement->layoutBox()->contentWidth() - layoutBox()->siz e().width(); 139 trackSize = trackElement->layoutBox()->contentWidth() - layoutBox()->siz e().width();
140 position = offset.x() - layoutBox()->size().width() / 2 - trackBoundingB ox.x() + inputBoundingBox.x(); 140 position = offset.x() - layoutBox()->size().width() / 2 - trackBoundingB ox.x() + inputBoundingBox.x();
141 position -= isLeftToRightDirection ? layoutBox()->marginLeft() : layoutB ox()->marginRight(); 141 position -= isLeftToRightDirection ? layoutBox()->marginLeft() : layoutB ox()->marginRight();
142 currentPosition = absoluteThumbOrigin.x() - absoluteSliderContentOrigin. x(); 142 currentPosition = absoluteThumbOrigin.x() - absoluteSliderContentOrigin. x();
143 } 143 }
144 position = std::min(position, trackSize).clampNegativeToZero(); 144 position = std::min(position, trackSize).clampNegativeToZero();
145 const Decimal ratio = Decimal::fromDouble(static_cast<double>(position) / tr ackSize); 145 const Decimal ratio = Decimal::fromDouble(static_cast<double>(position) / tr ackSize);
146 HTMLInputElement* host = hostInput();
majidvp 2016/08/04 15:20:36 I don't think this component should be involved wi
147 if (!isVertical) {
majidvp 2016/08/04 15:20:36 Good catch handling the vertical case. I think the
148 if (ratio <= Decimal(0)) {
149 host->setAttribute(styleAttr, "touch-action:pan-y pan-left");
150 } else if (ratio >= Decimal(1)) {
151 host->setAttribute(styleAttr, "touch-action:pan-y pan-right");
152 } else {
153 host->setAttribute(styleAttr, "touch-action:pan-y");
154 }
155 } else {
156 if (ratio <= Decimal(0)) {
157 host->setAttribute(styleAttr, "touch-action:pan-x pan-down");
158 } else if (ratio >= Decimal(1)) {
159 host->setAttribute(styleAttr, "touch-action:pan-x pan-up");
160 } else {
161 host->setAttribute(styleAttr, "touch-action:pan-x");
162 }
163 }
146 const Decimal fraction = isVertical || !isLeftToRightDirection ? Decimal(1) - ratio : ratio; 164 const Decimal fraction = isVertical || !isLeftToRightDirection ? Decimal(1) - ratio : ratio;
147 StepRange stepRange(input->createStepRange(RejectAny)); 165 StepRange stepRange(input->createStepRange(RejectAny));
148 Decimal value = stepRange.clampValue(stepRange.valueFromProportion(fraction) ); 166 Decimal value = stepRange.clampValue(stepRange.valueFromProportion(fraction) );
149 167
150 Decimal closest = input->findClosestTickMarkValue(value); 168 Decimal closest = input->findClosestTickMarkValue(value);
151 if (closest.isFinite()) { 169 if (closest.isFinite()) {
152 double closestFraction = stepRange.proportionFromValue(closest).toDouble (); 170 double closestFraction = stepRange.proportionFromValue(closest).toDouble ();
153 double closestRatio = isVertical || !isLeftToRightDirection ? 1.0 - clos estFraction : closestFraction; 171 double closestRatio = isVertical || !isLeftToRightDirection ? 1.0 - clos estFraction : closestFraction;
154 LayoutUnit closestPosition(trackSize * closestRatio); 172 LayoutUnit closestPosition(trackSize * closestRatio);
155 const LayoutUnit snappingThreshold(5); 173 const LayoutUnit snappingThreshold(5);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 case MediaVolumeSliderThumbPart: 341 case MediaVolumeSliderThumbPart:
324 case MediaFullScreenVolumeSliderPart: 342 case MediaFullScreenVolumeSliderPart:
325 case MediaFullScreenVolumeSliderThumbPart: 343 case MediaFullScreenVolumeSliderThumbPart:
326 return mediaSliderContainer; 344 return mediaSliderContainer;
327 default: 345 default:
328 return sliderContainer; 346 return sliderContainer;
329 } 347 }
330 } 348 }
331 349
332 } // namespace blink 350 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698