OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/frame/RootFrameViewport.h" | 5 #include "core/frame/RootFrameViewport.h" |
6 | 6 |
7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
8 #include "core/frame/LocalFrame.h" | |
8 #include "core/layout/ScrollAlignment.h" | 9 #include "core/layout/ScrollAlignment.h" |
10 #include "core/layout/compositing/CompositedLayerMapping.h" | |
11 #include "core/page/Page.h" | |
12 #include "core/paint/PaintLayer.h" | |
9 #include "platform/geometry/DoubleRect.h" | 13 #include "platform/geometry/DoubleRect.h" |
10 #include "platform/geometry/FloatRect.h" | 14 #include "platform/geometry/FloatRect.h" |
11 #include "platform/geometry/LayoutRect.h" | 15 #include "platform/geometry/LayoutRect.h" |
12 | 16 |
13 namespace blink { | 17 namespace blink { |
14 | 18 |
15 RootFrameViewport::RootFrameViewport(ScrollableArea& visualViewport, ScrollableA rea& layoutViewport) | 19 RootFrameViewport::RootFrameViewport(ScrollableArea& visualViewport, ScrollableA rea& layoutViewport) |
16 : m_visualViewport(visualViewport) | 20 : m_visualViewport(visualViewport) |
17 , m_layoutViewport(layoutViewport) | 21 , m_layoutViewport(layoutViewport) |
18 { | 22 { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 delta = targetPosition - scrollPositionDouble(); | 83 delta = targetPosition - scrollPositionDouble(); |
80 visualViewport().setScrollPosition( | 84 visualViewport().setScrollPosition( |
81 visualViewport().scrollPositionDouble() + delta, ProgrammaticScroll); | 85 visualViewport().scrollPositionDouble() + delta, ProgrammaticScroll); |
82 } | 86 } |
83 | 87 |
84 LayoutBox* RootFrameViewport::layoutBox() const | 88 LayoutBox* RootFrameViewport::layoutBox() const |
85 { | 89 { |
86 return layoutViewport().layoutBox(); | 90 return layoutViewport().layoutBox(); |
87 } | 91 } |
88 | 92 |
93 LocalFrame* RootFrameViewport::mainFrame() const | |
94 { | |
95 if (!layoutBox()) | |
96 return 0; | |
97 | |
98 LocalFrame* frame = layoutBox()->frame(); | |
99 if (!frame && !frame->page()) | |
100 return 0; | |
101 | |
102 return frame->page()->mainFrame() && frame->page()->mainFrame()->isLocalFram e() ? frame->page()->deprecatedLocalMainFrame() : 0; | |
103 } | |
104 | |
105 CompositedLayerMapping* RootFrameViewport::compositedLayerMapping() const | |
106 { | |
107 | |
108 LocalFrame* frame = mainFrame(); | |
109 | |
110 if (!frame || !frame->view()) | |
111 return 0; | |
112 | |
113 if (frame && frame->view()) { | |
114 FrameView* view = frame->view(); | |
115 if (!view->layoutViewItem().isNull() && view->layoutViewItem().layer()-> hasCompositedLayerMapping()) | |
116 return view->layoutViewItem().layer()->compositedLayerMapping(); | |
117 } | |
118 | |
119 return 0; | |
120 } | |
121 | |
89 void RootFrameViewport::updateScrollAnimator() | 122 void RootFrameViewport::updateScrollAnimator() |
90 { | 123 { |
91 scrollAnimator().setCurrentPosition(toFloatPoint(scrollOffsetFromScrollAnima tors())); | 124 scrollAnimator().setCurrentPosition(toFloatPoint(scrollOffsetFromScrollAnima tors())); |
92 } | 125 } |
93 | 126 |
94 DoublePoint RootFrameViewport::scrollOffsetFromScrollAnimators() const | 127 DoublePoint RootFrameViewport::scrollOffsetFromScrollAnimators() const |
95 { | 128 { |
96 return visualViewport().scrollAnimator().currentPosition() + layoutViewport( ).scrollAnimator().currentPosition(); | 129 return visualViewport().scrollAnimator().currentPosition() + layoutViewport( ).scrollAnimator().currentPosition(); |
97 } | 130 } |
98 | 131 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 return layoutViewport().layerForContainer(); | 320 return layoutViewport().layerForContainer(); |
288 } | 321 } |
289 | 322 |
290 GraphicsLayer* RootFrameViewport::layerForScrolling() const | 323 GraphicsLayer* RootFrameViewport::layerForScrolling() const |
291 { | 324 { |
292 return layoutViewport().layerForScrolling(); | 325 return layoutViewport().layerForScrolling(); |
293 } | 326 } |
294 | 327 |
295 GraphicsLayer* RootFrameViewport::layerForHorizontalScrollbar() const | 328 GraphicsLayer* RootFrameViewport::layerForHorizontalScrollbar() const |
296 { | 329 { |
297 return layoutViewport().layerForHorizontalScrollbar(); | 330 LocalFrame* frame = mainFrame(); |
bokan
2016/09/02 16:01:54
I don't think you need any of the changes in this
MuVen
2016/09/02 16:36:12
so as i understand its better to retain the old de
MuVen
2016/09/06 10:07:29
Done.
| |
331 | |
332 if (!frame || !frame->view()) | |
333 return 0; | |
334 | |
335 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | |
336 if (CompositedLayerMapping* m_compositedLayerMapping = compositedLayerMa pping()) { | |
337 return m_compositedLayerMapping->layerForHorizontalScrollbar(); | |
338 } | |
339 } | |
340 | |
341 return frame->view()->layerForHorizontalScrollbar(); | |
298 } | 342 } |
299 | 343 |
300 GraphicsLayer* RootFrameViewport::layerForVerticalScrollbar() const | 344 GraphicsLayer* RootFrameViewport::layerForVerticalScrollbar() const |
301 { | 345 { |
302 return layoutViewport().layerForVerticalScrollbar(); | 346 LocalFrame* frame = mainFrame(); |
347 | |
348 if (!frame || !frame->view()) | |
349 return 0; | |
350 | |
351 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | |
352 if (CompositedLayerMapping* m_compositedLayerMapping = compositedLayerMa pping()) { | |
353 return m_compositedLayerMapping->layerForVerticalScrollbar(); | |
354 } | |
355 } | |
356 | |
357 return frame->view()->layerForVerticalScrollbar(); | |
358 } | |
359 | |
360 GraphicsLayer* RootFrameViewport::layerForScrollCorner() const | |
361 { | |
362 LocalFrame* frame = mainFrame(); | |
363 | |
364 if (!frame || !frame->view()) | |
365 return 0; | |
366 | |
367 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | |
368 if (CompositedLayerMapping* m_compositedLayerMapping = compositedLayerMa pping()) { | |
369 return m_compositedLayerMapping->layerForScrollCorner(); | |
370 } | |
371 } | |
372 | |
373 return frame->view()->layerForScrollCorner(); | |
303 } | 374 } |
304 | 375 |
305 ScrollResult RootFrameViewport::userScroll(ScrollGranularity granularity, const FloatSize& delta) | 376 ScrollResult RootFrameViewport::userScroll(ScrollGranularity granularity, const FloatSize& delta) |
306 { | 377 { |
307 // TODO(bokan/ymalik): Once smooth scrolling is permanently enabled we | 378 // TODO(bokan/ymalik): Once smooth scrolling is permanently enabled we |
308 // should be able to remove this method override and use the base class | 379 // should be able to remove this method override and use the base class |
309 // version: ScrollableArea::userScroll. | 380 // version: ScrollableArea::userScroll. |
310 | 381 |
311 updateScrollAnimator(); | 382 updateScrollAnimator(); |
312 | 383 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
418 } | 489 } |
419 | 490 |
420 DEFINE_TRACE(RootFrameViewport) | 491 DEFINE_TRACE(RootFrameViewport) |
421 { | 492 { |
422 visitor->trace(m_visualViewport); | 493 visitor->trace(m_visualViewport); |
423 visitor->trace(m_layoutViewport); | 494 visitor->trace(m_layoutViewport); |
424 ScrollableArea::trace(visitor); | 495 ScrollableArea::trace(visitor); |
425 } | 496 } |
426 | 497 |
427 } // namespace blink | 498 } // namespace blink |
OLD | NEW |