Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/HTMLElement.cpp |
| diff --git a/third_party/WebKit/Source/core/html/HTMLElement.cpp b/third_party/WebKit/Source/core/html/HTMLElement.cpp |
| index 97f7595717213225f3016ec684e83d20fafde47f..7d232d27b792980f594d03353f394ffd3b571dda 100644 |
| --- a/third_party/WebKit/Source/core/html/HTMLElement.cpp |
| +++ b/third_party/WebKit/Source/core/html/HTMLElement.cpp |
| @@ -54,6 +54,7 @@ |
| #include "core/html/HTMLTemplateElement.h" |
| #include "core/html/HTMLTextFormControlElement.h" |
| #include "core/html/parser/HTMLParserIdioms.h" |
| +#include "core/layout/LayoutBoxModelObject.h" |
| #include "core/layout/LayoutObject.h" |
| #include "core/page/SpatialNavigation.h" |
| #include "platform/Language.h" |
| @@ -1051,6 +1052,52 @@ const AtomicString& HTMLElement::eventParameterName() |
| return eventString; |
| } |
| +int HTMLElement::offsetLeftForBinding() |
| +{ |
| + document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| + if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) |
| + return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSnappedOffsetLeft(unclosedOffsetParent())), layoutObject->styleRef()).round(); |
| + return 0; |
| +} |
| + |
| +int HTMLElement::offsetTopForBinding() |
| +{ |
| + document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| + if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) |
| + return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSnappedOffsetTop(unclosedOffsetParent())), layoutObject->styleRef()).round(); |
| + return 0; |
| +} |
| + |
| +int HTMLElement::offsetWidthForBinding() |
| +{ |
| + document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| + if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) |
| + return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSnappedOffsetWidth(unclosedOffsetParent())), layoutObject->styleRef()).round(); |
| + return 0; |
| +} |
| + |
| +int HTMLElement::offsetHeightForBinding() |
| +{ |
| + document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| + if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) |
| + return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSnappedOffsetHeight(unclosedOffsetParent())), layoutObject->styleRef()).round(); |
| + return 0; |
| +} |
| + |
| +Element* HTMLElement::unclosedOffsetParent() |
| +{ |
| + document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| + |
| + LayoutObject* layoutObject = this->layoutObject(); |
| + if (!layoutObject) |
| + return nullptr; |
| + |
| + Element* element = layoutObject->offsetParent(); |
| + while (element && (!element->isUnclosedNodeOf(*this) || (element->isInShadowTree() && element->containingShadowRoot()->type() == ShadowRootType::UserAgent))) |
|
hayato
2016/06/27 06:58:32
I do not think it is a good idea to loop here by c
kochi
2016/06/28 07:59:59
That will break LayoutObject::offsetParent, as you
|
| + element = element->layoutObject()->offsetParent(); |
| + return element; |
| +} |
| + |
| } // namespace blink |
| #ifndef NDEBUG |