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

Side by Side Diff: third_party/WebKit/Source/core/paint/FileUploadControlPainter.cpp

Issue 1660863002: Force all LayoutUnit construction to be explicit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also fix LayoutRectTest.cpp 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/FileUploadControlPainter.h" 5 #include "core/paint/FileUploadControlPainter.h"
6 6
7 #include "core/layout/LayoutButton.h" 7 #include "core/layout/LayoutButton.h"
8 #include "core/layout/LayoutFileUploadControl.h" 8 #include "core/layout/LayoutFileUploadControl.h"
9 #include "core/layout/TextRunConstructor.h" 9 #include "core/layout/TextRunConstructor.h"
10 #include "core/paint/LayoutObjectDrawingRecorder.h" 10 #include "core/paint/LayoutObjectDrawingRecorder.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 if (!button) 44 if (!button)
45 return; 45 return;
46 46
47 int buttonWidth = (button && button->layoutBox()) ? button->layoutBox()- >pixelSnappedWidth() : 0; 47 int buttonWidth = (button && button->layoutBox()) ? button->layoutBox()- >pixelSnappedWidth() : 0;
48 LayoutUnit buttonAndSpacingWidth(buttonWidth + LayoutFileUploadControl:: afterButtonSpacing); 48 LayoutUnit buttonAndSpacingWidth(buttonWidth + LayoutFileUploadControl:: afterButtonSpacing);
49 float textWidth = font.width(textRun); 49 float textWidth = font.width(textRun);
50 LayoutUnit textX; 50 LayoutUnit textX;
51 if (m_layoutFileUploadControl.style()->isLeftToRightDirection()) 51 if (m_layoutFileUploadControl.style()->isLeftToRightDirection())
52 textX = contentLeft + buttonAndSpacingWidth; 52 textX = contentLeft + buttonAndSpacingWidth;
53 else 53 else
54 textX = contentLeft + m_layoutFileUploadControl.contentWidth() - but tonAndSpacingWidth - textWidth; 54 textX = LayoutUnit(contentLeft + m_layoutFileUploadControl.contentWi dth() - buttonAndSpacingWidth - textWidth);
55 55
56 LayoutUnit textY; 56 LayoutUnit textY;
57 // We want to match the button's baseline 57 // We want to match the button's baseline
58 // FIXME: Make this work with transforms. 58 // FIXME: Make this work with transforms.
59 if (LayoutButton* buttonLayoutObject = toLayoutButton(button->layoutObje ct())) 59 if (LayoutButton* buttonLayoutObject = toLayoutButton(button->layoutObje ct()))
60 textY = paintOffset.y() + m_layoutFileUploadControl.borderTop() + m_ layoutFileUploadControl.paddingTop() + buttonLayoutObject->baselinePosition(Alph abeticBaseline, true, HorizontalLine, PositionOnContainingLine); 60 textY = paintOffset.y() + m_layoutFileUploadControl.borderTop() + m_ layoutFileUploadControl.paddingTop() + buttonLayoutObject->baselinePosition(Alph abeticBaseline, true, HorizontalLine, PositionOnContainingLine);
61 else 61 else
62 textY = LayoutUnit(m_layoutFileUploadControl.baselinePosition(Alphab eticBaseline, true, HorizontalLine, PositionOnContainingLine)); 62 textY = LayoutUnit(m_layoutFileUploadControl.baselinePosition(Alphab eticBaseline, true, HorizontalLine, PositionOnContainingLine));
63 TextRunPaintInfo textRunPaintInfo(textRun); 63 TextRunPaintInfo textRunPaintInfo(textRun);
64 // FIXME: Shouldn't these offsets be rounded? crbug.com/350474 64 // FIXME: Shouldn't these offsets be rounded? crbug.com/350474
65 textRunPaintInfo.bounds = FloatRect(textX.toFloat(), textY.toFloat() - m _layoutFileUploadControl.style()->fontMetrics().ascent(), 65 textRunPaintInfo.bounds = FloatRect(textX.toFloat(), textY.toFloat() - m _layoutFileUploadControl.style()->fontMetrics().ascent(),
66 textWidth, m_layoutFileUploadControl.style()->fontMetrics().height() ); 66 textWidth, m_layoutFileUploadControl.style()->fontMetrics().height() );
67 67
68 // Draw the filename. 68 // Draw the filename.
69 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutFileUplo adControl, paintInfo.phase, textRunPaintInfo.bounds, paintOffset); 69 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutFileUplo adControl, paintInfo.phase, textRunPaintInfo.bounds, paintOffset);
70 paintInfo.context.setFillColor(m_layoutFileUploadControl.resolveColor(CS SPropertyColor)); 70 paintInfo.context.setFillColor(m_layoutFileUploadControl.resolveColor(CS SPropertyColor));
71 paintInfo.context.drawBidiText(font, textRunPaintInfo, FloatPoint(roundT oInt(textX), roundToInt(textY))); 71 paintInfo.context.drawBidiText(font, textRunPaintInfo, FloatPoint(roundT oInt(textX), roundToInt(textY)));
72 } 72 }
73 73
74 // Paint the children. 74 // Paint the children.
75 m_layoutFileUploadControl.LayoutBlockFlow::paintObject(paintInfo, paintOffse t); 75 m_layoutFileUploadControl.LayoutBlockFlow::paintObject(paintInfo, paintOffse t);
76 } 76 }
77 77
78 } // namespace blink 78 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698