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 18 matching lines...) Expand all Loading... |
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 21 matching lines...) Expand all Loading... |
70 } | 71 } |
71 | 72 |
72 VisualViewport::~VisualViewport() | 73 VisualViewport::~VisualViewport() |
73 { | 74 { |
74 sendUMAMetrics(); | 75 sendUMAMetrics(); |
75 } | 76 } |
76 | 77 |
77 DEFINE_TRACE(VisualViewport) | 78 DEFINE_TRACE(VisualViewport) |
78 { | 79 { |
79 visitor->trace(m_frameHost); | 80 visitor->trace(m_frameHost); |
| 81 visitor->trace(m_scrollAndScaleEmulator); |
80 ScrollableArea::trace(visitor); | 82 ScrollableArea::trace(visitor); |
81 } | 83 } |
82 | 84 |
83 void VisualViewport::updateStyleAndLayoutIgnorePendingStylesheets() | 85 void VisualViewport::updateStyleAndLayoutIgnorePendingStylesheets() |
84 { | 86 { |
85 if (!mainFrame()) | 87 if (!mainFrame()) |
86 return; | 88 return; |
87 | 89 |
88 if (Document* document = mainFrame()->document()) | 90 if (Document* document = mainFrame()->document()) |
89 document->updateStyleAndLayoutIgnorePendingStylesheets(); | 91 document->updateStyleAndLayoutIgnorePendingStylesheets(); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 void VisualViewport::move(const FloatSize& delta) | 208 void VisualViewport::move(const FloatSize& delta) |
207 { | 209 { |
208 setLocation(m_offset + delta); | 210 setLocation(m_offset + delta); |
209 } | 211 } |
210 | 212 |
211 void VisualViewport::setScale(float scale) | 213 void VisualViewport::setScale(float scale) |
212 { | 214 { |
213 setScaleAndLocation(scale, m_offset); | 215 setScaleAndLocation(scale, m_offset); |
214 } | 216 } |
215 | 217 |
| 218 void VisualViewport::setScrollAndScaleEmulator(ScrollAndScaleEmulator* emulator) |
| 219 { |
| 220 m_scrollAndScaleEmulator = emulator; |
| 221 clampToBoundaries(); |
| 222 } |
| 223 |
216 double VisualViewport::scrollLeft() | 224 double VisualViewport::scrollLeft() |
217 { | 225 { |
218 if (!mainFrame()) | 226 if (!mainFrame()) |
219 return 0; | 227 return 0; |
220 | 228 |
221 updateStyleAndLayoutIgnorePendingStylesheets(); | 229 updateStyleAndLayoutIgnorePendingStylesheets(); |
222 | 230 |
223 return adjustScrollForAbsoluteZoom(visibleRect().x(), mainFrame()->pageZoomF
actor()); | 231 return adjustScrollForAbsoluteZoom(visibleRect().x(), mainFrame()->pageZoomF
actor()); |
224 } | 232 } |
225 | 233 |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 } | 550 } |
543 | 551 |
544 int VisualViewport::scrollSize(ScrollbarOrientation orientation) const | 552 int VisualViewport::scrollSize(ScrollbarOrientation orientation) const |
545 { | 553 { |
546 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition()
; | 554 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition()
; |
547 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr
ollDimensions.height(); | 555 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr
ollDimensions.height(); |
548 } | 556 } |
549 | 557 |
550 IntPoint VisualViewport::minimumScrollPosition() const | 558 IntPoint VisualViewport::minimumScrollPosition() const |
551 { | 559 { |
552 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(); |
553 } | 578 } |
554 | 579 |
555 IntPoint VisualViewport::maximumScrollPosition() const | 580 IntPoint VisualViewport::maximumScrollPosition() const |
556 { | 581 { |
557 return flooredIntPoint(maximumScrollPositionDouble()); | 582 return flooredIntPoint(maximumScrollPositionDouble()); |
558 } | 583 } |
559 | 584 |
560 DoublePoint VisualViewport::maximumScrollPositionDouble() const | 585 DoublePoint VisualViewport::maximumScrollPositionDouble() const |
561 { | 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 { |
562 if (!mainFrame()) | 599 if (!mainFrame()) |
563 return IntPoint(); | 600 return IntPoint(); |
564 | 601 |
565 // 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. |
566 FloatSize frameViewSize(contentsSize()); | 603 FloatSize frameViewSize(contentsSize()); |
567 | 604 |
568 if (m_topControlsAdjustment) { | 605 if (m_topControlsAdjustment) { |
569 float minScale = frameHost().pageScaleConstraintsSet().finalConstraints(
).minimumScale; | 606 float minScale = frameHost().pageScaleConstraintsSet().finalConstraints(
).minimumScale; |
570 frameViewSize.expand(0, m_topControlsAdjustment / minScale); | 607 frameViewSize.expand(0, m_topControlsAdjustment / minScale); |
571 } | 608 } |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 } else if (graphicsLayer == m_rootTransformLayer.get()) { | 869 } else if (graphicsLayer == m_rootTransformLayer.get()) { |
833 name = "Root Transform Layer"; | 870 name = "Root Transform Layer"; |
834 } else { | 871 } else { |
835 ASSERT_NOT_REACHED(); | 872 ASSERT_NOT_REACHED(); |
836 } | 873 } |
837 | 874 |
838 return name; | 875 return name; |
839 } | 876 } |
840 | 877 |
841 } // namespace blink | 878 } // namespace blink |
OLD | NEW |