| 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 } | 551 } |
| 544 | 552 |
| 545 int VisualViewport::scrollSize(ScrollbarOrientation orientation) const | 553 int VisualViewport::scrollSize(ScrollbarOrientation orientation) const |
| 546 { | 554 { |
| 547 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition()
; | 555 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition()
; |
| 548 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr
ollDimensions.height(); | 556 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr
ollDimensions.height(); |
| 549 } | 557 } |
| 550 | 558 |
| 551 IntPoint VisualViewport::minimumScrollPosition() const | 559 IntPoint VisualViewport::minimumScrollPosition() const |
| 552 { | 560 { |
| 553 return IntPoint(); | 561 return flooredIntPoint(minimumScrollPositionDouble()); |
| 562 } |
| 563 |
| 564 DoublePoint VisualViewport::minimumScrollPositionDouble() const |
| 565 { |
| 566 DoublePoint minimum = calculateMinimumScrollPositionDouble(); |
| 567 |
| 568 if (m_scrollAndScaleEmulator) { |
| 569 DoublePoint maximum = calculateMaximumScrollPositionDouble(); |
| 570 return m_scrollAndScaleEmulator->applyVisualViewportPositionOverride(min
imum).shrunkTo(maximum).expandedTo(minimum); |
| 571 } |
| 572 |
| 573 return minimum; |
| 574 } |
| 575 |
| 576 DoublePoint VisualViewport::calculateMinimumScrollPositionDouble() const |
| 577 { |
| 578 return DoublePoint(); |
| 554 } | 579 } |
| 555 | 580 |
| 556 IntPoint VisualViewport::maximumScrollPosition() const | 581 IntPoint VisualViewport::maximumScrollPosition() const |
| 557 { | 582 { |
| 558 return flooredIntPoint(maximumScrollPositionDouble()); | 583 return flooredIntPoint(maximumScrollPositionDouble()); |
| 559 } | 584 } |
| 560 | 585 |
| 561 DoublePoint VisualViewport::maximumScrollPositionDouble() const | 586 DoublePoint VisualViewport::maximumScrollPositionDouble() const |
| 562 { | 587 { |
| 588 DoublePoint maximum = calculateMaximumScrollPositionDouble(); |
| 589 |
| 590 if (m_scrollAndScaleEmulator) { |
| 591 DoublePoint minimum = calculateMinimumScrollPositionDouble(); |
| 592 return m_scrollAndScaleEmulator->applyVisualViewportPositionOverride(max
imum).shrunkTo(maximum).expandedTo(minimum); |
| 593 } |
| 594 |
| 595 return maximum; |
| 596 } |
| 597 |
| 598 DoublePoint VisualViewport::calculateMaximumScrollPositionDouble() const |
| 599 { |
| 563 if (!mainFrame()) | 600 if (!mainFrame()) |
| 564 return IntPoint(); | 601 return IntPoint(); |
| 565 | 602 |
| 566 // TODO(bokan): We probably shouldn't be storing the bounds in a float. crbu
g.com/470718. | 603 // TODO(bokan): We probably shouldn't be storing the bounds in a float. crbu
g.com/470718. |
| 567 FloatSize frameViewSize(contentsSize()); | 604 FloatSize frameViewSize(contentsSize()); |
| 568 | 605 |
| 569 if (m_topControlsAdjustment) { | 606 if (m_topControlsAdjustment) { |
| 570 float minScale = frameHost().pageScaleConstraintsSet().finalConstraints(
).minimumScale; | 607 float minScale = frameHost().pageScaleConstraintsSet().finalConstraints(
).minimumScale; |
| 571 frameViewSize.expand(0, m_topControlsAdjustment / minScale); | 608 frameViewSize.expand(0, m_topControlsAdjustment / minScale); |
| 572 } | 609 } |
| (...skipping 259 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 |