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 30 matching lines...) Expand all Loading... |
79 } | 80 } |
80 | 81 |
81 VisualViewport::~VisualViewport() | 82 VisualViewport::~VisualViewport() |
82 { | 83 { |
83 sendUMAMetrics(); | 84 sendUMAMetrics(); |
84 } | 85 } |
85 | 86 |
86 DEFINE_TRACE(VisualViewport) | 87 DEFINE_TRACE(VisualViewport) |
87 { | 88 { |
88 visitor->trace(m_frameHost); | 89 visitor->trace(m_frameHost); |
| 90 visitor->trace(m_scrollAndScaleEmulator); |
89 ScrollableArea::trace(visitor); | 91 ScrollableArea::trace(visitor); |
90 } | 92 } |
91 | 93 |
92 void VisualViewport::updateStyleAndLayoutIgnorePendingStylesheets() | 94 void VisualViewport::updateStyleAndLayoutIgnorePendingStylesheets() |
93 { | 95 { |
94 if (!mainFrame()) | 96 if (!mainFrame()) |
95 return; | 97 return; |
96 | 98 |
97 if (Document* document = mainFrame()->document()) | 99 if (Document* document = mainFrame()->document()) |
98 document->updateStyleAndLayoutIgnorePendingStylesheets(); | 100 document->updateStyleAndLayoutIgnorePendingStylesheets(); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 void VisualViewport::move(const FloatSize& delta) | 217 void VisualViewport::move(const FloatSize& delta) |
216 { | 218 { |
217 setLocation(m_offset + delta); | 219 setLocation(m_offset + delta); |
218 } | 220 } |
219 | 221 |
220 void VisualViewport::setScale(float scale) | 222 void VisualViewport::setScale(float scale) |
221 { | 223 { |
222 setScaleAndLocation(scale, m_offset); | 224 setScaleAndLocation(scale, m_offset); |
223 } | 225 } |
224 | 226 |
| 227 void VisualViewport::setScrollAndScaleEmulator(ScrollAndScaleEmulator* emulator) |
| 228 { |
| 229 m_scrollAndScaleEmulator = emulator; |
| 230 clampToBoundaries(); |
| 231 } |
| 232 |
225 double VisualViewport::scrollLeft() | 233 double VisualViewport::scrollLeft() |
226 { | 234 { |
227 if (!mainFrame()) | 235 if (!mainFrame()) |
228 return 0; | 236 return 0; |
229 | 237 |
230 updateStyleAndLayoutIgnorePendingStylesheets(); | 238 updateStyleAndLayoutIgnorePendingStylesheets(); |
231 | 239 |
232 return adjustScrollForAbsoluteZoom(visibleRect().x(), mainFrame()->pageZoomF
actor()); | 240 return adjustScrollForAbsoluteZoom(visibleRect().x(), mainFrame()->pageZoomF
actor()); |
233 } | 241 } |
234 | 242 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 | 543 |
536 bool VisualViewport::shouldUseIntegerScrollOffset() const | 544 bool VisualViewport::shouldUseIntegerScrollOffset() const |
537 { | 545 { |
538 LocalFrame* frame = mainFrame(); | 546 LocalFrame* frame = mainFrame(); |
539 if (frame && frame->settings() && !frame->settings()->preferCompositingToLCD
TextEnabled()) | 547 if (frame && frame->settings() && !frame->settings()->preferCompositingToLCD
TextEnabled()) |
540 return true; | 548 return true; |
541 | 549 |
542 return ScrollableArea::shouldUseIntegerScrollOffset(); | 550 return ScrollableArea::shouldUseIntegerScrollOffset(); |
543 } | 551 } |
544 | 552 |
| 553 void VisualViewport::setScrollPosition(const DoublePoint& scrollPoint, ScrollTyp
e scrollType, ScrollBehavior scrollBehavior) |
| 554 { |
| 555 DoublePoint newScrollPosition = clampScrollPosition(scrollPoint); |
| 556 ScrollableArea::setScrollPosition(newScrollPosition, scrollType, scrollBehav
ior); |
| 557 } |
| 558 |
545 int VisualViewport::scrollSize(ScrollbarOrientation orientation) const | 559 int VisualViewport::scrollSize(ScrollbarOrientation orientation) const |
546 { | 560 { |
547 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition()
; | 561 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition()
; |
548 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr
ollDimensions.height(); | 562 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr
ollDimensions.height(); |
549 } | 563 } |
550 | 564 |
551 IntPoint VisualViewport::minimumScrollPosition() const | 565 IntPoint VisualViewport::minimumScrollPosition() const |
552 { | 566 { |
553 return IntPoint(); | 567 return flooredIntPoint(minimumScrollPositionDouble()); |
| 568 } |
| 569 |
| 570 DoublePoint VisualViewport::minimumScrollPositionDouble() const |
| 571 { |
| 572 DoublePoint minimum = calculateMinimumScrollPositionDouble(); |
| 573 |
| 574 if (m_scrollAndScaleEmulator) { |
| 575 DoublePoint maximum = calculateMaximumScrollPositionDouble(); |
| 576 return m_scrollAndScaleEmulator->applyVisualViewportPositionOverride(min
imum).shrunkTo(maximum).expandedTo(minimum); |
| 577 } |
| 578 |
| 579 return minimum; |
| 580 } |
| 581 |
| 582 DoublePoint VisualViewport::calculateMinimumScrollPositionDouble() const |
| 583 { |
| 584 return DoublePoint(); |
554 } | 585 } |
555 | 586 |
556 IntPoint VisualViewport::maximumScrollPosition() const | 587 IntPoint VisualViewport::maximumScrollPosition() const |
557 { | 588 { |
558 return flooredIntPoint(maximumScrollPositionDouble()); | 589 return flooredIntPoint(maximumScrollPositionDouble()); |
559 } | 590 } |
560 | 591 |
561 DoublePoint VisualViewport::maximumScrollPositionDouble() const | 592 DoublePoint VisualViewport::maximumScrollPositionDouble() const |
562 { | 593 { |
| 594 DoublePoint maximum = calculateMaximumScrollPositionDouble(); |
| 595 |
| 596 if (m_scrollAndScaleEmulator) { |
| 597 DoublePoint minimum = calculateMinimumScrollPositionDouble(); |
| 598 return m_scrollAndScaleEmulator->applyVisualViewportPositionOverride(max
imum).shrunkTo(maximum).expandedTo(minimum); |
| 599 } |
| 600 |
| 601 return maximum; |
| 602 } |
| 603 |
| 604 DoublePoint VisualViewport::calculateMaximumScrollPositionDouble() const |
| 605 { |
563 if (!mainFrame()) | 606 if (!mainFrame()) |
564 return IntPoint(); | 607 return IntPoint(); |
565 | 608 |
566 // TODO(bokan): We probably shouldn't be storing the bounds in a float. crbu
g.com/470718. | 609 // TODO(bokan): We probably shouldn't be storing the bounds in a float. crbu
g.com/470718. |
567 FloatSize frameViewSize(contentsSize()); | 610 FloatSize frameViewSize(contentsSize()); |
568 | 611 |
569 if (m_topControlsAdjustment) { | 612 if (m_topControlsAdjustment) { |
570 float minScale = frameHost().pageScaleConstraintsSet().finalConstraints(
).minimumScale; | 613 float minScale = frameHost().pageScaleConstraintsSet().finalConstraints(
).minimumScale; |
571 frameViewSize.expand(0, m_topControlsAdjustment / minScale); | 614 frameViewSize.expand(0, m_topControlsAdjustment / minScale); |
572 } | 615 } |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 } else if (graphicsLayer == m_rootTransformLayer.get()) { | 875 } else if (graphicsLayer == m_rootTransformLayer.get()) { |
833 name = "Root Transform Layer"; | 876 name = "Root Transform Layer"; |
834 } else { | 877 } else { |
835 ASSERT_NOT_REACHED(); | 878 ASSERT_NOT_REACHED(); |
836 } | 879 } |
837 | 880 |
838 return name; | 881 return name; |
839 } | 882 } |
840 | 883 |
841 } // namespace blink | 884 } // namespace blink |
OLD | NEW |