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

Unified 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: Sync changes from patches 2111203004 + 2118773002. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/FrameView.cpp
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp
index 10897245dab43bf655cf30e9ef7aeae6ede030ae..bf4d34d01131c8c1f3bbdc97389ba34e10109558 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -44,6 +44,7 @@
#include "core/frame/LocalFrame.h"
#include "core/frame/Location.h"
#include "core/frame/PageScaleConstraintsSet.h"
+#include "core/frame/ScrollAndScaleEmulator.h"
#include "core/frame/Settings.h"
#include "core/frame/TopControls.h"
#include "core/frame/VisualViewport.h"
@@ -1603,6 +1604,12 @@ void FrameView::setScrollPosition(const DoublePoint& scrollPoint, ScrollType scr
ScrollableArea::setScrollPosition(newScrollPosition, scrollType, scrollBehavior);
}
+void FrameView::setScrollAndScaleEmulator(const RefPtr<ScrollAndScaleEmulator>& emulator)
+{
+ m_scrollAndScaleEmulator = emulator;
+ setScrollPosition(scrollPosition(), ProgrammaticScroll, ScrollBehaviorInstant);
+}
+
void FrameView::didUpdateElasticOverscroll()
{
Page* page = frame().page();
@@ -3172,12 +3179,24 @@ void FrameView::setTopControlsViewportAdjustment(float adjustment)
IntPoint FrameView::maximumScrollPosition() const
{
+ IntPoint minimum = calculateMinimumScrollPosition();
+ IntPoint maximum = calculateMaximumScrollPosition().expandedTo(minimum);
+
+ if (m_scrollAndScaleEmulator) {
bokan 2016/07/01 21:05:12 Nit: no braces
Eric Seckler 2016/07/04 14:33:08 Done.
+ return m_scrollAndScaleEmulator->applyFramePositionOverride(maximum, minimum, maximum);
bokan 2016/07/01 21:05:12 I would remove the min and max parameters from app
Eric Seckler 2016/07/04 14:33:08 Done.
+ }
+
+ return maximum;
+}
+
+IntPoint FrameView::calculateMaximumScrollPosition() const
+{
// Make the same calculation as in CC's LayerImpl::MaxScrollOffset()
// FIXME: We probably shouldn't be storing the bounds in a float. crbug.com/422331.
IntSize visibleSize = visibleContentSize(ExcludeScrollbars) + topControlsSize();
IntSize contentBounds = contentsSize();
IntPoint maximumPosition = -scrollOrigin() + (contentBounds - visibleSize);
- return maximumPosition.expandedTo(minimumScrollPosition());
+ return maximumPosition;
}
void FrameView::addChild(Widget* child)
@@ -3296,6 +3315,17 @@ IntSize FrameView::contentsSize() const
IntPoint FrameView::minimumScrollPosition() const
{
+ if (m_scrollAndScaleEmulator) {
+ IntPoint minimum = calculateMinimumScrollPosition();
+ IntPoint maximum = calculateMaximumScrollPosition().expandedTo(minimum);
+ return m_scrollAndScaleEmulator->applyFramePositionOverride(minimum, minimum, maximum);
+ }
+
+ return calculateMinimumScrollPosition();
+}
+
+IntPoint FrameView::calculateMinimumScrollPosition() const
+{
return IntPoint(-scrollOrigin().x(), -scrollOrigin().y());
}

Powered by Google App Engine
This is Rietveld 408576698