OLD | NEW |
1 /** | 1 /** |
2 * This file is part of the theme implementation for form controls in WebCore. | 2 * This file is part of the theme implementation for form controls in WebCore. |
3 * | 3 * |
4 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Computer, Inc. | 4 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Computer, Inc. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 namespace WebCore { | 68 namespace WebCore { |
69 | 69 |
70 using namespace HTMLNames; | 70 using namespace HTMLNames; |
71 | 71 |
72 static Color& customFocusRingColor() | 72 static Color& customFocusRingColor() |
73 { | 73 { |
74 DEFINE_STATIC_LOCAL(Color, color, ()); | 74 DEFINE_STATIC_LOCAL(Color, color, ()); |
75 return color; | 75 return color; |
76 } | 76 } |
77 | 77 |
78 static WebKit::WebFallbackThemeEngine::State getWebFallbackThemeState(const Rend
erTheme* theme, const RenderObject* o) | 78 static blink::WebFallbackThemeEngine::State getWebFallbackThemeState(const Rende
rTheme* theme, const RenderObject* o) |
79 { | 79 { |
80 if (!theme->isEnabled(o)) | 80 if (!theme->isEnabled(o)) |
81 return WebKit::WebFallbackThemeEngine::StateDisabled; | 81 return blink::WebFallbackThemeEngine::StateDisabled; |
82 if (theme->isPressed(o)) | 82 if (theme->isPressed(o)) |
83 return WebKit::WebFallbackThemeEngine::StatePressed; | 83 return blink::WebFallbackThemeEngine::StatePressed; |
84 if (theme->isHovered(o)) | 84 if (theme->isHovered(o)) |
85 return WebKit::WebFallbackThemeEngine::StateHover; | 85 return blink::WebFallbackThemeEngine::StateHover; |
86 | 86 |
87 return WebKit::WebFallbackThemeEngine::StateNormal; | 87 return blink::WebFallbackThemeEngine::StateNormal; |
88 } | 88 } |
89 | 89 |
90 RenderTheme::RenderTheme() | 90 RenderTheme::RenderTheme() |
91 #if USE(NEW_THEME) | 91 #if USE(NEW_THEME) |
92 : m_platformTheme(platformTheme()) | 92 : m_platformTheme(platformTheme()) |
93 #endif | 93 #endif |
94 { | 94 { |
95 } | 95 } |
96 | 96 |
97 void RenderTheme::adjustStyle(RenderStyle* style, Element* e, const CachedUAStyl
e& uaStyle) | 97 void RenderTheme::adjustStyle(RenderStyle* style, Element* e, const CachedUAStyl
e& uaStyle) |
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 return customFocusRingColor().isValid() ? customFocusRingColor() : theme().p
latformFocusRingColor(); | 1147 return customFocusRingColor().isValid() ? customFocusRingColor() : theme().p
latformFocusRingColor(); |
1148 } | 1148 } |
1149 | 1149 |
1150 String RenderTheme::fileListNameForWidth(Locale& locale, const FileList* fileLis
t, const Font& font, int width) const | 1150 String RenderTheme::fileListNameForWidth(Locale& locale, const FileList* fileLis
t, const Font& font, int width) const |
1151 { | 1151 { |
1152 if (width <= 0) | 1152 if (width <= 0) |
1153 return String(); | 1153 return String(); |
1154 | 1154 |
1155 String string; | 1155 String string; |
1156 if (fileList->isEmpty()) { | 1156 if (fileList->isEmpty()) { |
1157 string = locale.queryString(WebKit::WebLocalizedString::FileButtonNoFile
SelectedLabel); | 1157 string = locale.queryString(blink::WebLocalizedString::FileButtonNoFileS
electedLabel); |
1158 } else if (fileList->length() == 1) { | 1158 } else if (fileList->length() == 1) { |
1159 string = fileList->item(0)->name(); | 1159 string = fileList->item(0)->name(); |
1160 } else { | 1160 } else { |
1161 // FIXME: Localization of fileList->length(). | 1161 // FIXME: Localization of fileList->length(). |
1162 return StringTruncator::rightTruncate(locale.queryString(WebKit::WebLoca
lizedString::MultipleFileUploadText, String::number(fileList->length())), width,
font, StringTruncator::EnableRoundingHacks); | 1162 return StringTruncator::rightTruncate(locale.queryString(blink::WebLocal
izedString::MultipleFileUploadText, String::number(fileList->length())), width,
font, StringTruncator::EnableRoundingHacks); |
1163 } | 1163 } |
1164 | 1164 |
1165 return StringTruncator::centerTruncate(string, width, font, StringTruncator:
:EnableRoundingHacks); | 1165 return StringTruncator::centerTruncate(string, width, font, StringTruncator:
:EnableRoundingHacks); |
1166 } | 1166 } |
1167 | 1167 |
1168 bool RenderTheme::shouldOpenPickerWithF4Key() const | 1168 bool RenderTheme::shouldOpenPickerWithF4Key() const |
1169 { | 1169 { |
1170 return false; | 1170 return false; |
1171 } | 1171 } |
1172 | 1172 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 void RenderTheme::setSizeIfAuto(RenderStyle* style, const IntSize& size) | 1231 void RenderTheme::setSizeIfAuto(RenderStyle* style, const IntSize& size) |
1232 { | 1232 { |
1233 if (style->width().isIntrinsicOrAuto()) | 1233 if (style->width().isIntrinsicOrAuto()) |
1234 style->setWidth(Length(size.width(), Fixed)); | 1234 style->setWidth(Length(size.width(), Fixed)); |
1235 if (style->height().isAuto()) | 1235 if (style->height().isAuto()) |
1236 style->setHeight(Length(size.height(), Fixed)); | 1236 style->setHeight(Length(size.height(), Fixed)); |
1237 } | 1237 } |
1238 | 1238 |
1239 bool RenderTheme::paintCheckboxUsingFallbackTheme(RenderObject* o, const PaintIn
fo& i, const IntRect& r) | 1239 bool RenderTheme::paintCheckboxUsingFallbackTheme(RenderObject* o, const PaintIn
fo& i, const IntRect& r) |
1240 { | 1240 { |
1241 WebKit::WebFallbackThemeEngine::ExtraParams extraParams; | 1241 blink::WebFallbackThemeEngine::ExtraParams extraParams; |
1242 WebKit::WebCanvas* canvas = i.context->canvas(); | 1242 blink::WebCanvas* canvas = i.context->canvas(); |
1243 extraParams.button.checked = isChecked(o); | 1243 extraParams.button.checked = isChecked(o); |
1244 extraParams.button.indeterminate = isIndeterminate(o); | 1244 extraParams.button.indeterminate = isIndeterminate(o); |
1245 | 1245 |
1246 float zoomLevel = o->style()->effectiveZoom(); | 1246 float zoomLevel = o->style()->effectiveZoom(); |
1247 GraphicsContextStateSaver stateSaver(*i.context); | 1247 GraphicsContextStateSaver stateSaver(*i.context); |
1248 IntRect unzoomedRect = r; | 1248 IntRect unzoomedRect = r; |
1249 if (zoomLevel != 1) { | 1249 if (zoomLevel != 1) { |
1250 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); | 1250 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); |
1251 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); | 1251 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); |
1252 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); | 1252 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); |
1253 i.context->scale(FloatSize(zoomLevel, zoomLevel)); | 1253 i.context->scale(FloatSize(zoomLevel, zoomLevel)); |
1254 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); | 1254 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); |
1255 } | 1255 } |
1256 | 1256 |
1257 WebKit::Platform::current()->fallbackThemeEngine()->paint(canvas, WebKit::We
bFallbackThemeEngine::PartCheckbox, getWebFallbackThemeState(this, o), WebKit::W
ebRect(unzoomedRect), &extraParams); | 1257 blink::Platform::current()->fallbackThemeEngine()->paint(canvas, blink::WebF
allbackThemeEngine::PartCheckbox, getWebFallbackThemeState(this, o), blink::WebR
ect(unzoomedRect), &extraParams); |
1258 return false; | 1258 return false; |
1259 } | 1259 } |
1260 | 1260 |
1261 void RenderTheme::adjustCheckboxStyleUsingFallbackTheme(RenderStyle* style, Elem
ent*) const | 1261 void RenderTheme::adjustCheckboxStyleUsingFallbackTheme(RenderStyle* style, Elem
ent*) const |
1262 { | 1262 { |
1263 // If the width and height are both specified, then we have nothing to do. | 1263 // If the width and height are both specified, then we have nothing to do. |
1264 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) | 1264 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) |
1265 return; | 1265 return; |
1266 | 1266 |
1267 IntSize size = WebKit::Platform::current()->fallbackThemeEngine()->getSize(W
ebKit::WebFallbackThemeEngine::PartCheckbox); | 1267 IntSize size = blink::Platform::current()->fallbackThemeEngine()->getSize(bl
ink::WebFallbackThemeEngine::PartCheckbox); |
1268 float zoomLevel = style->effectiveZoom(); | 1268 float zoomLevel = style->effectiveZoom(); |
1269 size.setWidth(size.width() * zoomLevel); | 1269 size.setWidth(size.width() * zoomLevel); |
1270 size.setHeight(size.height() * zoomLevel); | 1270 size.setHeight(size.height() * zoomLevel); |
1271 setSizeIfAuto(style, size); | 1271 setSizeIfAuto(style, size); |
1272 | 1272 |
1273 // padding - not honored by WinIE, needs to be removed. | 1273 // padding - not honored by WinIE, needs to be removed. |
1274 style->resetPadding(); | 1274 style->resetPadding(); |
1275 | 1275 |
1276 // border - honored by WinIE, but looks terrible (just paints in the control
box and turns off the Windows XP theme) | 1276 // border - honored by WinIE, but looks terrible (just paints in the control
box and turns off the Windows XP theme) |
1277 // for now, we will not honor it. | 1277 // for now, we will not honor it. |
1278 style->resetBorder(); | 1278 style->resetBorder(); |
1279 } | 1279 } |
1280 | 1280 |
1281 bool RenderTheme::paintRadioUsingFallbackTheme(RenderObject* o, const PaintInfo&
i, const IntRect& r) | 1281 bool RenderTheme::paintRadioUsingFallbackTheme(RenderObject* o, const PaintInfo&
i, const IntRect& r) |
1282 { | 1282 { |
1283 WebKit::WebFallbackThemeEngine::ExtraParams extraParams; | 1283 blink::WebFallbackThemeEngine::ExtraParams extraParams; |
1284 WebKit::WebCanvas* canvas = i.context->canvas(); | 1284 blink::WebCanvas* canvas = i.context->canvas(); |
1285 extraParams.button.checked = isChecked(o); | 1285 extraParams.button.checked = isChecked(o); |
1286 extraParams.button.indeterminate = isIndeterminate(o); | 1286 extraParams.button.indeterminate = isIndeterminate(o); |
1287 | 1287 |
1288 float zoomLevel = o->style()->effectiveZoom(); | 1288 float zoomLevel = o->style()->effectiveZoom(); |
1289 GraphicsContextStateSaver stateSaver(*i.context); | 1289 GraphicsContextStateSaver stateSaver(*i.context); |
1290 IntRect unzoomedRect = r; | 1290 IntRect unzoomedRect = r; |
1291 if (zoomLevel != 1) { | 1291 if (zoomLevel != 1) { |
1292 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); | 1292 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); |
1293 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); | 1293 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); |
1294 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); | 1294 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); |
1295 i.context->scale(FloatSize(zoomLevel, zoomLevel)); | 1295 i.context->scale(FloatSize(zoomLevel, zoomLevel)); |
1296 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); | 1296 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); |
1297 } | 1297 } |
1298 | 1298 |
1299 WebKit::Platform::current()->fallbackThemeEngine()->paint(canvas, WebKit::We
bFallbackThemeEngine::PartRadio, getWebFallbackThemeState(this, o), WebKit::WebR
ect(unzoomedRect), &extraParams); | 1299 blink::Platform::current()->fallbackThemeEngine()->paint(canvas, blink::WebF
allbackThemeEngine::PartRadio, getWebFallbackThemeState(this, o), blink::WebRect
(unzoomedRect), &extraParams); |
1300 return false; | 1300 return false; |
1301 } | 1301 } |
1302 | 1302 |
1303 void RenderTheme::adjustRadioStyleUsingFallbackTheme(RenderStyle* style, Element
*) const | 1303 void RenderTheme::adjustRadioStyleUsingFallbackTheme(RenderStyle* style, Element
*) const |
1304 { | 1304 { |
1305 // If the width and height are both specified, then we have nothing to do. | 1305 // If the width and height are both specified, then we have nothing to do. |
1306 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) | 1306 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) |
1307 return; | 1307 return; |
1308 | 1308 |
1309 IntSize size = WebKit::Platform::current()->fallbackThemeEngine()->getSize(W
ebKit::WebFallbackThemeEngine::PartRadio); | 1309 IntSize size = blink::Platform::current()->fallbackThemeEngine()->getSize(bl
ink::WebFallbackThemeEngine::PartRadio); |
1310 float zoomLevel = style->effectiveZoom(); | 1310 float zoomLevel = style->effectiveZoom(); |
1311 size.setWidth(size.width() * zoomLevel); | 1311 size.setWidth(size.width() * zoomLevel); |
1312 size.setHeight(size.height() * zoomLevel); | 1312 size.setHeight(size.height() * zoomLevel); |
1313 setSizeIfAuto(style, size); | 1313 setSizeIfAuto(style, size); |
1314 | 1314 |
1315 // padding - not honored by WinIE, needs to be removed. | 1315 // padding - not honored by WinIE, needs to be removed. |
1316 style->resetPadding(); | 1316 style->resetPadding(); |
1317 | 1317 |
1318 // border - honored by WinIE, but looks terrible (just paints in the control
box and turns off the Windows XP theme) | 1318 // border - honored by WinIE, but looks terrible (just paints in the control
box and turns off the Windows XP theme) |
1319 // for now, we will not honor it. | 1319 // for now, we will not honor it. |
1320 style->resetBorder(); | 1320 style->resetBorder(); |
1321 } | 1321 } |
1322 | 1322 |
1323 } // namespace WebCore | 1323 } // namespace WebCore |
OLD | NEW |