Commit 8bae1eec authored by Alex Rudenko's avatar Alex Rudenko Committed by Commit Bot

DevTools: fix positioning of grid line number labels

When we position the labels using absolute coordinates we don't need
to subtract the first track position for the subsequent track
positions.

Bug: 1106681
Change-Id: I0c6f11d9c9277d5911af3cc3ef642f6868e56827
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2332256
Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
Reviewed-by: default avatarPeter Marshall <petermarshall@chromium.org>
Reviewed-by: default avatarBrandon Goddard <brgoddar@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#793648}
parent bff601a9
......@@ -486,7 +486,6 @@ std::unique_ptr<protocol::ListValue> BuildGridPositiveLineNumberPositions(
size_t first_explicit_index =
layout_grid->ExplicitGridStartForDirection(direction);
LayoutUnit first_offset = track_positions.front();
// Go line by line, calculating the offset to fall in the middle of gaps
// if needed.
for (size_t i = first_explicit_index; i < track_positions.size(); ++i) {
......@@ -496,8 +495,8 @@ std::unique_ptr<protocol::ListValue> BuildGridPositiveLineNumberPositions(
if (grid_gap == 0 || i == 0 || i == track_positions.size() - 1) {
gapOffset = LayoutUnit();
}
PhysicalOffset number_position(
track_positions.at(i) - gapOffset - first_offset, alt_axis_pos);
PhysicalOffset number_position(track_positions.at(i) - gapOffset,
alt_axis_pos);
if (direction == kForRows)
number_position = Transpose(number_position);
number_positions->pushValue(BuildPosition(
......@@ -545,8 +544,8 @@ std::unique_ptr<protocol::ListValue> BuildGridNegativeLineNumberPositions(
i == trackPositions.size() - 1)) {
gapOffset = LayoutUnit();
}
PhysicalOffset number_position(
trackPositions.at(i) - gapOffset - first_offset, alt_axis_pos);
PhysicalOffset number_position(trackPositions.at(i) - gapOffset,
alt_axis_pos);
if (direction == kForRows)
number_position = Transpose(number_position);
number_positions->pushValue(BuildPosition(
......@@ -699,7 +698,7 @@ std::unique_ptr<protocol::ListValue> BuildGridLineNames(
LayoutUnit gap_offset =
index > 0 && index < tracks.size() - 1 ? gap / 2 : LayoutUnit();
LayoutUnit main_axis_pos = track - gap_offset - first_offset;
LayoutUnit main_axis_pos = track - gap_offset;
PhysicalOffset line_name_pos(main_axis_pos, alt_axis_pos);
if (direction == kForRows)
......@@ -711,8 +710,8 @@ std::unique_ptr<protocol::ListValue> BuildGridLineNames(
line->setString("name", name);
// TODO (alexrudenko): offset should be removed once the frontend starts
// using absolute positions.
line->setValue("offset",
protocol::FundamentalValue::create(main_axis_pos * scale));
line->setValue("offset", protocol::FundamentalValue::create(
(main_axis_pos - first_offset) * scale));
lines->pushValue(std::move(line));
}
......
......@@ -219,30 +219,30 @@ paddedGrid{
],
"positiveRowLineNumberPositions": [
{
"x": 118,
"x": 173,
"y": 408
},
{
"x": 150.5,
"x": 205.5,
"y": 408
},
{
"x": 183,
"x": 238,
"y": 408
}
],
"positiveColumnLineNumberPositions": [
{
"x": 173,
"y": 1198
"y": 408
},
{
"x": 173,
"y": 1135.5
"y": 345.5
},
{
"x": 173,
"y": 923
"y": 133
}
],
"negativeRowLineNumberOffsets": [
......@@ -266,11 +266,11 @@ paddedGrid{
},
{
"x": 238,
"y": 1135.5
"y": 345.5
},
{
"x": 238,
"y": 923
"y": 133
}
],
"areaNames": {},
......
......@@ -124,30 +124,30 @@ This test verifies the position and size of the highlight rectangles overlayed o
],
"positiveRowLineNumberPositions": [
{
"x": 118,
"x": 173,
"y": 408
},
{
"x": 150.5,
"x": 205.5,
"y": 408
},
{
"x": 183,
"x": 238,
"y": 408
}
],
"positiveColumnLineNumberPositions": [
{
"x": 173,
"y": 1198
"y": 408
},
{
"x": 173,
"y": 1135.5
"y": 345.5
},
{
"x": 173,
"y": 923
"y": 133
}
],
"negativeRowLineNumberOffsets": [
......@@ -171,11 +171,11 @@ This test verifies the position and size of the highlight rectangles overlayed o
},
{
"x": 238,
"y": 1135.5
"y": 345.5
},
{
"x": 238,
"y": 923
"y": 133
}
],
"areaNames": {},
......
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