Commit 2498e5e5 authored by Patrick Noland's avatar Patrick Noland Committed by Commit Bot

Scroll anchoring: use correct corner when restoring in vertical-rl writing mode

Bug: 1111201
Change-Id: Iac335d42a332e4a6bee7bcda5c588c9d74de679a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2331070Reviewed-by: default avatarSteve Kobes <skobes@chromium.org>
Commit-Queue: Patrick Noland <pnoland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#793676}
parent 40124677
...@@ -597,9 +597,13 @@ bool ScrollAnchor::RestoreAnchor(const SerializedAnchor& serialized_anchor) { ...@@ -597,9 +597,13 @@ bool ScrollAnchor::RestoreAnchor(const SerializedAnchor& serialized_anchor) {
// and attempt to re-find the anchor. The user-visible effect should end up // and attempt to re-find the anchor. The user-visible effect should end up
// roughly the same. // roughly the same.
ScrollOffset current_offset = scroller_->GetScrollOffset(); ScrollOffset current_offset = scroller_->GetScrollOffset();
FloatPoint desired_point = FloatRect bounding_box = anchor_object->AbsoluteBoundingBoxFloatRect();
anchor_object->AbsoluteBoundingBoxFloatRect().Location() + FloatPoint location_point =
current_offset; anchor_object->Style()->IsFlippedBlocksWritingMode()
? bounding_box.MaxXMinYCorner()
: bounding_box.Location();
FloatPoint desired_point = location_point + current_offset;
ScrollOffset desired_offset = ScrollOffset desired_offset =
ScrollOffset(desired_point.X(), desired_point.Y()); ScrollOffset(desired_point.X(), desired_point.Y());
ScrollOffset delta = ScrollOffset delta =
...@@ -647,6 +651,7 @@ const SerializedAnchor ScrollAnchor::GetSerializedAnchor() { ...@@ -647,6 +651,7 @@ const SerializedAnchor ScrollAnchor::GetSerializedAnchor() {
SerializedAnchor new_anchor( SerializedAnchor new_anchor(
ComputeUniqueSelector(anchor_object_->GetNode()), ComputeUniqueSelector(anchor_object_->GetNode()),
ComputeRelativeOffset(anchor_object_, scroller_, corner_)); ComputeRelativeOffset(anchor_object_, scroller_, corner_));
if (new_anchor.IsValid()) { if (new_anchor.IsValid()) {
saved_selector_ = new_anchor.selector; saved_selector_ = new_anchor.selector;
} }
......
...@@ -751,6 +751,30 @@ TEST_P(ScrollAnchorTest, SerializeAnchorVerticalWritingMode) { ...@@ -751,6 +751,30 @@ TEST_P(ScrollAnchorTest, SerializeAnchorVerticalWritingMode) {
ValidateSerializedAnchor("html>body>.barbaz", LayoutPoint(-50, 0)); ValidateSerializedAnchor("html>body>.barbaz", LayoutPoint(-50, 0));
} }
TEST_P(ScrollAnchorTest, RestoreAnchorVerticalRlWritingMode) {
SetBodyInnerHTML(R"HTML(
<style>
body {
height: 100px;
margin: 0;
writing-mode:
vertical-rl;
}
div.big { width: 800px; }
div { width: 100px; height: 100px; }
</style>
<div class='big'></div>
<div id='last'></div>
)HTML");
SerializedAnchor serialized_anchor("#last", LayoutPoint(0, 0));
EXPECT_TRUE(
GetScrollAnchor(LayoutViewport()).RestoreAnchor(serialized_anchor));
EXPECT_EQ(LayoutViewport()->ScrollOffsetInt().Width(), 0);
EXPECT_EQ(LayoutViewport()->ScrollOffsetInt().Height(), 0);
}
TEST_P(ScrollAnchorTest, SerializeAnchorQualifiedTagName) { TEST_P(ScrollAnchorTest, SerializeAnchorQualifiedTagName) {
SetBodyInnerHTML(R"HTML( SetBodyInnerHTML(R"HTML(
<style> <style>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment