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

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

Issue 2096633002: Adds scroll position/scale emulation to DevTools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: setNeedsCompositingUpdate now using InputChange. 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "core/frame/VisualViewport.h" 31 #include "core/frame/VisualViewport.h"
32 32
33 #include "core/dom/DOMNodeIds.h" 33 #include "core/dom/DOMNodeIds.h"
34 #include "core/frame/FrameHost.h" 34 #include "core/frame/FrameHost.h"
35 #include "core/frame/FrameView.h" 35 #include "core/frame/FrameView.h"
36 #include "core/frame/LocalFrame.h" 36 #include "core/frame/LocalFrame.h"
37 #include "core/frame/PageScaleConstraints.h" 37 #include "core/frame/PageScaleConstraints.h"
38 #include "core/frame/PageScaleConstraintsSet.h" 38 #include "core/frame/PageScaleConstraintsSet.h"
39 #include "core/frame/ScrollAndScaleEmulator.h"
39 #include "core/frame/Settings.h" 40 #include "core/frame/Settings.h"
40 #include "core/inspector/InspectorInstrumentation.h" 41 #include "core/inspector/InspectorInstrumentation.h"
41 #include "core/layout/TextAutosizer.h" 42 #include "core/layout/TextAutosizer.h"
42 #include "core/layout/compositing/PaintLayerCompositor.h" 43 #include "core/layout/compositing/PaintLayerCompositor.h"
43 #include "core/loader/FrameLoaderClient.h" 44 #include "core/loader/FrameLoaderClient.h"
44 #include "core/page/ChromeClient.h" 45 #include "core/page/ChromeClient.h"
45 #include "core/page/Page.h" 46 #include "core/page/Page.h"
46 #include "core/page/scrolling/ScrollingCoordinator.h" 47 #include "core/page/scrolling/ScrollingCoordinator.h"
47 #include "platform/Histogram.h" 48 #include "platform/Histogram.h"
48 #include "platform/TraceEvent.h" 49 #include "platform/TraceEvent.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 void VisualViewport::move(const FloatSize& delta) 216 void VisualViewport::move(const FloatSize& delta)
216 { 217 {
217 setLocation(m_offset + delta); 218 setLocation(m_offset + delta);
218 } 219 }
219 220
220 void VisualViewport::setScale(float scale) 221 void VisualViewport::setScale(float scale)
221 { 222 {
222 setScaleAndLocation(scale, m_offset); 223 setScaleAndLocation(scale, m_offset);
223 } 224 }
224 225
226 void VisualViewport::setScrollAndScaleEmulator(const RefPtr<ScrollAndScaleEmulat or>& emulator)
227 {
228 m_scrollAndScaleEmulator = emulator;
229 clampToBoundaries();
230 }
231
225 double VisualViewport::scrollLeft() 232 double VisualViewport::scrollLeft()
226 { 233 {
227 if (!mainFrame()) 234 if (!mainFrame())
228 return 0; 235 return 0;
229 236
230 updateStyleAndLayoutIgnorePendingStylesheets(); 237 updateStyleAndLayoutIgnorePendingStylesheets();
231 238
232 return adjustScrollForAbsoluteZoom(visibleRect().x(), mainFrame()->pageZoomF actor()); 239 return adjustScrollForAbsoluteZoom(visibleRect().x(), mainFrame()->pageZoomF actor());
233 } 240 }
234 241
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 } 550 }
544 551
545 int VisualViewport::scrollSize(ScrollbarOrientation orientation) const 552 int VisualViewport::scrollSize(ScrollbarOrientation orientation) const
546 { 553 {
547 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition() ; 554 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition() ;
548 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr ollDimensions.height(); 555 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr ollDimensions.height();
549 } 556 }
550 557
551 IntPoint VisualViewport::minimumScrollPosition() const 558 IntPoint VisualViewport::minimumScrollPosition() const
552 { 559 {
553 return IntPoint(); 560 return flooredIntPoint(minimumScrollPositionDouble());
561 }
562
563 DoublePoint VisualViewport::minimumScrollPositionDouble() const
564 {
565 DoublePoint minimum = calculateMinimumScrollPositionDouble();
566
567 if (m_scrollAndScaleEmulator) {
568 DoublePoint maximum = calculateMaximumScrollPositionDouble();
569 return m_scrollAndScaleEmulator->applyVisualViewportPositionOverride(min imum).shrunkTo(maximum).expandedTo(minimum);
570 }
571
572 return minimum;
573 }
574
575 DoublePoint VisualViewport::calculateMinimumScrollPositionDouble() const
576 {
577 return DoublePoint();
554 } 578 }
555 579
556 IntPoint VisualViewport::maximumScrollPosition() const 580 IntPoint VisualViewport::maximumScrollPosition() const
557 { 581 {
558 return flooredIntPoint(maximumScrollPositionDouble()); 582 return flooredIntPoint(maximumScrollPositionDouble());
559 } 583 }
560 584
561 DoublePoint VisualViewport::maximumScrollPositionDouble() const 585 DoublePoint VisualViewport::maximumScrollPositionDouble() const
562 { 586 {
587 DoublePoint maximum = calculateMaximumScrollPositionDouble();
588
589 if (m_scrollAndScaleEmulator) {
590 DoublePoint minimum = calculateMinimumScrollPositionDouble();
591 return m_scrollAndScaleEmulator->applyVisualViewportPositionOverride(max imum).shrunkTo(maximum).expandedTo(minimum);
592 }
593
594 return maximum;
595 }
596
597 DoublePoint VisualViewport::calculateMaximumScrollPositionDouble() const
598 {
563 if (!mainFrame()) 599 if (!mainFrame())
564 return IntPoint(); 600 return IntPoint();
565 601
566 // TODO(bokan): We probably shouldn't be storing the bounds in a float. crbu g.com/470718. 602 // TODO(bokan): We probably shouldn't be storing the bounds in a float. crbu g.com/470718.
567 FloatSize frameViewSize(contentsSize()); 603 FloatSize frameViewSize(contentsSize());
568 604
569 if (m_topControlsAdjustment) { 605 if (m_topControlsAdjustment) {
570 float minScale = frameHost().pageScaleConstraintsSet().finalConstraints( ).minimumScale; 606 float minScale = frameHost().pageScaleConstraintsSet().finalConstraints( ).minimumScale;
571 frameViewSize.expand(0, m_topControlsAdjustment / minScale); 607 frameViewSize.expand(0, m_topControlsAdjustment / minScale);
572 } 608 }
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 } else if (graphicsLayer == m_rootTransformLayer.get()) { 868 } else if (graphicsLayer == m_rootTransformLayer.get()) {
833 name = "Root Transform Layer"; 869 name = "Root Transform Layer";
834 } else { 870 } else {
835 ASSERT_NOT_REACHED(); 871 ASSERT_NOT_REACHED();
836 } 872 }
837 873
838 return name; 874 return name;
839 } 875 }
840 876
841 } // namespace blink 877 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698