| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 inline static Decimal sliderPosition(HTMLInputElement* element) | 51 inline static Decimal sliderPosition(HTMLInputElement* element) |
| 52 { | 52 { |
| 53 const StepRange stepRange(element->createStepRange(RejectAny)); | 53 const StepRange stepRange(element->createStepRange(RejectAny)); |
| 54 const Decimal oldValue = parseToDecimalForNumberType(element->value(), stepR
ange.defaultValue()); | 54 const Decimal oldValue = parseToDecimalForNumberType(element->value(), stepR
ange.defaultValue()); |
| 55 return stepRange.proportionFromValue(stepRange.clampValue(oldValue)); | 55 return stepRange.proportionFromValue(stepRange.clampValue(oldValue)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 inline static bool hasVerticalAppearance(HTMLInputElement* input) | 58 inline static bool hasVerticalAppearance(HTMLInputElement* input) |
| 59 { | 59 { |
| 60 ASSERT(input->renderer()); | 60 ASSERT(input->renderer()); |
| 61 RenderStyle* sliderStyle = input->renderer()->style(); | 61 const RenderStyle* sliderStyle = input->renderer()->style(); |
| 62 | 62 |
| 63 return sliderStyle->appearance() == SliderVerticalPart; | 63 return sliderStyle->appearance() == SliderVerticalPart; |
| 64 } | 64 } |
| 65 | 65 |
| 66 void LayoutSliderContainer::computeLogicalHeight(LayoutUnit logicalHeight, Layou
tUnit logicalTop, LogicalExtentComputedValues& computedValues) const | 66 void LayoutSliderContainer::computeLogicalHeight(LayoutUnit logicalHeight, Layou
tUnit logicalTop, LogicalExtentComputedValues& computedValues) const |
| 67 { | 67 { |
| 68 HTMLInputElement* input = toHTMLInputElement(node()->shadowHost()); | 68 HTMLInputElement* input = toHTMLInputElement(node()->shadowHost()); |
| 69 bool isVertical = hasVerticalAppearance(input); | 69 bool isVertical = hasVerticalAppearance(input); |
| 70 | 70 |
| 71 if (input->renderer()->isSlider() && !isVertical && input->list()) { | 71 if (input->renderer()->isSlider() && !isVertical && input->list()) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 93 // FIXME: The trackHeight should have been added before updateLogicalHeight
was called to avoid this hack. | 93 // FIXME: The trackHeight should have been added before updateLogicalHeight
was called to avoid this hack. |
| 94 setIntrinsicContentLogicalHeight(logicalHeight); | 94 setIntrinsicContentLogicalHeight(logicalHeight); |
| 95 | 95 |
| 96 RenderBox::computeLogicalHeight(logicalHeight, logicalTop, computedValues); | 96 RenderBox::computeLogicalHeight(logicalHeight, logicalTop, computedValues); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void LayoutSliderContainer::layout() | 99 void LayoutSliderContainer::layout() |
| 100 { | 100 { |
| 101 HTMLInputElement* input = toHTMLInputElement(node()->shadowHost()); | 101 HTMLInputElement* input = toHTMLInputElement(node()->shadowHost()); |
| 102 bool isVertical = hasVerticalAppearance(input); | 102 bool isVertical = hasVerticalAppearance(input); |
| 103 style()->setFlexDirection(isVertical ? FlowColumn : FlowRow); | 103 deprecatedMutableStyle()->setFlexDirection(isVertical ? FlowColumn : FlowRow
); |
| 104 TextDirection oldTextDirection = style()->direction(); | 104 TextDirection oldTextDirection = style()->direction(); |
| 105 if (isVertical) { | 105 if (isVertical) { |
| 106 // FIXME: Work around rounding issues in RTL vertical sliders. We want t
hem to | 106 // FIXME: Work around rounding issues in RTL vertical sliders. We want t
hem to |
| 107 // render identically to LTR vertical sliders. We can remove this work a
round when | 107 // render identically to LTR vertical sliders. We can remove this work a
round when |
| 108 // subpixel rendering is enabled on all ports. | 108 // subpixel rendering is enabled on all ports. |
| 109 style()->setDirection(LTR); | 109 deprecatedMutableStyle()->setDirection(LTR); |
| 110 } | 110 } |
| 111 | 111 |
| 112 Element* thumbElement = input->userAgentShadowRoot()->getElementById(ShadowE
lementNames::sliderThumb()); | 112 Element* thumbElement = input->userAgentShadowRoot()->getElementById(ShadowE
lementNames::sliderThumb()); |
| 113 Element* trackElement = input->userAgentShadowRoot()->getElementById(ShadowE
lementNames::sliderTrack()); | 113 Element* trackElement = input->userAgentShadowRoot()->getElementById(ShadowE
lementNames::sliderTrack()); |
| 114 RenderBox* thumb = thumbElement ? thumbElement->renderBox() : 0; | 114 RenderBox* thumb = thumbElement ? thumbElement->renderBox() : 0; |
| 115 RenderBox* track = trackElement ? trackElement->renderBox() : 0; | 115 RenderBox* track = trackElement ? trackElement->renderBox() : 0; |
| 116 | 116 |
| 117 SubtreeLayoutScope layoutScope(*this); | 117 SubtreeLayoutScope layoutScope(*this); |
| 118 // Force a layout to reset the position of the thumb so the code below doesn
't move the thumb to the wrong place. | 118 // Force a layout to reset the position of the thumb so the code below doesn
't move the thumb to the wrong place. |
| 119 // FIXME: Make a custom Render class for the track and move the thumb positi
oning code there. | 119 // FIXME: Make a custom Render class for the track and move the thumb positi
oning code there. |
| 120 if (track) | 120 if (track) |
| 121 layoutScope.setChildNeedsLayout(track); | 121 layoutScope.setChildNeedsLayout(track); |
| 122 | 122 |
| 123 RenderFlexibleBox::layout(); | 123 RenderFlexibleBox::layout(); |
| 124 | 124 |
| 125 style()->setDirection(oldTextDirection); | 125 deprecatedMutableStyle()->setDirection(oldTextDirection); |
| 126 // These should always exist, unless someone mutates the shadow DOM (e.g., i
n the inspector). | 126 // These should always exist, unless someone mutates the shadow DOM (e.g., i
n the inspector). |
| 127 if (!thumb || !track) | 127 if (!thumb || !track) |
| 128 return; | 128 return; |
| 129 | 129 |
| 130 double percentageOffset = sliderPosition(input).toDouble(); | 130 double percentageOffset = sliderPosition(input).toDouble(); |
| 131 LayoutUnit availableExtent = isVertical ? track->contentHeight() : track->co
ntentWidth(); | 131 LayoutUnit availableExtent = isVertical ? track->contentHeight() : track->co
ntentWidth(); |
| 132 availableExtent -= isVertical ? thumb->size().height() : thumb->size().width
(); | 132 availableExtent -= isVertical ? thumb->size().height() : thumb->size().width
(); |
| 133 LayoutUnit offset = percentageOffset * availableExtent; | 133 LayoutUnit offset = percentageOffset * availableExtent; |
| 134 LayoutPoint thumbLocation = thumb->location(); | 134 LayoutPoint thumbLocation = thumb->location(); |
| 135 if (isVertical) | 135 if (isVertical) |
| 136 thumbLocation.setY(thumbLocation.y() + track->contentHeight() - thumb->s
ize().height() - offset); | 136 thumbLocation.setY(thumbLocation.y() + track->contentHeight() - thumb->s
ize().height() - offset); |
| 137 else if (style()->isLeftToRightDirection()) | 137 else if (style()->isLeftToRightDirection()) |
| 138 thumbLocation.setX(thumbLocation.x() + offset); | 138 thumbLocation.setX(thumbLocation.x() + offset); |
| 139 else | 139 else |
| 140 thumbLocation.setX(thumbLocation.x() - offset); | 140 thumbLocation.setX(thumbLocation.x() - offset); |
| 141 thumb->setLocation(thumbLocation); | 141 thumb->setLocation(thumbLocation); |
| 142 | 142 |
| 143 // We need one-off invalidation code here because painting of the timeline e
lement does not go through style. | 143 // We need one-off invalidation code here because painting of the timeline e
lement does not go through style. |
| 144 // Instead it has a custom implementation in C++ code. | 144 // Instead it has a custom implementation in C++ code. |
| 145 // Therefore the style system cannot understand when it needs to be paint in
validated. | 145 // Therefore the style system cannot understand when it needs to be paint in
validated. |
| 146 setShouldDoFullPaintInvalidation(); | 146 setShouldDoFullPaintInvalidation(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 } // namespace blink | 149 } // namespace blink |
| OLD | NEW |