| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 void LayoutSliderContainer::computeLogicalHeight(LayoutUnit logicalHeight, Layou
tUnit logicalTop, LogicalExtentComputedValues& computedValues) const | 65 void LayoutSliderContainer::computeLogicalHeight(LayoutUnit logicalHeight, Layou
tUnit logicalTop, LogicalExtentComputedValues& computedValues) const |
| 66 { | 66 { |
| 67 HTMLInputElement* input = toHTMLInputElement(node()->shadowHost()); | 67 HTMLInputElement* input = toHTMLInputElement(node()->shadowHost()); |
| 68 bool isVertical = hasVerticalAppearance(input); | 68 bool isVertical = hasVerticalAppearance(input); |
| 69 | 69 |
| 70 if (input->layoutObject()->isSlider() && !isVertical && input->list()) { | 70 if (input->layoutObject()->isSlider() && !isVertical && input->list()) { |
| 71 int offsetFromCenter = LayoutTheme::theme().sliderTickOffsetFromTrackCen
ter(); | 71 int offsetFromCenter = LayoutTheme::theme().sliderTickOffsetFromTrackCen
ter(); |
| 72 LayoutUnit trackHeight; | 72 LayoutUnit trackHeight; |
| 73 if (offsetFromCenter < 0) { | 73 if (offsetFromCenter < 0) { |
| 74 trackHeight = -2 * offsetFromCenter; | 74 trackHeight = LayoutUnit(-2 * offsetFromCenter); |
| 75 } else { | 75 } else { |
| 76 int tickLength = LayoutTheme::theme().sliderTickSize().height(); | 76 int tickLength = LayoutTheme::theme().sliderTickSize().height(); |
| 77 trackHeight = 2 * (offsetFromCenter + tickLength); | 77 trackHeight = LayoutUnit(2 * (offsetFromCenter + tickLength)); |
| 78 } | 78 } |
| 79 float zoomFactor = style()->effectiveZoom(); | 79 float zoomFactor = style()->effectiveZoom(); |
| 80 if (zoomFactor != 1.0) | 80 if (zoomFactor != 1.0) |
| 81 trackHeight *= zoomFactor; | 81 trackHeight *= zoomFactor; |
| 82 | 82 |
| 83 // FIXME: The trackHeight should have been added before updateLogicalHei
ght was called to avoid this hack. | 83 // FIXME: The trackHeight should have been added before updateLogicalHei
ght was called to avoid this hack. |
| 84 setIntrinsicContentLogicalHeight(trackHeight); | 84 setIntrinsicContentLogicalHeight(trackHeight); |
| 85 | 85 |
| 86 LayoutBox::computeLogicalHeight(trackHeight, logicalTop, computedValues)
; | 86 LayoutBox::computeLogicalHeight(trackHeight, logicalTop, computedValues)
; |
| 87 return; | 87 return; |
| 88 } | 88 } |
| 89 if (isVertical) | 89 if (isVertical) |
| 90 logicalHeight = LayoutSlider::defaultTrackLength; | 90 logicalHeight = LayoutUnit(LayoutSlider::defaultTrackLength); |
| 91 | 91 |
| 92 // FIXME: The trackHeight should have been added before updateLogicalHeight
was called to avoid this hack. | 92 // FIXME: The trackHeight should have been added before updateLogicalHeight
was called to avoid this hack. |
| 93 setIntrinsicContentLogicalHeight(logicalHeight); | 93 setIntrinsicContentLogicalHeight(logicalHeight); |
| 94 | 94 |
| 95 LayoutBox::computeLogicalHeight(logicalHeight, logicalTop, computedValues); | 95 LayoutBox::computeLogicalHeight(logicalHeight, logicalTop, computedValues); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void LayoutSliderContainer::layout() | 98 void LayoutSliderContainer::layout() |
| 99 { | 99 { |
| 100 HTMLInputElement* input = toHTMLInputElement(node()->shadowHost()); | 100 HTMLInputElement* input = toHTMLInputElement(node()->shadowHost()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 122 LayoutFlexibleBox::layout(); | 122 LayoutFlexibleBox::layout(); |
| 123 | 123 |
| 124 mutableStyleRef().setDirection(oldTextDirection); | 124 mutableStyleRef().setDirection(oldTextDirection); |
| 125 // These should always exist, unless someone mutates the shadow DOM (e.g., i
n the inspector). | 125 // These should always exist, unless someone mutates the shadow DOM (e.g., i
n the inspector). |
| 126 if (!thumb || !track) | 126 if (!thumb || !track) |
| 127 return; | 127 return; |
| 128 | 128 |
| 129 double percentageOffset = sliderPosition(input).toDouble(); | 129 double percentageOffset = sliderPosition(input).toDouble(); |
| 130 LayoutUnit availableExtent = isVertical ? track->contentHeight() : track->co
ntentWidth(); | 130 LayoutUnit availableExtent = isVertical ? track->contentHeight() : track->co
ntentWidth(); |
| 131 availableExtent -= isVertical ? thumb->size().height() : thumb->size().width
(); | 131 availableExtent -= isVertical ? thumb->size().height() : thumb->size().width
(); |
| 132 LayoutUnit offset = percentageOffset * availableExtent; | 132 LayoutUnit offset(percentageOffset * availableExtent); |
| 133 LayoutPoint thumbLocation = thumb->location(); | 133 LayoutPoint thumbLocation = thumb->location(); |
| 134 if (isVertical) | 134 if (isVertical) |
| 135 thumbLocation.setY(thumbLocation.y() + track->contentHeight() - thumb->s
ize().height() - offset); | 135 thumbLocation.setY(thumbLocation.y() + track->contentHeight() - thumb->s
ize().height() - offset); |
| 136 else if (style()->isLeftToRightDirection()) | 136 else if (style()->isLeftToRightDirection()) |
| 137 thumbLocation.setX(thumbLocation.x() + offset); | 137 thumbLocation.setX(thumbLocation.x() + offset); |
| 138 else | 138 else |
| 139 thumbLocation.setX(thumbLocation.x() - offset); | 139 thumbLocation.setX(thumbLocation.x() - offset); |
| 140 thumb->setLocation(thumbLocation); | 140 thumb->setLocation(thumbLocation); |
| 141 | 141 |
| 142 // We need one-off invalidation code here because painting of the timeline e
lement does not go through style. | 142 // We need one-off invalidation code here because painting of the timeline e
lement does not go through style. |
| 143 // Instead it has a custom implementation in C++ code. | 143 // Instead it has a custom implementation in C++ code. |
| 144 // Therefore the style system cannot understand when it needs to be paint in
validated. | 144 // Therefore the style system cannot understand when it needs to be paint in
validated. |
| 145 setShouldDoFullPaintInvalidation(); | 145 setShouldDoFullPaintInvalidation(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 } // namespace blink | 148 } // namespace blink |
| OLD | NEW |