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

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

Issue 2770123003: Replace ASSERT with DCHECK in core/layout/ excluding subdirs (Closed)
Patch Set: Split some DCHECKs and add DCHECK_ops wherever possible Created 3 years, 8 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 29 matching lines...) Expand all
40 const int defaultWidthNumChars = 34; 40 const int defaultWidthNumChars = 34;
41 41
42 LayoutFileUploadControl::LayoutFileUploadControl(HTMLInputElement* input) 42 LayoutFileUploadControl::LayoutFileUploadControl(HTMLInputElement* input)
43 : LayoutBlockFlow(input), 43 : LayoutBlockFlow(input),
44 m_canReceiveDroppedFiles(input->canReceiveDroppedFiles()) {} 44 m_canReceiveDroppedFiles(input->canReceiveDroppedFiles()) {}
45 45
46 LayoutFileUploadControl::~LayoutFileUploadControl() {} 46 LayoutFileUploadControl::~LayoutFileUploadControl() {}
47 47
48 void LayoutFileUploadControl::updateFromElement() { 48 void LayoutFileUploadControl::updateFromElement() {
49 HTMLInputElement* input = toHTMLInputElement(node()); 49 HTMLInputElement* input = toHTMLInputElement(node());
50 ASSERT(input->type() == InputTypeNames::file); 50 DCHECK_EQ(input->type(), InputTypeNames::file);
51 51
52 if (HTMLInputElement* button = uploadButton()) { 52 if (HTMLInputElement* button = uploadButton()) {
53 bool newCanReceiveDroppedFilesState = input->canReceiveDroppedFiles(); 53 bool newCanReceiveDroppedFilesState = input->canReceiveDroppedFiles();
54 if (m_canReceiveDroppedFiles != newCanReceiveDroppedFilesState) { 54 if (m_canReceiveDroppedFiles != newCanReceiveDroppedFilesState) {
55 m_canReceiveDroppedFiles = newCanReceiveDroppedFilesState; 55 m_canReceiveDroppedFiles = newCanReceiveDroppedFilesState;
56 button->setActive(newCanReceiveDroppedFilesState); 56 button->setActive(newCanReceiveDroppedFilesState);
57 } 57 }
58 } 58 }
59 59
60 // This only supports clearing out the files, but that's OK because for 60 // This only supports clearing out the files, but that's OK because for
61 // security reasons that's the only change the DOM is allowed to make. 61 // security reasons that's the only change the DOM is allowed to make.
62 FileList* files = input->files(); 62 FileList* files = input->files();
63 ASSERT(files); 63 DCHECK(files);
64 if (files && files->isEmpty()) 64 if (files && files->isEmpty())
65 setShouldDoFullPaintInvalidation(); 65 setShouldDoFullPaintInvalidation();
66 } 66 }
67 67
68 int LayoutFileUploadControl::maxFilenameWidth() const { 68 int LayoutFileUploadControl::maxFilenameWidth() const {
69 int uploadButtonWidth = (uploadButton() && uploadButton()->layoutBox()) 69 int uploadButtonWidth = (uploadButton() && uploadButton()->layoutBox())
70 ? uploadButton()->layoutBox()->pixelSnappedWidth() 70 ? uploadButton()->layoutBox()->pixelSnappedWidth()
71 : 0; 71 : 0;
72 return std::max(0, contentBoxRect().pixelSnappedWidth() - uploadButtonWidth - 72 return std::max(0, contentBoxRect().pixelSnappedWidth() - uploadButtonWidth -
73 afterButtonSpacing); 73 afterButtonSpacing);
(...skipping 28 matching lines...) Expand all
102 buttonLayoutObject->maxPreferredLogicalWidth() + afterButtonSpacing; 102 buttonLayoutObject->maxPreferredLogicalWidth() + afterButtonSpacing;
103 } 103 }
104 maxLogicalWidth = 104 maxLogicalWidth =
105 LayoutUnit(ceilf(std::max(minDefaultLabelWidth, defaultLabelWidth))); 105 LayoutUnit(ceilf(std::max(minDefaultLabelWidth, defaultLabelWidth)));
106 106
107 if (!style()->width().isPercentOrCalc()) 107 if (!style()->width().isPercentOrCalc())
108 minLogicalWidth = maxLogicalWidth; 108 minLogicalWidth = maxLogicalWidth;
109 } 109 }
110 110
111 void LayoutFileUploadControl::computePreferredLogicalWidths() { 111 void LayoutFileUploadControl::computePreferredLogicalWidths() {
112 ASSERT(preferredLogicalWidthsDirty()); 112 DCHECK(preferredLogicalWidthsDirty());
113 113
114 m_minPreferredLogicalWidth = LayoutUnit(); 114 m_minPreferredLogicalWidth = LayoutUnit();
115 m_maxPreferredLogicalWidth = LayoutUnit(); 115 m_maxPreferredLogicalWidth = LayoutUnit();
116 const ComputedStyle& styleToUse = styleRef(); 116 const ComputedStyle& styleToUse = styleRef();
117 117
118 if (styleToUse.width().isFixed() && styleToUse.width().value() > 0) 118 if (styleToUse.width().isFixed() && styleToUse.width().value() > 0)
119 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = 119 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth =
120 adjustContentBoxLogicalWidthForBoxSizing( 120 adjustContentBoxLogicalWidthForBoxSizing(
121 LayoutUnit(styleToUse.width().value())); 121 LayoutUnit(styleToUse.width().value()));
122 else 122 else
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 String LayoutFileUploadControl::buttonValue() { 168 String LayoutFileUploadControl::buttonValue() {
169 if (HTMLInputElement* button = uploadButton()) 169 if (HTMLInputElement* button = uploadButton())
170 return button->value(); 170 return button->value();
171 171
172 return String(); 172 return String();
173 } 173 }
174 174
175 String LayoutFileUploadControl::fileTextValue() const { 175 String LayoutFileUploadControl::fileTextValue() const {
176 HTMLInputElement* input = toHTMLInputElement(node()); 176 HTMLInputElement* input = toHTMLInputElement(node());
177 ASSERT(input->files()); 177 DCHECK(input->files());
178 return LayoutTheme::theme().fileListNameForWidth( 178 return LayoutTheme::theme().fileListNameForWidth(
179 input->locale(), input->files(), style()->font(), maxFilenameWidth()); 179 input->locale(), input->files(), style()->font(), maxFilenameWidth());
180 } 180 }
181 181
182 } // namespace blink 182 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698