| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 RefPtrWillBeRawPtr<SliderThumbElement> protector(this); | 111 RefPtrWillBeRawPtr<SliderThumbElement> protector(this); |
| 112 startDragging(); | 112 startDragging(); |
| 113 setPositionFromPoint(point); | 113 setPositionFromPoint(point); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void SliderThumbElement::setPositionFromPoint(const LayoutPoint& point) | 116 void SliderThumbElement::setPositionFromPoint(const LayoutPoint& point) |
| 117 { | 117 { |
| 118 RefPtrWillBeRawPtr<HTMLInputElement> input(hostInput()); | 118 RefPtrWillBeRawPtr<HTMLInputElement> input(hostInput()); |
| 119 Element* trackElement = input->closedShadowRoot()->getElementById(ShadowElem
entNames::sliderTrack()); | 119 Element* trackElement = input->closedShadowRoot()->getElementById(ShadowElem
entNames::sliderTrack()); |
| 120 | 120 |
| 121 if (!input->renderer() || !renderBox() || !trackElement->renderBox()) | 121 if (!input->renderer() || !layoutBox() || !trackElement->layoutBox()) |
| 122 return; | 122 return; |
| 123 | 123 |
| 124 LayoutPoint offset = roundedLayoutPoint(input->renderer()->absoluteToLocal(F
loatPoint(point), UseTransforms)); | 124 LayoutPoint offset = roundedLayoutPoint(input->renderer()->absoluteToLocal(F
loatPoint(point), UseTransforms)); |
| 125 bool isVertical = hasVerticalAppearance(input.get()); | 125 bool isVertical = hasVerticalAppearance(input.get()); |
| 126 bool isLeftToRightDirection = renderBox()->style()->isLeftToRightDirection()
; | 126 bool isLeftToRightDirection = layoutBox()->style()->isLeftToRightDirection()
; |
| 127 LayoutUnit trackSize; | 127 LayoutUnit trackSize; |
| 128 LayoutUnit position; | 128 LayoutUnit position; |
| 129 LayoutUnit currentPosition; | 129 LayoutUnit currentPosition; |
| 130 // We need to calculate currentPosition from absolute points becaue the | 130 // We need to calculate currentPosition from absolute points becaue the |
| 131 // renderer for this node is usually on a layer and renderBox()->x() and | 131 // renderer for this node is usually on a layer and layoutBox()->x() and |
| 132 // y() are unusable. | 132 // y() are unusable. |
| 133 // FIXME: This should probably respect transforms. | 133 // FIXME: This should probably respect transforms. |
| 134 LayoutPoint absoluteThumbOrigin = renderBox()->absoluteBoundingBoxRectIgnori
ngTransforms().location(); | 134 LayoutPoint absoluteThumbOrigin = layoutBox()->absoluteBoundingBoxRectIgnori
ngTransforms().location(); |
| 135 LayoutPoint absoluteSliderContentOrigin = roundedLayoutPoint(input->renderer
()->localToAbsolute()); | 135 LayoutPoint absoluteSliderContentOrigin = roundedLayoutPoint(input->renderer
()->localToAbsolute()); |
| 136 IntRect trackBoundingBox = trackElement->renderer()->absoluteBoundingBoxRect
IgnoringTransforms(); | 136 IntRect trackBoundingBox = trackElement->renderer()->absoluteBoundingBoxRect
IgnoringTransforms(); |
| 137 IntRect inputBoundingBox = input->renderer()->absoluteBoundingBoxRectIgnorin
gTransforms(); | 137 IntRect inputBoundingBox = input->renderer()->absoluteBoundingBoxRectIgnorin
gTransforms(); |
| 138 if (isVertical) { | 138 if (isVertical) { |
| 139 trackSize = trackElement->renderBox()->contentHeight() - renderBox()->si
ze().height(); | 139 trackSize = trackElement->layoutBox()->contentHeight() - layoutBox()->si
ze().height(); |
| 140 position = offset.y() - renderBox()->size().height() / 2 - trackBounding
Box.y() + inputBoundingBox.y() - renderBox()->marginBottom(); | 140 position = offset.y() - layoutBox()->size().height() / 2 - trackBounding
Box.y() + inputBoundingBox.y() - layoutBox()->marginBottom(); |
| 141 currentPosition = absoluteThumbOrigin.y() - absoluteSliderContentOrigin.
y(); | 141 currentPosition = absoluteThumbOrigin.y() - absoluteSliderContentOrigin.
y(); |
| 142 } else { | 142 } else { |
| 143 trackSize = trackElement->renderBox()->contentWidth() - renderBox()->siz
e().width(); | 143 trackSize = trackElement->layoutBox()->contentWidth() - layoutBox()->siz
e().width(); |
| 144 position = offset.x() - renderBox()->size().width() / 2 - trackBoundingB
ox.x() + inputBoundingBox.x(); | 144 position = offset.x() - layoutBox()->size().width() / 2 - trackBoundingB
ox.x() + inputBoundingBox.x(); |
| 145 position -= isLeftToRightDirection ? renderBox()->marginLeft() : renderB
ox()->marginRight(); | 145 position -= isLeftToRightDirection ? layoutBox()->marginLeft() : layoutB
ox()->marginRight(); |
| 146 currentPosition = absoluteThumbOrigin.x() - absoluteSliderContentOrigin.
x(); | 146 currentPosition = absoluteThumbOrigin.x() - absoluteSliderContentOrigin.
x(); |
| 147 } | 147 } |
| 148 position = std::max<LayoutUnit>(0, std::min(position, trackSize)); | 148 position = std::max<LayoutUnit>(0, std::min(position, trackSize)); |
| 149 const Decimal ratio = Decimal::fromDouble(static_cast<double>(position) / tr
ackSize); | 149 const Decimal ratio = Decimal::fromDouble(static_cast<double>(position) / tr
ackSize); |
| 150 const Decimal fraction = isVertical || !isLeftToRightDirection ? Decimal(1)
- ratio : ratio; | 150 const Decimal fraction = isVertical || !isLeftToRightDirection ? Decimal(1)
- ratio : ratio; |
| 151 StepRange stepRange(input->createStepRange(RejectAny)); | 151 StepRange stepRange(input->createStepRange(RejectAny)); |
| 152 Decimal value = stepRange.clampValue(stepRange.valueFromProportion(fraction)
); | 152 Decimal value = stepRange.clampValue(stepRange.valueFromProportion(fraction)
); |
| 153 | 153 |
| 154 Decimal closest = input->findClosestTickMarkValue(value); | 154 Decimal closest = input->findClosestTickMarkValue(value); |
| 155 if (closest.isFinite()) { | 155 if (closest.isFinite()) { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 case MediaVolumeSliderThumbPart: | 327 case MediaVolumeSliderThumbPart: |
| 328 case MediaFullScreenVolumeSliderPart: | 328 case MediaFullScreenVolumeSliderPart: |
| 329 case MediaFullScreenVolumeSliderThumbPart: | 329 case MediaFullScreenVolumeSliderThumbPart: |
| 330 return mediaSliderContainer; | 330 return mediaSliderContainer; |
| 331 default: | 331 default: |
| 332 return sliderContainer; | 332 return sliderContainer; |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 | 335 |
| 336 } | 336 } |
| OLD | NEW |