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

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: Add missing file, fix forbidden include. 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 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/frame/VisualViewport.h" 31 #include "core/frame/VisualViewport.h"
32 32
33 #include "core/frame/FrameHost.h" 33 #include "core/frame/FrameHost.h"
34 #include "core/frame/FrameView.h" 34 #include "core/frame/FrameView.h"
35 #include "core/frame/LocalFrame.h" 35 #include "core/frame/LocalFrame.h"
36 #include "core/frame/PageScaleConstraints.h" 36 #include "core/frame/PageScaleConstraints.h"
37 #include "core/frame/PageScaleConstraintsSet.h" 37 #include "core/frame/PageScaleConstraintsSet.h"
38 #include "core/frame/ScrollAndScaleEmulator.h"
38 #include "core/frame/Settings.h" 39 #include "core/frame/Settings.h"
39 #include "core/inspector/InspectorInstrumentation.h" 40 #include "core/inspector/InspectorInstrumentation.h"
40 #include "core/layout/TextAutosizer.h" 41 #include "core/layout/TextAutosizer.h"
41 #include "core/layout/compositing/PaintLayerCompositor.h" 42 #include "core/layout/compositing/PaintLayerCompositor.h"
42 #include "core/loader/FrameLoaderClient.h" 43 #include "core/loader/FrameLoaderClient.h"
43 #include "core/page/ChromeClient.h" 44 #include "core/page/ChromeClient.h"
44 #include "core/page/Page.h" 45 #include "core/page/Page.h"
45 #include "core/page/scrolling/ScrollingCoordinator.h" 46 #include "core/page/scrolling/ScrollingCoordinator.h"
46 #include "platform/Histogram.h" 47 #include "platform/Histogram.h"
47 #include "platform/TraceEvent.h" 48 #include "platform/TraceEvent.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 void VisualViewport::move(const FloatSize& delta) 205 void VisualViewport::move(const FloatSize& delta)
205 { 206 {
206 setLocation(m_offset + delta); 207 setLocation(m_offset + delta);
207 } 208 }
208 209
209 void VisualViewport::setScale(float scale) 210 void VisualViewport::setScale(float scale)
210 { 211 {
211 setScaleAndLocation(scale, m_offset); 212 setScaleAndLocation(scale, m_offset);
212 } 213 }
213 214
215 void VisualViewport::setScrollAndScaleEmulator(const RefPtr<ScrollAndScaleEmulat or>& emulator)
216 {
217 m_scrollAndScaleEmulator = emulator;
218 setScaleAndLocation(this->scale(), this->location());
219 }
220
214 double VisualViewport::scrollLeft() 221 double VisualViewport::scrollLeft()
215 { 222 {
216 if (!mainFrame()) 223 if (!mainFrame())
217 return 0; 224 return 0;
218 225
219 updateStyleAndLayoutIgnorePendingStylesheets(); 226 updateStyleAndLayoutIgnorePendingStylesheets();
220 227
221 return adjustScrollForAbsoluteZoom(visibleRect().x(), mainFrame()->pageZoomF actor()); 228 return adjustScrollForAbsoluteZoom(visibleRect().x(), mainFrame()->pageZoomF actor());
222 } 229 }
223 230
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 } 554 }
548 555
549 int VisualViewport::scrollSize(ScrollbarOrientation orientation) const 556 int VisualViewport::scrollSize(ScrollbarOrientation orientation) const
550 { 557 {
551 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition() ; 558 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition() ;
552 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr ollDimensions.height(); 559 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr ollDimensions.height();
553 } 560 }
554 561
555 IntPoint VisualViewport::minimumScrollPosition() const 562 IntPoint VisualViewport::minimumScrollPosition() const
556 { 563 {
557 return IntPoint(); 564 return flooredIntPoint(minimumScrollPositionDouble());
565 }
566
567 DoublePoint VisualViewport::minimumScrollPositionDouble() const
568 {
569 if (m_scrollAndScaleEmulator)
570 return m_scrollAndScaleEmulator->applyVisualViewportPositionOverride(Dou blePoint());
571
572 return DoublePoint();
558 } 573 }
559 574
560 IntPoint VisualViewport::maximumScrollPosition() const 575 IntPoint VisualViewport::maximumScrollPosition() const
561 { 576 {
562 return flooredIntPoint(maximumScrollPositionDouble()); 577 return flooredIntPoint(maximumScrollPositionDouble());
563 } 578 }
564 579
565 DoublePoint VisualViewport::maximumScrollPositionDouble() const 580 DoublePoint VisualViewport::maximumScrollPositionDouble() const
566 { 581 {
567 if (!mainFrame()) 582 if (!mainFrame())
568 return IntPoint(); 583 return IntPoint();
569 584
570 // TODO(bokan): We probably shouldn't be storing the bounds in a float. crbu g.com/470718. 585 // TODO(bokan): We probably shouldn't be storing the bounds in a float. crbu g.com/470718.
571 FloatSize frameViewSize(contentsSize()); 586 FloatSize frameViewSize(contentsSize());
572 587
573 if (m_topControlsAdjustment) { 588 if (m_topControlsAdjustment) {
574 float minScale = frameHost().pageScaleConstraintsSet().finalConstraints( ).minimumScale; 589 float minScale = frameHost().pageScaleConstraintsSet().finalConstraints( ).minimumScale;
575 frameViewSize.expand(0, m_topControlsAdjustment / minScale); 590 frameViewSize.expand(0, m_topControlsAdjustment / minScale);
576 } 591 }
577 592
578 frameViewSize.scale(m_scale); 593 frameViewSize.scale(m_scale);
579 frameViewSize = FloatSize(flooredIntSize(frameViewSize)); 594 frameViewSize = FloatSize(flooredIntSize(frameViewSize));
580 595
581 FloatSize viewportSize(m_size); 596 FloatSize viewportSize(m_size);
582 viewportSize.expand(0, ceilf(m_topControlsAdjustment)); 597 viewportSize.expand(0, ceilf(m_topControlsAdjustment));
583 598
584 FloatSize maxPosition = frameViewSize - viewportSize; 599 FloatSize maxPosition = frameViewSize - viewportSize;
585 maxPosition.scale(1 / m_scale); 600 maxPosition.scale(1 / m_scale);
601
602 if (m_scrollAndScaleEmulator)
603 return m_scrollAndScaleEmulator->applyVisualViewportPositionOverride(Dou blePoint(maxPosition));
604
586 return DoublePoint(maxPosition); 605 return DoublePoint(maxPosition);
587 } 606 }
588 607
589 IntPoint VisualViewport::clampDocumentOffsetAtScale(const IntPoint& offset, floa t scale) 608 IntPoint VisualViewport::clampDocumentOffsetAtScale(const IntPoint& offset, floa t scale)
590 { 609 {
591 if (!mainFrame() || !mainFrame()->view()) 610 if (!mainFrame() || !mainFrame()->view())
592 return IntPoint(); 611 return IntPoint();
593 612
594 FrameView* view = mainFrame()->view(); 613 FrameView* view = mainFrame()->view();
595 614
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 } else if (graphicsLayer == m_rootTransformLayer.get()) { 855 } else if (graphicsLayer == m_rootTransformLayer.get()) {
837 name = "Root Transform Layer"; 856 name = "Root Transform Layer";
838 } else { 857 } else {
839 ASSERT_NOT_REACHED(); 858 ASSERT_NOT_REACHED();
840 } 859 }
841 860
842 return name; 861 return name;
843 } 862 }
844 863
845 } // namespace blink 864 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698