| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 if (offsetFromCenter < 0) { | 72 if (offsetFromCenter < 0) { |
| 73 trackHeight = LayoutUnit(-2 * offsetFromCenter); | 73 trackHeight = LayoutUnit(-2 * offsetFromCenter); |
| 74 } else { | 74 } else { |
| 75 int tickLength = LayoutTheme::theme().sliderTickSize().height(); | 75 int tickLength = LayoutTheme::theme().sliderTickSize().height(); |
| 76 trackHeight = LayoutUnit(2 * (offsetFromCenter + tickLength)); | 76 trackHeight = LayoutUnit(2 * (offsetFromCenter + tickLength)); |
| 77 } | 77 } |
| 78 float zoomFactor = style()->effectiveZoom(); | 78 float zoomFactor = style()->effectiveZoom(); |
| 79 if (zoomFactor != 1.0) | 79 if (zoomFactor != 1.0) |
| 80 trackHeight *= zoomFactor; | 80 trackHeight *= zoomFactor; |
| 81 | 81 |
| 82 // FIXME: The trackHeight should have been added before updateLogicalHeight
was called to avoid this hack. | 82 // FIXME: The trackHeight should have been added before updateLogicalHeight |
| 83 // was called to avoid this hack. |
| 83 setIntrinsicContentLogicalHeight(trackHeight); | 84 setIntrinsicContentLogicalHeight(trackHeight); |
| 84 | 85 |
| 85 LayoutBox::computeLogicalHeight(trackHeight, logicalTop, computedValues); | 86 LayoutBox::computeLogicalHeight(trackHeight, logicalTop, computedValues); |
| 86 return; | 87 return; |
| 87 } | 88 } |
| 88 if (isVertical) | 89 if (isVertical) |
| 89 logicalHeight = LayoutUnit(LayoutSlider::defaultTrackLength); | 90 logicalHeight = LayoutUnit(LayoutSlider::defaultTrackLength); |
| 90 | 91 |
| 91 // FIXME: The trackHeight should have been added before updateLogicalHeight wa
s called to avoid this hack. | 92 // FIXME: The trackHeight should have been added before updateLogicalHeight |
| 93 // was called to avoid this hack. |
| 92 setIntrinsicContentLogicalHeight(logicalHeight); | 94 setIntrinsicContentLogicalHeight(logicalHeight); |
| 93 | 95 |
| 94 LayoutBox::computeLogicalHeight(logicalHeight, logicalTop, computedValues); | 96 LayoutBox::computeLogicalHeight(logicalHeight, logicalTop, computedValues); |
| 95 } | 97 } |
| 96 | 98 |
| 97 void LayoutSliderContainer::layout() { | 99 void LayoutSliderContainer::layout() { |
| 98 HTMLInputElement* input = toHTMLInputElement(node()->ownerShadowHost()); | 100 HTMLInputElement* input = toHTMLInputElement(node()->ownerShadowHost()); |
| 99 bool isVertical = hasVerticalAppearance(input); | 101 bool isVertical = hasVerticalAppearance(input); |
| 100 mutableStyleRef().setFlexDirection(isVertical ? FlowColumn : FlowRow); | 102 mutableStyleRef().setFlexDirection(isVertical ? FlowColumn : FlowRow); |
| 101 TextDirection oldTextDirection = style()->direction(); | 103 TextDirection oldTextDirection = style()->direction(); |
| 102 if (isVertical) { | 104 if (isVertical) { |
| 103 // FIXME: Work around rounding issues in RTL vertical sliders. We want them
to | 105 // FIXME: Work around rounding issues in RTL vertical sliders. We want them |
| 104 // render identically to LTR vertical sliders. We can remove this work aroun
d when | 106 // to render identically to LTR vertical sliders. We can remove this work |
| 105 // subpixel rendering is enabled on all ports. | 107 // around when subpixel rendering is enabled on all ports. |
| 106 mutableStyleRef().setDirection(LTR); | 108 mutableStyleRef().setDirection(LTR); |
| 107 } | 109 } |
| 108 | 110 |
| 109 Element* thumbElement = input->userAgentShadowRoot()->getElementById( | 111 Element* thumbElement = input->userAgentShadowRoot()->getElementById( |
| 110 ShadowElementNames::sliderThumb()); | 112 ShadowElementNames::sliderThumb()); |
| 111 Element* trackElement = input->userAgentShadowRoot()->getElementById( | 113 Element* trackElement = input->userAgentShadowRoot()->getElementById( |
| 112 ShadowElementNames::sliderTrack()); | 114 ShadowElementNames::sliderTrack()); |
| 113 LayoutBox* thumb = thumbElement ? thumbElement->layoutBox() : 0; | 115 LayoutBox* thumb = thumbElement ? thumbElement->layoutBox() : 0; |
| 114 LayoutBox* track = trackElement ? trackElement->layoutBox() : 0; | 116 LayoutBox* track = trackElement ? trackElement->layoutBox() : 0; |
| 115 | 117 |
| 116 SubtreeLayoutScope layoutScope(*this); | 118 SubtreeLayoutScope layoutScope(*this); |
| 117 // Force a layout to reset the position of the thumb so the code below doesn't
move the thumb to the wrong place. | 119 // Force a layout to reset the position of the thumb so the code below doesn't |
| 118 // FIXME: Make a custom layout class for the track and move the thumb position
ing code there. | 120 // move the thumb to the wrong place. |
| 121 // FIXME: Make a custom layout class for the track and move the thumb |
| 122 // positioning code there. |
| 119 if (track) | 123 if (track) |
| 120 layoutScope.setChildNeedsLayout(track); | 124 layoutScope.setChildNeedsLayout(track); |
| 121 | 125 |
| 122 LayoutFlexibleBox::layout(); | 126 LayoutFlexibleBox::layout(); |
| 123 | 127 |
| 124 mutableStyleRef().setDirection(oldTextDirection); | 128 mutableStyleRef().setDirection(oldTextDirection); |
| 125 // These should always exist, unless someone mutates the shadow DOM (e.g., in
the inspector). | 129 // These should always exist, unless someone mutates the shadow DOM (e.g., in |
| 130 // the inspector). |
| 126 if (!thumb || !track) | 131 if (!thumb || !track) |
| 127 return; | 132 return; |
| 128 | 133 |
| 129 double percentageOffset = sliderPosition(input).toDouble(); | 134 double percentageOffset = sliderPosition(input).toDouble(); |
| 130 LayoutUnit availableExtent = | 135 LayoutUnit availableExtent = |
| 131 isVertical ? track->contentHeight() : track->contentWidth(); | 136 isVertical ? track->contentHeight() : track->contentWidth(); |
| 132 availableExtent -= | 137 availableExtent -= |
| 133 isVertical ? thumb->size().height() : thumb->size().width(); | 138 isVertical ? thumb->size().height() : thumb->size().width(); |
| 134 LayoutUnit offset(percentageOffset * availableExtent); | 139 LayoutUnit offset(percentageOffset * availableExtent); |
| 135 LayoutPoint thumbLocation = thumb->location(); | 140 LayoutPoint thumbLocation = thumb->location(); |
| 136 if (isVertical) | 141 if (isVertical) |
| 137 thumbLocation.setY(thumbLocation.y() + track->contentHeight() - | 142 thumbLocation.setY(thumbLocation.y() + track->contentHeight() - |
| 138 thumb->size().height() - offset); | 143 thumb->size().height() - offset); |
| 139 else if (style()->isLeftToRightDirection()) | 144 else if (style()->isLeftToRightDirection()) |
| 140 thumbLocation.setX(thumbLocation.x() + offset); | 145 thumbLocation.setX(thumbLocation.x() + offset); |
| 141 else | 146 else |
| 142 thumbLocation.setX(thumbLocation.x() - offset); | 147 thumbLocation.setX(thumbLocation.x() - offset); |
| 143 thumb->setLocation(thumbLocation); | 148 thumb->setLocation(thumbLocation); |
| 144 | 149 |
| 145 // We need one-off invalidation code here because painting of the timeline ele
ment does not go through style. | 150 // We need one-off invalidation code here because painting of the timeline |
| 151 // element does not go through style. |
| 146 // Instead it has a custom implementation in C++ code. | 152 // Instead it has a custom implementation in C++ code. |
| 147 // Therefore the style system cannot understand when it needs to be paint inva
lidated. | 153 // Therefore the style system cannot understand when it needs to be paint |
| 154 // invalidated. |
| 148 setShouldDoFullPaintInvalidation(); | 155 setShouldDoFullPaintInvalidation(); |
| 149 } | 156 } |
| 150 | 157 |
| 151 } // namespace blink | 158 } // namespace blink |
| OLD | NEW |