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

Side by Side Diff: Source/core/page/FrameView.cpp

Issue 23819019: Refactor fixed layout mode (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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/page/FrameView.h ('k') | Source/core/platform/ScrollView.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) 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "core/page/Chrome.h" 47 #include "core/page/Chrome.h"
48 #include "core/page/ChromeClient.h" 48 #include "core/page/ChromeClient.h"
49 #include "core/page/EventHandler.h" 49 #include "core/page/EventHandler.h"
50 #include "core/page/FocusController.h" 50 #include "core/page/FocusController.h"
51 #include "core/page/Frame.h" 51 #include "core/page/Frame.h"
52 #include "core/page/FrameTree.h" 52 #include "core/page/FrameTree.h"
53 #include "core/page/Settings.h" 53 #include "core/page/Settings.h"
54 #include "core/page/animation/AnimationController.h" 54 #include "core/page/animation/AnimationController.h"
55 #include "core/page/scrolling/ScrollingCoordinator.h" 55 #include "core/page/scrolling/ScrollingCoordinator.h"
56 #include "core/platform/ScrollAnimator.h" 56 #include "core/platform/ScrollAnimator.h"
57 #include "core/platform/ScrollbarTheme.h"
57 #include "core/platform/graphics/FontCache.h" 58 #include "core/platform/graphics/FontCache.h"
58 #include "core/platform/graphics/GraphicsContext.h" 59 #include "core/platform/graphics/GraphicsContext.h"
59 #include "core/rendering/CompositedLayerMapping.h" 60 #include "core/rendering/CompositedLayerMapping.h"
60 #include "core/rendering/LayoutIndicator.h" 61 #include "core/rendering/LayoutIndicator.h"
61 #include "core/rendering/RenderCounter.h" 62 #include "core/rendering/RenderCounter.h"
62 #include "core/rendering/RenderEmbeddedObject.h" 63 #include "core/rendering/RenderEmbeddedObject.h"
63 #include "core/rendering/RenderLayer.h" 64 #include "core/rendering/RenderLayer.h"
64 #include "core/rendering/RenderLayerCompositor.h" 65 #include "core/rendering/RenderLayerCompositor.h"
65 #include "core/rendering/RenderPart.h" 66 #include "core/rendering/RenderPart.h"
66 #include "core/rendering/RenderScrollbar.h" 67 #include "core/rendering/RenderScrollbar.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 , m_shouldUpdateWhileOffscreen(true) 184 , m_shouldUpdateWhileOffscreen(true)
184 , m_deferSetNeedsLayouts(0) 185 , m_deferSetNeedsLayouts(0)
185 , m_setNeedsLayoutWasDeferred(false) 186 , m_setNeedsLayoutWasDeferred(false)
186 , m_scrollCorner(0) 187 , m_scrollCorner(0)
187 , m_shouldAutoSize(false) 188 , m_shouldAutoSize(false)
188 , m_inAutoSize(false) 189 , m_inAutoSize(false)
189 , m_didRunAutosize(false) 190 , m_didRunAutosize(false)
190 , m_hasSoftwareFilters(false) 191 , m_hasSoftwareFilters(false)
191 , m_visibleContentScaleFactor(1) 192 , m_visibleContentScaleFactor(1)
192 , m_partialLayout() 193 , m_partialLayout()
194 , m_layoutSizeFixedToFrameSize(true)
193 { 195 {
194 ASSERT(m_frame); 196 ASSERT(m_frame);
195 init(); 197 init();
196 198
197 if (!isMainFrame()) 199 if (!isMainFrame())
198 return; 200 return;
199 201
200 ScrollableArea::setVerticalScrollElasticity(ScrollElasticityAllowed); 202 ScrollableArea::setVerticalScrollElasticity(ScrollElasticityAllowed);
201 ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAllowed); 203 ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAllowed);
202 } 204 }
203 205
204 PassRefPtr<FrameView> FrameView::create(Frame* frame) 206 PassRefPtr<FrameView> FrameView::create(Frame* frame)
205 { 207 {
206 RefPtr<FrameView> view = adoptRef(new FrameView(frame)); 208 RefPtr<FrameView> view = adoptRef(new FrameView(frame));
207 view->show(); 209 view->show();
208 return view.release(); 210 return view.release();
209 } 211 }
210 212
211 PassRefPtr<FrameView> FrameView::create(Frame* frame, const IntSize& initialSize ) 213 PassRefPtr<FrameView> FrameView::create(Frame* frame, const IntSize& initialSize )
212 { 214 {
213 RefPtr<FrameView> view = adoptRef(new FrameView(frame)); 215 RefPtr<FrameView> view = adoptRef(new FrameView(frame));
214 view->Widget::setFrameRect(IntRect(view->location(), initialSize)); 216 view->Widget::setFrameRect(IntRect(view->location(), initialSize));
217 view->setLayoutSizeInternal(initialSize);
218
215 view->show(); 219 view->show();
216 return view.release(); 220 return view.release();
217 } 221 }
218 222
219 FrameView::~FrameView() 223 FrameView::~FrameView()
220 { 224 {
221 if (m_postLayoutTasksTimer.isActive()) { 225 if (m_postLayoutTasksTimer.isActive()) {
222 m_postLayoutTasksTimer.stop(); 226 m_postLayoutTasksTimer.stop();
223 m_overflowEventQueue.clear(); 227 m_overflowEventQueue.clear();
224 } 228 }
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 setHorizontalScrollbarMode(ScrollbarAlwaysOff); // This causes a horizontal scrollbar to disappear. 1059 setHorizontalScrollbarMode(ScrollbarAlwaysOff); // This causes a horizontal scrollbar to disappear.
1056 1060
1057 setScrollbarModes(hMode, vMode); 1061 setScrollbarModes(hMode, vMode);
1058 setScrollbarsSuppressed(false, true); 1062 setScrollbarsSuppressed(false, true);
1059 } else 1063 } else
1060 setScrollbarModes(hMode, vMode); 1064 setScrollbarModes(hMode, vMode);
1061 } 1065 }
1062 1066
1063 LayoutSize oldSize = m_size; 1067 LayoutSize oldSize = m_size;
1064 1068
1065 m_size = LayoutSize(layoutWidth(), layoutHeight()); 1069 m_size = LayoutSize(layoutSize().width(), layoutSize().height());
1066 1070
1067 if (oldSize != m_size) { 1071 if (oldSize != m_size) {
1068 m_doFullRepaint = true; 1072 m_doFullRepaint = true;
1069 if (!m_firstLayout) { 1073 if (!m_firstLayout) {
1070 RenderBox* rootRenderer = document->documentElement() ? docu ment->documentElement()->renderBox() : 0; 1074 RenderBox* rootRenderer = document->documentElement() ? docu ment->documentElement()->renderBox() : 0;
1071 RenderBox* bodyRenderer = rootRenderer && document->body() ? document->body()->renderBox() : 0; 1075 RenderBox* bodyRenderer = rootRenderer && document->body() ? document->body()->renderBox() : 0;
1072 if (bodyRenderer && bodyRenderer->stretchesToViewport()) 1076 if (bodyRenderer && bodyRenderer->stretchesToViewport())
1073 bodyRenderer->setChildNeedsLayout(); 1077 bodyRenderer->setChildNeedsLayout();
1074 else if (rootRenderer && rootRenderer->stretchesToViewport() ) 1078 else if (rootRenderer && rootRenderer->stretchesToViewport() )
1075 rootRenderer->setChildNeedsLayout(); 1079 rootRenderer->setChildNeedsLayout();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 1116
1113 if (AXObjectCache* cache = rootForThisLayout->document().existingAXObjectCac he()) 1117 if (AXObjectCache* cache = rootForThisLayout->document().existingAXObjectCac he())
1114 cache->postNotification(rootForThisLayout, AXObjectCache::AXLayoutComple te, true); 1118 cache->postNotification(rootForThisLayout, AXObjectCache::AXLayoutComple te, true);
1115 updateAnnotatedRegions(); 1119 updateAnnotatedRegions();
1116 1120
1117 ASSERT(partialLayout().isStopping() || !rootForThisLayout->needsLayout()); 1121 ASSERT(partialLayout().isStopping() || !rootForThisLayout->needsLayout());
1118 1122
1119 updateCanBlitOnScrollRecursively(); 1123 updateCanBlitOnScrollRecursively();
1120 1124
1121 if (document->hasListenerType(Document::OVERFLOWCHANGED_LISTENER)) 1125 if (document->hasListenerType(Document::OVERFLOWCHANGED_LISTENER))
1122 updateOverflowStatus(layoutWidth() < contentsWidth(), layoutHeight() < c ontentsHeight()); 1126 updateOverflowStatus(layoutSize().width() < contentsWidth(), layoutSize( ).height() < contentsHeight());
1123 1127
1124 scheduleOrPerformPostLayoutTasks(); 1128 scheduleOrPerformPostLayoutTasks();
1125 1129
1126 InspectorInstrumentation::didLayout(cookie, rootForThisLayout); 1130 InspectorInstrumentation::didLayout(cookie, rootForThisLayout);
1127 1131
1128 m_nestedLayoutCount--; 1132 m_nestedLayoutCount--;
1129 if (m_nestedLayoutCount) 1133 if (m_nestedLayoutCount)
1130 return; 1134 return;
1131 1135
1132 if (partialLayout().isStopping()) 1136 if (partialLayout().isStopping())
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 if (!hasViewportConstrainedObjects()) 1610 if (!hasViewportConstrainedObjects())
1607 return; 1611 return;
1608 1612
1609 ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObje cts->end(); 1613 ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObje cts->end();
1610 for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrained Objects->begin(); it != end; ++it) { 1614 for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrained Objects->begin(); it != end; ++it) {
1611 RenderObject* renderer = *it; 1615 RenderObject* renderer = *it;
1612 renderer->setNeedsLayout(); 1616 renderer->setNeedsLayout();
1613 } 1617 }
1614 } 1618 }
1615 1619
1620 IntSize FrameView::layoutSize(IncludeScrollbarsInRect scrollbarInclusion) const
1621 {
1622 return scrollbarInclusion == ExcludeScrollbars ? excludeScrollbars(m_layoutS ize) : m_layoutSize;
1623 }
1624
1625 void FrameView::setLayoutSize(const IntSize& size)
1626 {
1627 ASSERT(!layoutSizeFixedToFrameSize());
1628
1629 setLayoutSizeInternal(size);
1630 }
1616 1631
1617 void FrameView::scrollPositionChanged() 1632 void FrameView::scrollPositionChanged()
1618 { 1633 {
1619 m_frame->eventHandler()->sendScrollEvent(); 1634 m_frame->eventHandler()->sendScrollEvent();
1620 m_frame->eventHandler()->dispatchFakeMouseMoveEventSoon(); 1635 m_frame->eventHandler()->dispatchFakeMouseMoveEventSoon();
1621 1636
1622 if (RenderView* renderView = this->renderView()) { 1637 if (RenderView* renderView = this->renderView()) {
1623 if (renderView->usesCompositing()) 1638 if (renderView->usesCompositing())
1624 renderView->compositor()->frameViewDidScroll(); 1639 renderView->compositor()->frameViewDidScroll();
1625 } 1640 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 1737
1723 ScrollView::repaintContentRectangle(r); 1738 ScrollView::repaintContentRectangle(r);
1724 } 1739 }
1725 1740
1726 void FrameView::contentsResized() 1741 void FrameView::contentsResized()
1727 { 1742 {
1728 ScrollView::contentsResized(); 1743 ScrollView::contentsResized();
1729 setNeedsLayout(); 1744 setNeedsLayout();
1730 } 1745 }
1731 1746
1732 void FrameView::visibleContentsResized() 1747 void FrameView::scrollbarExistenceDidChange()
1733 { 1748 {
1734 // We check to make sure the view is attached to a frame() as this method ca n 1749 // We check to make sure the view is attached to a frame() as this method ca n
1735 // be triggered before the view is attached by Frame::createView(...) settin g 1750 // be triggered before the view is attached by Frame::createView(...) settin g
1736 // various values such as setScrollBarModes(...) for example. An ASSERT is 1751 // various values such as setScrollBarModes(...) for example. An ASSERT is
1737 // triggered when a view is layout before being attached to a frame(). 1752 // triggered when a view is layout before being attached to a frame().
1738 if (!frame().view()) 1753 if (!frame().view())
1739 return; 1754 return;
1740 1755
1741 if (!useFixedLayout() && needsLayout()) 1756 bool useOverlayScrollbars = ScrollbarTheme::theme()->usesOverlayScrollbars() ;
1757
1758 if (!useOverlayScrollbars && needsLayout())
1742 layout(); 1759 layout();
1743 1760
1744 if (RenderView* renderView = this->renderView()) { 1761 if (renderView() && renderView()->usesCompositing()) {
1745 if (renderView->usesCompositing()) 1762 renderView()->compositor()->frameViewScrollbarsExistenceDidChange();
1746 renderView->compositor()->frameViewDidChangeSize(); 1763
1764 if (!useOverlayScrollbars)
1765 renderView()->compositor()->frameViewDidChangeSize();
1747 } 1766 }
1748 } 1767 }
1749 1768
1750 void FrameView::beginDeferredRepaints() 1769 void FrameView::beginDeferredRepaints()
1751 { 1770 {
1752 Page* page = m_frame->page(); 1771 Page* page = m_frame->page();
1753 ASSERT(page); 1772 ASSERT(page);
1754 1773
1755 if (!isMainFrame()) { 1774 if (!isMainFrame()) {
1756 page->mainFrame()->view()->beginDeferredRepaints(); 1775 page->mainFrame()->view()->beginDeferredRepaints();
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
2393 if (newSize == size) 2412 if (newSize == size)
2394 continue; 2413 continue;
2395 2414
2396 // While loading only allow the size to increase (to avoid twitching dur ing intermediate smaller states) 2415 // While loading only allow the size to increase (to avoid twitching dur ing intermediate smaller states)
2397 // unless autoresize has just been turned on or the maximum size is smal ler than the current size. 2416 // unless autoresize has just been turned on or the maximum size is smal ler than the current size.
2398 if (m_didRunAutosize && size.height() <= m_maxAutoSize.height() && size. width() <= m_maxAutoSize.width() 2417 if (m_didRunAutosize && size.height() <= m_maxAutoSize.height() && size. width() <= m_maxAutoSize.width()
2399 && !m_frame->document()->loadEventFinished() && (newSize.height() < size.height() || newSize.width() < size.width())) 2418 && !m_frame->document()->loadEventFinished() && (newSize.height() < size.height() || newSize.width() < size.width()))
2400 break; 2419 break;
2401 2420
2402 resize(newSize.width(), newSize.height()); 2421 resize(newSize.width(), newSize.height());
2422 setLayoutSize(newSize);
2403 // Force the scrollbar state to avoid the scrollbar code adding them and causing them to be needed. For example, 2423 // Force the scrollbar state to avoid the scrollbar code adding them and causing them to be needed. For example,
2404 // a vertical scrollbar may cause text to wrap and thus increase the hei ght (which is the only reason the scollbar is needed). 2424 // a vertical scrollbar may cause text to wrap and thus increase the hei ght (which is the only reason the scollbar is needed).
2405 setVerticalScrollbarLock(false); 2425 setVerticalScrollbarLock(false);
2406 setHorizontalScrollbarLock(false); 2426 setHorizontalScrollbarLock(false);
2407 setScrollbarModes(horizonalScrollbarMode, verticalScrollbarMode, true, t rue); 2427 setScrollbarModes(horizonalScrollbarMode, verticalScrollbarMode, true, t rue);
2408 } 2428 }
2409 m_didRunAutosize = true; 2429 m_didRunAutosize = true;
2410 } 2430 }
2411 2431
2412 void FrameView::updateOverflowStatus(bool horizontalOverflow, bool verticalOverf low) 2432 void FrameView::updateOverflowStatus(bool horizontalOverflow, bool verticalOverf low)
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
3399 if (frame().document()) 3419 if (frame().document())
3400 return frame().document()->existingAXObjectCache(); 3420 return frame().document()->existingAXObjectCache();
3401 return 0; 3421 return 0;
3402 } 3422 }
3403 3423
3404 bool FrameView::isMainFrame() const 3424 bool FrameView::isMainFrame() const
3405 { 3425 {
3406 return m_frame->page() && m_frame->page()->mainFrame() == m_frame; 3426 return m_frame->page() && m_frame->page()->mainFrame() == m_frame;
3407 } 3427 }
3408 3428
3429 void FrameView::frameRectsChanged()
3430 {
3431 if (layoutSizeFixedToFrameSize())
3432 setLayoutSizeInternal(frameRect().size());
3433
3434 ScrollView::frameRectsChanged();
3435 }
3436
3437 void FrameView::setLayoutSizeInternal(const IntSize& size)
3438 {
3439 if (m_layoutSize == size)
3440 return;
3441
3442 m_layoutSize = size;
3443 contentsResized();
3444 }
3445
3409 } // namespace WebCore 3446 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/FrameView.h ('k') | Source/core/platform/ScrollView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698