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

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

Issue 463123003: Cleanup namespace usage in Source/core/rendering (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 4 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
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "public/platform/WebFallbackThemeEngine.h" 59 #include "public/platform/WebFallbackThemeEngine.h"
60 #include "public/platform/WebRect.h" 60 #include "public/platform/WebRect.h"
61 #include "wtf/text/StringBuilder.h" 61 #include "wtf/text/StringBuilder.h"
62 62
63 // The methods in this file are shared by all themes on every platform. 63 // The methods in this file are shared by all themes on every platform.
64 64
65 namespace blink { 65 namespace blink {
66 66
67 using namespace HTMLNames; 67 using namespace HTMLNames;
68 68
69 static blink::WebFallbackThemeEngine::State getWebFallbackThemeState(const Rende rTheme* theme, const RenderObject* o) 69 static WebFallbackThemeEngine::State getWebFallbackThemeState(const RenderTheme* theme, const RenderObject* o)
70 { 70 {
71 if (!theme->isEnabled(o)) 71 if (!theme->isEnabled(o))
72 return blink::WebFallbackThemeEngine::StateDisabled; 72 return WebFallbackThemeEngine::StateDisabled;
73 if (theme->isPressed(o)) 73 if (theme->isPressed(o))
74 return blink::WebFallbackThemeEngine::StatePressed; 74 return WebFallbackThemeEngine::StatePressed;
75 if (theme->isHovered(o)) 75 if (theme->isHovered(o))
76 return blink::WebFallbackThemeEngine::StateHover; 76 return WebFallbackThemeEngine::StateHover;
77 77
78 return blink::WebFallbackThemeEngine::StateNormal; 78 return WebFallbackThemeEngine::StateNormal;
79 } 79 }
80 80
81 RenderTheme::RenderTheme() 81 RenderTheme::RenderTheme()
82 : m_hasCustomFocusRingColor(false) 82 : m_hasCustomFocusRingColor(false)
83 #if USE(NEW_THEME) 83 #if USE(NEW_THEME)
84 , m_platformTheme(platformTheme()) 84 , m_platformTheme(platformTheme())
85 #endif 85 #endif
86 { 86 {
87 } 87 }
88 88
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 return m_hasCustomFocusRingColor ? m_customFocusRingColor : theme().platform FocusRingColor(); 1054 return m_hasCustomFocusRingColor ? m_customFocusRingColor : theme().platform FocusRingColor();
1055 } 1055 }
1056 1056
1057 String RenderTheme::fileListNameForWidth(Locale& locale, const FileList* fileLis t, const Font& font, int width) const 1057 String RenderTheme::fileListNameForWidth(Locale& locale, const FileList* fileLis t, const Font& font, int width) const
1058 { 1058 {
1059 if (width <= 0) 1059 if (width <= 0)
1060 return String(); 1060 return String();
1061 1061
1062 String string; 1062 String string;
1063 if (fileList->isEmpty()) { 1063 if (fileList->isEmpty()) {
1064 string = locale.queryString(blink::WebLocalizedString::FileButtonNoFileS electedLabel); 1064 string = locale.queryString(WebLocalizedString::FileButtonNoFileSelected Label);
1065 } else if (fileList->length() == 1) { 1065 } else if (fileList->length() == 1) {
1066 string = fileList->item(0)->name(); 1066 string = fileList->item(0)->name();
1067 } else { 1067 } else {
1068 // FIXME: Localization of fileList->length(). 1068 // FIXME: Localization of fileList->length().
1069 return StringTruncator::rightTruncate(locale.queryString(blink::WebLocal izedString::MultipleFileUploadText, String::number(fileList->length())), width, font); 1069 return StringTruncator::rightTruncate(locale.queryString(WebLocalizedStr ing::MultipleFileUploadText, String::number(fileList->length())), width, font);
1070 } 1070 }
1071 1071
1072 return StringTruncator::centerTruncate(string, width, font); 1072 return StringTruncator::centerTruncate(string, width, font);
1073 } 1073 }
1074 1074
1075 bool RenderTheme::shouldOpenPickerWithF4Key() const 1075 bool RenderTheme::shouldOpenPickerWithF4Key() const
1076 { 1076 {
1077 return false; 1077 return false;
1078 } 1078 }
1079 1079
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 void RenderTheme::setSizeIfAuto(RenderStyle* style, const IntSize& size) 1124 void RenderTheme::setSizeIfAuto(RenderStyle* style, const IntSize& size)
1125 { 1125 {
1126 if (style->width().isIntrinsicOrAuto()) 1126 if (style->width().isIntrinsicOrAuto())
1127 style->setWidth(Length(size.width(), Fixed)); 1127 style->setWidth(Length(size.width(), Fixed));
1128 if (style->height().isAuto()) 1128 if (style->height().isAuto())
1129 style->setHeight(Length(size.height(), Fixed)); 1129 style->setHeight(Length(size.height(), Fixed));
1130 } 1130 }
1131 1131
1132 bool RenderTheme::paintCheckboxUsingFallbackTheme(RenderObject* o, const PaintIn fo& i, const IntRect& r) 1132 bool RenderTheme::paintCheckboxUsingFallbackTheme(RenderObject* o, const PaintIn fo& i, const IntRect& r)
1133 { 1133 {
1134 blink::WebFallbackThemeEngine::ExtraParams extraParams; 1134 WebFallbackThemeEngine::ExtraParams extraParams;
1135 blink::WebCanvas* canvas = i.context->canvas(); 1135 WebCanvas* canvas = i.context->canvas();
1136 extraParams.button.checked = isChecked(o); 1136 extraParams.button.checked = isChecked(o);
1137 extraParams.button.indeterminate = isIndeterminate(o); 1137 extraParams.button.indeterminate = isIndeterminate(o);
1138 1138
1139 float zoomLevel = o->style()->effectiveZoom(); 1139 float zoomLevel = o->style()->effectiveZoom();
1140 GraphicsContextStateSaver stateSaver(*i.context); 1140 GraphicsContextStateSaver stateSaver(*i.context);
1141 IntRect unzoomedRect = r; 1141 IntRect unzoomedRect = r;
1142 if (zoomLevel != 1) { 1142 if (zoomLevel != 1) {
1143 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); 1143 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
1144 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); 1144 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
1145 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); 1145 i.context->translate(unzoomedRect.x(), unzoomedRect.y());
1146 i.context->scale(zoomLevel, zoomLevel); 1146 i.context->scale(zoomLevel, zoomLevel);
1147 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); 1147 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
1148 } 1148 }
1149 1149
1150 blink::Platform::current()->fallbackThemeEngine()->paint(canvas, blink::WebF allbackThemeEngine::PartCheckbox, getWebFallbackThemeState(this, o), blink::WebR ect(unzoomedRect), &extraParams); 1150 Platform::current()->fallbackThemeEngine()->paint(canvas, WebFallbackThemeEn gine::PartCheckbox, getWebFallbackThemeState(this, o), WebRect(unzoomedRect), &e xtraParams);
1151 return false; 1151 return false;
1152 } 1152 }
1153 1153
1154 void RenderTheme::adjustCheckboxStyleUsingFallbackTheme(RenderStyle* style, Elem ent*) const 1154 void RenderTheme::adjustCheckboxStyleUsingFallbackTheme(RenderStyle* style, Elem ent*) const
1155 { 1155 {
1156 // If the width and height are both specified, then we have nothing to do. 1156 // If the width and height are both specified, then we have nothing to do.
1157 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) 1157 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())
1158 return; 1158 return;
1159 1159
1160 IntSize size = blink::Platform::current()->fallbackThemeEngine()->getSize(bl ink::WebFallbackThemeEngine::PartCheckbox); 1160 IntSize size = Platform::current()->fallbackThemeEngine()->getSize(WebFallba ckThemeEngine::PartCheckbox);
1161 float zoomLevel = style->effectiveZoom(); 1161 float zoomLevel = style->effectiveZoom();
1162 size.setWidth(size.width() * zoomLevel); 1162 size.setWidth(size.width() * zoomLevel);
1163 size.setHeight(size.height() * zoomLevel); 1163 size.setHeight(size.height() * zoomLevel);
1164 setSizeIfAuto(style, size); 1164 setSizeIfAuto(style, size);
1165 1165
1166 // padding - not honored by WinIE, needs to be removed. 1166 // padding - not honored by WinIE, needs to be removed.
1167 style->resetPadding(); 1167 style->resetPadding();
1168 1168
1169 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme) 1169 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme)
1170 // for now, we will not honor it. 1170 // for now, we will not honor it.
1171 style->resetBorder(); 1171 style->resetBorder();
1172 } 1172 }
1173 1173
1174 bool RenderTheme::paintRadioUsingFallbackTheme(RenderObject* o, const PaintInfo& i, const IntRect& r) 1174 bool RenderTheme::paintRadioUsingFallbackTheme(RenderObject* o, const PaintInfo& i, const IntRect& r)
1175 { 1175 {
1176 blink::WebFallbackThemeEngine::ExtraParams extraParams; 1176 WebFallbackThemeEngine::ExtraParams extraParams;
1177 blink::WebCanvas* canvas = i.context->canvas(); 1177 WebCanvas* canvas = i.context->canvas();
1178 extraParams.button.checked = isChecked(o); 1178 extraParams.button.checked = isChecked(o);
1179 extraParams.button.indeterminate = isIndeterminate(o); 1179 extraParams.button.indeterminate = isIndeterminate(o);
1180 1180
1181 float zoomLevel = o->style()->effectiveZoom(); 1181 float zoomLevel = o->style()->effectiveZoom();
1182 GraphicsContextStateSaver stateSaver(*i.context); 1182 GraphicsContextStateSaver stateSaver(*i.context);
1183 IntRect unzoomedRect = r; 1183 IntRect unzoomedRect = r;
1184 if (zoomLevel != 1) { 1184 if (zoomLevel != 1) {
1185 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); 1185 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
1186 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); 1186 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
1187 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); 1187 i.context->translate(unzoomedRect.x(), unzoomedRect.y());
1188 i.context->scale(zoomLevel, zoomLevel); 1188 i.context->scale(zoomLevel, zoomLevel);
1189 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); 1189 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
1190 } 1190 }
1191 1191
1192 blink::Platform::current()->fallbackThemeEngine()->paint(canvas, blink::WebF allbackThemeEngine::PartRadio, getWebFallbackThemeState(this, o), blink::WebRect (unzoomedRect), &extraParams); 1192 Platform::current()->fallbackThemeEngine()->paint(canvas, WebFallbackThemeEn gine::PartRadio, getWebFallbackThemeState(this, o), WebRect(unzoomedRect), &extr aParams);
1193 return false; 1193 return false;
1194 } 1194 }
1195 1195
1196 void RenderTheme::adjustRadioStyleUsingFallbackTheme(RenderStyle* style, Element *) const 1196 void RenderTheme::adjustRadioStyleUsingFallbackTheme(RenderStyle* style, Element *) const
1197 { 1197 {
1198 // If the width and height are both specified, then we have nothing to do. 1198 // If the width and height are both specified, then we have nothing to do.
1199 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) 1199 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())
1200 return; 1200 return;
1201 1201
1202 IntSize size = blink::Platform::current()->fallbackThemeEngine()->getSize(bl ink::WebFallbackThemeEngine::PartRadio); 1202 IntSize size = Platform::current()->fallbackThemeEngine()->getSize(WebFallba ckThemeEngine::PartRadio);
1203 float zoomLevel = style->effectiveZoom(); 1203 float zoomLevel = style->effectiveZoom();
1204 size.setWidth(size.width() * zoomLevel); 1204 size.setWidth(size.width() * zoomLevel);
1205 size.setHeight(size.height() * zoomLevel); 1205 size.setHeight(size.height() * zoomLevel);
1206 setSizeIfAuto(style, size); 1206 setSizeIfAuto(style, size);
1207 1207
1208 // padding - not honored by WinIE, needs to be removed. 1208 // padding - not honored by WinIE, needs to be removed.
1209 style->resetPadding(); 1209 style->resetPadding();
1210 1210
1211 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme) 1211 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme)
1212 // for now, we will not honor it. 1212 // for now, we will not honor it.
1213 style->resetBorder(); 1213 style->resetBorder();
1214 } 1214 }
1215 1215
1216 } // namespace blink 1216 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderObject.cpp ('k') | Source/core/rendering/RenderThemeChromiumAndroid.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698