Index: third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp |
diff --git a/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp b/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp |
index 653dffb1188e470df8c63354f5ee628f2b27cf94..5d34008cc8094dd37912a4ab0a7e91947488fc01 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp |
@@ -990,7 +990,7 @@ LayoutSize LayoutBoxModelObject::stickyPositionOffset() const { |
LayoutPoint LayoutBoxModelObject::adjustedPositionRelativeTo( |
const LayoutPoint& startPoint, |
- const Element* element) const { |
+ const Element* offsetParent) const { |
// If the element is the HTML body element or doesn't have a parent |
// return 0 and stop this algorithm. |
if (isBody() || !parent()) |
@@ -998,13 +998,13 @@ LayoutPoint LayoutBoxModelObject::adjustedPositionRelativeTo( |
LayoutPoint referencePoint = startPoint; |
- // If the base element is null, return the distance between the canvas origin |
- // and the left border edge of the element and stop this algorithm. |
- if (!element) |
+ // If the offsetParent is null, return the distance between the canvas origin |
+ // and the left/top border edge of the element and stop this algorithm. |
+ if (!offsetParent) |
return referencePoint; |
- if (const LayoutBoxModelObject* offsetParent = |
- element->layoutBoxModelObject()) { |
+ if (const LayoutBoxModelObject* offsetParentObject = |
+ offsetParent->layoutBoxModelObject()) { |
if (!isOutOfFlowPositioned()) { |
if (isInFlowPositioned()) |
referencePoint.move(offsetForInFlowPosition()); |
@@ -1014,22 +1014,36 @@ LayoutPoint LayoutBoxModelObject::adjustedPositionRelativeTo( |
// continuations: <body style="display:inline;" id="offsetParent"><div> |
// </div><span id="this"> |
// This is why we have to do a nullptr check here. |
- // offset(Left|Top) is generally broken when offsetParent is inline. |
for (const LayoutObject* current = container(); |
- current && current != offsetParent; current = current->container()) { |
+ current && current != offsetParentObject; |
+ current = current->container()) { |
// FIXME: What are we supposed to do inside SVG content? |
referencePoint.move(current->columnOffset(referencePoint)); |
if (current->isBox() && !current->isTableRow()) |
referencePoint.moveBy(toLayoutBox(current)->topLeftLocation()); |
} |
- if (offsetParent->isBox() && offsetParent->isBody() && |
- !offsetParent->isPositioned()) |
- referencePoint.moveBy(toLayoutBox(offsetParent)->topLeftLocation()); |
+ if (offsetParentObject->isBox() && offsetParentObject->isBody() && |
+ !offsetParentObject->isPositioned()) |
+ referencePoint += toLayoutBox(offsetParentObject)->topLeftLocation(); |
atotic
2016/10/25 19:28:58
Why replace moveBy with '+='?
moveBy is used thr
Karl Øygard
2016/10/26 11:27:04
It was just done to conserve line space for cosmet
|
+ } |
+ |
+ if (offsetParentObject->isLayoutInline()) { |
+ const LayoutInline* inlineParent = toLayoutInline(offsetParentObject); |
atotic
2016/10/25 19:28:58
I am not very familiar with this code.
Can you e
Karl Øygard
2016/10/26 11:27:04
This covers the case when offsetParent is an inlin
|
+ |
+ referencePoint -= inlineParent->firstLineBoxTopLeft(); |
+ |
+ if (isBox() && style()->position() == AbsolutePosition && |
+ inlineParent->isInFlowPositioned()) { |
+ referencePoint += |
+ inlineParent->offsetForInFlowPositionedInline(*toLayoutBox(this)); |
+ } |
+ } |
+ |
+ if (offsetParentObject->isBox() && !offsetParentObject->isBody()) { |
+ referencePoint.move(-toLayoutBox(offsetParentObject)->borderLeft(), |
+ -toLayoutBox(offsetParentObject)->borderTop()); |
} |
- if (offsetParent->isBox() && !offsetParent->isBody()) |
- referencePoint.move(-toLayoutBox(offsetParent)->borderLeft(), |
- -toLayoutBox(offsetParent)->borderTop()); |
} |
return referencePoint; |