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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameView.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, 3 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) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 return !m_firstLayout; 389 return !m_firstLayout;
390 } 390 }
391 391
392 void FrameView::invalidateRect(const IntRect& rect) 392 void FrameView::invalidateRect(const IntRect& rect)
393 { 393 {
394 LayoutPartItem layoutItem = m_frame->ownerLayoutItem(); 394 LayoutPartItem layoutItem = m_frame->ownerLayoutItem();
395 if (layoutItem.isNull()) 395 if (layoutItem.isNull())
396 return; 396 return;
397 397
398 IntRect paintInvalidationRect = rect; 398 IntRect paintInvalidationRect = rect;
399 paintInvalidationRect.move(layoutItem.borderLeft() + layoutItem.paddingLeft( ), 399 paintInvalidationRect.move((layoutItem.borderLeft() + layoutItem.paddingLeft ()).toInt(),
400 layoutItem.borderTop() + layoutItem.paddingTop()); 400 (layoutItem.borderTop() + layoutItem.paddingTop()).toInt());
401 // FIXME: We should not allow paint invalidation out of paint invalidation s tate. crbug.com/457415 401 // FIXME: We should not allow paint invalidation out of paint invalidation s tate. crbug.com/457415
402 DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; 402 DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler;
403 layoutItem.invalidatePaintRectangle(LayoutRect(paintInvalidationRect)); 403 layoutItem.invalidatePaintRectangle(LayoutRect(paintInvalidationRect));
404 } 404 }
405 405
406 void FrameView::setFrameRect(const IntRect& newRect) 406 void FrameView::setFrameRect(const IntRect& newRect)
407 { 407 {
408 IntRect oldRect = frameRect(); 408 IntRect oldRect = frameRect();
409 if (newRect == oldRect) 409 if (newRect == oldRect)
410 return; 410 return;
(...skipping 2537 matching lines...) Expand 10 before | Expand all | Expand 10 after
2948 layoutView->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidatio n(LayoutInvalidationReason::PrintingChanged); 2948 layoutView->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidatio n(LayoutInvalidationReason::PrintingChanged);
2949 layout(); 2949 layout();
2950 2950
2951 const LayoutRect& updatedDocumentRect = LayoutRect(layoutView->docum entRect()); 2951 const LayoutRect& updatedDocumentRect = LayoutRect(layoutView->docum entRect());
2952 LayoutUnit docLogicalHeight = horizontalWritingMode ? updatedDocumen tRect.height() : updatedDocumentRect.width(); 2952 LayoutUnit docLogicalHeight = horizontalWritingMode ? updatedDocumen tRect.height() : updatedDocumentRect.width();
2953 LayoutUnit docLogicalTop = horizontalWritingMode ? updatedDocumentRe ct.y() : updatedDocumentRect.x(); 2953 LayoutUnit docLogicalTop = horizontalWritingMode ? updatedDocumentRe ct.y() : updatedDocumentRect.x();
2954 LayoutUnit docLogicalRight = horizontalWritingMode ? updatedDocument Rect.maxX() : updatedDocumentRect.maxY(); 2954 LayoutUnit docLogicalRight = horizontalWritingMode ? updatedDocument Rect.maxX() : updatedDocumentRect.maxY();
2955 LayoutUnit clippedLogicalLeft; 2955 LayoutUnit clippedLogicalLeft;
2956 if (!layoutView->style()->isLeftToRightDirection()) 2956 if (!layoutView->style()->isLeftToRightDirection())
2957 clippedLogicalLeft = LayoutUnit(docLogicalRight - pageLogicalWid th); 2957 clippedLogicalLeft = LayoutUnit(docLogicalRight - pageLogicalWid th);
2958 LayoutRect overflow(clippedLogicalLeft, docLogicalTop, pageLogicalWi dth, docLogicalHeight); 2958 // TODO(crbug.com/638981): Are the conversions to int intentional?
2959 LayoutRect overflow(clippedLogicalLeft.toInt(), docLogicalTop.toInt( ), pageLogicalWidth, docLogicalHeight.toInt());
2959 2960
2960 if (!horizontalWritingMode) 2961 if (!horizontalWritingMode)
2961 overflow = overflow.transposedRect(); 2962 overflow = overflow.transposedRect();
2962 layoutView->clearLayoutOverflow(); 2963 layoutView->clearLayoutOverflow();
2963 layoutView->addLayoutOverflow(overflow); // This is how we clip in c ase we overflow again. 2964 layoutView->addLayoutOverflow(overflow); // This is how we clip in c ase we overflow again.
2964 } 2965 }
2965 } 2966 }
2966 2967
2967 adjustViewSizeAndLayout(); 2968 adjustViewSizeAndLayout();
2968 } 2969 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3012 IntRect FrameView::convertToContainingWidget(const IntRect& localRect) const 3013 IntRect FrameView::convertToContainingWidget(const IntRect& localRect) const
3013 { 3014 {
3014 if (const FrameView* parentView = toFrameView(parent())) { 3015 if (const FrameView* parentView = toFrameView(parent())) {
3015 // Get our layoutObject in the parent view 3016 // Get our layoutObject in the parent view
3016 LayoutPart* layoutObject = m_frame->ownerLayoutObject(); 3017 LayoutPart* layoutObject = m_frame->ownerLayoutObject();
3017 if (!layoutObject) 3018 if (!layoutObject)
3018 return localRect; 3019 return localRect;
3019 3020
3020 IntRect rect(localRect); 3021 IntRect rect(localRect);
3021 // Add borders and padding?? 3022 // Add borders and padding??
3022 rect.move(layoutObject->borderLeft() + layoutObject->paddingLeft(), 3023 rect.move((layoutObject->borderLeft() + layoutObject->paddingLeft()).toI nt(),
3023 layoutObject->borderTop() + layoutObject->paddingTop()); 3024 (layoutObject->borderTop() + layoutObject->paddingTop()).toInt());
3024 return parentView->convertFromLayoutObject(*layoutObject, rect); 3025 return parentView->convertFromLayoutObject(*layoutObject, rect);
3025 } 3026 }
3026 3027
3027 return localRect; 3028 return localRect;
3028 } 3029 }
3029 3030
3030 IntRect FrameView::convertFromContainingWidget(const IntRect& parentRect) const 3031 IntRect FrameView::convertFromContainingWidget(const IntRect& parentRect) const
3031 { 3032 {
3032 if (const FrameView* parentView = toFrameView(parent())) { 3033 if (const FrameView* parentView = toFrameView(parent())) {
3033 // Get our layoutObject in the parent view 3034 // Get our layoutObject in the parent view
3034 LayoutPart* layoutObject = m_frame->ownerLayoutObject(); 3035 LayoutPart* layoutObject = m_frame->ownerLayoutObject();
3035 if (!layoutObject) 3036 if (!layoutObject)
3036 return parentRect; 3037 return parentRect;
3037 3038
3038 IntRect rect = parentView->convertToLayoutObject(*layoutObject, parentRe ct); 3039 IntRect rect = parentView->convertToLayoutObject(*layoutObject, parentRe ct);
3039 // Subtract borders and padding 3040 // Subtract borders and padding
3040 rect.move(-layoutObject->borderLeft() - layoutObject->paddingLeft(), 3041 rect.move((-layoutObject->borderLeft() - layoutObject->paddingLeft()).to Int(),
3041 -layoutObject->borderTop() - layoutObject->paddingTop()); 3042 (-layoutObject->borderTop() - layoutObject->paddingTop().toInt()));
3042 return rect; 3043 return rect;
3043 } 3044 }
3044 3045
3045 return parentRect; 3046 return parentRect;
3046 } 3047 }
3047 3048
3048 IntPoint FrameView::convertToContainingWidget(const IntPoint& localPoint) const 3049 IntPoint FrameView::convertToContainingWidget(const IntPoint& localPoint) const
3049 { 3050 {
3050 if (const FrameView* parentView = toFrameView(parent())) { 3051 if (const FrameView* parentView = toFrameView(parent())) {
3051 // Get our layoutObject in the parent view 3052 // Get our layoutObject in the parent view
3052 LayoutPart* layoutObject = m_frame->ownerLayoutObject(); 3053 LayoutPart* layoutObject = m_frame->ownerLayoutObject();
3053 if (!layoutObject) 3054 if (!layoutObject)
3054 return localPoint; 3055 return localPoint;
3055 3056
3056 IntPoint point(localPoint); 3057 IntPoint point(localPoint);
3057 3058
3058 // Add borders and padding 3059 // Add borders and padding
3059 point.move(layoutObject->borderLeft() + layoutObject->paddingLeft(), 3060 point.move((layoutObject->borderLeft() + layoutObject->paddingLeft()).to Int(),
3060 layoutObject->borderTop() + layoutObject->paddingTop()); 3061 (layoutObject->borderTop() + layoutObject->paddingTop()).toInt());
3061 return parentView->convertFromLayoutObject(*layoutObject, point); 3062 return parentView->convertFromLayoutObject(*layoutObject, point);
3062 } 3063 }
3063 3064
3064 return localPoint; 3065 return localPoint;
3065 } 3066 }
3066 3067
3067 IntPoint FrameView::convertFromContainingWidget(const IntPoint& parentPoint) con st 3068 IntPoint FrameView::convertFromContainingWidget(const IntPoint& parentPoint) con st
3068 { 3069 {
3069 if (const FrameView* parentView = toFrameView(parent())) { 3070 if (const FrameView* parentView = toFrameView(parent())) {
3070 // Get our layoutObject in the parent view 3071 // Get our layoutObject in the parent view
3071 LayoutPart* layoutObject = m_frame->ownerLayoutObject(); 3072 LayoutPart* layoutObject = m_frame->ownerLayoutObject();
3072 if (!layoutObject) 3073 if (!layoutObject)
3073 return parentPoint; 3074 return parentPoint;
3074 3075
3075 IntPoint point = parentView->convertToLayoutObject(*layoutObject, parent Point); 3076 IntPoint point = parentView->convertToLayoutObject(*layoutObject, parent Point);
3076 // Subtract borders and padding 3077 // Subtract borders and padding
3077 point.move(-layoutObject->borderLeft() - layoutObject->paddingLeft(), 3078 point.move((-layoutObject->borderLeft() - layoutObject->paddingLeft()).t oInt(),
3078 -layoutObject->borderTop() - layoutObject->paddingTop()); 3079 (-layoutObject->borderTop() - layoutObject->paddingTop()).toInt());
3079 return point; 3080 return point;
3080 } 3081 }
3081 3082
3082 return parentPoint; 3083 return parentPoint;
3083 } 3084 }
3084 3085
3085 void FrameView::setInitialTracksPaintInvalidationsForTesting(bool trackPaintInva lidations) 3086 void FrameView::setInitialTracksPaintInvalidationsForTesting(bool trackPaintInva lidations)
3086 { 3087 {
3087 s_initialTrackAllPaintInvalidations = trackPaintInvalidations; 3088 s_initialTrackAllPaintInvalidations = trackPaintInvalidations;
3088 } 3089 }
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
4336 } 4337 }
4337 4338
4338 bool FrameView::canThrottleRendering() const 4339 bool FrameView::canThrottleRendering() const
4339 { 4340 {
4340 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) 4341 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled())
4341 return false; 4342 return false;
4342 return m_subtreeThrottled || (m_hiddenForThrottling && m_crossOriginForThrot tling); 4343 return m_subtreeThrottled || (m_hiddenForThrottling && m_crossOriginForThrot tling);
4343 } 4344 }
4344 4345
4345 } // namespace blink 4346 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698