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

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

Issue 2251443002: Correct offsetLeft and offsetTop calculation for column-span:all. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Need to keep the nullptr check, thanks to inline continuations. Created 4 years, 4 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/multicol/span/offset-properties.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 } 770 }
771 771
772 LayoutPoint LayoutBoxModelObject::adjustedPositionRelativeTo(const LayoutPoint& startPoint, const Element* element) const 772 LayoutPoint LayoutBoxModelObject::adjustedPositionRelativeTo(const LayoutPoint& startPoint, const Element* element) const
773 { 773 {
774 // If the element is the HTML body element or doesn't have a parent 774 // If the element is the HTML body element or doesn't have a parent
775 // return 0 and stop this algorithm. 775 // return 0 and stop this algorithm.
776 if (isBody() || !parent()) 776 if (isBody() || !parent())
777 return LayoutPoint(); 777 return LayoutPoint();
778 778
779 LayoutPoint referencePoint = startPoint; 779 LayoutPoint referencePoint = startPoint;
780 referencePoint.move(parent()->columnOffset(referencePoint));
781 780
782 // If the base element is null, return the distance between the canvas origi n and 781 // If the base element is null, return the distance between the canvas origi n and
783 // the left border edge of the element and stop this algorithm. 782 // the left border edge of the element and stop this algorithm.
784 if (!element) 783 if (!element)
785 return referencePoint; 784 return referencePoint;
786 785
787 if (const LayoutBoxModelObject* offsetParent = element->layoutBoxModelObject ()) { 786 if (const LayoutBoxModelObject* offsetParent = element->layoutBoxModelObject ()) {
788 if (offsetParent->isBox() && !offsetParent->isBody()) 787 if (!isOutOfFlowPositioned()) {
789 referencePoint.move(-toLayoutBox(offsetParent)->borderLeft(), -toLay outBox(offsetParent)->borderTop());
790 if (!isOutOfFlowPositioned() || flowThreadContainingBlock()) {
791 if (isInFlowPositioned()) 788 if (isInFlowPositioned())
792 referencePoint.move(offsetForInFlowPosition()); 789 referencePoint.move(offsetForInFlowPosition());
793 790
794 LayoutObject* current; 791 // Note that we may fail to find |offsetParent| while walking the co ntainer chain, if
795 for (current = parent(); current != offsetParent && current->parent( ); current = current->parent()) { 792 // |offsetParent| is an inline split into continuations.
793 // <body style="display:inline;" id="offsetParent"><div></div><span id="this">
794 // This is why we have to do a nullptr check here.
795 // offset(Left|Top) is generally broken when offsetParent is inline.
796 for (const LayoutObject* current = container(); current && current ! = offsetParent; current = current->container()) {
796 // FIXME: What are we supposed to do inside SVG content? 797 // FIXME: What are we supposed to do inside SVG content?
797 if (!isOutOfFlowPositioned()) { 798 referencePoint.move(current->columnOffset(referencePoint));
798 if (current->isBox() && !current->isTableRow()) 799 if (current->isBox() && !current->isTableRow())
799 referencePoint.moveBy(toLayoutBox(current)->topLeftLocat ion()); 800 referencePoint.moveBy(toLayoutBox(current)->topLeftLocation( ));
800 referencePoint.move(current->parent()->columnOffset(referenc ePoint));
801 }
802 } 801 }
803 802
804 if (offsetParent->isBox() && offsetParent->isBody() && !offsetParent ->isPositioned()) 803 if (offsetParent->isBox() && offsetParent->isBody() && !offsetParent ->isPositioned())
805 referencePoint.moveBy(toLayoutBox(offsetParent)->topLeftLocation ()); 804 referencePoint.moveBy(toLayoutBox(offsetParent)->topLeftLocation ());
806 } 805 }
806 if (offsetParent->isBox() && !offsetParent->isBody())
807 referencePoint.move(-toLayoutBox(offsetParent)->borderLeft(), -toLay outBox(offsetParent)->borderTop());
807 } 808 }
808 809
809 return referencePoint; 810 return referencePoint;
810 } 811 }
811 812
812 LayoutSize LayoutBoxModelObject::offsetForInFlowPosition() const 813 LayoutSize LayoutBoxModelObject::offsetForInFlowPosition() const
813 { 814 {
814 if (isRelPositioned()) 815 if (isRelPositioned())
815 return relativePositionOffset(); 816 return relativePositionOffset();
816 817
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 if (rootElementStyle->hasBackground()) 1136 if (rootElementStyle->hasBackground())
1136 return false; 1137 return false;
1137 1138
1138 if (node() != document().firstBodyElement()) 1139 if (node() != document().firstBodyElement())
1139 return false; 1140 return false;
1140 1141
1141 return true; 1142 return true;
1142 } 1143 }
1143 1144
1144 } // namespace blink 1145 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/multicol/span/offset-properties.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698