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 23 matching lines...) Expand all Loading... |
34 #include "wtf/StdLibExtras.h" | 34 #include "wtf/StdLibExtras.h" |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 LayoutScrollbarTheme* LayoutScrollbarTheme::layoutScrollbarTheme() | 38 LayoutScrollbarTheme* LayoutScrollbarTheme::layoutScrollbarTheme() |
39 { | 39 { |
40 DEFINE_STATIC_LOCAL(LayoutScrollbarTheme, theme, ()); | 40 DEFINE_STATIC_LOCAL(LayoutScrollbarTheme, theme, ()); |
41 return &theme; | 41 return &theme; |
42 } | 42 } |
43 | 43 |
44 void LayoutScrollbarTheme::buttonSizesAlongTrackAxis(const ScrollbarThemeClient*
scrollbar, int& beforeSize, int& afterSize) | 44 void LayoutScrollbarTheme::buttonSizesAlongTrackAxis(const ScrollbarThemeClient&
scrollbar, int& beforeSize, int& afterSize) |
45 { | 45 { |
46 IntRect firstButton = backButtonRect(scrollbar, BackButtonStartPart); | 46 IntRect firstButton = backButtonRect(scrollbar, BackButtonStartPart); |
47 IntRect secondButton = forwardButtonRect(scrollbar, ForwardButtonStartPart); | 47 IntRect secondButton = forwardButtonRect(scrollbar, ForwardButtonStartPart); |
48 IntRect thirdButton = backButtonRect(scrollbar, BackButtonEndPart); | 48 IntRect thirdButton = backButtonRect(scrollbar, BackButtonEndPart); |
49 IntRect fourthButton = forwardButtonRect(scrollbar, ForwardButtonEndPart); | 49 IntRect fourthButton = forwardButtonRect(scrollbar, ForwardButtonEndPart); |
50 if (scrollbar->orientation() == HorizontalScrollbar) { | 50 if (scrollbar.orientation() == HorizontalScrollbar) { |
51 beforeSize = firstButton.width() + secondButton.width(); | 51 beforeSize = firstButton.width() + secondButton.width(); |
52 afterSize = thirdButton.width() + fourthButton.width(); | 52 afterSize = thirdButton.width() + fourthButton.width(); |
53 } else { | 53 } else { |
54 beforeSize = firstButton.height() + secondButton.height(); | 54 beforeSize = firstButton.height() + secondButton.height(); |
55 afterSize = thirdButton.height() + fourthButton.height(); | 55 afterSize = thirdButton.height() + fourthButton.height(); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 bool LayoutScrollbarTheme::hasButtons(const ScrollbarThemeClient* scrollbar) | 59 bool LayoutScrollbarTheme::hasButtons(const ScrollbarThemeClient& scrollbar) |
60 { | 60 { |
61 int startSize; | 61 int startSize; |
62 int endSize; | 62 int endSize; |
63 buttonSizesAlongTrackAxis(scrollbar, startSize, endSize); | 63 buttonSizesAlongTrackAxis(scrollbar, startSize, endSize); |
64 return (startSize + endSize) <= (scrollbar->orientation() == HorizontalScrol
lbar ? scrollbar->width() : scrollbar->height()); | 64 return (startSize + endSize) <= (scrollbar.orientation() == HorizontalScroll
bar ? scrollbar.width() : scrollbar.height()); |
65 } | 65 } |
66 | 66 |
67 bool LayoutScrollbarTheme::hasThumb(const ScrollbarThemeClient* scrollbar) | 67 bool LayoutScrollbarTheme::hasThumb(const ScrollbarThemeClient& scrollbar) |
68 { | 68 { |
69 return trackLength(scrollbar) - thumbLength(scrollbar) >= 0; | 69 return trackLength(scrollbar) - thumbLength(scrollbar) >= 0; |
70 } | 70 } |
71 | 71 |
72 int LayoutScrollbarTheme::minimumThumbLength(const ScrollbarThemeClient* scrollb
ar) | 72 int LayoutScrollbarTheme::minimumThumbLength(const ScrollbarThemeClient& scrollb
ar) |
73 { | 73 { |
74 return toLayoutScrollbar(scrollbar)->minimumThumbLength(); | 74 return toLayoutScrollbar(scrollbar).minimumThumbLength(); |
75 } | 75 } |
76 | 76 |
77 IntRect LayoutScrollbarTheme::backButtonRect(const ScrollbarThemeClient* scrollb
ar, ScrollbarPart partType, bool) | 77 IntRect LayoutScrollbarTheme::backButtonRect(const ScrollbarThemeClient& scrollb
ar, ScrollbarPart partType, bool) |
78 { | 78 { |
79 return toLayoutScrollbar(scrollbar)->buttonRect(partType); | 79 return toLayoutScrollbar(scrollbar).buttonRect(partType); |
80 } | 80 } |
81 | 81 |
82 IntRect LayoutScrollbarTheme::forwardButtonRect(const ScrollbarThemeClient* scro
llbar, ScrollbarPart partType, bool) | 82 IntRect LayoutScrollbarTheme::forwardButtonRect(const ScrollbarThemeClient& scro
llbar, ScrollbarPart partType, bool) |
83 { | 83 { |
84 return toLayoutScrollbar(scrollbar)->buttonRect(partType); | 84 return toLayoutScrollbar(scrollbar).buttonRect(partType); |
85 } | 85 } |
86 | 86 |
87 IntRect LayoutScrollbarTheme::trackRect(const ScrollbarThemeClient* scrollbar, b
ool) | 87 IntRect LayoutScrollbarTheme::trackRect(const ScrollbarThemeClient& scrollbar, b
ool) |
88 { | 88 { |
89 if (!hasButtons(scrollbar)) | 89 if (!hasButtons(scrollbar)) |
90 return scrollbar->frameRect(); | 90 return scrollbar.frameRect(); |
91 | 91 |
92 int startLength; | 92 int startLength; |
93 int endLength; | 93 int endLength; |
94 buttonSizesAlongTrackAxis(scrollbar, startLength, endLength); | 94 buttonSizesAlongTrackAxis(scrollbar, startLength, endLength); |
95 | 95 |
96 return toLayoutScrollbar(scrollbar)->trackRect(startLength, endLength); | 96 return toLayoutScrollbar(scrollbar).trackRect(startLength, endLength); |
97 } | 97 } |
98 | 98 |
99 IntRect LayoutScrollbarTheme::constrainTrackRectToTrackPieces(const ScrollbarThe
meClient* scrollbar, const IntRect& rect) | 99 IntRect LayoutScrollbarTheme::constrainTrackRectToTrackPieces(const ScrollbarThe
meClient& scrollbar, const IntRect& rect) |
100 { | 100 { |
101 IntRect backRect = toLayoutScrollbar(scrollbar)->trackPieceRectWithMargins(B
ackTrackPart, rect); | 101 IntRect backRect = toLayoutScrollbar(scrollbar).trackPieceRectWithMargins(Ba
ckTrackPart, rect); |
102 IntRect forwardRect = toLayoutScrollbar(scrollbar)->trackPieceRectWithMargin
s(ForwardTrackPart, rect); | 102 IntRect forwardRect = toLayoutScrollbar(scrollbar).trackPieceRectWithMargins
(ForwardTrackPart, rect); |
103 IntRect result = rect; | 103 IntRect result = rect; |
104 if (scrollbar->orientation() == HorizontalScrollbar) { | 104 if (scrollbar.orientation() == HorizontalScrollbar) { |
105 result.setX(backRect.x()); | 105 result.setX(backRect.x()); |
106 result.setWidth(forwardRect.maxX() - backRect.x()); | 106 result.setWidth(forwardRect.maxX() - backRect.x()); |
107 } else { | 107 } else { |
108 result.setY(backRect.y()); | 108 result.setY(backRect.y()); |
109 result.setHeight(forwardRect.maxY() - backRect.y()); | 109 result.setHeight(forwardRect.maxY() - backRect.y()); |
110 } | 110 } |
111 return result; | 111 return result; |
112 } | 112 } |
113 | 113 |
114 void LayoutScrollbarTheme::paintScrollCorner(GraphicsContext* context, const Dis
playItemClient& displayItemClient, const IntRect& cornerRect) | 114 void LayoutScrollbarTheme::paintScrollCorner(GraphicsContext& context, const Dis
playItemClient& displayItemClient, const IntRect& cornerRect) |
115 { | 115 { |
116 if (DrawingRecorder::useCachedDrawingIfPossible(*context, displayItemClient,
DisplayItem::ScrollbarCorner)) | 116 if (DrawingRecorder::useCachedDrawingIfPossible(context, displayItemClient,
DisplayItem::ScrollbarCorner)) |
117 return; | 117 return; |
118 | 118 |
119 DrawingRecorder recorder(*context, displayItemClient, DisplayItem::Scrollbar
Corner, cornerRect); | 119 DrawingRecorder recorder(context, displayItemClient, DisplayItem::ScrollbarC
orner, cornerRect); |
120 // FIXME: Implement. | 120 // FIXME: Implement. |
121 context->fillRect(cornerRect, Color::white); | 121 context.fillRect(cornerRect, Color::white); |
122 } | 122 } |
123 | 123 |
124 void LayoutScrollbarTheme::paintScrollbarBackground(GraphicsContext* context, co
nst ScrollbarThemeClient* scrollbar) | 124 void LayoutScrollbarTheme::paintScrollbarBackground(GraphicsContext& context, co
nst ScrollbarThemeClient& scrollbar) |
125 { | 125 { |
126 ScrollbarPainter(*toLayoutScrollbar(scrollbar)).paintPart(context, Scrollbar
BGPart, scrollbar->frameRect()); | 126 ScrollbarPainter(toLayoutScrollbar(scrollbar)).paintPart(context, ScrollbarB
GPart, scrollbar.frameRect()); |
127 } | 127 } |
128 | 128 |
129 void LayoutScrollbarTheme::paintTrackBackground(GraphicsContext* context, const
ScrollbarThemeClient* scrollbar, const IntRect& rect) | 129 void LayoutScrollbarTheme::paintTrackBackground(GraphicsContext& context, const
ScrollbarThemeClient& scrollbar, const IntRect& rect) |
130 { | 130 { |
131 ScrollbarPainter(*toLayoutScrollbar(scrollbar)).paintPart(context, TrackBGPa
rt, rect); | 131 ScrollbarPainter(toLayoutScrollbar(scrollbar)).paintPart(context, TrackBGPar
t, rect); |
132 } | 132 } |
133 | 133 |
134 void LayoutScrollbarTheme::paintTrackPiece(GraphicsContext* context, const Scrol
lbarThemeClient* scrollbar, const IntRect& rect, ScrollbarPart part) | 134 void LayoutScrollbarTheme::paintTrackPiece(GraphicsContext& context, const Scrol
lbarThemeClient& scrollbar, const IntRect& rect, ScrollbarPart part) |
135 { | 135 { |
136 ScrollbarPainter(*toLayoutScrollbar(scrollbar)).paintPart(context, part, rec
t); | 136 ScrollbarPainter(toLayoutScrollbar(scrollbar)).paintPart(context, part, rect
); |
137 } | 137 } |
138 | 138 |
139 void LayoutScrollbarTheme::paintButton(GraphicsContext* context, const Scrollbar
ThemeClient* scrollbar, const IntRect& rect, ScrollbarPart part) | 139 void LayoutScrollbarTheme::paintButton(GraphicsContext& context, const Scrollbar
ThemeClient& scrollbar, const IntRect& rect, ScrollbarPart part) |
140 { | 140 { |
141 ScrollbarPainter(*toLayoutScrollbar(scrollbar)).paintPart(context, part, rec
t); | 141 ScrollbarPainter(toLayoutScrollbar(scrollbar)).paintPart(context, part, rect
); |
142 } | 142 } |
143 | 143 |
144 void LayoutScrollbarTheme::paintThumb(GraphicsContext* context, const ScrollbarT
hemeClient* scrollbar, const IntRect& rect) | 144 void LayoutScrollbarTheme::paintThumb(GraphicsContext& context, const ScrollbarT
hemeClient& scrollbar, const IntRect& rect) |
145 { | 145 { |
146 ScrollbarPainter(*toLayoutScrollbar(scrollbar)).paintPart(context, ThumbPart
, rect); | 146 ScrollbarPainter(toLayoutScrollbar(scrollbar)).paintPart(context, ThumbPart,
rect); |
147 } | 147 } |
148 | 148 |
149 void LayoutScrollbarTheme::paintTickmarks(GraphicsContext* context, const Scroll
barThemeClient* scrollbar, const IntRect& rect) | 149 void LayoutScrollbarTheme::paintTickmarks(GraphicsContext& context, const Scroll
barThemeClient& scrollbar, const IntRect& rect) |
150 { | 150 { |
151 ScrollbarTheme::theme()->paintTickmarks(context, scrollbar, rect); | 151 ScrollbarTheme::theme().paintTickmarks(context, scrollbar, rect); |
152 } | 152 } |
153 | 153 |
154 } | 154 } |
OLD | NEW |