Commit f5215588 authored by Alex Rudenko's avatar Alex Rudenko Committed by Commit Bot

DevTools: remove deprecated offset calculations

Bug: 1106681
Change-Id: Ib61221e7847c71db4c27ae74524c44cb16a2fea2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2332445Reviewed-by: default avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#794955}
parent 2e6f078f
......@@ -560,77 +560,6 @@ std::unique_ptr<protocol::ListValue> BuildGridNegativeLineNumberPositions(
return number_positions;
}
// Deprecated in favor of BuildGridPositiveLineNumberPositions; it will be
// removed once the frontend is updated.
std::unique_ptr<protocol::ListValue> BuildGridPositiveLineNumberOffsets(
LayoutGrid* layout_grid,
const Vector<LayoutUnit>& trackPositions,
const LayoutUnit& grid_gap,
GridTrackSizingDirection direction,
float scale) {
std::unique_ptr<protocol::ListValue> number_offsets =
protocol::ListValue::create();
// Find index of the first explicit Grid Line.
size_t firstExplicitIndex =
layout_grid->ExplicitGridStartForDirection(direction);
LayoutUnit firstOffset = trackPositions.front();
// Go line by line, calculating the offset to fall in the middel of gaps
// if needed.
for (size_t i = firstExplicitIndex; i < trackPositions.size(); ++i) {
float gapOffset = grid_gap / 2;
// No need for a gap offset if there is no gap, or the first line is
// explicit, or this is the last line.
if (grid_gap == 0 || i == 0 || i == trackPositions.size() - 1) {
gapOffset = 0;
}
number_offsets->pushValue(protocol::FundamentalValue::create(
(trackPositions.at(i) - gapOffset - firstOffset) * scale));
}
return number_offsets;
}
// Deprecated in favor of BuildGridNegativeLineNumberPositions; it will be
// removed once the frontend is updated.
std::unique_ptr<protocol::ListValue> BuildGridNegativeLineNumberOffsets(
LayoutGrid* layout_grid,
const Vector<LayoutUnit>& trackPositions,
const LayoutUnit& grid_gap,
GridTrackSizingDirection direction,
float scale) {
std::unique_ptr<protocol::ListValue> number_offsets =
protocol::ListValue::create();
// This is the number of tracks from the start of the grid, to the end of the
// explicit grid (including any leading implicit tracks).
size_t explicit_grid_end_track_count =
layout_grid->ExplicitGridEndForDirection(direction);
LayoutUnit firstOffset = trackPositions.front();
// Always start negative numbers at the first line.
number_offsets->pushValue(protocol::FundamentalValue::create(0));
// Then go line by line, calculating the offset to fall in the middle of gaps
// if needed.
for (size_t i = 1; i <= explicit_grid_end_track_count; i++) {
float gapOffset = grid_gap / 2;
if (grid_gap == 0 || (i == explicit_grid_end_track_count &&
i == trackPositions.size() - 1)) {
gapOffset = 0;
}
number_offsets->pushValue(protocol::FundamentalValue::create(
(trackPositions.at(i) - gapOffset - firstOffset) * scale));
}
return number_offsets;
}
std::unique_ptr<protocol::DictionaryValue> BuildAreaNamePaths(
LayoutGrid* layout_grid,
float scale) {
......@@ -688,7 +617,6 @@ std::unique_ptr<protocol::ListValue> BuildGridLineNames(
direction == kForColumns ? layout_grid->StyleRef().NamedGridColumnLines()
: layout_grid->StyleRef().NamedGridRowLines();
LayoutUnit gap = layout_grid->GridGap(direction);
LayoutUnit first_offset = tracks.front();
const Vector<LayoutUnit>& alt_positions = direction == kForRows
? layout_grid->ColumnPositions()
: layout_grid->RowPositions();
......@@ -713,10 +641,6 @@ std::unique_ptr<protocol::ListValue> BuildGridLineNames(
LocalToAbsolutePoint(layout_grid, line_name_pos, scale));
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 - first_offset) * scale));
lines->pushValue(std::move(line));
}
......@@ -750,7 +674,7 @@ Vector<String> GetAuthoredGridTrackSizes(const CSSValue* value,
if (!value)
return result;
// TODO (alexrudenko): this would not handle track sizes defined using CSS
// TODO(alexrudenko): this would not handle track sizes defined using CSS
// variables.
const CSSValueList* value_list = DynamicTo<CSSValueList>(value);
......@@ -821,7 +745,7 @@ std::unique_ptr<protocol::DictionaryValue> BuildGridInfo(
Element* element = DynamicTo<Element>(node);
DCHECK(element);
InspectorCSSCascade cascade(element, kPseudoIdNone);
// TODO (alexrudenko): caching might be required. Currently, the style
// TODO(alexrudenko): caching might be required. Currently, the style
// resolver is used only for grid layouts when show_track_sizes is on.
Vector<String> column_authored_values = GetAuthoredGridTrackSizes(
cascade.GetCascadedProperty(CSSPropertyID::kGridTemplateColumns),
......@@ -898,15 +822,6 @@ std::unique_ptr<protocol::DictionaryValue> BuildGridInfo(
// Positive Row and column Line positions
if (grid_highlight_config.show_positive_line_numbers) {
// TODO (alexrudenko): offsets should be removed once the frontend is using
// positions.
grid_info->setValue("positiveRowLineNumberOffsets",
BuildGridPositiveLineNumberOffsets(
layout_grid, rows, row_gap, kForRows, scale));
grid_info->setValue(
"positiveColumnLineNumberOffsets",
BuildGridPositiveLineNumberOffsets(layout_grid, columns, column_gap,
kForColumns, scale));
grid_info->setValue("positiveRowLineNumberPositions",
BuildGridPositiveLineNumberPositions(
layout_grid, rows, row_gap, kForRows, scale));
......@@ -918,16 +833,6 @@ std::unique_ptr<protocol::DictionaryValue> BuildGridInfo(
// Negative Row and column Line positions
if (grid_highlight_config.show_negative_line_numbers) {
// TODO (alexrudenko): offsets should be removed once the frontend is using
// positions.
grid_info->setValue("negativeRowLineNumberOffsets",
BuildGridNegativeLineNumberOffsets(
layout_grid, rows, row_gap, kForRows, scale));
grid_info->setValue(
"negativeColumnLineNumberOffsets",
BuildGridNegativeLineNumberOffsets(layout_grid, columns, column_gap,
kForColumns, scale));
grid_info->setValue("negativeRowLineNumberPositions",
BuildGridNegativeLineNumberPositions(
layout_grid, rows, row_gap, kForRows, scale));
......
......@@ -208,16 +208,6 @@ grid-with-areas{
601,
"Z"
],
"positiveRowLineNumberOffsets": [
0,
300.5,
601
],
"positiveColumnLineNumberOffsets": [
0,
200.5,
401
],
"positiveRowLineNumberPositions": [
{
"x": 0,
......@@ -246,16 +236,6 @@ grid-with-areas{
"y": 0
}
],
"negativeRowLineNumberOffsets": [
0,
300.5,
601
],
"negativeColumnLineNumberOffsets": [
0,
200.5,
401
],
"negativeRowLineNumberPositions": [
{
"x": 401,
......
......@@ -207,16 +207,6 @@ paddedGrid{
358,
"Z"
],
"positiveRowLineNumberOffsets": [
0,
32.5,
65
],
"positiveColumnLineNumberOffsets": [
0,
62.5,
275
],
"positiveRowLineNumberPositions": [
{
"x": 173,
......@@ -245,14 +235,6 @@ paddedGrid{
"y": 133
}
],
"negativeRowLineNumberOffsets": [
0
],
"negativeColumnLineNumberOffsets": [
0,
62.5,
275
],
"negativeRowLineNumberPositions": [
{
"x": 173,
......@@ -508,16 +490,6 @@ nestedGrid{
1058,
"Z"
],
"positiveRowLineNumberOffsets": [
0,
25,
50
],
"positiveColumnLineNumberOffsets": [
0,
50,
250
],
"positiveRowLineNumberPositions": [
{
"x": 228,
......@@ -546,14 +518,6 @@ nestedGrid{
"y": 858
}
],
"negativeRowLineNumberOffsets": [
0
],
"negativeColumnLineNumberOffsets": [
0,
50,
250
],
"negativeRowLineNumberPositions": [
{
"x": 228,
......
......@@ -6284,212 +6284,6 @@ big-grid{
1003,
"Z"
],
"positiveRowLineNumberOffsets": [
0,
7.5,
17.5,
27.5,
37.5,
47.5,
57.5,
67.5,
77.5,
87.5,
97.5,
107.5,
117.5,
127.5,
137.5,
147.5,
157.5,
167.5,
177.5,
187.5,
197.5,
207.5,
217.5,
227.5,
237.5,
247.5,
257.5,
267.5,
277.5,
287.5,
297.5,
307.5,
317.5,
327.5,
337.5,
347.5,
357.5,
367.5,
377.5,
387.5,
397.5,
407.5,
417.5,
427.5,
437.5,
447.5,
457.5,
467.5,
477.5,
487.5,
497.5,
507.5,
517.5,
527.5,
537.5,
547.5,
557.5,
567.5,
577.5,
587.5,
597.5,
607.5,
617.5,
627.5,
637.5,
647.5,
657.5,
667.5,
677.5,
687.5,
697.5,
707.5,
717.5,
727.5,
737.5,
747.5,
757.5,
767.5,
777.5,
787.5,
797.5,
807.5,
817.5,
827.5,
837.5,
847.5,
857.5,
867.5,
877.5,
887.5,
897.5,
907.5,
917.5,
927.5,
937.5,
947.5,
957.5,
967.5,
977.5,
987.5,
995
],
"positiveColumnLineNumberOffsets": [
0,
7.5,
17.5,
27.5,
37.5,
47.5,
57.5,
67.5,
77.5,
87.5,
97.5,
107.5,
117.5,
127.5,
137.5,
147.5,
157.5,
167.5,
177.5,
187.5,
197.5,
207.5,
217.5,
227.5,
237.5,
247.5,
257.5,
267.5,
277.5,
287.5,
297.5,
307.5,
317.5,
327.5,
337.5,
347.5,
357.5,
367.5,
377.5,
387.5,
397.5,
407.5,
417.5,
427.5,
437.5,
447.5,
457.5,
467.5,
477.5,
487.5,
497.5,
507.5,
517.5,
527.5,
537.5,
547.5,
557.5,
567.5,
577.5,
587.5,
597.5,
607.5,
617.5,
627.5,
637.5,
647.5,
657.5,
667.5,
677.5,
687.5,
697.5,
707.5,
717.5,
727.5,
737.5,
747.5,
757.5,
767.5,
777.5,
787.5,
797.5,
807.5,
817.5,
827.5,
837.5,
847.5,
857.5,
867.5,
877.5,
887.5,
897.5,
907.5,
917.5,
927.5,
937.5,
947.5,
957.5,
967.5,
977.5,
987.5,
995
],
"positiveRowLineNumberPositions": [
{
"x": 8,
......@@ -7302,212 +7096,6 @@ big-grid{
"y": 8
}
],
"negativeRowLineNumberOffsets": [
0,
7.5,
17.5,
27.5,
37.5,
47.5,
57.5,
67.5,
77.5,
87.5,
97.5,
107.5,
117.5,
127.5,
137.5,
147.5,
157.5,
167.5,
177.5,
187.5,
197.5,
207.5,
217.5,
227.5,
237.5,
247.5,
257.5,
267.5,
277.5,
287.5,
297.5,
307.5,
317.5,
327.5,
337.5,
347.5,
357.5,
367.5,
377.5,
387.5,
397.5,
407.5,
417.5,
427.5,
437.5,
447.5,
457.5,
467.5,
477.5,
487.5,
497.5,
507.5,
517.5,
527.5,
537.5,
547.5,
557.5,
567.5,
577.5,
587.5,
597.5,
607.5,
617.5,
627.5,
637.5,
647.5,
657.5,
667.5,
677.5,
687.5,
697.5,
707.5,
717.5,
727.5,
737.5,
747.5,
757.5,
767.5,
777.5,
787.5,
797.5,
807.5,
817.5,
827.5,
837.5,
847.5,
857.5,
867.5,
877.5,
887.5,
897.5,
907.5,
917.5,
927.5,
937.5,
947.5,
957.5,
967.5,
977.5,
987.5,
995
],
"negativeColumnLineNumberOffsets": [
0,
7.5,
17.5,
27.5,
37.5,
47.5,
57.5,
67.5,
77.5,
87.5,
97.5,
107.5,
117.5,
127.5,
137.5,
147.5,
157.5,
167.5,
177.5,
187.5,
197.5,
207.5,
217.5,
227.5,
237.5,
247.5,
257.5,
267.5,
277.5,
287.5,
297.5,
307.5,
317.5,
327.5,
337.5,
347.5,
357.5,
367.5,
377.5,
387.5,
397.5,
407.5,
417.5,
427.5,
437.5,
447.5,
457.5,
467.5,
477.5,
487.5,
497.5,
507.5,
517.5,
527.5,
537.5,
547.5,
557.5,
567.5,
577.5,
587.5,
597.5,
607.5,
617.5,
627.5,
637.5,
647.5,
657.5,
667.5,
677.5,
687.5,
697.5,
707.5,
717.5,
727.5,
737.5,
747.5,
757.5,
767.5,
777.5,
787.5,
797.5,
807.5,
817.5,
827.5,
837.5,
847.5,
857.5,
867.5,
877.5,
887.5,
897.5,
907.5,
917.5,
927.5,
937.5,
947.5,
957.5,
967.5,
977.5,
987.5,
995
],
"negativeRowLineNumberPositions": [
{
"x": 1003,
......
......@@ -301,19 +301,6 @@ grid-with-line-names{
830,
"Z"
],
"positiveRowLineNumberOffsets": [
0,
205,
415,
625,
830
],
"positiveColumnLineNumberOffsets": [
0,
105,
615,
640
],
"positiveRowLineNumberPositions": [
{
"x": 0,
......@@ -354,19 +341,6 @@ grid-with-line-names{
"y": 0
}
],
"negativeRowLineNumberOffsets": [
0,
205,
415,
625,
830
],
"negativeColumnLineNumberOffsets": [
0,
105,
615,
640
],
"negativeRowLineNumberPositions": [
{
"x": 640,
......@@ -412,82 +386,69 @@ grid-with-line-names{
{
"x": 0,
"y": 205,
"name": "article",
"offset": 205
"name": "article"
},
{
"x": 0,
"y": 0,
"name": "header",
"offset": 0
"name": "header"
},
{
"x": 0,
"y": 205,
"name": "main",
"offset": 205
"name": "main"
},
{
"x": 0,
"y": 830,
"name": "end",
"offset": 830
"name": "end"
},
{
"x": 0,
"y": 205,
"name": "section",
"offset": 205
"name": "section"
},
{
"x": 0,
"y": 415,
"name": "section",
"offset": 415
"name": "section"
},
{
"x": 0,
"y": 625,
"name": "section",
"offset": 625
"name": "section"
},
{
"x": 0,
"y": 205,
"name": "images",
"offset": 205
"name": "images"
}
],
"columnLineNameOffsets": [
{
"x": 105,
"y": 0,
"name": "header",
"offset": 105
"name": "header"
},
{
"x": 105,
"y": 0,
"name": "content-start",
"offset": 105
"name": "content-start"
},
{
"x": 640,
"y": 0,
"name": "fullpage-end",
"offset": 640
"name": "fullpage-end"
},
{
"x": 0,
"y": 0,
"name": "fullpage-start",
"offset": 0
"name": "fullpage-start"
},
{
"x": 615,
"y": 0,
"name": "content-end",
"offset": 615
"name": "content-end"
}
],
"gridBorder": [
......
......@@ -6190,212 +6190,6 @@ This test verifies that huge CSS grids can be highlighted with the grid Highligh
1003,
"Z"
],
"positiveRowLineNumberOffsets": [
0,
7.5,
17.5,
27.5,
37.5,
47.5,
57.5,
67.5,
77.5,
87.5,
97.5,
107.5,
117.5,
127.5,
137.5,
147.5,
157.5,
167.5,
177.5,
187.5,
197.5,
207.5,
217.5,
227.5,
237.5,
247.5,
257.5,
267.5,
277.5,
287.5,
297.5,
307.5,
317.5,
327.5,
337.5,
347.5,
357.5,
367.5,
377.5,
387.5,
397.5,
407.5,
417.5,
427.5,
437.5,
447.5,
457.5,
467.5,
477.5,
487.5,
497.5,
507.5,
517.5,
527.5,
537.5,
547.5,
557.5,
567.5,
577.5,
587.5,
597.5,
607.5,
617.5,
627.5,
637.5,
647.5,
657.5,
667.5,
677.5,
687.5,
697.5,
707.5,
717.5,
727.5,
737.5,
747.5,
757.5,
767.5,
777.5,
787.5,
797.5,
807.5,
817.5,
827.5,
837.5,
847.5,
857.5,
867.5,
877.5,
887.5,
897.5,
907.5,
917.5,
927.5,
937.5,
947.5,
957.5,
967.5,
977.5,
987.5,
995
],
"positiveColumnLineNumberOffsets": [
0,
7.5,
17.5,
27.5,
37.5,
47.5,
57.5,
67.5,
77.5,
87.5,
97.5,
107.5,
117.5,
127.5,
137.5,
147.5,
157.5,
167.5,
177.5,
187.5,
197.5,
207.5,
217.5,
227.5,
237.5,
247.5,
257.5,
267.5,
277.5,
287.5,
297.5,
307.5,
317.5,
327.5,
337.5,
347.5,
357.5,
367.5,
377.5,
387.5,
397.5,
407.5,
417.5,
427.5,
437.5,
447.5,
457.5,
467.5,
477.5,
487.5,
497.5,
507.5,
517.5,
527.5,
537.5,
547.5,
557.5,
567.5,
577.5,
587.5,
597.5,
607.5,
617.5,
627.5,
637.5,
647.5,
657.5,
667.5,
677.5,
687.5,
697.5,
707.5,
717.5,
727.5,
737.5,
747.5,
757.5,
767.5,
777.5,
787.5,
797.5,
807.5,
817.5,
827.5,
837.5,
847.5,
857.5,
867.5,
877.5,
887.5,
897.5,
907.5,
917.5,
927.5,
937.5,
947.5,
957.5,
967.5,
977.5,
987.5,
995
],
"positiveRowLineNumberPositions": [
{
"x": 8,
......@@ -7208,212 +7002,6 @@ This test verifies that huge CSS grids can be highlighted with the grid Highligh
"y": 8
}
],
"negativeRowLineNumberOffsets": [
0,
7.5,
17.5,
27.5,
37.5,
47.5,
57.5,
67.5,
77.5,
87.5,
97.5,
107.5,
117.5,
127.5,
137.5,
147.5,
157.5,
167.5,
177.5,
187.5,
197.5,
207.5,
217.5,
227.5,
237.5,
247.5,
257.5,
267.5,
277.5,
287.5,
297.5,
307.5,
317.5,
327.5,
337.5,
347.5,
357.5,
367.5,
377.5,
387.5,
397.5,
407.5,
417.5,
427.5,
437.5,
447.5,
457.5,
467.5,
477.5,
487.5,
497.5,
507.5,
517.5,
527.5,
537.5,
547.5,
557.5,
567.5,
577.5,
587.5,
597.5,
607.5,
617.5,
627.5,
637.5,
647.5,
657.5,
667.5,
677.5,
687.5,
697.5,
707.5,
717.5,
727.5,
737.5,
747.5,
757.5,
767.5,
777.5,
787.5,
797.5,
807.5,
817.5,
827.5,
837.5,
847.5,
857.5,
867.5,
877.5,
887.5,
897.5,
907.5,
917.5,
927.5,
937.5,
947.5,
957.5,
967.5,
977.5,
987.5,
995
],
"negativeColumnLineNumberOffsets": [
0,
7.5,
17.5,
27.5,
37.5,
47.5,
57.5,
67.5,
77.5,
87.5,
97.5,
107.5,
117.5,
127.5,
137.5,
147.5,
157.5,
167.5,
177.5,
187.5,
197.5,
207.5,
217.5,
227.5,
237.5,
247.5,
257.5,
267.5,
277.5,
287.5,
297.5,
307.5,
317.5,
327.5,
337.5,
347.5,
357.5,
367.5,
377.5,
387.5,
397.5,
407.5,
417.5,
427.5,
437.5,
447.5,
457.5,
467.5,
477.5,
487.5,
497.5,
507.5,
517.5,
527.5,
537.5,
547.5,
557.5,
567.5,
577.5,
587.5,
597.5,
607.5,
617.5,
627.5,
637.5,
647.5,
657.5,
667.5,
677.5,
687.5,
697.5,
707.5,
717.5,
727.5,
737.5,
747.5,
757.5,
767.5,
777.5,
787.5,
797.5,
807.5,
817.5,
827.5,
837.5,
847.5,
857.5,
867.5,
877.5,
887.5,
897.5,
907.5,
917.5,
927.5,
937.5,
947.5,
957.5,
967.5,
977.5,
987.5,
995
],
"negativeRowLineNumberPositions": [
{
"x": 1003,
......
......@@ -112,16 +112,6 @@ This test verifies the position and size of the highlight rectangles overlayed o
358,
"Z"
],
"positiveRowLineNumberOffsets": [
0,
32.5,
65
],
"positiveColumnLineNumberOffsets": [
0,
62.5,
275
],
"positiveRowLineNumberPositions": [
{
"x": 173,
......@@ -150,14 +140,6 @@ This test verifies the position and size of the highlight rectangles overlayed o
"y": 133
}
],
"negativeRowLineNumberOffsets": [
0
],
"negativeColumnLineNumberOffsets": [
0,
62.5,
275
],
"negativeRowLineNumberPositions": [
{
"x": 173,
......@@ -326,16 +308,6 @@ This test verifies the position and size of the highlight rectangles overlayed o
1158,
"Z"
],
"positiveRowLineNumberOffsets": [
0,
110,
220
],
"positiveColumnLineNumberOffsets": [
0,
75,
1300
],
"positiveRowLineNumberPositions": [
{
"x": 108,
......@@ -364,14 +336,6 @@ This test verifies the position and size of the highlight rectangles overlayed o
"y": -92
}
],
"negativeRowLineNumberOffsets": [
0
],
"negativeColumnLineNumberOffsets": [
0,
75,
1300
],
"negativeRowLineNumberPositions": [
{
"x": 108,
......
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