OLD | NEW |
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 private: | 134 private: |
135 virtual void layout() OVERRIDE; | 135 virtual void layout() OVERRIDE; |
136 }; | 136 }; |
137 | 137 |
138 void RenderSliderContainer::computeLogicalHeight(LayoutUnit logicalHeight, Layou
tUnit logicalTop, LogicalExtentComputedValues& computedValues) const | 138 void RenderSliderContainer::computeLogicalHeight(LayoutUnit logicalHeight, Layou
tUnit logicalTop, LogicalExtentComputedValues& computedValues) const |
139 { | 139 { |
140 HTMLInputElement* input = node()->shadowHost()->toInputElement(); | 140 HTMLInputElement* input = node()->shadowHost()->toInputElement(); |
141 bool isVertical = hasVerticalAppearance(input); | 141 bool isVertical = hasVerticalAppearance(input); |
142 | 142 |
143 #if ENABLE(DATALIST_ELEMENT) | |
144 if (input->renderer()->isSlider() && !isVertical && input->list()) { | 143 if (input->renderer()->isSlider() && !isVertical && input->list()) { |
145 int offsetFromCenter = theme()->sliderTickOffsetFromTrackCenter(); | 144 int offsetFromCenter = theme()->sliderTickOffsetFromTrackCenter(); |
146 LayoutUnit trackHeight = 0; | 145 LayoutUnit trackHeight = 0; |
147 if (offsetFromCenter < 0) | 146 if (offsetFromCenter < 0) |
148 trackHeight = -2 * offsetFromCenter; | 147 trackHeight = -2 * offsetFromCenter; |
149 else { | 148 else { |
150 int tickLength = theme()->sliderTickSize().height(); | 149 int tickLength = theme()->sliderTickSize().height(); |
151 trackHeight = 2 * (offsetFromCenter + tickLength); | 150 trackHeight = 2 * (offsetFromCenter + tickLength); |
152 } | 151 } |
153 float zoomFactor = style()->effectiveZoom(); | 152 float zoomFactor = style()->effectiveZoom(); |
154 if (zoomFactor != 1.0) | 153 if (zoomFactor != 1.0) |
155 trackHeight *= zoomFactor; | 154 trackHeight *= zoomFactor; |
156 | 155 |
157 RenderBox::computeLogicalHeight(trackHeight, logicalTop, computedValues)
; | 156 RenderBox::computeLogicalHeight(trackHeight, logicalTop, computedValues)
; |
158 return; | 157 return; |
159 } | 158 } |
160 #endif | |
161 if (isVertical) | 159 if (isVertical) |
162 logicalHeight = RenderSlider::defaultTrackLength; | 160 logicalHeight = RenderSlider::defaultTrackLength; |
163 RenderBox::computeLogicalHeight(logicalHeight, logicalTop, computedValues); | 161 RenderBox::computeLogicalHeight(logicalHeight, logicalTop, computedValues); |
164 } | 162 } |
165 | 163 |
166 void RenderSliderContainer::layout() | 164 void RenderSliderContainer::layout() |
167 { | 165 { |
168 HTMLInputElement* input = node()->shadowHost()->toInputElement(); | 166 HTMLInputElement* input = node()->shadowHost()->toInputElement(); |
169 bool isVertical = hasVerticalAppearance(input); | 167 bool isVertical = hasVerticalAppearance(input); |
170 style()->setFlexDirection(isVertical ? FlowColumn : FlowRow); | 168 style()->setFlexDirection(isVertical ? FlowColumn : FlowRow); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 position = offset.x() - renderBox()->width() / 2 - trackBoundingBox.x()
+ inputBoundingBox.x(); | 285 position = offset.x() - renderBox()->width() / 2 - trackBoundingBox.x()
+ inputBoundingBox.x(); |
288 position -= isLeftToRightDirection ? renderBox()->marginLeft() : renderB
ox()->marginRight(); | 286 position -= isLeftToRightDirection ? renderBox()->marginLeft() : renderB
ox()->marginRight(); |
289 currentPosition = absoluteThumbOrigin.x() - absoluteSliderContentOrigin.
x(); | 287 currentPosition = absoluteThumbOrigin.x() - absoluteSliderContentOrigin.
x(); |
290 } | 288 } |
291 position = max<LayoutUnit>(0, min(position, trackSize)); | 289 position = max<LayoutUnit>(0, min(position, trackSize)); |
292 const Decimal ratio = Decimal::fromDouble(static_cast<double>(position) / tr
ackSize); | 290 const Decimal ratio = Decimal::fromDouble(static_cast<double>(position) / tr
ackSize); |
293 const Decimal fraction = isVertical || !isLeftToRightDirection ? Decimal(1)
- ratio : ratio; | 291 const Decimal fraction = isVertical || !isLeftToRightDirection ? Decimal(1)
- ratio : ratio; |
294 StepRange stepRange(input->createStepRange(RejectAny)); | 292 StepRange stepRange(input->createStepRange(RejectAny)); |
295 Decimal value = stepRange.clampValue(stepRange.valueFromProportion(fraction)
); | 293 Decimal value = stepRange.clampValue(stepRange.valueFromProportion(fraction)
); |
296 | 294 |
297 #if ENABLE(DATALIST_ELEMENT) | |
298 const LayoutUnit snappingThreshold = renderer()->theme()->sliderTickSnapping
Threshold(); | 295 const LayoutUnit snappingThreshold = renderer()->theme()->sliderTickSnapping
Threshold(); |
299 if (snappingThreshold > 0) { | 296 if (snappingThreshold > 0) { |
300 Decimal closest = input->findClosestTickMarkValue(value); | 297 Decimal closest = input->findClosestTickMarkValue(value); |
301 if (closest.isFinite()) { | 298 if (closest.isFinite()) { |
302 double closestFraction = stepRange.proportionFromValue(closest).toDo
uble(); | 299 double closestFraction = stepRange.proportionFromValue(closest).toDo
uble(); |
303 double closestRatio = isVertical || !isLeftToRightDirection ? 1.0 -
closestFraction : closestFraction; | 300 double closestRatio = isVertical || !isLeftToRightDirection ? 1.0 -
closestFraction : closestFraction; |
304 LayoutUnit closestPosition = trackSize * closestRatio; | 301 LayoutUnit closestPosition = trackSize * closestRatio; |
305 if ((closestPosition - position).abs() <= snappingThreshold) | 302 if ((closestPosition - position).abs() <= snappingThreshold) |
306 value = closest; | 303 value = closest; |
307 } | 304 } |
308 } | 305 } |
309 #endif | |
310 | 306 |
311 String valueString = serializeForNumberType(value); | 307 String valueString = serializeForNumberType(value); |
312 if (valueString == input->value()) | 308 if (valueString == input->value()) |
313 return; | 309 return; |
314 | 310 |
315 // FIXME: This is no longer being set from renderer. Consider updating the m
ethod name. | 311 // FIXME: This is no longer being set from renderer. Consider updating the m
ethod name. |
316 input->setValueFromRenderer(valueString); | 312 input->setValueFromRenderer(valueString); |
317 renderer()->setNeedsLayout(true); | 313 renderer()->setNeedsLayout(true); |
318 input->dispatchFormControlChangeEvent(); | 314 input->dispatchFormControlChangeEvent(); |
319 } | 315 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 case MediaVolumeSliderThumbPart: | 472 case MediaVolumeSliderThumbPart: |
477 case MediaFullScreenVolumeSliderPart: | 473 case MediaFullScreenVolumeSliderPart: |
478 case MediaFullScreenVolumeSliderThumbPart: | 474 case MediaFullScreenVolumeSliderThumbPart: |
479 return mediaSliderContainer; | 475 return mediaSliderContainer; |
480 default: | 476 default: |
481 return sliderContainer; | 477 return sliderContainer; |
482 } | 478 } |
483 } | 479 } |
484 | 480 |
485 } | 481 } |
OLD | NEW |