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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutScrollbar.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, 2009 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008, 2009 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 if (destroy) 180 if (destroy)
181 return; 181 return;
182 182
183 // See if the scrollbar's thickness changed. If so, we need to mark our own ing object as needing a layout. 183 // See if the scrollbar's thickness changed. If so, we need to mark our own ing object as needing a layout.
184 bool isHorizontal = orientation() == HorizontalScrollbar; 184 bool isHorizontal = orientation() == HorizontalScrollbar;
185 int oldThickness = isHorizontal ? height() : width(); 185 int oldThickness = isHorizontal ? height() : width();
186 int newThickness = 0; 186 int newThickness = 0;
187 LayoutScrollbarPart* part = m_parts.get(ScrollbarBGPart); 187 LayoutScrollbarPart* part = m_parts.get(ScrollbarBGPart);
188 if (part) { 188 if (part) {
189 part->layout(); 189 part->layout();
190 newThickness = isHorizontal ? part->size().height() : part->size().width (); 190 newThickness = (isHorizontal ? part->size().height() : part->size().widt h()).toInt();
191 } 191 }
192 192
193 if (newThickness != oldThickness) { 193 if (newThickness != oldThickness) {
194 setFrameRect(IntRect(location(), IntSize(isHorizontal ? width() : newThi ckness, isHorizontal ? newThickness : height()))); 194 setFrameRect(IntRect(location(), IntSize(isHorizontal ? width() : newThi ckness, isHorizontal ? newThickness : height())));
195 if (LayoutBox* box = owningLayoutObjectWithinFrame()) { 195 if (LayoutBox* box = owningLayoutObjectWithinFrame()) {
196 if (box->isLayoutBlock()) 196 if (box->isLayoutBlock())
197 toLayoutBlock(box)->notifyScrollbarThicknessChanged(); 197 toLayoutBlock(box)->notifyScrollbarThicknessChanged();
198 box->setChildNeedsLayout(); 198 box->setChildNeedsLayout();
199 if (m_scrollableArea) 199 if (m_scrollableArea)
200 m_scrollableArea->setScrollCornerNeedsPaintInvalidation(); 200 m_scrollableArea->setScrollCornerNeedsPaintInvalidation();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 isHorizontal ? height() : partLayoutObject->pixelSnappedHeight()); 306 isHorizontal ? height() : partLayoutObject->pixelSnappedHeight());
307 } 307 }
308 308
309 IntRect LayoutScrollbar::trackRect(int startLength, int endLength) const 309 IntRect LayoutScrollbar::trackRect(int startLength, int endLength) const
310 { 310 {
311 LayoutScrollbarPart* part = m_parts.get(TrackBGPart); 311 LayoutScrollbarPart* part = m_parts.get(TrackBGPart);
312 if (part) 312 if (part)
313 part->layout(); 313 part->layout();
314 314
315 if (orientation() == HorizontalScrollbar) { 315 if (orientation() == HorizontalScrollbar) {
316 int marginLeft = part ? static_cast<int>(part->marginLeft()) : 0; 316 int marginLeft = part ? part->marginLeft().toInt() : 0;
317 int marginRight = part ? static_cast<int>(part->marginRight()) : 0; 317 int marginRight = part ? part->marginRight().toInt() : 0;
318 startLength += marginLeft; 318 startLength += marginLeft;
319 endLength += marginRight; 319 endLength += marginRight;
320 int totalLength = startLength + endLength; 320 int totalLength = startLength + endLength;
321 return IntRect(x() + startLength, y(), width() - totalLength, height()); 321 return IntRect(x() + startLength, y(), width() - totalLength, height());
322 } 322 }
323 323
324 int marginTop = part ? static_cast<int>(part->marginTop()) : 0; 324 int marginTop = part ? part->marginTop().toInt() : 0;
325 int marginBottom = part ? static_cast<int>(part->marginBottom()) : 0; 325 int marginBottom = part ? part->marginBottom().toInt() : 0;
326 startLength += marginTop; 326 startLength += marginTop;
327 endLength += marginBottom; 327 endLength += marginBottom;
328 int totalLength = startLength + endLength; 328 int totalLength = startLength + endLength;
329 329
330 return IntRect(x(), y() + startLength, width(), height() - totalLength); 330 return IntRect(x(), y() + startLength, width(), height() - totalLength);
331 } 331 }
332 332
333 IntRect LayoutScrollbar::trackPieceRectWithMargins(ScrollbarPart partType, const IntRect& oldRect) const 333 IntRect LayoutScrollbar::trackPieceRectWithMargins(ScrollbarPart partType, const IntRect& oldRect) const
334 { 334 {
335 LayoutScrollbarPart* partLayoutObject = m_parts.get(partType); 335 LayoutScrollbarPart* partLayoutObject = m_parts.get(partType);
336 if (!partLayoutObject) 336 if (!partLayoutObject)
337 return oldRect; 337 return oldRect;
338 338
339 partLayoutObject->layout(); 339 partLayoutObject->layout();
340 340
341 IntRect rect = oldRect; 341 IntRect rect = oldRect;
342 if (orientation() == HorizontalScrollbar) { 342 if (orientation() == HorizontalScrollbar) {
343 rect.setX(rect.x() + partLayoutObject->marginLeft()); 343 rect.setX((rect.x() + partLayoutObject->marginLeft()).toInt());
344 rect.setWidth(rect.width() - partLayoutObject->marginWidth()); 344 rect.setWidth((rect.width() - partLayoutObject->marginWidth()).toInt());
345 } else { 345 } else {
346 rect.setY(rect.y() + partLayoutObject->marginTop()); 346 rect.setY((rect.y() + partLayoutObject->marginTop()).toInt());
347 rect.setHeight(rect.height() - partLayoutObject->marginHeight()); 347 rect.setHeight((rect.height() - partLayoutObject->marginHeight()).toInt( ));
348 } 348 }
349 return rect; 349 return rect;
350 } 350 }
351 351
352 int LayoutScrollbar::minimumThumbLength() const 352 int LayoutScrollbar::minimumThumbLength() const
353 { 353 {
354 LayoutScrollbarPart* partLayoutObject = m_parts.get(ThumbPart); 354 LayoutScrollbarPart* partLayoutObject = m_parts.get(ThumbPart);
355 if (!partLayoutObject) 355 if (!partLayoutObject)
356 return 0; 356 return 0;
357 partLayoutObject->layout(); 357 partLayoutObject->layout();
358 return orientation() == HorizontalScrollbar ? partLayoutObject->size().width () : partLayoutObject->size().height(); 358 return (orientation() == HorizontalScrollbar ? partLayoutObject->size().widt h() : partLayoutObject->size().height()).toInt();
359 } 359 }
360 360
361 void LayoutScrollbar::invalidateDisplayItemClientsOfScrollbarParts() 361 void LayoutScrollbar::invalidateDisplayItemClientsOfScrollbarParts()
362 { 362 {
363 for (auto& part : m_parts) 363 for (auto& part : m_parts)
364 part.value->invalidateDisplayItemClientsIncludingNonCompositingDescendan ts(PaintInvalidationScroll); 364 part.value->invalidateDisplayItemClientsIncludingNonCompositingDescendan ts(PaintInvalidationScroll);
365 } 365 }
366 366
367 } // namespace blink 367 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698