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

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: Fixes issues with visual viewport scroll override, mainFrameSize on scale override, clamps 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 25 matching lines...) Expand all
36 #include "core/editing/EditingUtilities.h" 36 #include "core/editing/EditingUtilities.h"
37 #include "core/editing/FrameSelection.h" 37 #include "core/editing/FrameSelection.h"
38 #include "core/editing/RenderedPosition.h" 38 #include "core/editing/RenderedPosition.h"
39 #include "core/editing/markers/DocumentMarkerController.h" 39 #include "core/editing/markers/DocumentMarkerController.h"
40 #include "core/fetch/ResourceFetcher.h" 40 #include "core/fetch/ResourceFetcher.h"
41 #include "core/frame/EventHandlerRegistry.h" 41 #include "core/frame/EventHandlerRegistry.h"
42 #include "core/frame/FrameHost.h" 42 #include "core/frame/FrameHost.h"
43 #include "core/frame/LocalFrame.h" 43 #include "core/frame/LocalFrame.h"
44 #include "core/frame/Location.h" 44 #include "core/frame/Location.h"
45 #include "core/frame/PageScaleConstraintsSet.h" 45 #include "core/frame/PageScaleConstraintsSet.h"
46 #include "core/frame/ScrollAndScaleEmulator.h"
46 #include "core/frame/Settings.h" 47 #include "core/frame/Settings.h"
47 #include "core/frame/TopControls.h" 48 #include "core/frame/TopControls.h"
48 #include "core/frame/VisualViewport.h" 49 #include "core/frame/VisualViewport.h"
49 #include "core/html/HTMLFrameElement.h" 50 #include "core/html/HTMLFrameElement.h"
50 #include "core/html/HTMLPlugInElement.h" 51 #include "core/html/HTMLPlugInElement.h"
51 #include "core/html/HTMLTextFormControlElement.h" 52 #include "core/html/HTMLTextFormControlElement.h"
52 #include "core/html/parser/TextResourceDecoder.h" 53 #include "core/html/parser/TextResourceDecoder.h"
53 #include "core/input/EventHandler.h" 54 #include "core/input/EventHandler.h"
54 #include "core/inspector/InspectorInstrumentation.h" 55 #include "core/inspector/InspectorInstrumentation.h"
55 #include "core/inspector/InspectorTraceEvents.h" 56 #include "core/inspector/InspectorTraceEvents.h"
(...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 DoublePoint newScrollPosition = clampScrollPosition(scrollPoint); 1580 DoublePoint newScrollPosition = clampScrollPosition(scrollPoint);
1580 if (newScrollPosition == scrollPositionDouble()) 1581 if (newScrollPosition == scrollPositionDouble())
1581 return; 1582 return;
1582 1583
1583 if (scrollBehavior == ScrollBehaviorAuto) 1584 if (scrollBehavior == ScrollBehaviorAuto)
1584 scrollBehavior = scrollBehaviorStyle(); 1585 scrollBehavior = scrollBehaviorStyle();
1585 1586
1586 ScrollableArea::setScrollPosition(newScrollPosition, scrollType, scrollBehav ior); 1587 ScrollableArea::setScrollPosition(newScrollPosition, scrollType, scrollBehav ior);
1587 } 1588 }
1588 1589
1590 void FrameView::setScrollAndScaleEmulator(const RefPtr<ScrollAndScaleEmulator>& emulator)
1591 {
1592 m_scrollAndScaleEmulator = emulator;
1593 setScrollPosition(scrollPosition(), ProgrammaticScroll, ScrollBehaviorInstan t);
1594 }
1595
1589 void FrameView::didUpdateElasticOverscroll() 1596 void FrameView::didUpdateElasticOverscroll()
1590 { 1597 {
1591 Page* page = frame().page(); 1598 Page* page = frame().page();
1592 if (!page) 1599 if (!page)
1593 return; 1600 return;
1594 FloatSize elasticOverscroll = page->chromeClient().elasticOverscroll(); 1601 FloatSize elasticOverscroll = page->chromeClient().elasticOverscroll();
1595 if (m_horizontalScrollbar) { 1602 if (m_horizontalScrollbar) {
1596 float delta = elasticOverscroll.width() - m_horizontalScrollbar->elastic Overscroll(); 1603 float delta = elasticOverscroll.width() - m_horizontalScrollbar->elastic Overscroll();
1597 if (delta != 0) { 1604 if (delta != 0) {
1598 m_horizontalScrollbar->setElasticOverscroll(elasticOverscroll.width( )); 1605 m_horizontalScrollbar->setElasticOverscroll(elasticOverscroll.width( ));
(...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after
3156 ScrollableArea::didAddScrollbar(scrollbar, orientation); 3163 ScrollableArea::didAddScrollbar(scrollbar, orientation);
3157 } 3164 }
3158 3165
3159 void FrameView::setTopControlsViewportAdjustment(float adjustment) 3166 void FrameView::setTopControlsViewportAdjustment(float adjustment)
3160 { 3167 {
3161 m_topControlsViewportAdjustment = adjustment; 3168 m_topControlsViewportAdjustment = adjustment;
3162 } 3169 }
3163 3170
3164 IntPoint FrameView::maximumScrollPosition() const 3171 IntPoint FrameView::maximumScrollPosition() const
3165 { 3172 {
3173 IntPoint minimum = calculateMinimumScrollPosition();
3174 IntPoint maximum = calculateMaximumScrollPosition().expandedTo(minimum);
3175
3176 if (m_scrollAndScaleEmulator) {
3177 return m_scrollAndScaleEmulator->applyFramePositionOverride(maximum, min imum, maximum);
3178 }
3179
3180 return maximum;
3181 }
3182
3183 IntPoint FrameView::calculateMaximumScrollPosition() const
3184 {
3166 // Make the same calculation as in CC's LayerImpl::MaxScrollOffset() 3185 // Make the same calculation as in CC's LayerImpl::MaxScrollOffset()
3167 // FIXME: We probably shouldn't be storing the bounds in a float. crbug.com/ 422331. 3186 // FIXME: We probably shouldn't be storing the bounds in a float. crbug.com/ 422331.
3168 IntSize visibleSize = visibleContentSize(ExcludeScrollbars) + topControlsSiz e(); 3187 IntSize visibleSize = visibleContentSize(ExcludeScrollbars) + topControlsSiz e();
3169 IntSize contentBounds = contentsSize(); 3188 IntSize contentBounds = contentsSize();
3170 IntPoint maximumPosition = -scrollOrigin() + (contentBounds - visibleSize); 3189 IntPoint maximumPosition = -scrollOrigin() + (contentBounds - visibleSize);
3171 return maximumPosition.expandedTo(minimumScrollPosition()); 3190 return maximumPosition;
3172 } 3191 }
3173 3192
3174 void FrameView::addChild(Widget* child) 3193 void FrameView::addChild(Widget* child)
3175 { 3194 {
3176 ASSERT(child != this && !child->parent()); 3195 ASSERT(child != this && !child->parent());
3177 child->setParent(this); 3196 child->setParent(this);
3178 m_children.add(child); 3197 m_children.add(child);
3179 } 3198 }
3180 3199
3181 void FrameView::setHasHorizontalScrollbar(bool hasBar) 3200 void FrameView::setHasHorizontalScrollbar(bool hasBar)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
3280 return IntRect(flooredIntPoint(m_scrollPosition), visibleContentSize(scrollb arInclusion)); 3299 return IntRect(flooredIntPoint(m_scrollPosition), visibleContentSize(scrollb arInclusion));
3281 } 3300 }
3282 3301
3283 IntSize FrameView::contentsSize() const 3302 IntSize FrameView::contentsSize() const
3284 { 3303 {
3285 return m_contentsSize; 3304 return m_contentsSize;
3286 } 3305 }
3287 3306
3288 IntPoint FrameView::minimumScrollPosition() const 3307 IntPoint FrameView::minimumScrollPosition() const
3289 { 3308 {
3309 if (m_scrollAndScaleEmulator) {
3310 IntPoint minimum = calculateMinimumScrollPosition();
3311 IntPoint maximum = calculateMaximumScrollPosition().expandedTo(minimum);
3312 return m_scrollAndScaleEmulator->applyFramePositionOverride(minimum, min imum, maximum);
3313 }
3314
3315 return calculateMinimumScrollPosition();
3316 }
3317
3318 IntPoint FrameView::calculateMinimumScrollPosition() const
3319 {
3290 return IntPoint(-scrollOrigin().x(), -scrollOrigin().y()); 3320 return IntPoint(-scrollOrigin().x(), -scrollOrigin().y());
3291 } 3321 }
3292 3322
3293 void FrameView::adjustScrollbarOpacity() 3323 void FrameView::adjustScrollbarOpacity()
3294 { 3324 {
3295 if (m_horizontalScrollbar && layerForHorizontalScrollbar()) { 3325 if (m_horizontalScrollbar && layerForHorizontalScrollbar()) {
3296 bool isOpaqueScrollbar = !m_horizontalScrollbar->isOverlayScrollbar(); 3326 bool isOpaqueScrollbar = !m_horizontalScrollbar->isOverlayScrollbar();
3297 layerForHorizontalScrollbar()->setContentsOpaque(isOpaqueScrollbar); 3327 layerForHorizontalScrollbar()->setContentsOpaque(isOpaqueScrollbar);
3298 } 3328 }
3299 if (m_verticalScrollbar && layerForVerticalScrollbar()) { 3329 if (m_verticalScrollbar && layerForVerticalScrollbar()) {
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
4230 return m_subtreeThrottled || (m_hiddenForThrottling && m_crossOriginForThrot tling); 4260 return m_subtreeThrottled || (m_hiddenForThrottling && m_crossOriginForThrot tling);
4231 } 4261 }
4232 4262
4233 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const 4263 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const
4234 { 4264 {
4235 ASSERT(!layoutViewItem().isNull()); 4265 ASSERT(!layoutViewItem().isNull());
4236 return *layoutView(); 4266 return *layoutView();
4237 } 4267 }
4238 4268
4239 } // namespace blink 4269 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698