| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/rendering/RenderScrollbarPart.h" | 27 #include "core/rendering/RenderScrollbarPart.h" |
| 28 | 28 |
| 29 #include "core/rendering/PaintInfo.h" | 29 #include "core/rendering/PaintInfo.h" |
| 30 #include "core/rendering/RenderScrollbar.h" | 30 #include "core/rendering/RenderScrollbar.h" |
| 31 #include "core/rendering/RenderScrollbarTheme.h" | 31 #include "core/rendering/RenderScrollbarTheme.h" |
| 32 #include "core/rendering/RenderView.h" | 32 #include "core/rendering/RenderView.h" |
| 33 #include "platform/LengthFunctions.h" | 33 #include "platform/LengthFunctions.h" |
| 34 | 34 |
| 35 using namespace std; | |
| 36 | |
| 37 namespace WebCore { | 35 namespace WebCore { |
| 38 | 36 |
| 39 RenderScrollbarPart::RenderScrollbarPart(RenderScrollbar* scrollbar, ScrollbarPa
rt part) | 37 RenderScrollbarPart::RenderScrollbarPart(RenderScrollbar* scrollbar, ScrollbarPa
rt part) |
| 40 : RenderBlock(0) | 38 : RenderBlock(0) |
| 41 , m_scrollbar(scrollbar) | 39 , m_scrollbar(scrollbar) |
| 42 , m_part(part) | 40 , m_part(part) |
| 43 { | 41 { |
| 44 } | 42 } |
| 45 | 43 |
| 46 RenderScrollbarPart::~RenderScrollbarPart() | 44 RenderScrollbarPart::~RenderScrollbarPart() |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 void RenderScrollbarPart::computeScrollbarWidth() | 95 void RenderScrollbarPart::computeScrollbarWidth() |
| 98 { | 96 { |
| 99 if (!m_scrollbar->owningRenderer()) | 97 if (!m_scrollbar->owningRenderer()) |
| 100 return; | 98 return; |
| 101 // FIXME: We are querying layout information but nothing guarantees that it'
s up-to-date, especially since we are called at style change. | 99 // FIXME: We are querying layout information but nothing guarantees that it'
s up-to-date, especially since we are called at style change. |
| 102 // FIXME: Querying the style's border information doesn't work on table cell
s with collapsing borders. | 100 // FIXME: Querying the style's border information doesn't work on table cell
s with collapsing borders. |
| 103 int visibleSize = m_scrollbar->owningRenderer()->width() - m_scrollbar->owni
ngRenderer()->style()->borderLeftWidth() - m_scrollbar->owningRenderer()->style(
)->borderRightWidth(); | 101 int visibleSize = m_scrollbar->owningRenderer()->width() - m_scrollbar->owni
ngRenderer()->style()->borderLeftWidth() - m_scrollbar->owningRenderer()->style(
)->borderRightWidth(); |
| 104 int w = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->width(), v
isibleSize); | 102 int w = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->width(), v
isibleSize); |
| 105 int minWidth = calcScrollbarThicknessUsing(MinSize, style()->minWidth(), vis
ibleSize); | 103 int minWidth = calcScrollbarThicknessUsing(MinSize, style()->minWidth(), vis
ibleSize); |
| 106 int maxWidth = style()->maxWidth().isUndefined() ? w : calcScrollbarThicknes
sUsing(MaxSize, style()->maxWidth(), visibleSize); | 104 int maxWidth = style()->maxWidth().isUndefined() ? w : calcScrollbarThicknes
sUsing(MaxSize, style()->maxWidth(), visibleSize); |
| 107 setWidth(max(minWidth, min(maxWidth, w))); | 105 setWidth(std::max(minWidth, std::min(maxWidth, w))); |
| 108 | 106 |
| 109 // Buttons and track pieces can all have margins along the axis of the scrol
lbar. | 107 // Buttons and track pieces can all have margins along the axis of the scrol
lbar. |
| 110 m_marginBox.setLeft(minimumValueForLength(style()->marginLeft(), visibleSize
)); | 108 m_marginBox.setLeft(minimumValueForLength(style()->marginLeft(), visibleSize
)); |
| 111 m_marginBox.setRight(minimumValueForLength(style()->marginRight(), visibleSi
ze)); | 109 m_marginBox.setRight(minimumValueForLength(style()->marginRight(), visibleSi
ze)); |
| 112 } | 110 } |
| 113 | 111 |
| 114 void RenderScrollbarPart::computeScrollbarHeight() | 112 void RenderScrollbarPart::computeScrollbarHeight() |
| 115 { | 113 { |
| 116 if (!m_scrollbar->owningRenderer()) | 114 if (!m_scrollbar->owningRenderer()) |
| 117 return; | 115 return; |
| 118 // FIXME: We are querying layout information but nothing guarantees that it'
s up-to-date, especially since we are called at style change. | 116 // FIXME: We are querying layout information but nothing guarantees that it'
s up-to-date, especially since we are called at style change. |
| 119 // FIXME: Querying the style's border information doesn't work on table cell
s with collapsing borders. | 117 // FIXME: Querying the style's border information doesn't work on table cell
s with collapsing borders. |
| 120 int visibleSize = m_scrollbar->owningRenderer()->height() - m_scrollbar->ow
ningRenderer()->style()->borderTopWidth() - m_scrollbar->owningRenderer()->style
()->borderBottomWidth(); | 118 int visibleSize = m_scrollbar->owningRenderer()->height() - m_scrollbar->ow
ningRenderer()->style()->borderTopWidth() - m_scrollbar->owningRenderer()->style
()->borderBottomWidth(); |
| 121 int h = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->height(),
visibleSize); | 119 int h = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->height(),
visibleSize); |
| 122 int minHeight = calcScrollbarThicknessUsing(MinSize, style()->minHeight(), v
isibleSize); | 120 int minHeight = calcScrollbarThicknessUsing(MinSize, style()->minHeight(), v
isibleSize); |
| 123 int maxHeight = style()->maxHeight().isUndefined() ? h : calcScrollbarThickn
essUsing(MaxSize, style()->maxHeight(), visibleSize); | 121 int maxHeight = style()->maxHeight().isUndefined() ? h : calcScrollbarThickn
essUsing(MaxSize, style()->maxHeight(), visibleSize); |
| 124 setHeight(max(minHeight, min(maxHeight, h))); | 122 setHeight(std::max(minHeight, std::min(maxHeight, h))); |
| 125 | 123 |
| 126 // Buttons and track pieces can all have margins along the axis of the scrol
lbar. | 124 // Buttons and track pieces can all have margins along the axis of the scrol
lbar. |
| 127 m_marginBox.setTop(minimumValueForLength(style()->marginTop(), visibleSize))
; | 125 m_marginBox.setTop(minimumValueForLength(style()->marginTop(), visibleSize))
; |
| 128 m_marginBox.setBottom(minimumValueForLength(style()->marginBottom(), visible
Size)); | 126 m_marginBox.setBottom(minimumValueForLength(style()->marginBottom(), visible
Size)); |
| 129 } | 127 } |
| 130 | 128 |
| 131 void RenderScrollbarPart::computePreferredLogicalWidths() | 129 void RenderScrollbarPart::computePreferredLogicalWidths() |
| 132 { | 130 { |
| 133 if (!preferredLogicalWidthsDirty()) | 131 if (!preferredLogicalWidthsDirty()) |
| 134 return; | 132 return; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 } | 193 } |
| 196 | 194 |
| 197 RenderObject* RenderScrollbarPart::rendererOwningScrollbar() const | 195 RenderObject* RenderScrollbarPart::rendererOwningScrollbar() const |
| 198 { | 196 { |
| 199 if (!m_scrollbar) | 197 if (!m_scrollbar) |
| 200 return 0; | 198 return 0; |
| 201 return m_scrollbar->owningRenderer(); | 199 return m_scrollbar->owningRenderer(); |
| 202 } | 200 } |
| 203 | 201 |
| 204 } | 202 } |
| OLD | NEW |