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) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
7 * Copyright (C) 2010 Google Inc. All rights reserved. | 7 * Copyright (C) 2010 Google Inc. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 FloatRect constrainingRect = computeStickyConstrainingRect(); | 751 FloatRect constrainingRect = computeStickyConstrainingRect(); |
752 PaintLayerScrollableArea* scrollableArea = ancestorOverflowLayer->getScrolla
bleArea(); | 752 PaintLayerScrollableArea* scrollableArea = ancestorOverflowLayer->getScrolla
bleArea(); |
753 | 753 |
754 // The sticky offset is physical, so we can just return the delta computed i
n absolute coords (though it may be wrong with transforms). | 754 // The sticky offset is physical, so we can just return the delta computed i
n absolute coords (though it may be wrong with transforms). |
755 // TODO: Force compositing input update if we ask for offset with stale comp
ositing inputs. | 755 // TODO: Force compositing input update if we ask for offset with stale comp
ositing inputs. |
756 if (!scrollableArea->stickyConstraintsMap().contains(layer())) | 756 if (!scrollableArea->stickyConstraintsMap().contains(layer())) |
757 return LayoutSize(); | 757 return LayoutSize(); |
758 return LayoutSize(scrollableArea->stickyConstraintsMap().get(layer()).comput
eStickyOffset(constrainingRect)); | 758 return LayoutSize(scrollableArea->stickyConstraintsMap().get(layer()).comput
eStickyOffset(constrainingRect)); |
759 } | 759 } |
760 | 760 |
761 LayoutPoint LayoutBoxModelObject::adjustedPositionRelativeToOffsetParent(const L
ayoutPoint& startPoint) const | 761 LayoutPoint LayoutBoxModelObject::adjustedPositionRelativeTo(const LayoutPoint&
startPoint, const Element* element) const |
762 { | 762 { |
763 // If the element is the HTML body element or doesn't have a parent | 763 // If the element is the HTML body element or doesn't have a parent |
764 // return 0 and stop this algorithm. | 764 // return 0 and stop this algorithm. |
765 if (isBody() || !parent()) | 765 if (isBody() || !parent()) |
766 return LayoutPoint(); | 766 return LayoutPoint(); |
767 | 767 |
768 LayoutPoint referencePoint = startPoint; | 768 LayoutPoint referencePoint = startPoint; |
769 referencePoint.move(parent()->columnOffset(referencePoint)); | 769 referencePoint.move(parent()->columnOffset(referencePoint)); |
770 | 770 |
771 // If the offsetParent of the element is null, or is the HTML body element, | 771 // If the base element is null, return the distance between the canvas origi
n and |
772 // return the distance between the canvas origin and the left border edge | 772 // the left border edge of the element and stop this algorithm. |
773 // of the element and stop this algorithm. | |
774 Element* element = offsetParent(); | |
775 if (!element) | 773 if (!element) |
776 return referencePoint; | 774 return referencePoint; |
777 | 775 |
778 if (const LayoutBoxModelObject* offsetParent = element->layoutBoxModelObject
()) { | 776 if (const LayoutBoxModelObject* offsetParent = element->layoutBoxModelObject
()) { |
779 if (offsetParent->isBox() && !offsetParent->isBody()) | 777 if (offsetParent->isBox() && !offsetParent->isBody()) |
780 referencePoint.move(-toLayoutBox(offsetParent)->borderLeft(), -toLay
outBox(offsetParent)->borderTop()); | 778 referencePoint.move(-toLayoutBox(offsetParent)->borderLeft(), -toLay
outBox(offsetParent)->borderTop()); |
781 if (!isOutOfFlowPositioned() || flowThreadContainingBlock()) { | 779 if (!isOutOfFlowPositioned() || flowThreadContainingBlock()) { |
782 if (isInFlowPositioned()) | 780 if (isInFlowPositioned()) |
783 referencePoint.move(offsetForInFlowPosition()); | 781 referencePoint.move(offsetForInFlowPosition()); |
784 | 782 |
(...skipping 19 matching lines...) Expand all Loading... |
804 { | 802 { |
805 if (isRelPositioned()) | 803 if (isRelPositioned()) |
806 return relativePositionOffset(); | 804 return relativePositionOffset(); |
807 | 805 |
808 if (isStickyPositioned()) | 806 if (isStickyPositioned()) |
809 return stickyPositionOffset(); | 807 return stickyPositionOffset(); |
810 | 808 |
811 return LayoutSize(); | 809 return LayoutSize(); |
812 } | 810 } |
813 | 811 |
814 LayoutUnit LayoutBoxModelObject::offsetLeft() const | 812 LayoutUnit LayoutBoxModelObject::offsetLeft(const Element* parent) const |
815 { | 813 { |
816 // Note that LayoutInline and LayoutBox override this to pass a different | 814 // Note that LayoutInline and LayoutBox override this to pass a different |
817 // startPoint to adjustedPositionRelativeToOffsetParent. | 815 // startPoint to adjustedPositionRelativeTo. |
818 return adjustedPositionRelativeToOffsetParent(LayoutPoint()).x(); | 816 return adjustedPositionRelativeTo(LayoutPoint(), parent).x(); |
819 } | 817 } |
820 | 818 |
821 LayoutUnit LayoutBoxModelObject::offsetTop() const | 819 LayoutUnit LayoutBoxModelObject::offsetTop(const Element* parent) const |
822 { | 820 { |
823 // Note that LayoutInline and LayoutBox override this to pass a different | 821 // Note that LayoutInline and LayoutBox override this to pass a different |
824 // startPoint to adjustedPositionRelativeToOffsetParent. | 822 // startPoint to adjustedPositionRelativeTo. |
825 return adjustedPositionRelativeToOffsetParent(LayoutPoint()).y(); | 823 return adjustedPositionRelativeTo(LayoutPoint(), parent).y(); |
826 } | 824 } |
827 | 825 |
828 int LayoutBoxModelObject::pixelSnappedOffsetWidth() const | 826 int LayoutBoxModelObject::pixelSnappedOffsetWidth(const Element* parent) const |
829 { | 827 { |
830 return snapSizeToPixel(offsetWidth(), offsetLeft()); | 828 return snapSizeToPixel(offsetWidth(), offsetLeft(parent)); |
831 } | 829 } |
832 | 830 |
833 int LayoutBoxModelObject::pixelSnappedOffsetHeight() const | 831 int LayoutBoxModelObject::pixelSnappedOffsetHeight(const Element* parent) const |
834 { | 832 { |
835 return snapSizeToPixel(offsetHeight(), offsetTop()); | 833 return snapSizeToPixel(offsetHeight(), offsetTop(parent)); |
836 } | 834 } |
837 | 835 |
838 LayoutUnit LayoutBoxModelObject::computedCSSPadding(const Length& padding) const | 836 LayoutUnit LayoutBoxModelObject::computedCSSPadding(const Length& padding) const |
839 { | 837 { |
840 LayoutUnit w; | 838 LayoutUnit w; |
841 if (padding.hasPercent()) | 839 if (padding.hasPercent()) |
842 w = containingBlockLogicalWidthForContent(); | 840 w = containingBlockLogicalWidthForContent(); |
843 return minimumValueForLength(padding, w); | 841 return minimumValueForLength(padding, w); |
844 } | 842 } |
845 | 843 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 if (rootElementStyle->hasBackground()) | 1124 if (rootElementStyle->hasBackground()) |
1127 return false; | 1125 return false; |
1128 | 1126 |
1129 if (node() != document().firstBodyElement()) | 1127 if (node() != document().firstBodyElement()) |
1130 return false; | 1128 return false; |
1131 | 1129 |
1132 return true; | 1130 return true; |
1133 } | 1131 } |
1134 | 1132 |
1135 } // namespace blink | 1133 } // namespace blink |
OLD | NEW |