| Index: third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
|
| diff --git a/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp b/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
|
| index 0b3212850f6eb4a78d7d6013a92dcba244a55370..070654f048df9d1e3c1743b8b34695e3a5af6c5f 100644
|
| --- a/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
|
| +++ b/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
|
| @@ -4,6 +4,10 @@
|
|
|
| #include "core/layout/ScrollAnchor.h"
|
|
|
| +#include "core/frame/FrameView.h"
|
| +#include "core/layout/LayoutBox.h"
|
| +#include "core/layout/LayoutView.h"
|
| +#include "core/paint/PaintLayerScrollableArea.h"
|
| #include "platform/scroll/ScrollableArea.h"
|
| #include "wtf/Assertions.h"
|
|
|
| @@ -21,16 +25,41 @@ ScrollAnchor::~ScrollAnchor()
|
| {
|
| }
|
|
|
| +static LayoutBox* scrollerLayoutBox(const ScrollableArea* scroller)
|
| +{
|
| + LayoutBox* box = scroller->isFrameView()
|
| + ? toFrameView(scroller)->layoutView()
|
| + : &toPaintLayerScrollableArea(scroller)->box();
|
| + ASSERT(box);
|
| + return box;
|
| +}
|
| +
|
| static LayoutObject* findAnchor(const ScrollableArea* scroller)
|
| {
|
| - // TODO(skobes): implement.
|
| - return nullptr;
|
| + LayoutBox* scrollerBox = scrollerLayoutBox(scroller);
|
| +
|
| + FloatRect absoluteVisibleRect = scroller->isFrameView()
|
| + ? scroller->visibleContentRect()
|
| + : scrollerBox->localToAbsoluteQuad(
|
| + FloatQuad(FloatRect(scrollerBox->overflowClipRect(LayoutPoint())))).boundingBox();
|
| +
|
| + LayoutObject* child = scrollerBox->nextInPreOrder(scrollerBox);
|
| + LayoutObject* candidate = nullptr;
|
| + while (child) {
|
| + // TODO(skobes): Compute scroller-relative bounds instead of absolute bounds.
|
| + FloatRect childRect = child->absoluteBoundingBoxFloatRect();
|
| + if (absoluteVisibleRect.intersects(childRect))
|
| + candidate = child;
|
| + if (absoluteVisibleRect.contains(childRect))
|
| + break;
|
| + child = child->nextInPreOrder(scrollerBox);
|
| + }
|
| + return candidate;
|
| }
|
|
|
| static DoublePoint computeRelativeOffset(const ScrollableArea* scroller, const LayoutObject* layoutObject)
|
| {
|
| - // TODO(skobes): implement.
|
| - return DoublePoint();
|
| + return DoublePoint(layoutObject->localToAbsolute() - scrollerLayoutBox(scroller)->localToAbsolute());
|
| }
|
|
|
| void ScrollAnchor::save()
|
|
|