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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutFileUploadControl.cpp

Issue 1651703002: More explicit LayoutUnit conversions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@evenMoarConstructors
Patch Set: Traits vs Properties vs Pandas Created 4 years, 10 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 const String characterAsString = String(&character, 1); 92 const String characterAsString = String(&character, 1);
93 const Font& font = style()->font(); 93 const Font& font = style()->font();
94 float minDefaultLabelWidth = defaultWidthNumChars * font.width(constructText Run(font, characterAsString, styleRef(), TextRun::AllowTrailingExpansion)); 94 float minDefaultLabelWidth = defaultWidthNumChars * font.width(constructText Run(font, characterAsString, styleRef(), TextRun::AllowTrailingExpansion));
95 95
96 const String label = toHTMLInputElement(node())->locale().queryString(WebLoc alizedString::FileButtonNoFileSelectedLabel); 96 const String label = toHTMLInputElement(node())->locale().queryString(WebLoc alizedString::FileButtonNoFileSelectedLabel);
97 float defaultLabelWidth = font.width(constructTextRun(font, label, styleRef( ), TextRun::AllowTrailingExpansion)); 97 float defaultLabelWidth = font.width(constructTextRun(font, label, styleRef( ), TextRun::AllowTrailingExpansion));
98 if (HTMLInputElement* button = uploadButton()) { 98 if (HTMLInputElement* button = uploadButton()) {
99 if (LayoutObject* buttonLayoutObject = button->layoutObject()) 99 if (LayoutObject* buttonLayoutObject = button->layoutObject())
100 defaultLabelWidth += buttonLayoutObject->maxPreferredLogicalWidth() + afterButtonSpacing; 100 defaultLabelWidth += buttonLayoutObject->maxPreferredLogicalWidth() + afterButtonSpacing;
101 } 101 }
102 maxLogicalWidth = static_cast<int>(ceilf(std::max(minDefaultLabelWidth, defa ultLabelWidth))); 102 maxLogicalWidth = LayoutUnit(ceilf(std::max(minDefaultLabelWidth, defaultLab elWidth)));
103 103
104 if (!style()->width().hasPercent()) 104 if (!style()->width().hasPercent())
105 minLogicalWidth = maxLogicalWidth; 105 minLogicalWidth = maxLogicalWidth;
106 } 106 }
107 107
108 void LayoutFileUploadControl::computePreferredLogicalWidths() 108 void LayoutFileUploadControl::computePreferredLogicalWidths()
109 { 109 {
110 ASSERT(preferredLogicalWidthsDirty()); 110 ASSERT(preferredLogicalWidthsDirty());
111 111
112 m_minPreferredLogicalWidth = 0; 112 m_minPreferredLogicalWidth = LayoutUnit();
113 m_maxPreferredLogicalWidth = 0; 113 m_maxPreferredLogicalWidth = LayoutUnit();
114 const ComputedStyle& styleToUse = styleRef(); 114 const ComputedStyle& styleToUse = styleRef();
115 115
116 if (styleToUse.width().isFixed() && styleToUse.width().value() > 0) 116 if (styleToUse.width().isFixed() && styleToUse.width().value() > 0)
117 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentB oxLogicalWidthForBoxSizing(styleToUse.width().value()); 117 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentB oxLogicalWidthForBoxSizing(styleToUse.width().value());
118 else 118 else
119 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferred LogicalWidth); 119 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferred LogicalWidth);
120 120
121 if (styleToUse.minWidth().isFixed() && styleToUse.minWidth().value() > 0) { 121 if (styleToUse.minWidth().isFixed() && styleToUse.minWidth().value() > 0) {
122 m_maxPreferredLogicalWidth = std::max(m_maxPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(LayoutUnit(styleToUse.minWidth().value()))); 122 m_maxPreferredLogicalWidth = std::max(m_maxPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(LayoutUnit(styleToUse.minWidth().value())));
123 m_minPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(LayoutUnit(styleToUse.minWidth().value()))); 123 m_minPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, adjust ContentBoxLogicalWidthForBoxSizing(LayoutUnit(styleToUse.minWidth().value())));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 157 }
158 158
159 String LayoutFileUploadControl::fileTextValue() const 159 String LayoutFileUploadControl::fileTextValue() const
160 { 160 {
161 HTMLInputElement* input = toHTMLInputElement(node()); 161 HTMLInputElement* input = toHTMLInputElement(node());
162 ASSERT(input->files()); 162 ASSERT(input->files());
163 return LayoutTheme::theme().fileListNameForWidth(input->locale(), input->fil es(), style()->font(), maxFilenameWidth()); 163 return LayoutTheme::theme().fileListNameForWidth(input->locale(), input->fil es(), style()->font(), maxFilenameWidth());
164 } 164 }
165 165
166 } // namespace blink 166 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698