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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 bool isVertical = hasVerticalAppearance(input); | 170 bool isVertical = hasVerticalAppearance(input); |
171 style()->setFlexDirection(isVertical ? FlowColumn : FlowRow); | 171 style()->setFlexDirection(isVertical ? FlowColumn : FlowRow); |
172 TextDirection oldTextDirection = style()->direction(); | 172 TextDirection oldTextDirection = style()->direction(); |
173 if (isVertical) { | 173 if (isVertical) { |
174 // FIXME: Work around rounding issues in RTL vertical sliders. We want t
hem to | 174 // FIXME: Work around rounding issues in RTL vertical sliders. We want t
hem to |
175 // render identically to LTR vertical sliders. We can remove this work a
round when | 175 // render identically to LTR vertical sliders. We can remove this work a
round when |
176 // subpixel rendering is enabled on all ports. | 176 // subpixel rendering is enabled on all ports. |
177 style()->setDirection(LTR); | 177 style()->setDirection(LTR); |
178 } | 178 } |
179 | 179 |
180 RenderBox* thumb = 0; | 180 RenderBox* thumb = input->sliderThumbElement() ? input->sliderThumbElement()
->renderBox() : 0; |
181 RenderBox* track = 0; | 181 RenderBox* track = input->sliderTrackElement() ? input->sliderTrackElement()
->renderBox() : 0; |
182 if (input->sliderThumbElement() && input->sliderThumbElement()->renderer())
{ | 182 // Force a layout to reset the position of the thumb so the code below doesn
't move the thumb to the wrong place. |
183 thumb = toRenderBox(input->sliderThumbElement()->renderer()); | 183 // FIXME: Make a custom Render class for the track and move the thumb positi
oning code there. |
184 track = toRenderBox(thumb->parent()); | 184 if (track) |
185 // Force a layout to reset the position of the thumb so the code below d
oesn't move the thumb to the wrong place. | |
186 // FIXME: Make a custom Render class for the track and move the thumb po
sitioning code there. | |
187 track->setChildNeedsLayout(true, MarkOnlyThis); | 185 track->setChildNeedsLayout(true, MarkOnlyThis); |
188 } | |
189 | 186 |
190 RenderFlexibleBox::layout(); | 187 RenderFlexibleBox::layout(); |
191 | 188 |
192 style()->setDirection(oldTextDirection); | 189 style()->setDirection(oldTextDirection); |
193 // These should always exist, unless someone mutates the shadow DOM (e.g., i
n the inspector). | 190 // These should always exist, unless someone mutates the shadow DOM (e.g., i
n the inspector). |
194 if (!thumb) | 191 if (!thumb || !track) |
195 return; | 192 return; |
196 | 193 |
197 double percentageOffset = sliderPosition(input).toDouble(); | 194 double percentageOffset = sliderPosition(input).toDouble(); |
198 LayoutUnit availableExtent = isVertical ? track->contentHeight() : track->co
ntentWidth(); | 195 LayoutUnit availableExtent = isVertical ? track->contentHeight() : track->co
ntentWidth(); |
199 availableExtent -= isVertical ? thumb->height() : thumb->width(); | 196 availableExtent -= isVertical ? thumb->height() : thumb->width(); |
200 LayoutUnit offset = percentageOffset * availableExtent; | 197 LayoutUnit offset = percentageOffset * availableExtent; |
201 LayoutPoint thumbLocation = thumb->location(); | 198 LayoutPoint thumbLocation = thumb->location(); |
202 if (isVertical) | 199 if (isVertical) |
203 thumbLocation.setY(thumbLocation.y() + track->contentHeight() - thumb->h
eight() - offset); | 200 thumbLocation.setY(thumbLocation.y() + track->contentHeight() - thumb->h
eight() - offset); |
204 else if (style()->isLeftToRightDirection()) | 201 else if (style()->isLeftToRightDirection()) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 { | 245 { |
249 setPositionFromPoint(point); | 246 setPositionFromPoint(point); |
250 startDragging(); | 247 startDragging(); |
251 } | 248 } |
252 | 249 |
253 void SliderThumbElement::setPositionFromPoint(const LayoutPoint& point) | 250 void SliderThumbElement::setPositionFromPoint(const LayoutPoint& point) |
254 { | 251 { |
255 HTMLInputElement* input = hostInput(); | 252 HTMLInputElement* input = hostInput(); |
256 HTMLElement* trackElement = sliderTrackElementOf(input); | 253 HTMLElement* trackElement = sliderTrackElementOf(input); |
257 | 254 |
258 if (!input->renderer() || !renderer() || !trackElement->renderer()) | 255 if (!input->renderer() || !renderBox() || !trackElement->renderBox()) |
259 return; | 256 return; |
260 | 257 |
261 input->setTextAsOfLastFormControlChangeEvent(input->value()); | 258 input->setTextAsOfLastFormControlChangeEvent(input->value()); |
262 LayoutPoint offset = roundedLayoutPoint(input->renderer()->absoluteToLocal(p
oint, UseTransforms)); | 259 LayoutPoint offset = roundedLayoutPoint(input->renderer()->absoluteToLocal(p
oint, UseTransforms)); |
263 bool isVertical = hasVerticalAppearance(input); | 260 bool isVertical = hasVerticalAppearance(input); |
264 bool isLeftToRightDirection = renderBox()->style()->isLeftToRightDirection()
; | 261 bool isLeftToRightDirection = renderBox()->style()->isLeftToRightDirection()
; |
265 LayoutUnit trackSize; | 262 LayoutUnit trackSize; |
266 LayoutUnit position; | 263 LayoutUnit position; |
267 LayoutUnit currentPosition; | 264 LayoutUnit currentPosition; |
268 // We need to calculate currentPosition from absolute points becaue the | 265 // We need to calculate currentPosition from absolute points becaue the |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 case MediaVolumeSliderThumbPart: | 467 case MediaVolumeSliderThumbPart: |
471 case MediaFullScreenVolumeSliderPart: | 468 case MediaFullScreenVolumeSliderPart: |
472 case MediaFullScreenVolumeSliderThumbPart: | 469 case MediaFullScreenVolumeSliderThumbPart: |
473 return mediaSliderContainer; | 470 return mediaSliderContainer; |
474 default: | 471 default: |
475 return sliderContainer; | 472 return sliderContainer; |
476 } | 473 } |
477 } | 474 } |
478 | 475 |
479 } | 476 } |
OLD | NEW |