| 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 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 // compositing inputs. | 972 // compositing inputs. |
| 973 if (!scrollableArea->stickyConstraintsMap().contains(layer())) | 973 if (!scrollableArea->stickyConstraintsMap().contains(layer())) |
| 974 return LayoutSize(); | 974 return LayoutSize(); |
| 975 return LayoutSize( | 975 return LayoutSize( |
| 976 scrollableArea->stickyConstraintsMap().get(layer()).computeStickyOffset( | 976 scrollableArea->stickyConstraintsMap().get(layer()).computeStickyOffset( |
| 977 constrainingRect)); | 977 constrainingRect)); |
| 978 } | 978 } |
| 979 | 979 |
| 980 LayoutPoint LayoutBoxModelObject::adjustedPositionRelativeTo( | 980 LayoutPoint LayoutBoxModelObject::adjustedPositionRelativeTo( |
| 981 const LayoutPoint& startPoint, | 981 const LayoutPoint& startPoint, |
| 982 const Element* element) const { | 982 const Element* offsetParent) const { |
| 983 // If the element is the HTML body element or doesn't have a parent | 983 // If the element is the HTML body element or doesn't have a parent |
| 984 // return 0 and stop this algorithm. | 984 // return 0 and stop this algorithm. |
| 985 if (isBody() || !parent()) | 985 if (isBody() || !parent()) |
| 986 return LayoutPoint(); | 986 return LayoutPoint(); |
| 987 | 987 |
| 988 LayoutPoint referencePoint = startPoint; | 988 LayoutPoint referencePoint = startPoint; |
| 989 | 989 |
| 990 // If the base element is null, return the distance between the canvas origin | 990 // If the offsetParent is null, return the distance between the canvas origin |
| 991 // and the left border edge of the element and stop this algorithm. | 991 // and the left/top border edge of the element and stop this algorithm. |
| 992 if (!element) | 992 if (!offsetParent) |
| 993 return referencePoint; | 993 return referencePoint; |
| 994 | 994 |
| 995 if (const LayoutBoxModelObject* offsetParent = | 995 if (const LayoutBoxModelObject* offsetParentObject = |
| 996 element->layoutBoxModelObject()) { | 996 offsetParent->layoutBoxModelObject()) { |
| 997 if (!isOutOfFlowPositioned()) { | 997 if (!isOutOfFlowPositioned()) { |
| 998 if (isInFlowPositioned()) | 998 if (isInFlowPositioned()) |
| 999 referencePoint.move(offsetForInFlowPosition()); | 999 referencePoint.move(offsetForInFlowPosition()); |
| 1000 | 1000 |
| 1001 // Note that we may fail to find |offsetParent| while walking the | 1001 // Note that we may fail to find |offsetParent| while walking the |
| 1002 // container chain, if |offsetParent| is an inline split into | 1002 // container chain, if |offsetParent| is an inline split into |
| 1003 // continuations: <body style="display:inline;" id="offsetParent"> | 1003 // continuations: <body style="display:inline;" id="offsetParent"> |
| 1004 // <div id="this"> | 1004 // <div id="this"> |
| 1005 // This is why we have to do a nullptr check here. | 1005 // This is why we have to do a nullptr check here. |
| 1006 // offset(Left|Top) is generally broken when offsetParent is inline. | |
| 1007 for (const LayoutObject* current = container(); | 1006 for (const LayoutObject* current = container(); |
| 1008 current && current->node() != element; | 1007 current && current->node() != offsetParent; |
| 1009 current = current->container()) { | 1008 current = current->container()) { |
| 1010 // FIXME: What are we supposed to do inside SVG content? | 1009 // FIXME: What are we supposed to do inside SVG content? |
| 1011 referencePoint.move(current->columnOffset(referencePoint)); | 1010 referencePoint.move(current->columnOffset(referencePoint)); |
| 1012 if (current->isBox() && !current->isTableRow()) | 1011 if (current->isBox() && !current->isTableRow()) |
| 1013 referencePoint.moveBy(toLayoutBox(current)->topLeftLocation()); | 1012 referencePoint.moveBy(toLayoutBox(current)->topLeftLocation()); |
| 1014 } | 1013 } |
| 1015 | 1014 |
| 1016 if (offsetParent->isBox() && offsetParent->isBody() && | 1015 if (offsetParentObject->isBox() && offsetParentObject->isBody() && |
| 1017 !offsetParent->isPositioned()) | 1016 !offsetParentObject->isPositioned()) { |
| 1018 referencePoint.moveBy(toLayoutBox(offsetParent)->topLeftLocation()); | 1017 referencePoint.moveBy( |
| 1018 toLayoutBox(offsetParentObject)->topLeftLocation()); |
| 1019 } |
| 1019 } | 1020 } |
| 1020 if (offsetParent->isBox() && !offsetParent->isBody()) | 1021 |
| 1021 referencePoint.move(-toLayoutBox(offsetParent)->borderLeft(), | 1022 if (offsetParentObject->isLayoutInline()) { |
| 1022 -toLayoutBox(offsetParent)->borderTop()); | 1023 const LayoutInline* inlineParent = toLayoutInline(offsetParentObject); |
| 1024 |
| 1025 if (isBox() && style()->position() == AbsolutePosition && |
| 1026 inlineParent->isInFlowPositioned()) { |
| 1027 // Offset for absolute elements with inline parent is a special |
| 1028 // case in the CSS spec |
| 1029 referencePoint += |
| 1030 inlineParent->offsetForInFlowPositionedInline(*toLayoutBox(this)); |
| 1031 } |
| 1032 |
| 1033 referencePoint -= inlineParent->firstLineBoxTopLeft(); |
| 1034 } |
| 1035 |
| 1036 if (offsetParentObject->isBox() && !offsetParentObject->isBody()) { |
| 1037 referencePoint.move(-toLayoutBox(offsetParentObject)->borderLeft(), |
| 1038 -toLayoutBox(offsetParentObject)->borderTop()); |
| 1039 } |
| 1023 } | 1040 } |
| 1024 | 1041 |
| 1025 return referencePoint; | 1042 return referencePoint; |
| 1026 } | 1043 } |
| 1027 | 1044 |
| 1028 LayoutSize LayoutBoxModelObject::offsetForInFlowPosition() const { | 1045 LayoutSize LayoutBoxModelObject::offsetForInFlowPosition() const { |
| 1029 if (isRelPositioned()) | 1046 if (isRelPositioned()) |
| 1030 return relativePositionOffset(); | 1047 return relativePositionOffset(); |
| 1031 | 1048 |
| 1032 if (isStickyPositioned()) | 1049 if (isStickyPositioned()) |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1376 if (rootElementStyle->hasBackground()) | 1393 if (rootElementStyle->hasBackground()) |
| 1377 return false; | 1394 return false; |
| 1378 | 1395 |
| 1379 if (node() != document().firstBodyElement()) | 1396 if (node() != document().firstBodyElement()) |
| 1380 return false; | 1397 return false; |
| 1381 | 1398 |
| 1382 return true; | 1399 return true; |
| 1383 } | 1400 } |
| 1384 | 1401 |
| 1385 } // namespace blink | 1402 } // namespace blink |
| OLD | NEW |