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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2096633002: Adds scroll position/scale emulation to DevTools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add C++ tests, clamp visual viewport position. Created 4 years, 5 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) 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 26 matching lines...) Expand all
37 #include "core/editing/EditingUtilities.h" 37 #include "core/editing/EditingUtilities.h"
38 #include "core/editing/FrameSelection.h" 38 #include "core/editing/FrameSelection.h"
39 #include "core/editing/RenderedPosition.h" 39 #include "core/editing/RenderedPosition.h"
40 #include "core/editing/markers/DocumentMarkerController.h" 40 #include "core/editing/markers/DocumentMarkerController.h"
41 #include "core/fetch/ResourceFetcher.h" 41 #include "core/fetch/ResourceFetcher.h"
42 #include "core/frame/EventHandlerRegistry.h" 42 #include "core/frame/EventHandlerRegistry.h"
43 #include "core/frame/FrameHost.h" 43 #include "core/frame/FrameHost.h"
44 #include "core/frame/LocalFrame.h" 44 #include "core/frame/LocalFrame.h"
45 #include "core/frame/Location.h" 45 #include "core/frame/Location.h"
46 #include "core/frame/PageScaleConstraintsSet.h" 46 #include "core/frame/PageScaleConstraintsSet.h"
47 #include "core/frame/ScrollAndScaleEmulator.h"
47 #include "core/frame/Settings.h" 48 #include "core/frame/Settings.h"
48 #include "core/frame/TopControls.h" 49 #include "core/frame/TopControls.h"
49 #include "core/frame/VisualViewport.h" 50 #include "core/frame/VisualViewport.h"
50 #include "core/html/HTMLFrameElement.h" 51 #include "core/html/HTMLFrameElement.h"
51 #include "core/html/HTMLPlugInElement.h" 52 #include "core/html/HTMLPlugInElement.h"
52 #include "core/html/HTMLTextFormControlElement.h" 53 #include "core/html/HTMLTextFormControlElement.h"
53 #include "core/html/parser/TextResourceDecoder.h" 54 #include "core/html/parser/TextResourceDecoder.h"
54 #include "core/input/EventHandler.h" 55 #include "core/input/EventHandler.h"
55 #include "core/inspector/InspectorInstrumentation.h" 56 #include "core/inspector/InspectorInstrumentation.h"
56 #include "core/inspector/InspectorTraceEvents.h" 57 #include "core/inspector/InspectorTraceEvents.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 198
198 DEFINE_TRACE(FrameView) 199 DEFINE_TRACE(FrameView)
199 { 200 {
200 visitor->trace(m_frame); 201 visitor->trace(m_frame);
201 visitor->trace(m_fragmentAnchor); 202 visitor->trace(m_fragmentAnchor);
202 visitor->trace(m_scrollableAreas); 203 visitor->trace(m_scrollableAreas);
203 visitor->trace(m_animatingScrollableAreas); 204 visitor->trace(m_animatingScrollableAreas);
204 visitor->trace(m_autoSizeInfo); 205 visitor->trace(m_autoSizeInfo);
205 visitor->trace(m_horizontalScrollbar); 206 visitor->trace(m_horizontalScrollbar);
206 visitor->trace(m_verticalScrollbar); 207 visitor->trace(m_verticalScrollbar);
208 visitor->trace(m_scrollAndScaleEmulator);
207 visitor->trace(m_children); 209 visitor->trace(m_children);
208 visitor->trace(m_viewportScrollableArea); 210 visitor->trace(m_viewportScrollableArea);
209 visitor->trace(m_scrollAnchor); 211 visitor->trace(m_scrollAnchor);
210 Widget::trace(visitor); 212 Widget::trace(visitor);
211 ScrollableArea::trace(visitor); 213 ScrollableArea::trace(visitor);
212 } 214 }
213 215
214 void FrameView::reset() 216 void FrameView::reset()
215 { 217 {
216 m_hasPendingLayout = false; 218 m_hasPendingLayout = false;
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 DoublePoint newScrollPosition = clampScrollPosition(scrollPoint); 1598 DoublePoint newScrollPosition = clampScrollPosition(scrollPoint);
1597 if (newScrollPosition == scrollPositionDouble()) 1599 if (newScrollPosition == scrollPositionDouble())
1598 return; 1600 return;
1599 1601
1600 if (scrollBehavior == ScrollBehaviorAuto) 1602 if (scrollBehavior == ScrollBehaviorAuto)
1601 scrollBehavior = scrollBehaviorStyle(); 1603 scrollBehavior = scrollBehaviorStyle();
1602 1604
1603 ScrollableArea::setScrollPosition(newScrollPosition, scrollType, scrollBehav ior); 1605 ScrollableArea::setScrollPosition(newScrollPosition, scrollType, scrollBehav ior);
1604 } 1606 }
1605 1607
1608 void FrameView::setScrollAndScaleEmulator(ScrollAndScaleEmulator* emulator)
1609 {
1610 m_scrollAndScaleEmulator = emulator;
1611 setScrollPosition(scrollPosition(), ProgrammaticScroll, ScrollBehaviorInstan t);
1612 }
1613
1606 void FrameView::didUpdateElasticOverscroll() 1614 void FrameView::didUpdateElasticOverscroll()
1607 { 1615 {
1608 Page* page = frame().page(); 1616 Page* page = frame().page();
1609 if (!page) 1617 if (!page)
1610 return; 1618 return;
1611 FloatSize elasticOverscroll = page->chromeClient().elasticOverscroll(); 1619 FloatSize elasticOverscroll = page->chromeClient().elasticOverscroll();
1612 if (m_horizontalScrollbar) { 1620 if (m_horizontalScrollbar) {
1613 float delta = elasticOverscroll.width() - m_horizontalScrollbar->elastic Overscroll(); 1621 float delta = elasticOverscroll.width() - m_horizontalScrollbar->elastic Overscroll();
1614 if (delta != 0) { 1622 if (delta != 0) {
1615 m_horizontalScrollbar->setElasticOverscroll(elasticOverscroll.width( )); 1623 m_horizontalScrollbar->setElasticOverscroll(elasticOverscroll.width( ));
(...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after
3169 ScrollableArea::didAddScrollbar(scrollbar, orientation); 3177 ScrollableArea::didAddScrollbar(scrollbar, orientation);
3170 } 3178 }
3171 3179
3172 void FrameView::setTopControlsViewportAdjustment(float adjustment) 3180 void FrameView::setTopControlsViewportAdjustment(float adjustment)
3173 { 3181 {
3174 m_topControlsViewportAdjustment = adjustment; 3182 m_topControlsViewportAdjustment = adjustment;
3175 } 3183 }
3176 3184
3177 IntPoint FrameView::maximumScrollPosition() const 3185 IntPoint FrameView::maximumScrollPosition() const
3178 { 3186 {
3187 IntPoint minimum = calculateMinimumScrollPosition();
3188 IntPoint maximum = calculateMaximumScrollPosition().expandedTo(minimum);
3189
3190 if (m_scrollAndScaleEmulator)
3191 return m_scrollAndScaleEmulator->applyFramePositionOverride(maximum).shr unkTo(maximum).expandedTo(minimum);
3192
3193 return maximum;
3194 }
3195
3196 IntPoint FrameView::calculateMaximumScrollPosition() const
3197 {
3179 // Make the same calculation as in CC's LayerImpl::MaxScrollOffset() 3198 // Make the same calculation as in CC's LayerImpl::MaxScrollOffset()
3180 // FIXME: We probably shouldn't be storing the bounds in a float. crbug.com/ 422331. 3199 // FIXME: We probably shouldn't be storing the bounds in a float. crbug.com/ 422331.
3181 IntSize visibleSize = visibleContentSize(ExcludeScrollbars) + topControlsSiz e(); 3200 IntSize visibleSize = visibleContentSize(ExcludeScrollbars) + topControlsSiz e();
3182 IntSize contentBounds = contentsSize(); 3201 IntSize contentBounds = contentsSize();
3183 IntPoint maximumPosition = -scrollOrigin() + (contentBounds - visibleSize); 3202 IntPoint maximumPosition = -scrollOrigin() + (contentBounds - visibleSize);
3184 return maximumPosition.expandedTo(minimumScrollPosition()); 3203 return maximumPosition;
3185 } 3204 }
3186 3205
3187 void FrameView::addChild(Widget* child) 3206 void FrameView::addChild(Widget* child)
3188 { 3207 {
3189 ASSERT(child != this && !child->parent()); 3208 ASSERT(child != this && !child->parent());
3190 child->setParent(this); 3209 child->setParent(this);
3191 m_children.add(child); 3210 m_children.add(child);
3192 } 3211 }
3193 3212
3194 void FrameView::setHasHorizontalScrollbar(bool hasBar) 3213 void FrameView::setHasHorizontalScrollbar(bool hasBar)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
3293 return IntRect(flooredIntPoint(m_scrollPosition), visibleContentSize(scrollb arInclusion)); 3312 return IntRect(flooredIntPoint(m_scrollPosition), visibleContentSize(scrollb arInclusion));
3294 } 3313 }
3295 3314
3296 IntSize FrameView::contentsSize() const 3315 IntSize FrameView::contentsSize() const
3297 { 3316 {
3298 return m_contentsSize; 3317 return m_contentsSize;
3299 } 3318 }
3300 3319
3301 IntPoint FrameView::minimumScrollPosition() const 3320 IntPoint FrameView::minimumScrollPosition() const
3302 { 3321 {
3322 IntPoint minimum = calculateMinimumScrollPosition();
3323 IntPoint maximum = calculateMaximumScrollPosition().expandedTo(minimum);
3324
3325 if (m_scrollAndScaleEmulator)
3326 return m_scrollAndScaleEmulator->applyFramePositionOverride(minimum).shr unkTo(maximum).expandedTo(minimum);
3327
3328 return minimum;
3329 }
3330
3331 IntPoint FrameView::calculateMinimumScrollPosition() const
3332 {
3303 return IntPoint(-scrollOrigin().x(), -scrollOrigin().y()); 3333 return IntPoint(-scrollOrigin().x(), -scrollOrigin().y());
3304 } 3334 }
3305 3335
3306 void FrameView::adjustScrollbarOpacity() 3336 void FrameView::adjustScrollbarOpacity()
3307 { 3337 {
3308 if (m_horizontalScrollbar && layerForHorizontalScrollbar()) { 3338 if (m_horizontalScrollbar && layerForHorizontalScrollbar()) {
3309 bool isOpaqueScrollbar = !m_horizontalScrollbar->isOverlayScrollbar(); 3339 bool isOpaqueScrollbar = !m_horizontalScrollbar->isOverlayScrollbar();
3310 layerForHorizontalScrollbar()->setContentsOpaque(isOpaqueScrollbar); 3340 layerForHorizontalScrollbar()->setContentsOpaque(isOpaqueScrollbar);
3311 } 3341 }
3312 if (m_verticalScrollbar && layerForVerticalScrollbar()) { 3342 if (m_verticalScrollbar && layerForVerticalScrollbar()) {
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
4243 return m_subtreeThrottled || (m_hiddenForThrottling && m_crossOriginForThrot tling); 4273 return m_subtreeThrottled || (m_hiddenForThrottling && m_crossOriginForThrot tling);
4244 } 4274 }
4245 4275
4246 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const 4276 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const
4247 { 4277 {
4248 ASSERT(!layoutViewItem().isNull()); 4278 ASSERT(!layoutViewItem().isNull());
4249 return *layoutView(); 4279 return *layoutView();
4250 } 4280 }
4251 4281
4252 } // namespace blink 4282 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698