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

Side by Side Diff: Source/platform/scroll/Scrollbar.cpp

Issue 603193005: Move the Widget hierarchy to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add ~Scrollbar assert Created 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 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 25 matching lines...) Expand all
36 #include "platform/scroll/ScrollbarTheme.h" 36 #include "platform/scroll/ScrollbarTheme.h"
37 37
38 #if ((OS(POSIX) && !OS(MACOSX)) || OS(WIN)) 38 #if ((OS(POSIX) && !OS(MACOSX)) || OS(WIN))
39 // The position of the scrollbar thumb affects the appearance of the steppers, s o 39 // The position of the scrollbar thumb affects the appearance of the steppers, s o
40 // when the thumb moves, we have to invalidate them for painting. 40 // when the thumb moves, we have to invalidate them for painting.
41 #define THUMB_POSITION_AFFECTS_BUTTONS 41 #define THUMB_POSITION_AFFECTS_BUTTONS
42 #endif 42 #endif
43 43
44 namespace blink { 44 namespace blink {
45 45
46 PassRefPtr<Scrollbar> Scrollbar::create(ScrollableArea* scrollableArea, Scrollba rOrientation orientation, ScrollbarControlSize size) 46 PassRefPtrWillBeRawPtr<Scrollbar> Scrollbar::create(ScrollableArea* scrollableAr ea, ScrollbarOrientation orientation, ScrollbarControlSize size)
47 { 47 {
48 return adoptRef(new Scrollbar(scrollableArea, orientation, size)); 48 return adoptRefWillBeNoop(new Scrollbar(scrollableArea, orientation, size));
49 } 49 }
50 50
51 Scrollbar::Scrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orient ation, ScrollbarControlSize controlSize, ScrollbarTheme* theme) 51 Scrollbar::Scrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orient ation, ScrollbarControlSize controlSize, ScrollbarTheme* theme)
52 : m_scrollableArea(scrollableArea) 52 : m_scrollableArea(scrollableArea)
53 , m_orientation(orientation) 53 , m_orientation(orientation)
54 , m_controlSize(controlSize) 54 , m_controlSize(controlSize)
55 , m_theme(theme) 55 , m_theme(theme)
56 , m_visibleSize(0) 56 , m_visibleSize(0)
57 , m_totalSize(0) 57 , m_totalSize(0)
58 , m_currentPos(0) 58 , m_currentPos(0)
(...skipping 15 matching lines...) Expand all
74 74
75 m_theme->registerScrollbar(this); 75 m_theme->registerScrollbar(this);
76 76
77 // FIXME: This is ugly and would not be necessary if we fix cross-platform c ode to actually query for 77 // FIXME: This is ugly and would not be necessary if we fix cross-platform c ode to actually query for
78 // scrollbar thickness and use it when sizing scrollbars (rather than leavin g one dimension of the scrollbar 78 // scrollbar thickness and use it when sizing scrollbars (rather than leavin g one dimension of the scrollbar
79 // alone when sizing). 79 // alone when sizing).
80 int thickness = m_theme->scrollbarThickness(controlSize); 80 int thickness = m_theme->scrollbarThickness(controlSize);
81 Widget::setFrameRect(IntRect(0, 0, thickness, thickness)); 81 Widget::setFrameRect(IntRect(0, 0, thickness, thickness));
82 82
83 m_currentPos = scrollableAreaCurrentPos(); 83 m_currentPos = scrollableAreaCurrentPos();
84
85 #if ENABLE(OILPAN)
86 if (m_scrollableArea)
87 m_animator = m_scrollableArea->scrollAnimator();
88 #endif
84 } 89 }
85 90
86 Scrollbar::~Scrollbar() 91 Scrollbar::~Scrollbar()
87 { 92 {
88 stopTimerIfNeeded(); 93 stopTimerIfNeeded();
89 94
90 m_theme->unregisterScrollbar(this); 95 m_theme->unregisterScrollbar(this);
96
97 #if ENABLE(OILPAN)
98 if (!m_animator)
99 return;
100
101 ASSERT(m_scrollableArea);
102 if (m_orientation == VerticalScrollbar)
103 m_animator->willRemoveVerticalScrollbar(this);
104 else
105 m_animator->willRemoveHorizontalScrollbar(this);
106 #endif
91 } 107 }
92 108
93 void Scrollbar::removeFromParent() 109 void Scrollbar::removeFromParent()
94 { 110 {
95 if (parent()) 111 if (parent())
96 toScrollView(parent())->removeChild(this); 112 toScrollView(parent())->removeChild(this);
97 } 113 }
98 114
99 ScrollView* Scrollbar::parentScrollView() const 115 ScrollView* Scrollbar::parentScrollView() const
100 { 116 {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 if (position == m_currentPos) 153 if (position == m_currentPos)
138 return; 154 return;
139 155
140 int oldThumbPosition = theme()->thumbPosition(this); 156 int oldThumbPosition = theme()->thumbPosition(this);
141 m_currentPos = position; 157 m_currentPos = position;
142 updateThumbPosition(); 158 updateThumbPosition();
143 if (m_pressedPart == ThumbPart) 159 if (m_pressedPart == ThumbPart)
144 setPressedPos(m_pressedPos + theme()->thumbPosition(this) - oldThumbPosi tion); 160 setPressedPos(m_pressedPos + theme()->thumbPosition(this) - oldThumbPosi tion);
145 } 161 }
146 162
163 void Scrollbar::disconnectFromScrollableArea()
164 {
165 m_scrollableArea = nullptr;
166 #if ENABLE(OILPAN)
167 m_animator = nullptr;
168 #endif
169 }
170
147 void Scrollbar::setProportion(int visibleSize, int totalSize) 171 void Scrollbar::setProportion(int visibleSize, int totalSize)
148 { 172 {
149 if (visibleSize == m_visibleSize && totalSize == m_totalSize) 173 if (visibleSize == m_visibleSize && totalSize == m_totalSize)
150 return; 174 return;
151 175
152 m_visibleSize = visibleSize; 176 m_visibleSize = visibleSize;
153 m_totalSize = totalSize; 177 m_totalSize = totalSize;
154 178
155 updateThumbProportion(); 179 updateThumbProportion();
156 } 180 }
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 if (!m_scrollableArea) 609 if (!m_scrollableArea)
586 return 0; 610 return 0;
587 611
588 if (m_orientation == HorizontalScrollbar) 612 if (m_orientation == HorizontalScrollbar)
589 return m_scrollableArea->scrollPosition().x() - m_scrollableArea->minimu mScrollPosition().x(); 613 return m_scrollableArea->scrollPosition().x() - m_scrollableArea->minimu mScrollPosition().x();
590 614
591 return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScr ollPosition().y(); 615 return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScr ollPosition().y();
592 } 616 }
593 617
594 } // namespace blink 618 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698