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

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

Issue 2261663002: Disallow cast/implicit conversion from LayoutUnit to int/unsigned (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: - Created 4 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 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 setHeight(LayoutUnit(m_scrollbar->height())); 118 setHeight(LayoutUnit(m_scrollbar->height()));
119 } else { 119 } else {
120 setWidth(LayoutUnit(m_scrollbar->width())); 120 setWidth(LayoutUnit(m_scrollbar->width()));
121 computeScrollbarHeight(); 121 computeScrollbarHeight();
122 } 122 }
123 } 123 }
124 124
125 static int calcScrollbarThicknessUsing(SizeType sizeType, const Length& length, int containingLength) 125 static int calcScrollbarThicknessUsing(SizeType sizeType, const Length& length, int containingLength)
126 { 126 {
127 if (!length.isIntrinsicOrAuto() || (sizeType == MinSize && length.isAuto())) 127 if (!length.isIntrinsicOrAuto() || (sizeType == MinSize && length.isAuto()))
128 return minimumValueForLength(length, LayoutUnit(containingLength)); 128 return minimumValueForLength(length, LayoutUnit(containingLength)).toInt ();
129 return ScrollbarTheme::theme().scrollbarThickness(); 129 return ScrollbarTheme::theme().scrollbarThickness();
130 } 130 }
131 131
132 void LayoutScrollbarPart::computeScrollbarWidth() 132 void LayoutScrollbarPart::computeScrollbarWidth()
133 { 133 {
134 if (!m_scrollbar->owningLayoutObject()) 134 if (!m_scrollbar->owningLayoutObject())
135 return; 135 return;
136 // FIXME: We are querying layout information but nothing guarantees that it' s up to date, especially since we are called at style change. 136 // FIXME: We are querying layout information but nothing guarantees that it' s up to date, especially since we are called at style change.
137 // FIXME: Querying the style's border information doesn't work on table cell s with collapsing borders. 137 // FIXME: Querying the style's border information doesn't work on table cell s with collapsing borders.
138 int visibleSize = m_scrollbar->owningLayoutObject()->size().width() - m_scro llbar->owningLayoutObject()->style()->borderLeftWidth() - m_scrollbar->owningLay outObject()->style()->borderRightWidth(); 138 int visibleSize = (m_scrollbar->owningLayoutObject()->size().width() - m_scr ollbar->owningLayoutObject()->style()->borderLeftWidth() - m_scrollbar->owningLa youtObject()->style()->borderRightWidth()).toInt();
139 int w = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->width(), v isibleSize); 139 int w = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->width(), v isibleSize);
140 int minWidth = calcScrollbarThicknessUsing(MinSize, style()->minWidth(), vis ibleSize); 140 int minWidth = calcScrollbarThicknessUsing(MinSize, style()->minWidth(), vis ibleSize);
141 int maxWidth = style()->maxWidth().isMaxSizeNone() ? w : calcScrollbarThickn essUsing(MaxSize, style()->maxWidth(), visibleSize); 141 int maxWidth = style()->maxWidth().isMaxSizeNone() ? w : calcScrollbarThickn essUsing(MaxSize, style()->maxWidth(), visibleSize);
142 setWidth(LayoutUnit(std::max(minWidth, std::min(maxWidth, w)))); 142 setWidth(LayoutUnit(std::max(minWidth, std::min(maxWidth, w))));
143 143
144 // Buttons and track pieces can all have margins along the axis of the scrol lbar. 144 // Buttons and track pieces can all have margins along the axis of the scrol lbar.
145 setMarginLeft(minimumValueForLength(style()->marginLeft(), LayoutUnit(visibl eSize))); 145 setMarginLeft(minimumValueForLength(style()->marginLeft(), LayoutUnit(visibl eSize)));
146 setMarginRight(minimumValueForLength(style()->marginRight(), LayoutUnit(visi bleSize))); 146 setMarginRight(minimumValueForLength(style()->marginRight(), LayoutUnit(visi bleSize)));
147 } 147 }
148 148
149 void LayoutScrollbarPart::computeScrollbarHeight() 149 void LayoutScrollbarPart::computeScrollbarHeight()
150 { 150 {
151 if (!m_scrollbar->owningLayoutObject()) 151 if (!m_scrollbar->owningLayoutObject())
152 return; 152 return;
153 // FIXME: We are querying layout information but nothing guarantees that it' s up to date, especially since we are called at style change. 153 // FIXME: We are querying layout information but nothing guarantees that it' s up to date, especially since we are called at style change.
154 // FIXME: Querying the style's border information doesn't work on table cell s with collapsing borders. 154 // FIXME: Querying the style's border information doesn't work on table cell s with collapsing borders.
155 int visibleSize = m_scrollbar->owningLayoutObject()->size().height() - m_sc rollbar->owningLayoutObject()->style()->borderTopWidth() - m_scrollbar->owningLa youtObject()->style()->borderBottomWidth(); 155 int visibleSize = (m_scrollbar->owningLayoutObject()->size().height() - m_s crollbar->owningLayoutObject()->style()->borderTopWidth() - m_scrollbar->owningL ayoutObject()->style()->borderBottomWidth()).toInt();
156 int h = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->height(), visibleSize); 156 int h = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->height(), visibleSize);
157 int minHeight = calcScrollbarThicknessUsing(MinSize, style()->minHeight(), v isibleSize); 157 int minHeight = calcScrollbarThicknessUsing(MinSize, style()->minHeight(), v isibleSize);
158 int maxHeight = style()->maxHeight().isMaxSizeNone() ? h : calcScrollbarThic knessUsing(MaxSize, style()->maxHeight(), visibleSize); 158 int maxHeight = style()->maxHeight().isMaxSizeNone() ? h : calcScrollbarThic knessUsing(MaxSize, style()->maxHeight(), visibleSize);
159 setHeight(LayoutUnit(std::max(minHeight, std::min(maxHeight, h)))); 159 setHeight(LayoutUnit(std::max(minHeight, std::min(maxHeight, h))));
160 160
161 // Buttons and track pieces can all have margins along the axis of the scrol lbar. 161 // Buttons and track pieces can all have margins along the axis of the scrol lbar.
162 setMarginTop(minimumValueForLength(style()->marginTop(), LayoutUnit(visibleS ize))); 162 setMarginTop(minimumValueForLength(style()->marginTop(), LayoutUnit(visibleS ize)));
163 setMarginBottom(minimumValueForLength(style()->marginBottom(), LayoutUnit(vi sibleSize))); 163 setMarginBottom(minimumValueForLength(style()->marginBottom(), LayoutUnit(vi sibleSize)));
164 } 164 }
165 165
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 222 }
223 223
224 LayoutRect LayoutScrollbarPart::visualRect() const 224 LayoutRect LayoutScrollbarPart::visualRect() const
225 { 225 {
226 // This returns the combined bounds of all scrollbar parts, which is suffici ent for correctness 226 // This returns the combined bounds of all scrollbar parts, which is suffici ent for correctness
227 // but not as tight as it could be. 227 // but not as tight as it could be.
228 return m_scrollableArea->visualRectForScrollbarParts(); 228 return m_scrollableArea->visualRectForScrollbarParts();
229 } 229 }
230 230
231 } // namespace blink 231 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutScrollbar.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutSlider.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698