Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp

Issue 2051703002: Implement closed shadow adjustment for Element.offsetParent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re-revert the previous and check position:fixed in layout code. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 FloatRect constrainingRect = computeStickyConstrainingRect(); 740 FloatRect constrainingRect = computeStickyConstrainingRect();
741 PaintLayerScrollableArea* scrollableArea = ancestorOverflowLayer->getScrolla bleArea(); 741 PaintLayerScrollableArea* scrollableArea = ancestorOverflowLayer->getScrolla bleArea();
742 742
743 // The sticky offset is physical, so we can just return the delta computed i n absolute coords (though it may be wrong with transforms). 743 // The sticky offset is physical, so we can just return the delta computed i n absolute coords (though it may be wrong with transforms).
744 // TODO: Force compositing input update if we ask for offset with stale comp ositing inputs. 744 // TODO: Force compositing input update if we ask for offset with stale comp ositing inputs.
745 if (!scrollableArea->stickyConstraintsMap().contains(layer())) 745 if (!scrollableArea->stickyConstraintsMap().contains(layer()))
746 return LayoutSize(); 746 return LayoutSize();
747 return LayoutSize(scrollableArea->stickyConstraintsMap().get(layer()).comput eStickyOffset(constrainingRect)); 747 return LayoutSize(scrollableArea->stickyConstraintsMap().get(layer()).comput eStickyOffset(constrainingRect));
748 } 748 }
749 749
750 LayoutPoint LayoutBoxModelObject::adjustedPositionRelativeToOffsetParent(const L ayoutPoint& startPoint) const 750 LayoutPoint LayoutBoxModelObject::adjustedPositionRelativeTo(const LayoutPoint& startPoint, const Element* element) const
751 { 751 {
752 // If the element is the HTML body element or doesn't have a parent 752 // If the element is the HTML body element or doesn't have a parent
753 // return 0 and stop this algorithm. 753 // return 0 and stop this algorithm.
754 if (isBody() || !parent()) 754 if (isBody() || !parent())
755 return LayoutPoint(); 755 return LayoutPoint();
756 756
757 LayoutPoint referencePoint = startPoint; 757 LayoutPoint referencePoint = startPoint;
758 referencePoint.move(parent()->columnOffset(referencePoint)); 758 referencePoint.move(parent()->columnOffset(referencePoint));
759 759
760 // If the offsetParent of the element is null, or is the HTML body element, 760 // If the base element is null, return the distance between the canvas origi n and
761 // return the distance between the canvas origin and the left border edge 761 // the left border edge of the element and stop this algorithm.
762 // of the element and stop this algorithm.
763 Element* element = offsetParent();
764 if (!element) 762 if (!element)
765 return referencePoint; 763 return referencePoint;
766 764
767 if (const LayoutBoxModelObject* offsetParent = element->layoutBoxModelObject ()) { 765 if (const LayoutBoxModelObject* offsetParent = element->layoutBoxModelObject ()) {
768 if (offsetParent->isBox() && !offsetParent->isBody()) 766 if (offsetParent->isBox() && !offsetParent->isBody())
769 referencePoint.move(-toLayoutBox(offsetParent)->borderLeft(), -toLay outBox(offsetParent)->borderTop()); 767 referencePoint.move(-toLayoutBox(offsetParent)->borderLeft(), -toLay outBox(offsetParent)->borderTop());
770 if (!isOutOfFlowPositioned() || flowThreadContainingBlock()) { 768 if (!isOutOfFlowPositioned() || flowThreadContainingBlock()) {
771 if (isInFlowPositioned()) 769 if (isInFlowPositioned())
772 referencePoint.move(offsetForInFlowPosition()); 770 referencePoint.move(offsetForInFlowPosition());
773 771
(...skipping 19 matching lines...) Expand all
793 { 791 {
794 if (isRelPositioned()) 792 if (isRelPositioned())
795 return relativePositionOffset(); 793 return relativePositionOffset();
796 794
797 if (isStickyPositioned()) 795 if (isStickyPositioned())
798 return stickyPositionOffset(); 796 return stickyPositionOffset();
799 797
800 return LayoutSize(); 798 return LayoutSize();
801 } 799 }
802 800
803 LayoutUnit LayoutBoxModelObject::offsetLeft() const 801 LayoutUnit LayoutBoxModelObject::offsetLeft(const Element* parent) const
804 { 802 {
805 // Note that LayoutInline and LayoutBox override this to pass a different 803 // Note that LayoutInline and LayoutBox override this to pass a different
806 // startPoint to adjustedPositionRelativeToOffsetParent. 804 // startPoint to adjustedPositionRelativeTo.
807 return adjustedPositionRelativeToOffsetParent(LayoutPoint()).x(); 805 return adjustedPositionRelativeTo(LayoutPoint(), parent).x();
808 } 806 }
809 807
810 LayoutUnit LayoutBoxModelObject::offsetTop() const 808 LayoutUnit LayoutBoxModelObject::offsetTop(const Element* parent) const
811 { 809 {
812 // Note that LayoutInline and LayoutBox override this to pass a different 810 // Note that LayoutInline and LayoutBox override this to pass a different
813 // startPoint to adjustedPositionRelativeToOffsetParent. 811 // startPoint to adjustedPositionRelativeTo.
814 return adjustedPositionRelativeToOffsetParent(LayoutPoint()).y(); 812 return adjustedPositionRelativeTo(LayoutPoint(), parent).y();
815 } 813 }
816 814
817 int LayoutBoxModelObject::pixelSnappedOffsetWidth() const 815 int LayoutBoxModelObject::pixelSnappedOffsetWidth(const Element* parent) const
818 { 816 {
819 return snapSizeToPixel(offsetWidth(), offsetLeft()); 817 return snapSizeToPixel(offsetWidth(), offsetLeft(parent));
820 } 818 }
821 819
822 int LayoutBoxModelObject::pixelSnappedOffsetHeight() const 820 int LayoutBoxModelObject::pixelSnappedOffsetHeight(const Element* parent) const
823 { 821 {
824 return snapSizeToPixel(offsetHeight(), offsetTop()); 822 return snapSizeToPixel(offsetHeight(), offsetTop(parent));
825 } 823 }
826 824
827 LayoutUnit LayoutBoxModelObject::computedCSSPadding(const Length& padding) const 825 LayoutUnit LayoutBoxModelObject::computedCSSPadding(const Length& padding) const
828 { 826 {
829 LayoutUnit w; 827 LayoutUnit w;
830 if (padding.hasPercent()) 828 if (padding.hasPercent())
831 w = containingBlockLogicalWidthForContent(); 829 w = containingBlockLogicalWidthForContent();
832 return minimumValueForLength(padding, w); 830 return minimumValueForLength(padding, w);
833 } 831 }
834 832
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 if (rootElementStyle->hasBackground()) 1113 if (rootElementStyle->hasBackground())
1116 return false; 1114 return false;
1117 1115
1118 if (node() != document().firstBodyElement()) 1116 if (node() != document().firstBodyElement())
1119 return false; 1117 return false;
1120 1118
1121 return true; 1119 return true;
1122 } 1120 }
1123 1121
1124 } // namespace blink 1122 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698