| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 layoutHorizontalPart(); | 89 layoutHorizontalPart(); |
| 90 else | 90 else |
| 91 layoutVerticalPart(); | 91 layoutVerticalPart(); |
| 92 | 92 |
| 93 clearNeedsLayout(); | 93 clearNeedsLayout(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void LayoutScrollbarPart::layoutHorizontalPart() | 96 void LayoutScrollbarPart::layoutHorizontalPart() |
| 97 { | 97 { |
| 98 if (m_part == ScrollbarBGPart) { | 98 if (m_part == ScrollbarBGPart) { |
| 99 setWidth(m_scrollbar->width()); | 99 setWidth(LayoutUnit(m_scrollbar->width())); |
| 100 computeScrollbarHeight(); | 100 computeScrollbarHeight(); |
| 101 } else { | 101 } else { |
| 102 computeScrollbarWidth(); | 102 computeScrollbarWidth(); |
| 103 setHeight(m_scrollbar->height()); | 103 setHeight(LayoutUnit(m_scrollbar->height())); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 void LayoutScrollbarPart::layoutVerticalPart() | 107 void LayoutScrollbarPart::layoutVerticalPart() |
| 108 { | 108 { |
| 109 if (m_part == ScrollbarBGPart) { | 109 if (m_part == ScrollbarBGPart) { |
| 110 computeScrollbarWidth(); | 110 computeScrollbarWidth(); |
| 111 setHeight(m_scrollbar->height()); | 111 setHeight(LayoutUnit(m_scrollbar->height())); |
| 112 } else { | 112 } else { |
| 113 setWidth(m_scrollbar->width()); | 113 setWidth(LayoutUnit(m_scrollbar->width())); |
| 114 computeScrollbarHeight(); | 114 computeScrollbarHeight(); |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 static int calcScrollbarThicknessUsing(SizeType sizeType, const Length& length,
int containingLength) | 118 static int calcScrollbarThicknessUsing(SizeType sizeType, const Length& length,
int containingLength) |
| 119 { | 119 { |
| 120 if (!length.isIntrinsicOrAuto() || (sizeType == MinSize && length.isAuto())) | 120 if (!length.isIntrinsicOrAuto() || (sizeType == MinSize && length.isAuto())) |
| 121 return minimumValueForLength(length, containingLength); | 121 return minimumValueForLength(length, LayoutUnit(containingLength)); |
| 122 return ScrollbarTheme::theme().scrollbarThickness(); | 122 return ScrollbarTheme::theme().scrollbarThickness(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void LayoutScrollbarPart::computeScrollbarWidth() | 125 void LayoutScrollbarPart::computeScrollbarWidth() |
| 126 { | 126 { |
| 127 if (!m_scrollbar->owningLayoutObject()) | 127 if (!m_scrollbar->owningLayoutObject()) |
| 128 return; | 128 return; |
| 129 // FIXME: We are querying layout information but nothing guarantees that it'
s up-to-date, especially since we are called at style change. | 129 // FIXME: We are querying layout information but nothing guarantees that it'
s up-to-date, especially since we are called at style change. |
| 130 // FIXME: Querying the style's border information doesn't work on table cell
s with collapsing borders. | 130 // FIXME: Querying the style's border information doesn't work on table cell
s with collapsing borders. |
| 131 int visibleSize = m_scrollbar->owningLayoutObject()->size().width() - m_scro
llbar->owningLayoutObject()->style()->borderLeftWidth() - m_scrollbar->owningLay
outObject()->style()->borderRightWidth(); | 131 int visibleSize = m_scrollbar->owningLayoutObject()->size().width() - m_scro
llbar->owningLayoutObject()->style()->borderLeftWidth() - m_scrollbar->owningLay
outObject()->style()->borderRightWidth(); |
| 132 int w = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->width(), v
isibleSize); | 132 int w = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->width(), v
isibleSize); |
| 133 int minWidth = calcScrollbarThicknessUsing(MinSize, style()->minWidth(), vis
ibleSize); | 133 int minWidth = calcScrollbarThicknessUsing(MinSize, style()->minWidth(), vis
ibleSize); |
| 134 int maxWidth = style()->maxWidth().isMaxSizeNone() ? w : calcScrollbarThickn
essUsing(MaxSize, style()->maxWidth(), visibleSize); | 134 int maxWidth = style()->maxWidth().isMaxSizeNone() ? w : calcScrollbarThickn
essUsing(MaxSize, style()->maxWidth(), visibleSize); |
| 135 setWidth(std::max(minWidth, std::min(maxWidth, w))); | 135 setWidth(LayoutUnit(std::max(minWidth, std::min(maxWidth, w)))); |
| 136 | 136 |
| 137 // Buttons and track pieces can all have margins along the axis of the scrol
lbar. | 137 // Buttons and track pieces can all have margins along the axis of the scrol
lbar. |
| 138 setMarginLeft(minimumValueForLength(style()->marginLeft(), visibleSize)); | 138 setMarginLeft(minimumValueForLength(style()->marginLeft(), LayoutUnit(visibl
eSize))); |
| 139 setMarginRight(minimumValueForLength(style()->marginRight(), visibleSize)); | 139 setMarginRight(minimumValueForLength(style()->marginRight(), LayoutUnit(visi
bleSize))); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void LayoutScrollbarPart::computeScrollbarHeight() | 142 void LayoutScrollbarPart::computeScrollbarHeight() |
| 143 { | 143 { |
| 144 if (!m_scrollbar->owningLayoutObject()) | 144 if (!m_scrollbar->owningLayoutObject()) |
| 145 return; | 145 return; |
| 146 // FIXME: We are querying layout information but nothing guarantees that it'
s up-to-date, especially since we are called at style change. | 146 // FIXME: We are querying layout information but nothing guarantees that it'
s up-to-date, especially since we are called at style change. |
| 147 // FIXME: Querying the style's border information doesn't work on table cell
s with collapsing borders. | 147 // FIXME: Querying the style's border information doesn't work on table cell
s with collapsing borders. |
| 148 int visibleSize = m_scrollbar->owningLayoutObject()->size().height() - m_sc
rollbar->owningLayoutObject()->style()->borderTopWidth() - m_scrollbar->owningLa
youtObject()->style()->borderBottomWidth(); | 148 int visibleSize = m_scrollbar->owningLayoutObject()->size().height() - m_sc
rollbar->owningLayoutObject()->style()->borderTopWidth() - m_scrollbar->owningLa
youtObject()->style()->borderBottomWidth(); |
| 149 int h = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->height(),
visibleSize); | 149 int h = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->height(),
visibleSize); |
| 150 int minHeight = calcScrollbarThicknessUsing(MinSize, style()->minHeight(), v
isibleSize); | 150 int minHeight = calcScrollbarThicknessUsing(MinSize, style()->minHeight(), v
isibleSize); |
| 151 int maxHeight = style()->maxHeight().isMaxSizeNone() ? h : calcScrollbarThic
knessUsing(MaxSize, style()->maxHeight(), visibleSize); | 151 int maxHeight = style()->maxHeight().isMaxSizeNone() ? h : calcScrollbarThic
knessUsing(MaxSize, style()->maxHeight(), visibleSize); |
| 152 setHeight(std::max(minHeight, std::min(maxHeight, h))); | 152 setHeight(LayoutUnit(std::max(minHeight, std::min(maxHeight, h)))); |
| 153 | 153 |
| 154 // Buttons and track pieces can all have margins along the axis of the scrol
lbar. | 154 // Buttons and track pieces can all have margins along the axis of the scrol
lbar. |
| 155 setMarginTop(minimumValueForLength(style()->marginTop(), visibleSize)); | 155 setMarginTop(minimumValueForLength(style()->marginTop(), LayoutUnit(visibleS
ize))); |
| 156 setMarginBottom(minimumValueForLength(style()->marginBottom(), visibleSize))
; | 156 setMarginBottom(minimumValueForLength(style()->marginBottom(), LayoutUnit(vi
sibleSize))); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void LayoutScrollbarPart::computePreferredLogicalWidths() | 159 void LayoutScrollbarPart::computePreferredLogicalWidths() |
| 160 { | 160 { |
| 161 if (!preferredLogicalWidthsDirty()) | 161 if (!preferredLogicalWidthsDirty()) |
| 162 return; | 162 return; |
| 163 | 163 |
| 164 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = 0; | 164 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = LayoutUnit(); |
| 165 | 165 |
| 166 clearPreferredLogicalWidthsDirty(); | 166 clearPreferredLogicalWidthsDirty(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void LayoutScrollbarPart::styleWillChange(StyleDifference diff, const ComputedSt
yle& newStyle) | 169 void LayoutScrollbarPart::styleWillChange(StyleDifference diff, const ComputedSt
yle& newStyle) |
| 170 { | 170 { |
| 171 LayoutBlock::styleWillChange(diff, newStyle); | 171 LayoutBlock::styleWillChange(diff, newStyle); |
| 172 setInline(false); | 172 setInline(false); |
| 173 } | 173 } |
| 174 | 174 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 frameView->setScrollCornerNeedsPaintInvalidation(); | 208 frameView->setScrollCornerNeedsPaintInvalidation(); |
| 209 return; | 209 return; |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 | 212 |
| 213 // This LayoutScrollbarPart belongs to a PaintLayerScrollableArea. | 213 // This LayoutScrollbarPart belongs to a PaintLayerScrollableArea. |
| 214 toLayoutBox(parent())->scrollableArea()->setScrollCornerNeedsPaintInvalidati
on(); | 214 toLayoutBox(parent())->scrollableArea()->setScrollCornerNeedsPaintInvalidati
on(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 } // namespace blink | 217 } // namespace blink |
| OLD | NEW |