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 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 FloatRect constrainingRect = computeStickyConstrainingRect(); | 737 FloatRect constrainingRect = computeStickyConstrainingRect(); |
738 PaintLayerScrollableArea* scrollableArea = ancestorOverflowLayer->getScrolla
bleArea(); | 738 PaintLayerScrollableArea* scrollableArea = ancestorOverflowLayer->getScrolla
bleArea(); |
739 | 739 |
740 // The sticky offset is physical, so we can just return the delta computed i
n absolute coords (though it may be wrong with transforms). | 740 // The sticky offset is physical, so we can just return the delta computed i
n absolute coords (though it may be wrong with transforms). |
741 // TODO: Force compositing input update if we ask for offset with stale comp
ositing inputs. | 741 // TODO: Force compositing input update if we ask for offset with stale comp
ositing inputs. |
742 if (!scrollableArea->stickyConstraintsMap().contains(layer())) | 742 if (!scrollableArea->stickyConstraintsMap().contains(layer())) |
743 return LayoutSize(); | 743 return LayoutSize(); |
744 return LayoutSize(scrollableArea->stickyConstraintsMap().get(layer()).comput
eStickyOffset(constrainingRect)); | 744 return LayoutSize(scrollableArea->stickyConstraintsMap().get(layer()).comput
eStickyOffset(constrainingRect)); |
745 } | 745 } |
746 | 746 |
747 LayoutPoint LayoutBoxModelObject::adjustedPositionRelativeToOffsetParent(const L
ayoutPoint& startPoint) const | 747 LayoutPoint LayoutBoxModelObject::adjustedPositionRelativeTo(const LayoutPoint&
startPoint, const Element* element) const |
748 { | 748 { |
749 // If the element is the HTML body element or doesn't have a parent | 749 // If the element is the HTML body element or doesn't have a parent |
750 // return 0 and stop this algorithm. | 750 // return 0 and stop this algorithm. |
751 if (isBody() || !parent()) | 751 if (isBody() || !parent()) |
752 return LayoutPoint(); | 752 return LayoutPoint(); |
753 | 753 |
754 LayoutPoint referencePoint = startPoint; | 754 LayoutPoint referencePoint = startPoint; |
755 referencePoint.move(parent()->columnOffset(referencePoint)); | 755 referencePoint.move(parent()->columnOffset(referencePoint)); |
756 | 756 |
757 // If the offsetParent of the element is null, or is the HTML body element, | 757 // If the base element is null, return the distance between the canvas origi
n and |
758 // return the distance between the canvas origin and the left border edge | 758 // the left border edge of the element and stop this algorithm. |
759 // of the element and stop this algorithm. | |
760 Element* element = offsetParent(); | |
761 if (!element) | 759 if (!element) |
762 return referencePoint; | 760 return referencePoint; |
763 | 761 |
764 if (const LayoutBoxModelObject* offsetParent = element->layoutBoxModelObject
()) { | 762 if (const LayoutBoxModelObject* offsetParent = element->layoutBoxModelObject
()) { |
765 if (offsetParent->isBox() && !offsetParent->isBody()) | 763 if (offsetParent->isBox() && !offsetParent->isBody()) |
766 referencePoint.move(-toLayoutBox(offsetParent)->borderLeft(), -toLay
outBox(offsetParent)->borderTop()); | 764 referencePoint.move(-toLayoutBox(offsetParent)->borderLeft(), -toLay
outBox(offsetParent)->borderTop()); |
767 if (!isOutOfFlowPositioned() || flowThreadContainingBlock()) { | 765 if (!isOutOfFlowPositioned() || flowThreadContainingBlock()) { |
768 if (isInFlowPositioned()) | 766 if (isInFlowPositioned()) |
769 referencePoint.move(offsetForInFlowPosition()); | 767 referencePoint.move(offsetForInFlowPosition()); |
770 | 768 |
(...skipping 19 matching lines...) Expand all Loading... |
790 { | 788 { |
791 if (isRelPositioned()) | 789 if (isRelPositioned()) |
792 return relativePositionOffset(); | 790 return relativePositionOffset(); |
793 | 791 |
794 if (isStickyPositioned()) | 792 if (isStickyPositioned()) |
795 return stickyPositionOffset(); | 793 return stickyPositionOffset(); |
796 | 794 |
797 return LayoutSize(); | 795 return LayoutSize(); |
798 } | 796 } |
799 | 797 |
800 LayoutUnit LayoutBoxModelObject::offsetLeft() const | 798 LayoutUnit LayoutBoxModelObject::offsetLeft(const Element* parent) const |
801 { | 799 { |
802 // Note that LayoutInline and LayoutBox override this to pass a different | 800 // Note that LayoutInline and LayoutBox override this to pass a different |
803 // startPoint to adjustedPositionRelativeToOffsetParent. | 801 // startPoint to adjustedPositionRelativeTo. |
804 return adjustedPositionRelativeToOffsetParent(LayoutPoint()).x(); | 802 return adjustedPositionRelativeTo(LayoutPoint(), parent).x(); |
805 } | 803 } |
806 | 804 |
807 LayoutUnit LayoutBoxModelObject::offsetTop() const | 805 LayoutUnit LayoutBoxModelObject::offsetTop(const Element* parent) const |
808 { | 806 { |
809 // Note that LayoutInline and LayoutBox override this to pass a different | 807 // Note that LayoutInline and LayoutBox override this to pass a different |
810 // startPoint to adjustedPositionRelativeToOffsetParent. | 808 // startPoint to adjustedPositionRelativeTo. |
811 return adjustedPositionRelativeToOffsetParent(LayoutPoint()).y(); | 809 return adjustedPositionRelativeTo(LayoutPoint(), parent).y(); |
812 } | 810 } |
813 | 811 |
814 int LayoutBoxModelObject::pixelSnappedOffsetWidth() const | 812 int LayoutBoxModelObject::pixelSnappedOffsetWidth(const Element* parent) const |
815 { | 813 { |
816 return snapSizeToPixel(offsetWidth(), offsetLeft()); | 814 return snapSizeToPixel(offsetWidth(), offsetLeft(parent)); |
817 } | 815 } |
818 | 816 |
819 int LayoutBoxModelObject::pixelSnappedOffsetHeight() const | 817 int LayoutBoxModelObject::pixelSnappedOffsetHeight(const Element* parent) const |
820 { | 818 { |
821 return snapSizeToPixel(offsetHeight(), offsetTop()); | 819 return snapSizeToPixel(offsetHeight(), offsetTop(parent)); |
822 } | 820 } |
823 | 821 |
824 LayoutUnit LayoutBoxModelObject::computedCSSPadding(const Length& padding) const | 822 LayoutUnit LayoutBoxModelObject::computedCSSPadding(const Length& padding) const |
825 { | 823 { |
826 LayoutUnit w; | 824 LayoutUnit w; |
827 if (padding.hasPercent()) | 825 if (padding.hasPercent()) |
828 w = containingBlockLogicalWidthForContent(); | 826 w = containingBlockLogicalWidthForContent(); |
829 return minimumValueForLength(padding, w); | 827 return minimumValueForLength(padding, w); |
830 } | 828 } |
831 | 829 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 if (rootElementStyle->hasBackground()) | 1110 if (rootElementStyle->hasBackground()) |
1113 return false; | 1111 return false; |
1114 | 1112 |
1115 if (node() != document().firstBodyElement()) | 1113 if (node() != document().firstBodyElement()) |
1116 return false; | 1114 return false; |
1117 | 1115 |
1118 return true; | 1116 return true; |
1119 } | 1117 } |
1120 | 1118 |
1121 } // namespace blink | 1119 } // namespace blink |
OLD | NEW |