| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 LayoutScrollbar* scrollbar, | 86 LayoutScrollbar* scrollbar, |
| 87 ScrollbarPart part) { | 87 ScrollbarPart part) { |
| 88 LayoutScrollbarPart* layoutObject = | 88 LayoutScrollbarPart* layoutObject = |
| 89 new LayoutScrollbarPart(scrollableArea, scrollbar, part); | 89 new LayoutScrollbarPart(scrollableArea, scrollbar, part); |
| 90 recordScrollbarPartStats(*document, part); | 90 recordScrollbarPartStats(*document, part); |
| 91 layoutObject->setDocumentForAnonymous(document); | 91 layoutObject->setDocumentForAnonymous(document); |
| 92 return layoutObject; | 92 return layoutObject; |
| 93 } | 93 } |
| 94 | 94 |
| 95 void LayoutScrollbarPart::layout() { | 95 void LayoutScrollbarPart::layout() { |
| 96 setLocation( | 96 // We don't worry about positioning ourselves. We're just determining our |
| 97 LayoutPoint()); // We don't worry about positioning ourselves. We're just
determining our minimum width/height. | 97 // minimum width/height. |
| 98 setLocation(LayoutPoint()); |
| 98 if (m_scrollbar->orientation() == HorizontalScrollbar) | 99 if (m_scrollbar->orientation() == HorizontalScrollbar) |
| 99 layoutHorizontalPart(); | 100 layoutHorizontalPart(); |
| 100 else | 101 else |
| 101 layoutVerticalPart(); | 102 layoutVerticalPart(); |
| 102 | 103 |
| 103 clearNeedsLayout(); | 104 clearNeedsLayout(); |
| 104 } | 105 } |
| 105 | 106 |
| 106 void LayoutScrollbarPart::layoutHorizontalPart() { | 107 void LayoutScrollbarPart::layoutHorizontalPart() { |
| 107 if (m_part == ScrollbarBGPart) { | 108 if (m_part == ScrollbarBGPart) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 127 const Length& length, | 128 const Length& length, |
| 128 int containingLength) { | 129 int containingLength) { |
| 129 if (!length.isIntrinsicOrAuto() || (sizeType == MinSize && length.isAuto())) | 130 if (!length.isIntrinsicOrAuto() || (sizeType == MinSize && length.isAuto())) |
| 130 return minimumValueForLength(length, LayoutUnit(containingLength)).toInt(); | 131 return minimumValueForLength(length, LayoutUnit(containingLength)).toInt(); |
| 131 return ScrollbarTheme::theme().scrollbarThickness(); | 132 return ScrollbarTheme::theme().scrollbarThickness(); |
| 132 } | 133 } |
| 133 | 134 |
| 134 void LayoutScrollbarPart::computeScrollbarWidth() { | 135 void LayoutScrollbarPart::computeScrollbarWidth() { |
| 135 if (!m_scrollbar->owningLayoutObject()) | 136 if (!m_scrollbar->owningLayoutObject()) |
| 136 return; | 137 return; |
| 137 // FIXME: We are querying layout information but nothing guarantees that it's
up to date, especially since we are called at style change. | 138 // FIXME: We are querying layout information but nothing guarantees that it's |
| 138 // FIXME: Querying the style's border information doesn't work on table cells
with collapsing borders. | 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 |
| 141 // with collapsing borders. |
| 139 int visibleSize = | 142 int visibleSize = |
| 140 (m_scrollbar->owningLayoutObject()->size().width() - | 143 (m_scrollbar->owningLayoutObject()->size().width() - |
| 141 m_scrollbar->owningLayoutObject()->style()->borderLeftWidth() - | 144 m_scrollbar->owningLayoutObject()->style()->borderLeftWidth() - |
| 142 m_scrollbar->owningLayoutObject()->style()->borderRightWidth()) | 145 m_scrollbar->owningLayoutObject()->style()->borderRightWidth()) |
| 143 .toInt(); | 146 .toInt(); |
| 144 int w = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->width(), | 147 int w = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->width(), |
| 145 visibleSize); | 148 visibleSize); |
| 146 int minWidth = | 149 int minWidth = |
| 147 calcScrollbarThicknessUsing(MinSize, style()->minWidth(), visibleSize); | 150 calcScrollbarThicknessUsing(MinSize, style()->minWidth(), visibleSize); |
| 148 int maxWidth = style()->maxWidth().isMaxSizeNone() | 151 int maxWidth = style()->maxWidth().isMaxSizeNone() |
| 149 ? w | 152 ? w |
| 150 : calcScrollbarThicknessUsing(MaxSize, style()->maxWidth(), | 153 : calcScrollbarThicknessUsing(MaxSize, style()->maxWidth(), |
| 151 visibleSize); | 154 visibleSize); |
| 152 setWidth(LayoutUnit(std::max(minWidth, std::min(maxWidth, w)))); | 155 setWidth(LayoutUnit(std::max(minWidth, std::min(maxWidth, w)))); |
| 153 | 156 |
| 154 // Buttons and track pieces can all have margins along the axis of the scrollb
ar. | 157 // Buttons and track pieces can all have margins along the axis of the |
| 158 // scrollbar. |
| 155 setMarginLeft( | 159 setMarginLeft( |
| 156 minimumValueForLength(style()->marginLeft(), LayoutUnit(visibleSize))); | 160 minimumValueForLength(style()->marginLeft(), LayoutUnit(visibleSize))); |
| 157 setMarginRight( | 161 setMarginRight( |
| 158 minimumValueForLength(style()->marginRight(), LayoutUnit(visibleSize))); | 162 minimumValueForLength(style()->marginRight(), LayoutUnit(visibleSize))); |
| 159 } | 163 } |
| 160 | 164 |
| 161 void LayoutScrollbarPart::computeScrollbarHeight() { | 165 void LayoutScrollbarPart::computeScrollbarHeight() { |
| 162 if (!m_scrollbar->owningLayoutObject()) | 166 if (!m_scrollbar->owningLayoutObject()) |
| 163 return; | 167 return; |
| 164 // FIXME: We are querying layout information but nothing guarantees that it's
up to date, especially since we are called at style change. | 168 // FIXME: We are querying layout information but nothing guarantees that it's |
| 165 // FIXME: Querying the style's border information doesn't work on table cells
with collapsing borders. | 169 // up to date, especially since we are called at style change. |
| 170 // FIXME: Querying the style's border information doesn't work on table cells |
| 171 // with collapsing borders. |
| 166 int visibleSize = | 172 int visibleSize = |
| 167 (m_scrollbar->owningLayoutObject()->size().height() - | 173 (m_scrollbar->owningLayoutObject()->size().height() - |
| 168 m_scrollbar->owningLayoutObject()->style()->borderTopWidth() - | 174 m_scrollbar->owningLayoutObject()->style()->borderTopWidth() - |
| 169 m_scrollbar->owningLayoutObject()->style()->borderBottomWidth()) | 175 m_scrollbar->owningLayoutObject()->style()->borderBottomWidth()) |
| 170 .toInt(); | 176 .toInt(); |
| 171 int h = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->height(), | 177 int h = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->height(), |
| 172 visibleSize); | 178 visibleSize); |
| 173 int minHeight = | 179 int minHeight = |
| 174 calcScrollbarThicknessUsing(MinSize, style()->minHeight(), visibleSize); | 180 calcScrollbarThicknessUsing(MinSize, style()->minHeight(), visibleSize); |
| 175 int maxHeight = style()->maxHeight().isMaxSizeNone() | 181 int maxHeight = style()->maxHeight().isMaxSizeNone() |
| 176 ? h | 182 ? h |
| 177 : calcScrollbarThicknessUsing( | 183 : calcScrollbarThicknessUsing( |
| 178 MaxSize, style()->maxHeight(), visibleSize); | 184 MaxSize, style()->maxHeight(), visibleSize); |
| 179 setHeight(LayoutUnit(std::max(minHeight, std::min(maxHeight, h)))); | 185 setHeight(LayoutUnit(std::max(minHeight, std::min(maxHeight, h)))); |
| 180 | 186 |
| 181 // Buttons and track pieces can all have margins along the axis of the scrollb
ar. | 187 // Buttons and track pieces can all have margins along the axis of the |
| 188 // scrollbar. |
| 182 setMarginTop( | 189 setMarginTop( |
| 183 minimumValueForLength(style()->marginTop(), LayoutUnit(visibleSize))); | 190 minimumValueForLength(style()->marginTop(), LayoutUnit(visibleSize))); |
| 184 setMarginBottom( | 191 setMarginBottom( |
| 185 minimumValueForLength(style()->marginBottom(), LayoutUnit(visibleSize))); | 192 minimumValueForLength(style()->marginBottom(), LayoutUnit(visibleSize))); |
| 186 } | 193 } |
| 187 | 194 |
| 188 void LayoutScrollbarPart::computePreferredLogicalWidths() { | 195 void LayoutScrollbarPart::computePreferredLogicalWidths() { |
| 189 if (!preferredLogicalWidthsDirty()) | 196 if (!preferredLogicalWidthsDirty()) |
| 190 return; | 197 return; |
| 191 | 198 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 if (frameView->isFrameViewScrollCorner(this)) { | 241 if (frameView->isFrameViewScrollCorner(this)) { |
| 235 frameView->setScrollCornerNeedsPaintInvalidation(); | 242 frameView->setScrollCornerNeedsPaintInvalidation(); |
| 236 return; | 243 return; |
| 237 } | 244 } |
| 238 } | 245 } |
| 239 | 246 |
| 240 m_scrollableArea->setScrollCornerNeedsPaintInvalidation(); | 247 m_scrollableArea->setScrollCornerNeedsPaintInvalidation(); |
| 241 } | 248 } |
| 242 | 249 |
| 243 LayoutRect LayoutScrollbarPart::visualRect() const { | 250 LayoutRect LayoutScrollbarPart::visualRect() const { |
| 244 // This returns the combined bounds of all scrollbar parts, which is sufficien
t for correctness | 251 // This returns the combined bounds of all scrollbar parts, which is |
| 245 // but not as tight as it could be. | 252 // sufficient for correctness but not as tight as it could be. |
| 246 return m_scrollableArea->visualRectForScrollbarParts(); | 253 return m_scrollableArea->visualRectForScrollbarParts(); |
| 247 } | 254 } |
| 248 | 255 |
| 249 } // namespace blink | 256 } // namespace blink |
| OLD | NEW |