OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 }; | 400 }; |
401 | 401 |
402 void RenderLayerCompositor::frameViewDidScroll() | 402 void RenderLayerCompositor::frameViewDidScroll() |
403 { | 403 { |
404 FrameView* frameView = m_renderView.frameView(); | 404 FrameView* frameView = m_renderView.frameView(); |
405 IntPoint scrollPosition = frameView->scrollPosition(); | 405 IntPoint scrollPosition = frameView->scrollPosition(); |
406 | 406 |
407 if (!m_scrollLayer) | 407 if (!m_scrollLayer) |
408 return; | 408 return; |
409 | 409 |
410 bool scrollingCoordinatorHandlesOffset = false; | |
411 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator(
)) { | |
412 scrollingCoordinatorHandlesOffset = scrollingCoordinator->scrollableArea
ScrollLayerDidChange(frameView); | |
413 } | |
414 | |
415 // Scroll position = scroll minimum + scroll offset. Adjust the layer's | 410 // Scroll position = scroll minimum + scroll offset. Adjust the layer's |
416 // position to handle whatever the scroll coordinator isn't handling. | 411 // position to handle whatever the scroll coordinator isn't handling. |
417 // The minimum scroll position is non-zero for RTL pages with overflow. | 412 // The minimum scroll position is non-zero for RTL pages with overflow. |
418 if (scrollingCoordinatorHandlesOffset) | 413 m_scrollLayer->setPosition(-scrollPosition); |
419 m_scrollLayer->setPosition(-frameView->minimumScrollPosition()); | |
420 else | |
421 m_scrollLayer->setPosition(-scrollPosition); | |
422 | 414 |
423 | 415 |
424 Platform::current()->histogramEnumeration("Renderer.AcceleratedFixedRootBack
ground", | 416 Platform::current()->histogramEnumeration("Renderer.AcceleratedFixedRootBack
ground", |
425 ScrolledMainFrameBucket, | 417 ScrolledMainFrameBucket, |
426 AcceleratedFixedRootBackgroundHistogramMax); | 418 AcceleratedFixedRootBackgroundHistogramMax); |
427 } | 419 } |
428 | 420 |
429 void RenderLayerCompositor::frameViewScrollbarsExistenceDidChange() | 421 void RenderLayerCompositor::frameViewScrollbarsExistenceDidChange() |
430 { | 422 { |
431 if (m_containerLayer) | 423 if (m_containerLayer) |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 } | 624 } |
633 | 625 |
634 // If an element has negative z-index children, those children render in front o
f the | 626 // If an element has negative z-index children, those children render in front o
f the |
635 // layer background, so we need an extra 'contents' layer for the foreground of
the layer | 627 // layer background, so we need an extra 'contents' layer for the foreground of
the layer |
636 // object. | 628 // object. |
637 bool RenderLayerCompositor::needsContentsCompositingLayer(const RenderLayer* lay
er) const | 629 bool RenderLayerCompositor::needsContentsCompositingLayer(const RenderLayer* lay
er) const |
638 { | 630 { |
639 return layer->stackingNode()->hasNegativeZOrderList(); | 631 return layer->stackingNode()->hasNegativeZOrderList(); |
640 } | 632 } |
641 | 633 |
642 static void paintScrollbar(Scrollbar* scrollbar, GraphicsContext& context, const
IntRect& clip) | |
643 { | |
644 if (!scrollbar) | |
645 return; | |
646 | |
647 context.save(); | |
648 const IntRect& scrollbarRect = scrollbar->frameRect(); | |
649 context.translate(-scrollbarRect.x(), -scrollbarRect.y()); | |
650 IntRect transformedClip = clip; | |
651 transformedClip.moveBy(scrollbarRect.location()); | |
652 scrollbar->paint(&context, transformedClip); | |
653 context.restore(); | |
654 } | |
655 | |
656 void RenderLayerCompositor::paintContents(const GraphicsLayer* graphicsLayer, Gr
aphicsContext& context, GraphicsLayerPaintingPhase, const IntRect& clip) | 634 void RenderLayerCompositor::paintContents(const GraphicsLayer* graphicsLayer, Gr
aphicsContext& context, GraphicsLayerPaintingPhase, const IntRect& clip) |
657 { | 635 { |
658 if (graphicsLayer == layerForHorizontalScrollbar()) | 636 // FIXME(sky): Remove. |
659 paintScrollbar(m_renderView.frameView()->horizontalScrollbar(), context,
clip); | |
660 else if (graphicsLayer == layerForVerticalScrollbar()) | |
661 paintScrollbar(m_renderView.frameView()->verticalScrollbar(), context, c
lip); | |
662 else if (graphicsLayer == layerForScrollCorner()) { | |
663 const IntRect& scrollCorner = m_renderView.frameView()->scrollCornerRect
(); | |
664 context.save(); | |
665 context.translate(-scrollCorner.x(), -scrollCorner.y()); | |
666 IntRect transformedClip = clip; | |
667 transformedClip.moveBy(scrollCorner.location()); | |
668 m_renderView.frameView()->paintScrollCorner(&context, transformedClip); | |
669 context.restore(); | |
670 } | |
671 } | 637 } |
672 | 638 |
673 bool RenderLayerCompositor::supportsFixedRootBackgroundCompositing() const | 639 bool RenderLayerCompositor::supportsFixedRootBackgroundCompositing() const |
674 { | 640 { |
675 if (Settings* settings = m_renderView.document().settings()) | 641 if (Settings* settings = m_renderView.document().settings()) |
676 return settings->preferCompositingToLCDTextEnabled(); | 642 return settings->preferCompositingToLCDTextEnabled(); |
677 return false; | 643 return false; |
678 } | 644 } |
679 | 645 |
680 bool RenderLayerCompositor::needsFixedRootBackgroundLayer(const RenderLayer* lay
er) const | 646 bool RenderLayerCompositor::needsFixedRootBackgroundLayer(const RenderLayer* lay
er) const |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 { | 691 { |
726 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean); | 692 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean); |
727 m_isTrackingPaintInvalidations = tracksPaintInvalidations; | 693 m_isTrackingPaintInvalidations = tracksPaintInvalidations; |
728 } | 694 } |
729 | 695 |
730 bool RenderLayerCompositor::isTrackingPaintInvalidations() const | 696 bool RenderLayerCompositor::isTrackingPaintInvalidations() const |
731 { | 697 { |
732 return m_isTrackingPaintInvalidations; | 698 return m_isTrackingPaintInvalidations; |
733 } | 699 } |
734 | 700 |
735 static bool shouldCompositeOverflowControls(FrameView* view) | |
736 { | |
737 if (Page* page = view->frame().page()) { | |
738 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordina
tor()) | |
739 if (scrollingCoordinator->coordinatesScrollingForFrameView(view)) | |
740 return true; | |
741 } | |
742 | |
743 return true; | |
744 } | |
745 | |
746 bool RenderLayerCompositor::requiresHorizontalScrollbarLayer() const | 701 bool RenderLayerCompositor::requiresHorizontalScrollbarLayer() const |
747 { | 702 { |
748 FrameView* view = m_renderView.frameView(); | 703 // FIXME(sky): Remove |
749 return shouldCompositeOverflowControls(view) && view->horizontalScrollbar(); | 704 return false; |
750 } | 705 } |
751 | 706 |
752 bool RenderLayerCompositor::requiresVerticalScrollbarLayer() const | 707 bool RenderLayerCompositor::requiresVerticalScrollbarLayer() const |
753 { | 708 { |
754 FrameView* view = m_renderView.frameView(); | 709 // FIXME(sky): Remove |
755 return shouldCompositeOverflowControls(view) && view->verticalScrollbar(); | 710 return false; |
756 } | 711 } |
757 | 712 |
758 bool RenderLayerCompositor::requiresScrollCornerLayer() const | 713 bool RenderLayerCompositor::requiresScrollCornerLayer() const |
759 { | 714 { |
760 FrameView* view = m_renderView.frameView(); | 715 // FIXME(sky): Remove |
761 return shouldCompositeOverflowControls(view) && view->isScrollCornerVisible(
); | 716 return false; |
762 } | 717 } |
763 | 718 |
764 void RenderLayerCompositor::updateOverflowControlsLayers() | 719 void RenderLayerCompositor::updateOverflowControlsLayers() |
765 { | 720 { |
766 GraphicsLayer* controlsParent = m_rootTransformLayer.get() ? m_rootTransform
Layer.get() : m_overflowControlsHostLayer.get(); | 721 GraphicsLayer* controlsParent = m_rootTransformLayer.get() ? m_rootTransform
Layer.get() : m_overflowControlsHostLayer.get(); |
767 | 722 |
768 if (requiresHorizontalScrollbarLayer()) { | 723 if (requiresHorizontalScrollbarLayer()) { |
769 if (!m_layerForHorizontalScrollbar) { | 724 if (!m_layerForHorizontalScrollbar) { |
770 m_layerForHorizontalScrollbar = GraphicsLayer::create(graphicsLayerF
actory(), this); | 725 m_layerForHorizontalScrollbar = GraphicsLayer::create(graphicsLayerF
actory(), this); |
771 } | 726 } |
772 | 727 |
773 if (m_layerForHorizontalScrollbar->parent() != controlsParent) { | 728 if (m_layerForHorizontalScrollbar->parent() != controlsParent) { |
774 controlsParent->addChild(m_layerForHorizontalScrollbar.get()); | 729 controlsParent->addChild(m_layerForHorizontalScrollbar.get()); |
775 | |
776 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoor
dinator()) | |
777 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_re
nderView.frameView(), HorizontalScrollbar); | |
778 } | 730 } |
779 } else if (m_layerForHorizontalScrollbar) { | 731 } else if (m_layerForHorizontalScrollbar) { |
780 m_layerForHorizontalScrollbar->removeFromParent(); | 732 m_layerForHorizontalScrollbar->removeFromParent(); |
781 m_layerForHorizontalScrollbar = nullptr; | 733 m_layerForHorizontalScrollbar = nullptr; |
782 | |
783 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordina
tor()) | |
784 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_render
View.frameView(), HorizontalScrollbar); | |
785 } | 734 } |
786 | 735 |
787 if (requiresVerticalScrollbarLayer()) { | 736 if (requiresVerticalScrollbarLayer()) { |
788 if (!m_layerForVerticalScrollbar) { | 737 if (!m_layerForVerticalScrollbar) { |
789 m_layerForVerticalScrollbar = GraphicsLayer::create(graphicsLayerFac
tory(), this); | 738 m_layerForVerticalScrollbar = GraphicsLayer::create(graphicsLayerFac
tory(), this); |
790 } | 739 } |
791 | 740 |
792 if (m_layerForVerticalScrollbar->parent() != controlsParent) { | 741 if (m_layerForVerticalScrollbar->parent() != controlsParent) { |
793 controlsParent->addChild(m_layerForVerticalScrollbar.get()); | 742 controlsParent->addChild(m_layerForVerticalScrollbar.get()); |
794 | |
795 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoor
dinator()) | |
796 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_re
nderView.frameView(), VerticalScrollbar); | |
797 } | 743 } |
798 } else if (m_layerForVerticalScrollbar) { | 744 } else if (m_layerForVerticalScrollbar) { |
799 m_layerForVerticalScrollbar->removeFromParent(); | 745 m_layerForVerticalScrollbar->removeFromParent(); |
800 m_layerForVerticalScrollbar = nullptr; | 746 m_layerForVerticalScrollbar = nullptr; |
801 | |
802 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordina
tor()) | |
803 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_render
View.frameView(), VerticalScrollbar); | |
804 } | 747 } |
805 | 748 |
806 if (requiresScrollCornerLayer()) { | 749 if (requiresScrollCornerLayer()) { |
807 if (!m_layerForScrollCorner) { | 750 if (!m_layerForScrollCorner) { |
808 m_layerForScrollCorner = GraphicsLayer::create(graphicsLayerFactory(
), this); | 751 m_layerForScrollCorner = GraphicsLayer::create(graphicsLayerFactory(
), this); |
809 controlsParent->addChild(m_layerForScrollCorner.get()); | 752 controlsParent->addChild(m_layerForScrollCorner.get()); |
810 } | 753 } |
811 } else if (m_layerForScrollCorner) { | 754 } else if (m_layerForScrollCorner) { |
812 m_layerForScrollCorner->removeFromParent(); | 755 m_layerForScrollCorner->removeFromParent(); |
813 m_layerForScrollCorner = nullptr; | 756 m_layerForScrollCorner = nullptr; |
814 } | 757 } |
815 | |
816 m_renderView.frameView()->positionScrollbarLayers(); | |
817 } | 758 } |
818 | 759 |
819 void RenderLayerCompositor::ensureRootLayer() | 760 void RenderLayerCompositor::ensureRootLayer() |
820 { | 761 { |
821 RootLayerAttachment expectedAttachment = RootLayerAttachedViaChromeClient; | 762 RootLayerAttachment expectedAttachment = RootLayerAttachedViaChromeClient; |
822 if (expectedAttachment == m_rootLayerAttachment) | 763 if (expectedAttachment == m_rootLayerAttachment) |
823 return; | 764 return; |
824 | 765 |
825 if (!m_rootContentLayer) { | 766 if (!m_rootContentLayer) { |
826 m_rootContentLayer = GraphicsLayer::create(graphicsLayerFactory(), this)
; | 767 m_rootContentLayer = GraphicsLayer::create(graphicsLayerFactory(), this)
; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 void RenderLayerCompositor::destroyRootLayer() | 812 void RenderLayerCompositor::destroyRootLayer() |
872 { | 813 { |
873 if (!m_rootContentLayer) | 814 if (!m_rootContentLayer) |
874 return; | 815 return; |
875 | 816 |
876 detachRootLayer(); | 817 detachRootLayer(); |
877 | 818 |
878 if (m_layerForHorizontalScrollbar) { | 819 if (m_layerForHorizontalScrollbar) { |
879 m_layerForHorizontalScrollbar->removeFromParent(); | 820 m_layerForHorizontalScrollbar->removeFromParent(); |
880 m_layerForHorizontalScrollbar = nullptr; | 821 m_layerForHorizontalScrollbar = nullptr; |
881 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordina
tor()) | |
882 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_render
View.frameView(), HorizontalScrollbar); | |
883 if (Scrollbar* horizontalScrollbar = m_renderView.frameView()->verticalS
crollbar()) | |
884 m_renderView.frameView()->invalidateScrollbar(horizontalScrollbar, I
ntRect(IntPoint(0, 0), horizontalScrollbar->frameRect().size())); | |
885 } | 822 } |
886 | 823 |
887 if (m_layerForVerticalScrollbar) { | 824 if (m_layerForVerticalScrollbar) { |
888 m_layerForVerticalScrollbar->removeFromParent(); | 825 m_layerForVerticalScrollbar->removeFromParent(); |
889 m_layerForVerticalScrollbar = nullptr; | 826 m_layerForVerticalScrollbar = nullptr; |
890 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordina
tor()) | |
891 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(m_render
View.frameView(), VerticalScrollbar); | |
892 if (Scrollbar* verticalScrollbar = m_renderView.frameView()->verticalScr
ollbar()) | |
893 m_renderView.frameView()->invalidateScrollbar(verticalScrollbar, Int
Rect(IntPoint(0, 0), verticalScrollbar->frameRect().size())); | |
894 } | 827 } |
895 | 828 |
896 if (m_layerForScrollCorner) { | 829 if (m_layerForScrollCorner) { |
897 m_layerForScrollCorner = nullptr; | 830 m_layerForScrollCorner = nullptr; |
898 m_renderView.frameView()->invalidateScrollCorner(m_renderView.frameView(
)->scrollCornerRect()); | |
899 } | 831 } |
900 | 832 |
901 if (m_overflowControlsHostLayer) { | 833 if (m_overflowControlsHostLayer) { |
902 m_overflowControlsHostLayer = nullptr; | 834 m_overflowControlsHostLayer = nullptr; |
903 m_containerLayer = nullptr; | 835 m_containerLayer = nullptr; |
904 m_scrollLayer = nullptr; | 836 m_scrollLayer = nullptr; |
905 } | 837 } |
906 ASSERT(!m_scrollLayer); | 838 ASSERT(!m_scrollLayer); |
907 m_rootContentLayer = nullptr; | 839 m_rootContentLayer = nullptr; |
908 m_rootTransformLayer = nullptr; | 840 m_rootTransformLayer = nullptr; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 } else if (graphicsLayer == m_scrollLayer.get()) { | 939 } else if (graphicsLayer == m_scrollLayer.get()) { |
1008 name = "LocalFrame Scrolling Layer"; | 940 name = "LocalFrame Scrolling Layer"; |
1009 } else { | 941 } else { |
1010 ASSERT_NOT_REACHED(); | 942 ASSERT_NOT_REACHED(); |
1011 } | 943 } |
1012 | 944 |
1013 return name; | 945 return name; |
1014 } | 946 } |
1015 | 947 |
1016 } // namespace blink | 948 } // namespace blink |
OLD | NEW |