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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.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) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@gmail.com> 9 * Christian Biesinger <cbiesinger@gmail.com>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 return layer()->size().height(); 473 return layer()->size().height();
474 } 474 }
475 475
476 int PaintLayerScrollableArea::visibleWidth() const 476 int PaintLayerScrollableArea::visibleWidth() const
477 { 477 {
478 return layer()->size().width(); 478 return layer()->size().width();
479 } 479 }
480 480
481 IntSize PaintLayerScrollableArea::contentsSize() const 481 IntSize PaintLayerScrollableArea::contentsSize() const
482 { 482 {
483 return IntSize(scrollWidth(), scrollHeight()); 483 return IntSize(scrollWidth().toInt(), scrollHeight().toInt());
484 } 484 }
485 485
486 IntPoint PaintLayerScrollableArea::lastKnownMousePosition() const 486 IntPoint PaintLayerScrollableArea::lastKnownMousePosition() const
487 { 487 {
488 return box().frame() ? box().frame()->eventHandler().lastKnownMousePosition( ) : IntPoint(); 488 return box().frame() ? box().frame()->eventHandler().lastKnownMousePosition( ) : IntPoint();
489 } 489 }
490 490
491 bool PaintLayerScrollableArea::scrollAnimatorEnabled() const 491 bool PaintLayerScrollableArea::scrollAnimatorEnabled() const
492 { 492 {
493 if (Settings* settings = box().frame()->settings()) 493 if (Settings* settings = box().frame()->settings())
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 } 710 }
711 } 711 }
712 712
713 { 713 {
714 // Hits in compositing/overflow/automatically-opt-into-composited-scroll ing-after-style-change.html. 714 // Hits in compositing/overflow/automatically-opt-into-composited-scroll ing-after-style-change.html.
715 DisableCompositingQueryAsserts disabler; 715 DisableCompositingQueryAsserts disabler;
716 716
717 // Set up the range (and page step/line step). 717 // Set up the range (and page step/line step).
718 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { 718 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) {
719 int clientWidth = box().pixelSnappedClientWidth(); 719 int clientWidth = box().pixelSnappedClientWidth();
720 horizontalScrollbar->setProportion(clientWidth, overflowRect().width ()); 720 horizontalScrollbar->setProportion(clientWidth, overflowRect().width ().toInt());
721 } 721 }
722 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) { 722 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) {
723 int clientHeight = box().pixelSnappedClientHeight(); 723 int clientHeight = box().pixelSnappedClientHeight();
724 verticalScrollbar->setProportion(clientHeight, overflowRect().height ()); 724 verticalScrollbar->setProportion(clientHeight, overflowRect().height ().toInt());
725 } 725 }
726 } 726 }
727 727
728 if (!scrollbarsAreFrozen && hasOverlayScrollbars()) { 728 if (!scrollbarsAreFrozen && hasOverlayScrollbars()) {
729 if (!scrollSize(HorizontalScrollbar)) 729 if (!scrollSize(HorizontalScrollbar))
730 setHasHorizontalScrollbar(false); 730 setHasHorizontalScrollbar(false);
731 if (!scrollSize(VerticalScrollbar)) 731 if (!scrollSize(VerticalScrollbar))
732 setHasVerticalScrollbar(false); 732 setHasVerticalScrollbar(false);
733 } 733 }
734 734
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 m_topmostScrollChild = m_nextTopmostScrollChild; 918 m_topmostScrollChild = m_nextTopmostScrollChild;
919 m_nextTopmostScrollChild = nullptr; 919 m_nextTopmostScrollChild = nullptr;
920 return layersChanged; 920 return layersChanged;
921 } 921 }
922 922
923 void PaintLayerScrollableArea::updateAfterOverflowRecalc() 923 void PaintLayerScrollableArea::updateAfterOverflowRecalc()
924 { 924 {
925 updateScrollDimensions(); 925 updateScrollDimensions();
926 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { 926 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) {
927 int clientWidth = box().pixelSnappedClientWidth(); 927 int clientWidth = box().pixelSnappedClientWidth();
928 horizontalScrollbar->setProportion(clientWidth, overflowRect().width()); 928 horizontalScrollbar->setProportion(clientWidth, overflowRect().width().t oInt());
929 } 929 }
930 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) { 930 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) {
931 int clientHeight = box().pixelSnappedClientHeight(); 931 int clientHeight = box().pixelSnappedClientHeight();
932 verticalScrollbar->setProportion(clientHeight, overflowRect().height()); 932 verticalScrollbar->setProportion(clientHeight, overflowRect().height().t oInt());
933 } 933 }
934 934
935 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); 935 bool hasHorizontalOverflow = this->hasHorizontalOverflow();
936 bool hasVerticalOverflow = this->hasVerticalOverflow(); 936 bool hasVerticalOverflow = this->hasVerticalOverflow();
937 bool autoHorizontalScrollbarChanged = box().hasAutoHorizontalScrollbar() && (hasHorizontalScrollbar() != hasHorizontalOverflow); 937 bool autoHorizontalScrollbarChanged = box().hasAutoHorizontalScrollbar() && (hasHorizontalScrollbar() != hasHorizontalOverflow);
938 bool autoVerticalScrollbarChanged = box().hasAutoVerticalScrollbar() && (has VerticalScrollbar() != hasVerticalOverflow); 938 bool autoVerticalScrollbarChanged = box().hasAutoVerticalScrollbar() && (has VerticalScrollbar() != hasVerticalOverflow);
939 if (autoHorizontalScrollbarChanged || autoVerticalScrollbarChanged) 939 if (autoHorizontalScrollbarChanged || autoVerticalScrollbarChanged)
940 box().setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::U nknown); 940 box().setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::U nknown);
941 } 941 }
942 942
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 { 977 {
978 int x = minX + box().borderLeft(); 978 int x = minX + box().borderLeft();
979 if (box().shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) 979 if (box().shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
980 x += hasVerticalScrollbar() ? verticalScrollbar()->width() : resizerCorn erRect(box().pixelSnappedBorderBoxRect(), ResizerForPointer).width(); 980 x += hasVerticalScrollbar() ? verticalScrollbar()->width() : resizerCorn erRect(box().pixelSnappedBorderBoxRect(), ResizerForPointer).width();
981 return x; 981 return x;
982 } 982 }
983 983
984 IntSize PaintLayerScrollableArea::scrollbarOffset(const Scrollbar& scrollbar) co nst 984 IntSize PaintLayerScrollableArea::scrollbarOffset(const Scrollbar& scrollbar) co nst
985 { 985 {
986 if (&scrollbar == verticalScrollbar()) 986 if (&scrollbar == verticalScrollbar())
987 return IntSize(verticalScrollbarStart(0, box().size().width()), box().bo rderTop()); 987 return IntSize(verticalScrollbarStart(0, box().size().width().toInt()), box().borderTop());
988 988
989 if (&scrollbar == horizontalScrollbar()) 989 if (&scrollbar == horizontalScrollbar())
990 return IntSize(horizontalScrollbarStart(0), box().size().height() - box( ).borderBottom() - scrollbar.height()); 990 return IntSize(horizontalScrollbarStart(0), (box().size().height() - box ().borderBottom() - scrollbar.height()).toInt());
991 991
992 ASSERT_NOT_REACHED(); 992 ASSERT_NOT_REACHED();
993 return IntSize(); 993 return IntSize();
994 } 994 }
995 995
996 static inline const LayoutObject& layoutObjectForScrollbar(const LayoutObject& l ayoutObject) 996 static inline const LayoutObject& layoutObjectForScrollbar(const LayoutObject& l ayoutObject)
997 { 997 {
998 if (Node* node = layoutObject.node()) { 998 if (Node* node = layoutObject.node()) {
999 if (layoutObject.isLayoutView()) { 999 if (layoutObject.isLayoutView()) {
1000 Document& doc = node->document(); 1000 Document& doc = node->document();
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 1173
1174 IntRect resizeControlRect; 1174 IntRect resizeControlRect;
1175 if (box().style()->resize() != RESIZE_NONE) { 1175 if (box().style()->resize() != RESIZE_NONE) {
1176 resizeControlRect = resizerCornerRect(box().pixelSnappedBorderBoxRect(), ResizerForPointer); 1176 resizeControlRect = resizerCornerRect(box().pixelSnappedBorderBoxRect(), ResizerForPointer);
1177 if (resizeControlRect.contains(localPoint)) 1177 if (resizeControlRect.contains(localPoint))
1178 return true; 1178 return true;
1179 } 1179 }
1180 1180
1181 int resizeControlSize = max(resizeControlRect.height(), 0); 1181 int resizeControlSize = max(resizeControlRect.height(), 0);
1182 if (hasVerticalScrollbar() && verticalScrollbar()->shouldParticipateInHitTes ting()) { 1182 if (hasVerticalScrollbar() && verticalScrollbar()->shouldParticipateInHitTes ting()) {
1183 LayoutRect vBarRect(verticalScrollbarStart(0, box().size().width()), 1183 // TODO(crbug.com/638981): Are the conversions to int intentional?
1184 LayoutUnit(box().borderTop()), 1184 LayoutRect vBarRect(verticalScrollbarStart(0, box().size().width().toInt ()),
1185 box().borderTop(),
1185 verticalScrollbar()->width(), 1186 verticalScrollbar()->width(),
1186 box().size().height() - (box().borderTop() + box().borderBottom()) - (hasHorizontalScrollbar() ? horizontalScrollbar()->height() : resizeControlSize )); 1187 (box().size().height() - (box().borderTop() + box().borderBottom()) - (hasHorizontalScrollbar() ? horizontalScrollbar()->height() : resizeControlSiz e)).toInt());
1187 if (vBarRect.contains(localPoint)) { 1188 if (vBarRect.contains(localPoint)) {
1188 result.setScrollbar(verticalScrollbar()); 1189 result.setScrollbar(verticalScrollbar());
1189 return true; 1190 return true;
1190 } 1191 }
1191 } 1192 }
1192 1193
1193 resizeControlSize = max(resizeControlRect.width(), 0); 1194 resizeControlSize = max(resizeControlRect.width(), 0);
1194 if (hasHorizontalScrollbar() && horizontalScrollbar()->shouldParticipateInHi tTesting()) { 1195 if (hasHorizontalScrollbar() && horizontalScrollbar()->shouldParticipateInHi tTesting()) {
1195 LayoutRect hBarRect(horizontalScrollbarStart(LayoutUnit()), 1196 // TODO(crbug.com/638981): Are the conversions to int intentional?
1196 box().size().height() - box().borderBottom() - horizontalScrollbar() ->height(), 1197 LayoutRect hBarRect(horizontalScrollbarStart(0),
1197 box().size().width() - (box().borderLeft() + box().borderRight()) - (hasVerticalScrollbar() ? verticalScrollbar()->width() : resizeControlSize), 1198 (box().size().height() - box().borderBottom() - horizontalScrollbar( )->height()).toInt(),
1199 (box().size().width() - (box().borderLeft() + box().borderRight()) - (hasVerticalScrollbar() ? verticalScrollbar()->width() : resizeControlSize)).to Int(),
1198 horizontalScrollbar()->height()); 1200 horizontalScrollbar()->height());
1199 if (hBarRect.contains(localPoint)) { 1201 if (hBarRect.contains(localPoint)) {
1200 result.setScrollbar(horizontalScrollbar()); 1202 result.setScrollbar(horizontalScrollbar());
1201 return true; 1203 return true;
1202 } 1204 }
1203 } 1205 }
1204 1206
1205 // FIXME: We should hit test the m_scrollCorner and pass it back through the result. 1207 // FIXME: We should hit test the m_scrollCorner and pass it back through the result.
1206 1208
1207 return false; 1209 return false;
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 1773
1772 void PaintLayerScrollableArea::DelayScrollPositionClampScope::clampScrollableAre as() 1774 void PaintLayerScrollableArea::DelayScrollPositionClampScope::clampScrollableAre as()
1773 { 1775 {
1774 for (auto& scrollableArea : *s_needsClamp) 1776 for (auto& scrollableArea : *s_needsClamp)
1775 scrollableArea->clampScrollPositionsAfterLayout(); 1777 scrollableArea->clampScrollPositionsAfterLayout();
1776 delete s_needsClamp; 1778 delete s_needsClamp;
1777 s_needsClamp = nullptr; 1779 s_needsClamp = nullptr;
1778 } 1780 }
1779 1781
1780 } // namespace blink 1782 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698