OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
6 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. |
8 * All rights reserved. | 8 * All rights reserved. |
9 * (C) 2007 Eric Seidel (eric@webkit.org) | 9 * (C) 2007 Eric Seidel (eric@webkit.org) |
10 * | 10 * |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
767 | 767 |
768 if (LayoutBox* layoutObject = layoutBox()) | 768 if (LayoutBox* layoutObject = layoutBox()) |
769 return adjustLayoutUnitForAbsoluteZoom( | 769 return adjustLayoutUnitForAbsoluteZoom( |
770 LayoutUnit(layoutObject->pixelSnappedClientHeight()), | 770 LayoutUnit(layoutObject->pixelSnappedClientHeight()), |
771 layoutObject->styleRef()) | 771 layoutObject->styleRef()) |
772 .round(); | 772 .round(); |
773 return 0; | 773 return 0; |
774 } | 774 } |
775 | 775 |
776 double Element::scrollLeft() { | 776 double Element::scrollLeft() { |
777 if (!inActiveDocument()) | |
chrishtr
2017/01/11 21:43:19
These were needed because updateStyleAndLayoutIgno
| |
778 return 0; | |
779 | |
777 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); | 780 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
778 | 781 |
779 if (document().scrollingElement() == this) { | 782 if (document().scrollingElementNoLayout() == this) { |
780 if (document().domWindow()) | 783 if (document().domWindow()) |
781 return document().domWindow()->scrollX(); | 784 return document().domWindow()->scrollX(); |
782 return 0; | 785 return 0; |
783 } | 786 } |
784 | 787 |
785 if (LayoutBox* box = layoutBox()) | 788 if (LayoutBox* box = layoutBox()) |
786 return adjustScrollForAbsoluteZoom(box->scrollLeft(), *box); | 789 return adjustScrollForAbsoluteZoom(box->scrollLeft(), *box); |
787 | 790 |
788 return 0; | 791 return 0; |
789 } | 792 } |
790 | 793 |
791 double Element::scrollTop() { | 794 double Element::scrollTop() { |
795 if (!inActiveDocument()) | |
796 return 0; | |
797 | |
792 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); | 798 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
793 | 799 |
794 if (document().scrollingElement() == this) { | 800 if (document().scrollingElementNoLayout() == this) { |
795 if (document().domWindow()) | 801 if (document().domWindow()) |
796 return document().domWindow()->scrollY(); | 802 return document().domWindow()->scrollY(); |
797 return 0; | 803 return 0; |
798 } | 804 } |
799 | 805 |
800 if (LayoutBox* box = layoutBox()) | 806 if (LayoutBox* box = layoutBox()) |
801 return adjustScrollForAbsoluteZoom(box->scrollTop(), *box); | 807 return adjustScrollForAbsoluteZoom(box->scrollTop(), *box); |
802 | 808 |
803 return 0; | 809 return 0; |
804 } | 810 } |
805 | 811 |
806 void Element::setScrollLeft(double newLeft) { | 812 void Element::setScrollLeft(double newLeft) { |
813 if (!inActiveDocument()) | |
814 return; | |
815 | |
807 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); | 816 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
808 | 817 |
809 newLeft = ScrollableArea::normalizeNonFiniteScroll(newLeft); | 818 newLeft = ScrollableArea::normalizeNonFiniteScroll(newLeft); |
810 | 819 |
811 if (document().scrollingElement() == this) { | 820 if (document().scrollingElementNoLayout() == this) { |
812 if (LocalDOMWindow* window = document().domWindow()) | 821 if (LocalDOMWindow* window = document().domWindow()) |
813 window->scrollTo(newLeft, window->scrollY()); | 822 window->scrollTo(newLeft, window->scrollY()); |
814 } else { | 823 } else { |
815 LayoutBox* box = layoutBox(); | 824 LayoutBox* box = layoutBox(); |
816 if (box) | 825 if (box) |
817 box->setScrollLeft( | 826 box->setScrollLeft( |
818 LayoutUnit::fromFloatRound(newLeft * box->style()->effectiveZoom())); | 827 LayoutUnit::fromFloatRound(newLeft * box->style()->effectiveZoom())); |
819 } | 828 } |
820 } | 829 } |
821 | 830 |
822 void Element::setScrollTop(double newTop) { | 831 void Element::setScrollTop(double newTop) { |
832 if (!inActiveDocument()) | |
833 return; | |
834 | |
823 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); | 835 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
824 | 836 |
825 newTop = ScrollableArea::normalizeNonFiniteScroll(newTop); | 837 newTop = ScrollableArea::normalizeNonFiniteScroll(newTop); |
826 | 838 |
827 if (document().scrollingElement() == this) { | 839 if (document().scrollingElementNoLayout() == this) { |
828 if (LocalDOMWindow* window = document().domWindow()) | 840 if (LocalDOMWindow* window = document().domWindow()) |
829 window->scrollTo(window->scrollX(), newTop); | 841 window->scrollTo(window->scrollX(), newTop); |
830 } else { | 842 } else { |
831 LayoutBox* box = layoutBox(); | 843 LayoutBox* box = layoutBox(); |
832 if (box) | 844 if (box) |
833 box->setScrollTop( | 845 box->setScrollTop( |
834 LayoutUnit::fromFloatRound(newTop * box->style()->effectiveZoom())); | 846 LayoutUnit::fromFloatRound(newTop * box->style()->effectiveZoom())); |
835 } | 847 } |
836 } | 848 } |
837 | 849 |
838 int Element::scrollWidth() { | 850 int Element::scrollWidth() { |
851 if (!inActiveDocument()) | |
852 return 0; | |
853 | |
839 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); | 854 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
840 | 855 |
841 if (document().scrollingElement() == this) { | 856 if (document().scrollingElementNoLayout() == this) { |
842 if (document().view()) | 857 if (document().view()) |
843 return adjustForAbsoluteZoom(document().view()->contentsWidth(), | 858 return adjustForAbsoluteZoom(document().view()->contentsWidth(), |
844 document().frame()->pageZoomFactor()); | 859 document().frame()->pageZoomFactor()); |
845 return 0; | 860 return 0; |
846 } | 861 } |
847 | 862 |
848 if (LayoutBox* box = layoutBox()) | 863 if (LayoutBox* box = layoutBox()) |
849 return adjustForAbsoluteZoom(box->pixelSnappedScrollWidth(), box); | 864 return adjustForAbsoluteZoom(box->pixelSnappedScrollWidth(), box); |
850 return 0; | 865 return 0; |
851 } | 866 } |
852 | 867 |
853 int Element::scrollHeight() { | 868 int Element::scrollHeight() { |
869 if (!inActiveDocument()) | |
870 return 0; | |
871 | |
854 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); | 872 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
855 | 873 |
856 if (document().scrollingElement() == this) { | 874 if (document().scrollingElementNoLayout() == this) { |
857 if (document().view()) | 875 if (document().view()) |
858 return adjustForAbsoluteZoom(document().view()->contentsHeight(), | 876 return adjustForAbsoluteZoom(document().view()->contentsHeight(), |
859 document().frame()->pageZoomFactor()); | 877 document().frame()->pageZoomFactor()); |
860 return 0; | 878 return 0; |
861 } | 879 } |
862 | 880 |
863 if (LayoutBox* box = layoutBox()) | 881 if (LayoutBox* box = layoutBox()) |
864 return adjustForAbsoluteZoom(box->pixelSnappedScrollHeight(), box); | 882 return adjustForAbsoluteZoom(box->pixelSnappedScrollHeight(), box); |
865 return 0; | 883 return 0; |
866 } | 884 } |
867 | 885 |
868 void Element::scrollBy(double x, double y) { | 886 void Element::scrollBy(double x, double y) { |
869 ScrollToOptions scrollToOptions; | 887 ScrollToOptions scrollToOptions; |
870 scrollToOptions.setLeft(x); | 888 scrollToOptions.setLeft(x); |
871 scrollToOptions.setTop(y); | 889 scrollToOptions.setTop(y); |
872 scrollBy(scrollToOptions); | 890 scrollBy(scrollToOptions); |
873 } | 891 } |
874 | 892 |
875 void Element::scrollBy(const ScrollToOptions& scrollToOptions) { | 893 void Element::scrollBy(const ScrollToOptions& scrollToOptions) { |
894 if (!inActiveDocument()) | |
895 return; | |
896 | |
876 // FIXME: This should be removed once scroll updates are processed only after | 897 // FIXME: This should be removed once scroll updates are processed only after |
877 // the compositing update. See http://crbug.com/420741. | 898 // the compositing update. See http://crbug.com/420741. |
878 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); | 899 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
879 | 900 |
880 if (document().scrollingElement() == this) { | 901 if (document().scrollingElementNoLayout() == this) { |
881 scrollFrameBy(scrollToOptions); | 902 scrollFrameBy(scrollToOptions); |
882 } else { | 903 } else { |
883 scrollLayoutBoxBy(scrollToOptions); | 904 scrollLayoutBoxBy(scrollToOptions); |
884 } | 905 } |
885 } | 906 } |
886 | 907 |
887 void Element::scrollTo(double x, double y) { | 908 void Element::scrollTo(double x, double y) { |
888 ScrollToOptions scrollToOptions; | 909 ScrollToOptions scrollToOptions; |
889 scrollToOptions.setLeft(x); | 910 scrollToOptions.setLeft(x); |
890 scrollToOptions.setTop(y); | 911 scrollToOptions.setTop(y); |
891 scrollTo(scrollToOptions); | 912 scrollTo(scrollToOptions); |
892 } | 913 } |
893 | 914 |
894 void Element::scrollTo(const ScrollToOptions& scrollToOptions) { | 915 void Element::scrollTo(const ScrollToOptions& scrollToOptions) { |
916 if (!inActiveDocument()) | |
917 return; | |
918 | |
895 // FIXME: This should be removed once scroll updates are processed only after | 919 // FIXME: This should be removed once scroll updates are processed only after |
896 // the compositing update. See http://crbug.com/420741. | 920 // the compositing update. See http://crbug.com/420741. |
897 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); | 921 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
898 | 922 |
899 if (document().scrollingElement() == this) { | 923 if (document().scrollingElementNoLayout() == this) { |
900 scrollFrameTo(scrollToOptions); | 924 scrollFrameTo(scrollToOptions); |
901 } else { | 925 } else { |
902 scrollLayoutBoxTo(scrollToOptions); | 926 scrollLayoutBoxTo(scrollToOptions); |
903 } | 927 } |
904 } | 928 } |
905 | 929 |
906 void Element::scrollLayoutBoxBy(const ScrollToOptions& scrollToOptions) { | 930 void Element::scrollLayoutBoxBy(const ScrollToOptions& scrollToOptions) { |
907 double left = | 931 double left = |
908 scrollToOptions.hasLeft() | 932 scrollToOptions.hasLeft() |
909 ? ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.left()) | 933 ? ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.left()) |
(...skipping 3200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4110 } | 4134 } |
4111 | 4135 |
4112 DEFINE_TRACE_WRAPPERS(Element) { | 4136 DEFINE_TRACE_WRAPPERS(Element) { |
4113 if (hasRareData()) { | 4137 if (hasRareData()) { |
4114 visitor->traceWrappers(elementRareData()); | 4138 visitor->traceWrappers(elementRareData()); |
4115 } | 4139 } |
4116 ContainerNode::traceWrappers(visitor); | 4140 ContainerNode::traceWrappers(visitor); |
4117 } | 4141 } |
4118 | 4142 |
4119 } // namespace blink | 4143 } // namespace blink |
OLD | NEW |