Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: Source/core/rendering/RenderScrollbarPart.cpp

Issue 951453003: Rename rendering/RenderScrollbar* to layout/LayoutScrollbar* (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #include "config.h"
27 #include "core/rendering/RenderScrollbarPart.h"
28
29 #include "core/frame/UseCounter.h"
30 #include "core/layout/PaintInfo.h"
31 #include "core/rendering/RenderScrollbar.h"
32 #include "core/rendering/RenderScrollbarTheme.h"
33 #include "core/rendering/RenderView.h"
34 #include "platform/LengthFunctions.h"
35
36 namespace blink {
37
38 RenderScrollbarPart::RenderScrollbarPart(RenderScrollbar* scrollbar, ScrollbarPa rt part)
39 : RenderBlock(0)
40 , m_scrollbar(scrollbar)
41 , m_part(part)
42 {
43 }
44
45 RenderScrollbarPart::~RenderScrollbarPart()
46 {
47 }
48
49 static void recordScrollbarPartStats(Document& document, ScrollbarPart part)
50 {
51 switch (part) {
52 case BackButtonStartPart:
53 case ForwardButtonStartPart:
54 case BackButtonEndPart:
55 case ForwardButtonEndPart:
56 UseCounter::count(document, UseCounter::CSSSelectorPseudoScrollbarButton );
57 break;
58 case BackTrackPart:
59 case ForwardTrackPart:
60 UseCounter::count(document, UseCounter::CSSSelectorPseudoScrollbarTrackP iece);
61 break;
62 case ThumbPart:
63 UseCounter::count(document, UseCounter::CSSSelectorPseudoScrollbarThumb) ;
64 break;
65 case TrackBGPart:
66 UseCounter::count(document, UseCounter::CSSSelectorPseudoScrollbarTrack) ;
67 break;
68 case ScrollbarBGPart:
69 UseCounter::count(document, UseCounter::CSSSelectorPseudoScrollbar);
70 break;
71 case NoPart:
72 case AllParts:
73 break;
74 }
75 }
76
77 RenderScrollbarPart* RenderScrollbarPart::createAnonymous(Document* document, Re nderScrollbar* scrollbar, ScrollbarPart part)
78 {
79 RenderScrollbarPart* renderer = new RenderScrollbarPart(scrollbar, part);
80 recordScrollbarPartStats(*document, part);
81 renderer->setDocumentForAnonymous(document);
82 return renderer;
83 }
84
85 void RenderScrollbarPart::layout()
86 {
87 setLocation(LayoutPoint()); // We don't worry about positioning ourselves. W e're just determining our minimum width/height.
88 if (m_scrollbar->orientation() == HorizontalScrollbar)
89 layoutHorizontalPart();
90 else
91 layoutVerticalPart();
92
93 clearNeedsLayout();
94 }
95
96 void RenderScrollbarPart::layoutHorizontalPart()
97 {
98 if (m_part == ScrollbarBGPart) {
99 setWidth(m_scrollbar->width());
100 computeScrollbarHeight();
101 } else {
102 computeScrollbarWidth();
103 setHeight(m_scrollbar->height());
104 }
105 }
106
107 void RenderScrollbarPart::layoutVerticalPart()
108 {
109 if (m_part == ScrollbarBGPart) {
110 computeScrollbarWidth();
111 setHeight(m_scrollbar->height());
112 } else {
113 setWidth(m_scrollbar->width());
114 computeScrollbarHeight();
115 }
116 }
117
118 static int calcScrollbarThicknessUsing(SizeType sizeType, const Length& length, int containingLength)
119 {
120 if (!length.isIntrinsicOrAuto() || (sizeType == MinSize && length.isAuto()))
121 return minimumValueForLength(length, containingLength);
122 return ScrollbarTheme::theme()->scrollbarThickness();
123 }
124
125 void RenderScrollbarPart::computeScrollbarWidth()
126 {
127 if (!m_scrollbar->owningRenderer())
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.
130 // FIXME: Querying the style's border information doesn't work on table cell s with collapsing borders.
131 int visibleSize = m_scrollbar->owningRenderer()->size().width() - m_scrollba r->owningRenderer()->style()->borderLeftWidth() - m_scrollbar->owningRenderer()- >style()->borderRightWidth();
132 int w = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->width(), v isibleSize);
133 int minWidth = calcScrollbarThicknessUsing(MinSize, style()->minWidth(), vis ibleSize);
134 int maxWidth = style()->maxWidth().isMaxSizeNone() ? w : calcScrollbarThickn essUsing(MaxSize, style()->maxWidth(), visibleSize);
135 setWidth(std::max(minWidth, std::min(maxWidth, w)));
136
137 // Buttons and track pieces can all have margins along the axis of the scrol lbar.
138 setMarginLeft(minimumValueForLength(style()->marginLeft(), visibleSize));
139 setMarginRight(minimumValueForLength(style()->marginRight(), visibleSize));
140 }
141
142 void RenderScrollbarPart::computeScrollbarHeight()
143 {
144 if (!m_scrollbar->owningRenderer())
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.
147 // FIXME: Querying the style's border information doesn't work on table cell s with collapsing borders.
148 int visibleSize = m_scrollbar->owningRenderer()->size().height() - m_scroll bar->owningRenderer()->style()->borderTopWidth() - m_scrollbar->owningRenderer() ->style()->borderBottomWidth();
149 int h = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->height(), visibleSize);
150 int minHeight = calcScrollbarThicknessUsing(MinSize, style()->minHeight(), v isibleSize);
151 int maxHeight = style()->maxHeight().isMaxSizeNone() ? h : calcScrollbarThic knessUsing(MaxSize, style()->maxHeight(), visibleSize);
152 setHeight(std::max(minHeight, std::min(maxHeight, h)));
153
154 // Buttons and track pieces can all have margins along the axis of the scrol lbar.
155 setMarginTop(minimumValueForLength(style()->marginTop(), visibleSize));
156 setMarginBottom(minimumValueForLength(style()->marginBottom(), visibleSize)) ;
157 }
158
159 void RenderScrollbarPart::computePreferredLogicalWidths()
160 {
161 if (!preferredLogicalWidthsDirty())
162 return;
163
164 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = 0;
165
166 clearPreferredLogicalWidthsDirty();
167 }
168
169 void RenderScrollbarPart::styleWillChange(StyleDifference diff, const LayoutStyl e& newStyle)
170 {
171 RenderBlock::styleWillChange(diff, newStyle);
172 setInline(false);
173 }
174
175 void RenderScrollbarPart::styleDidChange(StyleDifference diff, const LayoutStyle * oldStyle)
176 {
177 RenderBlock::styleDidChange(diff, oldStyle);
178 setInline(false);
179 clearPositionedState();
180 setFloating(false);
181 setHasOverflowClip(false);
182 if (oldStyle && m_scrollbar && m_part != NoPart && (diff.needsPaintInvalidat ion() || diff.needsLayout()))
183 m_scrollbar->theme()->invalidatePart(m_scrollbar, m_part);
184 }
185
186 void RenderScrollbarPart::imageChanged(WrappedImagePtr image, const IntRect* rec t)
187 {
188 if (m_scrollbar && m_part != NoPart)
189 m_scrollbar->theme()->invalidatePart(m_scrollbar, m_part);
190 else {
191 if (FrameView* frameView = view()->frameView()) {
192 if (frameView->isFrameViewScrollCorner(this)) {
193 frameView->invalidateScrollCorner(frameView->scrollCornerRect()) ;
194 return;
195 }
196 }
197
198 RenderBlock::imageChanged(image, rect);
199 }
200 }
201
202 LayoutObject* RenderScrollbarPart::rendererOwningScrollbar() const
203 {
204 if (!m_scrollbar)
205 return 0;
206 return m_scrollbar->owningRenderer();
207 }
208
209 }
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderScrollbarPart.h ('k') | Source/core/rendering/RenderScrollbarTheme.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698