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( ...@@ -486,7 +486,6 @@ std::unique_ptr<protocol::ListValue> BuildGridPositiveLineNumberPositions(
size_t first_explicit_index = size_t first_explicit_index =
layout_grid->ExplicitGridStartForDirection(direction); layout_grid->ExplicitGridStartForDirection(direction);
LayoutUnit first_offset = track_positions.front();
// Go line by line, calculating the offset to fall in the middle of gaps // Go line by line, calculating the offset to fall in the middle of gaps
// if needed. // if needed.
for (size_t i = first_explicit_index; i < track_positions.size(); ++i) { for (size_t i = first_explicit_index; i < track_positions.size(); ++i) {
...@@ -496,8 +495,8 @@ std::unique_ptr<protocol::ListValue> BuildGridPositiveLineNumberPositions( ...@@ -496,8 +495,8 @@ std::unique_ptr<protocol::ListValue> BuildGridPositiveLineNumberPositions(
if (grid_gap == 0 || i == 0 || i == track_positions.size() - 1) { if (grid_gap == 0 || i == 0 || i == track_positions.size() - 1) {
gapOffset = LayoutUnit(); gapOffset = LayoutUnit();
} }
PhysicalOffset number_position( PhysicalOffset number_position(track_positions.at(i) - gapOffset,
track_positions.at(i) - gapOffset - first_offset, alt_axis_pos); alt_axis_pos);
if (direction == kForRows) if (direction == kForRows)
number_position = Transpose(number_position); number_position = Transpose(number_position);
number_positions->pushValue(BuildPosition( number_positions->pushValue(BuildPosition(
...@@ -545,8 +544,8 @@ std::unique_ptr<protocol::ListValue> BuildGridNegativeLineNumberPositions( ...@@ -545,8 +544,8 @@ std::unique_ptr<protocol::ListValue> BuildGridNegativeLineNumberPositions(
i == trackPositions.size() - 1)) { i == trackPositions.size() - 1)) {
gapOffset = LayoutUnit(); gapOffset = LayoutUnit();
} }
PhysicalOffset number_position( PhysicalOffset number_position(trackPositions.at(i) - gapOffset,
trackPositions.at(i) - gapOffset - first_offset, alt_axis_pos); alt_axis_pos);
if (direction == kForRows) if (direction == kForRows)
number_position = Transpose(number_position); number_position = Transpose(number_position);
number_positions->pushValue(BuildPosition( number_positions->pushValue(BuildPosition(
...@@ -699,7 +698,7 @@ std::unique_ptr<protocol::ListValue> BuildGridLineNames( ...@@ -699,7 +698,7 @@ std::unique_ptr<protocol::ListValue> BuildGridLineNames(
LayoutUnit gap_offset = LayoutUnit gap_offset =
index > 0 && index < tracks.size() - 1 ? gap / 2 : LayoutUnit(); 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); PhysicalOffset line_name_pos(main_axis_pos, alt_axis_pos);
if (direction == kForRows) if (direction == kForRows)
...@@ -711,8 +710,8 @@ std::unique_ptr<protocol::ListValue> BuildGridLineNames( ...@@ -711,8 +710,8 @@ std::unique_ptr<protocol::ListValue> BuildGridLineNames(
line->setString("name", name); line->setString("name", name);
// TODO (alexrudenko): offset should be removed once the frontend starts // TODO (alexrudenko): offset should be removed once the frontend starts
// using absolute positions. // using absolute positions.
line->setValue("offset", line->setValue("offset", protocol::FundamentalValue::create(
protocol::FundamentalValue::create(main_axis_pos * scale)); (main_axis_pos - first_offset) * scale));
lines->pushValue(std::move(line)); lines->pushValue(std::move(line));
} }
......
...@@ -219,30 +219,30 @@ paddedGrid{ ...@@ -219,30 +219,30 @@ paddedGrid{
], ],
"positiveRowLineNumberPositions": [ "positiveRowLineNumberPositions": [
{ {
"x": 118, "x": 173,
"y": 408 "y": 408
}, },
{ {
"x": 150.5, "x": 205.5,
"y": 408 "y": 408
}, },
{ {
"x": 183, "x": 238,
"y": 408 "y": 408
} }
], ],
"positiveColumnLineNumberPositions": [ "positiveColumnLineNumberPositions": [
{ {
"x": 173, "x": 173,
"y": 1198 "y": 408
}, },
{ {
"x": 173, "x": 173,
"y": 1135.5 "y": 345.5
}, },
{ {
"x": 173, "x": 173,
"y": 923 "y": 133
} }
], ],
"negativeRowLineNumberOffsets": [ "negativeRowLineNumberOffsets": [
...@@ -266,11 +266,11 @@ paddedGrid{ ...@@ -266,11 +266,11 @@ paddedGrid{
}, },
{ {
"x": 238, "x": 238,
"y": 1135.5 "y": 345.5
}, },
{ {
"x": 238, "x": 238,
"y": 923 "y": 133
} }
], ],
"areaNames": {}, "areaNames": {},
......
...@@ -124,30 +124,30 @@ This test verifies the position and size of the highlight rectangles overlayed o ...@@ -124,30 +124,30 @@ This test verifies the position and size of the highlight rectangles overlayed o
], ],
"positiveRowLineNumberPositions": [ "positiveRowLineNumberPositions": [
{ {
"x": 118, "x": 173,
"y": 408 "y": 408
}, },
{ {
"x": 150.5, "x": 205.5,
"y": 408 "y": 408
}, },
{ {
"x": 183, "x": 238,
"y": 408 "y": 408
} }
], ],
"positiveColumnLineNumberPositions": [ "positiveColumnLineNumberPositions": [
{ {
"x": 173, "x": 173,
"y": 1198 "y": 408
}, },
{ {
"x": 173, "x": 173,
"y": 1135.5 "y": 345.5
}, },
{ {
"x": 173, "x": 173,
"y": 923 "y": 133
} }
], ],
"negativeRowLineNumberOffsets": [ "negativeRowLineNumberOffsets": [
...@@ -171,11 +171,11 @@ This test verifies the position and size of the highlight rectangles overlayed o ...@@ -171,11 +171,11 @@ This test verifies the position and size of the highlight rectangles overlayed o
}, },
{ {
"x": 238, "x": 238,
"y": 1135.5 "y": 345.5
}, },
{ {
"x": 238, "x": 238,
"y": 923 "y": 133
} }
], ],
"areaNames": {}, "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