OLD | NEW |
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 Loading... |
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 Loading... |
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(scale(), 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 Loading... |
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 DoublePoint minimum = calculateMinimumScrollPositionDouble(); |
| 571 DoublePoint maximum = calculateMaximumScrollPositionDouble(); |
| 572 return m_scrollAndScaleEmulator->applyVisualViewportPositionOverride(min
imum, minimum, maximum); |
| 573 } |
| 574 |
| 575 return calculateMinimumScrollPositionDouble(); |
| 576 } |
| 577 |
| 578 DoublePoint VisualViewport::calculateMinimumScrollPositionDouble() const |
| 579 { |
| 580 return DoublePoint(); |
558 } | 581 } |
559 | 582 |
560 IntPoint VisualViewport::maximumScrollPosition() const | 583 IntPoint VisualViewport::maximumScrollPosition() const |
561 { | 584 { |
562 return flooredIntPoint(maximumScrollPositionDouble()); | 585 return flooredIntPoint(maximumScrollPositionDouble()); |
563 } | 586 } |
564 | 587 |
565 DoublePoint VisualViewport::maximumScrollPositionDouble() const | 588 DoublePoint VisualViewport::maximumScrollPositionDouble() const |
566 { | 589 { |
| 590 if (m_scrollAndScaleEmulator) { |
| 591 DoublePoint minimum = calculateMinimumScrollPositionDouble(); |
| 592 DoublePoint maximum = calculateMaximumScrollPositionDouble(); |
| 593 return m_scrollAndScaleEmulator->applyVisualViewportPositionOverride(max
imum, minimum, maximum); |
| 594 } |
| 595 |
| 596 return calculateMaximumScrollPositionDouble(); |
| 597 } |
| 598 |
| 599 DoublePoint VisualViewport::calculateMaximumScrollPositionDouble() const |
| 600 { |
567 if (!mainFrame()) | 601 if (!mainFrame()) |
568 return IntPoint(); | 602 return IntPoint(); |
569 | 603 |
570 // TODO(bokan): We probably shouldn't be storing the bounds in a float. crbu
g.com/470718. | 604 // TODO(bokan): We probably shouldn't be storing the bounds in a float. crbu
g.com/470718. |
571 FloatSize frameViewSize(contentsSize()); | 605 FloatSize frameViewSize(contentsSize()); |
572 | 606 |
573 if (m_topControlsAdjustment) { | 607 if (m_topControlsAdjustment) { |
574 float minScale = frameHost().pageScaleConstraintsSet().finalConstraints(
).minimumScale; | 608 float minScale = frameHost().pageScaleConstraintsSet().finalConstraints(
).minimumScale; |
575 frameViewSize.expand(0, m_topControlsAdjustment / minScale); | 609 frameViewSize.expand(0, m_topControlsAdjustment / minScale); |
576 } | 610 } |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 } else if (graphicsLayer == m_rootTransformLayer.get()) { | 870 } else if (graphicsLayer == m_rootTransformLayer.get()) { |
837 name = "Root Transform Layer"; | 871 name = "Root Transform Layer"; |
838 } else { | 872 } else { |
839 ASSERT_NOT_REACHED(); | 873 ASSERT_NOT_REACHED(); |
840 } | 874 } |
841 | 875 |
842 return name; | 876 return name; |
843 } | 877 } |
844 | 878 |
845 } // namespace blink | 879 } // namespace blink |
OLD | NEW |