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

Side by Side Diff: Source/core/frame/FrameViewAutoSizeInfo.cpp

Issue 603193005: Move the Widget hierarchy to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Switch LocalFrame::m_pluginElements rep to HashSet<HTMLPlugInElement*> 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/frame/FrameViewAutoSizeInfo.h" 6 #include "core/frame/FrameViewAutoSizeInfo.h"
7 7
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/rendering/RenderBox.h" 10 #include "core/rendering/RenderBox.h"
11 #include "core/rendering/RenderView.h" 11 #include "core/rendering/RenderView.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 FrameViewAutoSizeInfo::FrameViewAutoSizeInfo(FrameView* view) 15 FrameViewAutoSizeInfo::FrameViewAutoSizeInfo(FrameView* view)
16 : m_frameView(view) 16 : m_frameView(view)
17 , m_inAutoSize(false) 17 , m_inAutoSize(false)
18 , m_didRunAutosize(false) 18 , m_didRunAutosize(false)
19 { 19 {
20 ASSERT(m_frameView); 20 ASSERT(m_frameView);
21 } 21 }
22 22
23 FrameViewAutoSizeInfo::~FrameViewAutoSizeInfo() 23 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(FrameViewAutoSizeInfo);
24
25 void FrameViewAutoSizeInfo::trace(Visitor* visitor)
24 { 26 {
25 removeAutoSizeMode(); 27 visitor->trace(m_frameView);
26 } 28 }
27 29
28 void FrameViewAutoSizeInfo::configureAutoSizeMode(const IntSize& minSize, const IntSize& maxSize) 30 void FrameViewAutoSizeInfo::configureAutoSizeMode(const IntSize& minSize, const IntSize& maxSize)
29 { 31 {
30 ASSERT(!minSize.isEmpty()); 32 ASSERT(!minSize.isEmpty());
31 ASSERT(minSize.width() <= maxSize.width()); 33 ASSERT(minSize.width() <= maxSize.width());
32 ASSERT(minSize.height() <= maxSize.height()); 34 ASSERT(minSize.height() <= maxSize.height());
33 35
34 if (m_minAutoSize == minSize && m_maxAutoSize == maxSize) 36 if (m_minAutoSize == minSize && m_maxAutoSize == maxSize)
35 return; 37 return;
36 38
37 m_minAutoSize = minSize; 39 m_minAutoSize = minSize;
38 m_maxAutoSize = maxSize; 40 m_maxAutoSize = maxSize;
39 m_didRunAutosize = false; 41 m_didRunAutosize = false;
40
41 m_frameView->setLayoutSizeFixedToFrameSize(true);
42 m_frameView->setNeedsLayout();
43 m_frameView->scheduleRelayout();
44 }
45
46 void FrameViewAutoSizeInfo::removeAutoSizeMode()
47 {
48 m_frameView->setLayoutSizeFixedToFrameSize(false);
49 m_frameView->setNeedsLayout();
50 m_frameView->scheduleRelayout();
51
52 // Since autosize mode forces the scrollbar mode, change them to being auto.
53 m_frameView->setVerticalScrollbarLock(false);
54 m_frameView->setHorizontalScrollbarLock(false);
55 m_frameView->setScrollbarModes(ScrollbarAuto, ScrollbarAuto);
56 } 42 }
57 43
58 void FrameViewAutoSizeInfo::autoSizeIfNeeded() 44 void FrameViewAutoSizeInfo::autoSizeIfNeeded()
59 { 45 {
60 if (m_inAutoSize) 46 if (m_inAutoSize)
61 return; 47 return;
62 48
63 TemporaryChange<bool> changeInAutoSize(m_inAutoSize, true); 49 TemporaryChange<bool> changeInAutoSize(m_inAutoSize, true);
64 50
65 Document* document = m_frameView->frame().document(); 51 Document* document = m_frameView->frame().document();
(...skipping 28 matching lines...) Expand all
94 return; 80 return;
95 81
96 int height = documentRenderBox->scrollHeight(); 82 int height = documentRenderBox->scrollHeight();
97 IntSize newSize(width, height); 83 IntSize newSize(width, height);
98 84
99 // Check to see if a scrollbar is needed for a given dimension and 85 // Check to see if a scrollbar is needed for a given dimension and
100 // if so, increase the other dimension to account for the scrollbar. 86 // if so, increase the other dimension to account for the scrollbar.
101 // Since the dimensions are only for the view rectangle, once a 87 // Since the dimensions are only for the view rectangle, once a
102 // dimension exceeds the maximum, there is no need to increase it furthe r. 88 // dimension exceeds the maximum, there is no need to increase it furthe r.
103 if (newSize.width() > m_maxAutoSize.width()) { 89 if (newSize.width() > m_maxAutoSize.width()) {
104 RefPtr<Scrollbar> localHorizontalScrollbar = m_frameView->horizontal Scrollbar(); 90 RefPtrWillBeRawPtr<Scrollbar> localHorizontalScrollbar = m_frameView ->horizontalScrollbar();
105 if (!localHorizontalScrollbar) 91 if (!localHorizontalScrollbar)
106 localHorizontalScrollbar = m_frameView->createScrollbar(Horizont alScrollbar); 92 localHorizontalScrollbar = m_frameView->createScrollbar(Horizont alScrollbar);
107 if (!localHorizontalScrollbar->isOverlayScrollbar()) 93 if (!localHorizontalScrollbar->isOverlayScrollbar())
108 newSize.setHeight(newSize.height() + localHorizontalScrollbar->h eight()); 94 newSize.setHeight(newSize.height() + localHorizontalScrollbar->h eight());
109 95
110 // Don't bother checking for a vertical scrollbar because the width is at 96 // Don't bother checking for a vertical scrollbar because the width is at
111 // already greater the maximum. 97 // already greater the maximum.
112 } else if (newSize.height() > m_maxAutoSize.height()) { 98 } else if (newSize.height() > m_maxAutoSize.height()) {
113 RefPtr<Scrollbar> localVerticalScrollbar = m_frameView->verticalScro llbar(); 99 RefPtrWillBeRawPtr<Scrollbar> localVerticalScrollbar = m_frameView-> verticalScrollbar();
114 if (!localVerticalScrollbar) 100 if (!localVerticalScrollbar)
115 localVerticalScrollbar = m_frameView->createScrollbar(VerticalSc rollbar); 101 localVerticalScrollbar = m_frameView->createScrollbar(VerticalSc rollbar);
116 if (!localVerticalScrollbar->isOverlayScrollbar()) 102 if (!localVerticalScrollbar->isOverlayScrollbar())
117 newSize.setWidth(newSize.width() + localVerticalScrollbar->width ()); 103 newSize.setWidth(newSize.width() + localVerticalScrollbar->width ());
118 104
119 // Don't bother checking for a horizontal scrollbar because the heig ht is 105 // Don't bother checking for a horizontal scrollbar because the heig ht is
120 // already greater the maximum. 106 // already greater the maximum.
121 } 107 }
122 108
123 // Ensure the size is at least the min bounds. 109 // Ensure the size is at least the min bounds.
(...skipping 24 matching lines...) Expand all
148 // Force the scrollbar state to avoid the scrollbar code adding them and causing them to be needed. For example, 134 // Force the scrollbar state to avoid the scrollbar code adding them and causing them to be needed. For example,
149 // a vertical scrollbar may cause text to wrap and thus increase the hei ght (which is the only reason the scollbar is needed). 135 // a vertical scrollbar may cause text to wrap and thus increase the hei ght (which is the only reason the scollbar is needed).
150 m_frameView->setVerticalScrollbarLock(false); 136 m_frameView->setVerticalScrollbarLock(false);
151 m_frameView->setHorizontalScrollbarLock(false); 137 m_frameView->setHorizontalScrollbarLock(false);
152 m_frameView->setScrollbarModes(horizonalScrollbarMode, verticalScrollbar Mode, true, true); 138 m_frameView->setScrollbarModes(horizonalScrollbarMode, verticalScrollbar Mode, true, true);
153 } 139 }
154 m_didRunAutosize = true; 140 m_didRunAutosize = true;
155 } 141 }
156 142
157 } // namespace blink 143 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698