1 | /* |
2 | * Copyright (C) 2008-2017 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 "Theme.h" |
28 | |
29 | #include "GraphicsContext.h" |
30 | #include "LengthBox.h" |
31 | #include "LengthSize.h" |
32 | #include <wtf/Optional.h> |
33 | |
34 | namespace WebCore { |
35 | |
36 | int Theme::baselinePositionAdjustment(ControlPart) const |
37 | { |
38 | return 0; |
39 | } |
40 | |
41 | Optional<FontCascadeDescription> Theme::controlFont(ControlPart, const FontCascade&, float) const |
42 | { |
43 | return WTF::nullopt; |
44 | } |
45 | |
46 | LengthSize Theme::controlSize(ControlPart, const FontCascade&, const LengthSize& zoomedSize, float) const |
47 | { |
48 | return zoomedSize; |
49 | } |
50 | |
51 | LengthSize Theme::minimumControlSize(ControlPart, const FontCascade&, float) const |
52 | { |
53 | return { { 0, Fixed }, { 0, Fixed } }; |
54 | } |
55 | |
56 | bool Theme::controlRequiresPreWhiteSpace(ControlPart) const |
57 | { |
58 | return false; |
59 | } |
60 | |
61 | void Theme::paint(ControlPart, ControlStates&, GraphicsContext&, const FloatRect&, float, ScrollView*, float, float, bool, bool) |
62 | { |
63 | } |
64 | |
65 | void Theme::inflateControlPaintRect(ControlPart, const ControlStates&, FloatRect&, float) const |
66 | { |
67 | } |
68 | |
69 | bool Theme::userPrefersReducedMotion() const |
70 | { |
71 | return false; |
72 | } |
73 | |
74 | LengthBox Theme::controlBorder(ControlPart part, const FontCascade&, const LengthBox& zoomedBox, float) const |
75 | { |
76 | switch (part) { |
77 | case PushButtonPart: |
78 | case MenulistPart: |
79 | case SearchFieldPart: |
80 | case CheckboxPart: |
81 | case RadioPart: |
82 | return LengthBox(0); |
83 | default: |
84 | return zoomedBox; |
85 | } |
86 | } |
87 | |
88 | LengthBox Theme::controlPadding(ControlPart part, const FontCascade&, const LengthBox& zoomedBox, float) const |
89 | { |
90 | switch (part) { |
91 | case MenulistPart: |
92 | case MenulistButtonPart: |
93 | case CheckboxPart: |
94 | case RadioPart: |
95 | return LengthBox(0); |
96 | default: |
97 | return zoomedBox; |
98 | } |
99 | } |
100 | |
101 | void Theme::drawNamedImage(const String& name, GraphicsContext& context, const FloatRect& rect) const |
102 | { |
103 | // We only handle one icon at the moment. |
104 | if (name != "wireless-playback" ) |
105 | return; |
106 | |
107 | GraphicsContextStateSaver stateSaver(context); |
108 | context.setFillColor(Color::black); |
109 | |
110 | // Draw a generic Wireless Playback icon. |
111 | |
112 | context.scale(rect.size() / 100); |
113 | context.translate(8, 1); |
114 | |
115 | Path outline; |
116 | outline.moveTo(FloatPoint(59, 58.7)); |
117 | outline.addBezierCurveTo(FloatPoint(58.1, 58.7), FloatPoint(57.2, 58.4), FloatPoint(56.4, 57.7)); |
118 | outline.addLineTo(FloatPoint(42, 45.5)); |
119 | outline.addLineTo(FloatPoint(27.6, 57.8)); |
120 | outline.addBezierCurveTo(FloatPoint(25.9, 59.2), FloatPoint(23.4, 59), FloatPoint(22, 57.3)); |
121 | outline.addBezierCurveTo(FloatPoint(20.6, 55.6), FloatPoint(20.8, 53.1), FloatPoint(22.5, 51.7)); |
122 | outline.addLineTo(FloatPoint(39.5, 37.3)); |
123 | outline.addBezierCurveTo(FloatPoint(41, 36), FloatPoint(43.2, 36), FloatPoint(44.7, 37.3)); |
124 | outline.addLineTo(FloatPoint(61.7, 51.7)); |
125 | outline.addBezierCurveTo(FloatPoint(63.4, 53.1), FloatPoint(63.6, 55.7), FloatPoint(62.2, 57.3)); |
126 | outline.addBezierCurveTo(FloatPoint(61.3, 58.2), FloatPoint(60.1, 58.7), FloatPoint(59, 58.7)); |
127 | outline.addLineTo(FloatPoint(59, 58.7)); |
128 | outline.closeSubpath(); |
129 | |
130 | outline.moveTo(FloatPoint(42, 98)); |
131 | outline.addBezierCurveTo(FloatPoint(39.8, 98), FloatPoint(38, 96.3), FloatPoint(38, 94.2)); |
132 | outline.addLineTo(FloatPoint(38, 43.6)); |
133 | outline.addBezierCurveTo(FloatPoint(38, 41.5), FloatPoint(39.8, 39.8), FloatPoint(42, 39.8)); |
134 | outline.addBezierCurveTo(FloatPoint(44.2, 39.8), FloatPoint(46, 41.5), FloatPoint(46, 43.6)); |
135 | outline.addLineTo(FloatPoint(46, 94.2)); |
136 | outline.addBezierCurveTo(FloatPoint(46, 96.3), FloatPoint(44.2, 98), FloatPoint(42, 98)); |
137 | outline.addLineTo(FloatPoint(42, 98)); |
138 | outline.closeSubpath(); |
139 | |
140 | outline.moveTo(FloatPoint(83.6, 41.6)); |
141 | outline.addBezierCurveTo(FloatPoint(83.6, 18.6), FloatPoint(65, 0), FloatPoint(42, 0)); |
142 | outline.addBezierCurveTo(FloatPoint(19, 0), FloatPoint(0.4, 18.6), FloatPoint(0.4, 41.6)); |
143 | outline.addBezierCurveTo(FloatPoint(0.4, 62.2), FloatPoint(15, 79.2), FloatPoint(35, 82.6)); |
144 | outline.addLineTo(FloatPoint(35, 74.5)); |
145 | outline.addBezierCurveTo(FloatPoint(20, 71.2), FloatPoint(8.4, 57.7), FloatPoint(8.4, 41.6)); |
146 | outline.addBezierCurveTo(FloatPoint(8.4, 23.1), FloatPoint(23.5, 8), FloatPoint(42, 8)); |
147 | outline.addBezierCurveTo(FloatPoint(60.5, 8), FloatPoint(75.5, 23.1), FloatPoint(75.5, 41.6)); |
148 | outline.addBezierCurveTo(FloatPoint(75.6, 57.7), FloatPoint(64, 71.2), FloatPoint(49, 74.5)); |
149 | outline.addLineTo(FloatPoint(49, 82.6)); |
150 | outline.addBezierCurveTo(FloatPoint(69, 79.3), FloatPoint(83.6, 62.2), FloatPoint(83.6, 41.6)); |
151 | outline.addLineTo(FloatPoint(83.6, 41.6)); |
152 | outline.closeSubpath(); |
153 | |
154 | context.fillPath(outline); |
155 | } |
156 | |
157 | } |
158 | |