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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 return ScrollbarTheme::theme().scrollbarThickness(); | 132 return ScrollbarTheme::theme().scrollbarThickness(); |
133 } | 133 } |
134 | 134 |
135 void LayoutScrollbarPart::computeScrollbarWidth() { | 135 void LayoutScrollbarPart::computeScrollbarWidth() { |
136 if (!m_scrollbar->styleSource()) | 136 if (!m_scrollbar->styleSource()) |
137 return; | 137 return; |
138 // FIXME: We are querying layout information but nothing guarantees that it's | 138 // FIXME: We are querying layout information but nothing guarantees that it's |
139 // up to date, especially since we are called at style change. | 139 // up to date, especially since we are called at style change. |
140 // FIXME: Querying the style's border information doesn't work on table cells | 140 // FIXME: Querying the style's border information doesn't work on table cells |
141 // with collapsing borders. | 141 // with collapsing borders. |
142 int visibleSize = (m_scrollbar->styleSource()->size().width() - | 142 int visibleSize = m_scrollbar->styleSource()->size().width() - |
143 m_scrollbar->styleSource()->style()->borderLeftWidth() - | 143 m_scrollbar->styleSource()->style()->borderLeftWidth() - |
144 m_scrollbar->styleSource()->style()->borderRightWidth()) | 144 m_scrollbar->styleSource()->style()->borderRightWidth(); |
145 .toInt(); | |
146 int w = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->width(), | 145 int w = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->width(), |
147 visibleSize); | 146 visibleSize); |
148 int minWidth = | 147 int minWidth = |
149 calcScrollbarThicknessUsing(MinSize, style()->minWidth(), visibleSize); | 148 calcScrollbarThicknessUsing(MinSize, style()->minWidth(), visibleSize); |
150 int maxWidth = style()->maxWidth().isMaxSizeNone() | 149 int maxWidth = style()->maxWidth().isMaxSizeNone() |
151 ? w | 150 ? w |
152 : calcScrollbarThicknessUsing(MaxSize, style()->maxWidth(), | 151 : calcScrollbarThicknessUsing(MaxSize, style()->maxWidth(), |
153 visibleSize); | 152 visibleSize); |
154 setWidth(LayoutUnit(std::max(minWidth, std::min(maxWidth, w)))); | 153 setWidth(LayoutUnit(std::max(minWidth, std::min(maxWidth, w)))); |
155 | 154 |
156 // Buttons and track pieces can all have margins along the axis of the | 155 // Buttons and track pieces can all have margins along the axis of the |
157 // scrollbar. | 156 // scrollbar. |
158 setMarginLeft( | 157 setMarginLeft( |
159 minimumValueForLength(style()->marginLeft(), LayoutUnit(visibleSize))); | 158 minimumValueForLength(style()->marginLeft(), LayoutUnit(visibleSize))); |
160 setMarginRight( | 159 setMarginRight( |
161 minimumValueForLength(style()->marginRight(), LayoutUnit(visibleSize))); | 160 minimumValueForLength(style()->marginRight(), LayoutUnit(visibleSize))); |
162 } | 161 } |
163 | 162 |
164 void LayoutScrollbarPart::computeScrollbarHeight() { | 163 void LayoutScrollbarPart::computeScrollbarHeight() { |
165 if (!m_scrollbar->styleSource()) | 164 if (!m_scrollbar->styleSource()) |
166 return; | 165 return; |
167 // FIXME: We are querying layout information but nothing guarantees that it's | 166 // FIXME: We are querying layout information but nothing guarantees that it's |
168 // up to date, especially since we are called at style change. | 167 // up to date, especially since we are called at style change. |
169 // FIXME: Querying the style's border information doesn't work on table cells | 168 // FIXME: Querying the style's border information doesn't work on table cells |
170 // with collapsing borders. | 169 // with collapsing borders. |
171 int visibleSize = (m_scrollbar->styleSource()->size().height() - | 170 int visibleSize = m_scrollbar->styleSource()->size().height() - |
172 m_scrollbar->styleSource()->style()->borderTopWidth() - | 171 m_scrollbar->styleSource()->style()->borderTopWidth() - |
173 m_scrollbar->styleSource()->style()->borderBottomWidth()) | 172 m_scrollbar->styleSource()->style()->borderBottomWidth(); |
174 .toInt(); | |
175 int h = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->height(), | 173 int h = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->height(), |
176 visibleSize); | 174 visibleSize); |
177 int minHeight = | 175 int minHeight = |
178 calcScrollbarThicknessUsing(MinSize, style()->minHeight(), visibleSize); | 176 calcScrollbarThicknessUsing(MinSize, style()->minHeight(), visibleSize); |
179 int maxHeight = style()->maxHeight().isMaxSizeNone() | 177 int maxHeight = style()->maxHeight().isMaxSizeNone() |
180 ? h | 178 ? h |
181 : calcScrollbarThicknessUsing( | 179 : calcScrollbarThicknessUsing( |
182 MaxSize, style()->maxHeight(), visibleSize); | 180 MaxSize, style()->maxHeight(), visibleSize); |
183 setHeight(LayoutUnit(std::max(minHeight, std::min(maxHeight, h)))); | 181 setHeight(LayoutUnit(std::max(minHeight, std::min(maxHeight, h)))); |
184 | 182 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 m_scrollableArea->setScrollCornerNeedsPaintInvalidation(); | 243 m_scrollableArea->setScrollCornerNeedsPaintInvalidation(); |
246 } | 244 } |
247 | 245 |
248 LayoutRect LayoutScrollbarPart::visualRect() const { | 246 LayoutRect LayoutScrollbarPart::visualRect() const { |
249 // This returns the combined bounds of all scrollbar parts, which is | 247 // This returns the combined bounds of all scrollbar parts, which is |
250 // sufficient for correctness but not as tight as it could be. | 248 // sufficient for correctness but not as tight as it could be. |
251 return m_scrollableArea->visualRectForScrollbarParts(); | 249 return m_scrollableArea->visualRectForScrollbarParts(); |
252 } | 250 } |
253 | 251 |
254 } // namespace blink | 252 } // namespace blink |
OLD | NEW |