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

Side by Side Diff: Source/core/platform/ScrollView.cpp

Issue 26936002: Remove Widget's dependency upon its own inheritor aka ScrollView. This was nasty from an OO design… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Fix for clang compile error Created 7 years, 2 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
« no previous file with comments | « Source/core/platform/ScrollView.h ('k') | Source/core/platform/Scrollbar.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 bool ScrollView::containsScrollbarsAvoidingResizer() const 638 bool ScrollView::containsScrollbarsAvoidingResizer() const
639 { 639 {
640 return !m_scrollbarsAvoidingResizer; 640 return !m_scrollbarsAvoidingResizer;
641 } 641 }
642 642
643 void ScrollView::adjustScrollbarsAvoidingResizerCount(int overlapDelta) 643 void ScrollView::adjustScrollbarsAvoidingResizerCount(int overlapDelta)
644 { 644 {
645 int oldCount = m_scrollbarsAvoidingResizer; 645 int oldCount = m_scrollbarsAvoidingResizer;
646 m_scrollbarsAvoidingResizer += overlapDelta; 646 m_scrollbarsAvoidingResizer += overlapDelta;
647 if (parent()) 647 if (parent())
648 parent()->adjustScrollbarsAvoidingResizerCount(overlapDelta); 648 toScrollView(parent())->adjustScrollbarsAvoidingResizerCount(overlapDelt a);
649 else if (!scrollbarsSuppressed()) { 649 else if (!scrollbarsSuppressed()) {
650 // If we went from n to 0 or from 0 to n and we're the outermost view, 650 // If we went from n to 0 or from 0 to n and we're the outermost view,
651 // we need to invalidate the windowResizerRect(), since it will now need to paint 651 // we need to invalidate the windowResizerRect(), since it will now need to paint
652 // differently. 652 // differently.
653 if ((oldCount > 0 && m_scrollbarsAvoidingResizer == 0) || 653 if ((oldCount > 0 && m_scrollbarsAvoidingResizer == 0) ||
654 (oldCount == 0 && m_scrollbarsAvoidingResizer > 0)) 654 (oldCount == 0 && m_scrollbarsAvoidingResizer > 0))
655 invalidateRect(windowResizerRect()); 655 invalidateRect(windowResizerRect());
656 } 656 }
657 } 657 }
658 658
659 void ScrollView::setParent(ScrollView* parentView) 659 void ScrollView::setParent(Widget* parentView)
660 { 660 {
661 if (parentView == parent()) 661 if (parentView == parent())
662 return; 662 return;
663 663
664 if (m_scrollbarsAvoidingResizer && parent()) 664 if (m_scrollbarsAvoidingResizer && parent())
665 parent()->adjustScrollbarsAvoidingResizerCount(-m_scrollbarsAvoidingResi zer); 665 toScrollView(parent())->adjustScrollbarsAvoidingResizerCount(-m_scrollba rsAvoidingResizer);
666 666
667 Widget::setParent(parentView); 667 Widget::setParent(parentView);
668 668
669 if (m_scrollbarsAvoidingResizer && parent()) 669 if (m_scrollbarsAvoidingResizer && parent())
670 parent()->adjustScrollbarsAvoidingResizerCount(m_scrollbarsAvoidingResiz er); 670 toScrollView(parent())->adjustScrollbarsAvoidingResizerCount(m_scrollbar sAvoidingResizer);
671 } 671 }
672 672
673 void ScrollView::setScrollbarsSuppressed(bool suppressed, bool repaintOnUnsuppre ss) 673 void ScrollView::setScrollbarsSuppressed(bool suppressed, bool repaintOnUnsuppre ss)
674 { 674 {
675 if (suppressed == m_scrollbarsSuppressed) 675 if (suppressed == m_scrollbarsSuppressed)
676 return; 676 return;
677 677
678 m_scrollbarsSuppressed = suppressed; 678 m_scrollbarsSuppressed = suppressed;
679 679
680 if (repaintOnUnsuppress && !suppressed) { 680 if (repaintOnUnsuppress && !suppressed) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 if (layerForScrollCorner()) 859 if (layerForScrollCorner())
860 return; 860 return;
861 paintScrollCorner(context, scrollCornerRect()); 861 paintScrollCorner(context, scrollCornerRect());
862 } 862 }
863 863
864 void ScrollView::paintPanScrollIcon(GraphicsContext* context) 864 void ScrollView::paintPanScrollIcon(GraphicsContext* context)
865 { 865 {
866 static Image* panScrollIcon = Image::loadPlatformResource("panIcon").leakRef (); 866 static Image* panScrollIcon = Image::loadPlatformResource("panIcon").leakRef ();
867 IntPoint iconGCPoint = m_panScrollIconPoint; 867 IntPoint iconGCPoint = m_panScrollIconPoint;
868 if (parent()) 868 if (parent())
869 iconGCPoint = parent()->windowToContents(iconGCPoint); 869 iconGCPoint = toScrollView(parent())->windowToContents(iconGCPoint);
870 context->drawImage(panScrollIcon, iconGCPoint); 870 context->drawImage(panScrollIcon, iconGCPoint);
871 } 871 }
872 872
873 void ScrollView::paint(GraphicsContext* context, const IntRect& rect) 873 void ScrollView::paint(GraphicsContext* context, const IntRect& rect)
874 { 874 {
875 if (context->paintingDisabled() && !context->updatingControlTints()) 875 if (context->paintingDisabled() && !context->updatingControlTints())
876 return; 876 return;
877 877
878 notifyPageThatContentAreaWillPaint(); 878 notifyPageThatContentAreaWillPaint();
879 879
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 int ScrollView::pageStep(ScrollbarOrientation orientation) const 1157 int ScrollView::pageStep(ScrollbarOrientation orientation) const
1158 { 1158 {
1159 int length = (orientation == HorizontalScrollbar) ? visibleWidth() : visible Height(); 1159 int length = (orientation == HorizontalScrollbar) ? visibleWidth() : visible Height();
1160 int minPageStep = static_cast<float>(length) * minFractionToStepWhenPaging() ; 1160 int minPageStep = static_cast<float>(length) * minFractionToStepWhenPaging() ;
1161 int pageStep = std::max(minPageStep, length - maxOverlapBetweenPages()); 1161 int pageStep = std::max(minPageStep, length - maxOverlapBetweenPages());
1162 1162
1163 return std::max(pageStep, 1); 1163 return std::max(pageStep, 1);
1164 } 1164 }
1165 1165
1166 } // namespace WebCore 1166 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/platform/ScrollView.h ('k') | Source/core/platform/Scrollbar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698