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

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

Issue 339333002: Removing using declarations that import names in the C++ Standard library. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixing mac error Created 6 years, 6 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 * Copyright (C) 2006, 2007, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 17 matching lines...) Expand all
28 #include "core/html/HTMLInputElement.h" 28 #include "core/html/HTMLInputElement.h"
29 #include "core/rendering/PaintInfo.h" 29 #include "core/rendering/PaintInfo.h"
30 #include "core/rendering/RenderButton.h" 30 #include "core/rendering/RenderButton.h"
31 #include "core/rendering/RenderTheme.h" 31 #include "core/rendering/RenderTheme.h"
32 #include "platform/fonts/Font.h" 32 #include "platform/fonts/Font.h"
33 #include "platform/graphics/GraphicsContextStateSaver.h" 33 #include "platform/graphics/GraphicsContextStateSaver.h"
34 #include "platform/text/PlatformLocale.h" 34 #include "platform/text/PlatformLocale.h"
35 #include "platform/text/TextRun.h" 35 #include "platform/text/TextRun.h"
36 #include <math.h> 36 #include <math.h>
37 37
38 using namespace std;
39
40 namespace WebCore { 38 namespace WebCore {
41 39
42 using namespace HTMLNames; 40 using namespace HTMLNames;
43 41
44 const int afterButtonSpacing = 4; 42 const int afterButtonSpacing = 4;
45 const int defaultWidthNumChars = 34; 43 const int defaultWidthNumChars = 34;
46 const int buttonShadowHeight = 2; 44 const int buttonShadowHeight = 2;
47 45
48 RenderFileUploadControl::RenderFileUploadControl(HTMLInputElement* input) 46 RenderFileUploadControl::RenderFileUploadControl(HTMLInputElement* input)
49 : RenderBlockFlow(input) 47 : RenderBlockFlow(input)
(...skipping 26 matching lines...) Expand all
76 paintInvalidationForWholeRenderer(); 74 paintInvalidationForWholeRenderer();
77 } 75 }
78 76
79 static int nodeWidth(Node* node) 77 static int nodeWidth(Node* node)
80 { 78 {
81 return (node && node->renderBox()) ? node->renderBox()->pixelSnappedWidth() : 0; 79 return (node && node->renderBox()) ? node->renderBox()->pixelSnappedWidth() : 0;
82 } 80 }
83 81
84 int RenderFileUploadControl::maxFilenameWidth() const 82 int RenderFileUploadControl::maxFilenameWidth() const
85 { 83 {
86 return max(0, contentBoxRect().pixelSnappedWidth() - nodeWidth(uploadButton( )) - afterButtonSpacing); 84 return std::max(0, contentBoxRect().pixelSnappedWidth() - nodeWidth(uploadBu tton()) - afterButtonSpacing);
87 } 85 }
88 86
89 void RenderFileUploadControl::paintObject(PaintInfo& paintInfo, const LayoutPoin t& paintOffset) 87 void RenderFileUploadControl::paintObject(PaintInfo& paintInfo, const LayoutPoin t& paintOffset)
90 { 88 {
91 if (style()->visibility() != VISIBLE) 89 if (style()->visibility() != VISIBLE)
92 return; 90 return;
93 91
94 // Push a clip. 92 // Push a clip.
95 GraphicsContextStateSaver stateSaver(*paintInfo.context, false); 93 GraphicsContextStateSaver stateSaver(*paintInfo.context, false);
96 if (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhase ChildBlockBackgrounds) { 94 if (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhase ChildBlockBackgrounds) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 const Font& font = style()->font(); 152 const Font& font = style()->font();
155 // FIXME: Remove the need for this const_cast by making constructTextRun tak e a const RenderObject*. 153 // FIXME: Remove the need for this const_cast by making constructTextRun tak e a const RenderObject*.
156 RenderFileUploadControl* renderer = const_cast<RenderFileUploadControl*>(thi s); 154 RenderFileUploadControl* renderer = const_cast<RenderFileUploadControl*>(thi s);
157 float minDefaultLabelWidth = defaultWidthNumChars * font.width(constructText Run(renderer, font, characterAsString, style(), TextRun::AllowTrailingExpansion) ); 155 float minDefaultLabelWidth = defaultWidthNumChars * font.width(constructText Run(renderer, font, characterAsString, style(), TextRun::AllowTrailingExpansion) );
158 156
159 const String label = toHTMLInputElement(node())->locale().queryString(blink: :WebLocalizedString::FileButtonNoFileSelectedLabel); 157 const String label = toHTMLInputElement(node())->locale().queryString(blink: :WebLocalizedString::FileButtonNoFileSelectedLabel);
160 float defaultLabelWidth = font.width(constructTextRun(renderer, font, label, style(), TextRun::AllowTrailingExpansion)); 158 float defaultLabelWidth = font.width(constructTextRun(renderer, font, label, style(), TextRun::AllowTrailingExpansion));
161 if (HTMLInputElement* button = uploadButton()) 159 if (HTMLInputElement* button = uploadButton())
162 if (RenderObject* buttonRenderer = button->renderer()) 160 if (RenderObject* buttonRenderer = button->renderer())
163 defaultLabelWidth += buttonRenderer->maxPreferredLogicalWidth() + af terButtonSpacing; 161 defaultLabelWidth += buttonRenderer->maxPreferredLogicalWidth() + af terButtonSpacing;
164 maxLogicalWidth = static_cast<int>(ceilf(max(minDefaultLabelWidth, defaultLa belWidth))); 162 maxLogicalWidth = static_cast<int>(ceilf(std::max(minDefaultLabelWidth, defa ultLabelWidth)));
165 163
166 if (!style()->width().isPercent()) 164 if (!style()->width().isPercent())
167 minLogicalWidth = maxLogicalWidth; 165 minLogicalWidth = maxLogicalWidth;
168 } 166 }
169 167
170 void RenderFileUploadControl::computePreferredLogicalWidths() 168 void RenderFileUploadControl::computePreferredLogicalWidths()
171 { 169 {
172 ASSERT(preferredLogicalWidthsDirty()); 170 ASSERT(preferredLogicalWidthsDirty());
173 171
174 m_minPreferredLogicalWidth = 0; 172 m_minPreferredLogicalWidth = 0;
175 m_maxPreferredLogicalWidth = 0; 173 m_maxPreferredLogicalWidth = 0;
176 RenderStyle* styleToUse = style(); 174 RenderStyle* styleToUse = style();
177 175
178 if (styleToUse->width().isFixed() && styleToUse->width().value() > 0) 176 if (styleToUse->width().isFixed() && styleToUse->width().value() > 0)
179 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentB oxLogicalWidthForBoxSizing(styleToUse->width().value()); 177 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentB oxLogicalWidthForBoxSizing(styleToUse->width().value());
180 else 178 else
181 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferred LogicalWidth); 179 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferred LogicalWidth);
182 180
183 if (styleToUse->minWidth().isFixed() && styleToUse->minWidth().value() > 0) { 181 if (styleToUse->minWidth().isFixed() && styleToUse->minWidth().value() > 0) {
184 m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustConte ntBoxLogicalWidthForBoxSizing(styleToUse->minWidth().value())); 182 m_maxPreferredLogicalWidth = std::max(m_maxPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(styleToUse->minWidth().value()));
185 m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustConte ntBoxLogicalWidthForBoxSizing(styleToUse->minWidth().value())); 183 m_minPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(styleToUse->minWidth().value()));
186 } 184 }
187 185
188 if (styleToUse->maxWidth().isFixed()) { 186 if (styleToUse->maxWidth().isFixed()) {
189 m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustConte ntBoxLogicalWidthForBoxSizing(styleToUse->maxWidth().value())); 187 m_maxPreferredLogicalWidth = std::min(m_maxPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(styleToUse->maxWidth().value()));
190 m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, adjustConte ntBoxLogicalWidthForBoxSizing(styleToUse->maxWidth().value())); 188 m_minPreferredLogicalWidth = std::min(m_minPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(styleToUse->maxWidth().value()));
191 } 189 }
192 190
193 int toAdd = borderAndPaddingWidth(); 191 int toAdd = borderAndPaddingWidth();
194 m_minPreferredLogicalWidth += toAdd; 192 m_minPreferredLogicalWidth += toAdd;
195 m_maxPreferredLogicalWidth += toAdd; 193 m_maxPreferredLogicalWidth += toAdd;
196 194
197 clearPreferredLogicalWidthsDirty(); 195 clearPreferredLogicalWidthsDirty();
198 } 196 }
199 197
200 PositionWithAffinity RenderFileUploadControl::positionForPoint(const LayoutPoint &) 198 PositionWithAffinity RenderFileUploadControl::positionForPoint(const LayoutPoint &)
(...skipping 18 matching lines...) Expand all
219 } 217 }
220 218
221 String RenderFileUploadControl::fileTextValue() const 219 String RenderFileUploadControl::fileTextValue() const
222 { 220 {
223 HTMLInputElement* input = toHTMLInputElement(node()); 221 HTMLInputElement* input = toHTMLInputElement(node());
224 ASSERT(input->files()); 222 ASSERT(input->files());
225 return RenderTheme::theme().fileListNameForWidth(input->locale(), input->fil es(), style()->font(), maxFilenameWidth()); 223 return RenderTheme::theme().fileListNameForWidth(input->locale(), input->fil es(), style()->font(), maxFilenameWidth());
226 } 224 }
227 225
228 } // namespace WebCore 226 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderDeprecatedFlexibleBox.cpp ('k') | Source/core/rendering/RenderImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698