Changeset 273155 in webkit
- Timestamp:
- Feb 19, 2021 12:01:31 PM (17 months ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
inspector/InspectorOverlay.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r273143 r273155 1 2021-02-19 Patrick Angle <pangle@apple.com> 2 3 Web Inspector: Implement Grid Overlay "Show line names" drawing 4 https://bugs.webkit.org/show_bug.cgi?id=222006 5 <rdar://problem/74409722> 6 7 Reviewed by BJ Burg. 8 9 Add support for showing line names to the grid overlay, including explicit, auto-repeated, and implicit names. 10 11 * inspector/InspectorOverlay.cpp: 12 (WebCore::gridLineNames): 13 - Gather the grid line names for a grid from the multiple possible sources. 14 (WebCore::InspectorOverlay::drawGridOverlay): 15 - Support showing grid line name labels. 16 - Refactored line number label drawing to share a common structure with line name label drawing. 17 1 18 2021-02-19 Devin Rousso <drousso@apple.com> 2 19 -
trunk/Source/WebCore/inspector/InspectorOverlay.cpp
r273098 r273155 64 64 #include "RenderObject.h" 65 65 #include "Settings.h" 66 #include "StyleGridData.h" 66 67 #include "StyleResolver.h" 67 68 #include <wtf/MathExtras.h> … … 1332 1333 } 1333 1334 1335 static OrderedNamedGridLinesMap gridLineNames(const RenderStyle* renderStyle, GridTrackSizingDirection direction, unsigned expectedLineCount) 1336 { 1337 if (!renderStyle) 1338 return { }; 1339 1340 OrderedNamedGridLinesMap combinedGridLineNames; 1341 auto appendLineNames = [&](unsigned index, Vector<String> newNames) { 1342 if (combinedGridLineNames.contains(index)) { 1343 auto names = combinedGridLineNames.take(index); 1344 names.appendVector(newNames); 1345 combinedGridLineNames.add(index, names); 1346 } else 1347 combinedGridLineNames.add(index, newNames); 1348 }; 1349 1350 auto orderedGridLineNames = direction == GridTrackSizingDirection::ForColumns ? renderStyle->orderedNamedGridColumnLines() : renderStyle->orderedNamedGridRowLines(); 1351 for (auto& [i, names] : orderedGridLineNames) 1352 appendLineNames(i, names); 1353 1354 auto autoRepeatOrderedGridLineNames = direction == GridTrackSizingDirection::ForColumns ? renderStyle->autoRepeatOrderedNamedGridColumnLines() : renderStyle->autoRepeatOrderedNamedGridRowLines(); 1355 auto autoRepeatInsertionPoint = direction == GridTrackSizingDirection::ForColumns ? renderStyle->gridAutoRepeatColumnsInsertionPoint() : renderStyle->gridAutoRepeatRowsInsertionPoint(); 1356 unsigned autoRepeatIndex = 0; 1357 while (autoRepeatOrderedGridLineNames.size() && autoRepeatIndex < expectedLineCount - autoRepeatInsertionPoint) { 1358 auto names = autoRepeatOrderedGridLineNames.get(autoRepeatIndex % autoRepeatOrderedGridLineNames.size()); 1359 auto lineIndex = autoRepeatIndex + autoRepeatInsertionPoint; 1360 appendLineNames(lineIndex, names); 1361 ++autoRepeatIndex; 1362 } 1363 1364 auto implicitGridLineNames = direction == GridTrackSizingDirection::ForColumns ? renderStyle->implicitNamedGridColumnLines() : renderStyle->implicitNamedGridRowLines(); 1365 for (auto& [name, indexes] : implicitGridLineNames) { 1366 for (auto i : indexes) 1367 appendLineNames(i, {name}); 1368 } 1369 1370 return combinedGridLineNames; 1371 } 1372 1334 1373 void InspectorOverlay::drawGridOverlay(GraphicsContext& context, const InspectorOverlay::Grid& gridOverlay) 1335 1374 { … … 1395 1434 // Draw columns and rows. 1396 1435 auto columnWidths = renderGrid->trackSizesForComputedStyle(GridTrackSizingDirection::ForColumns); 1436 auto columnLineNames = gridLineNames(node->renderStyle(), GridTrackSizingDirection::ForColumns, columnPositions.size()); 1397 1437 auto authoredTrackColumnSizes = authoredGridTrackSizes(node, GridTrackSizingDirection::ForColumns, columnWidths.size()); 1398 1438 float previousColumnX = 0; … … 1439 1479 context.strokePath(columnPaths); 1440 1480 1481 Vector<String> lineLabelParts; 1441 1482 if (gridOverlay.config.showLineNumbers) { 1483 lineLabelParts.append(String::number(i + 1)); 1484 lineLabelParts.append(String::number(-static_cast<int>(columnPositions.size() - i))); 1485 } 1486 if (gridOverlay.config.showLineNames && columnLineNames.contains(i)) 1487 lineLabelParts.appendVector(columnLineNames.get(i)); 1488 if (lineLabelParts.size()) { 1489 auto lineLabel = lineLabelParts[0]; 1490 for (size_t i = 1; i < lineLabelParts.size(); ++i) { 1491 lineLabel.append(thinSpace); 1492 lineLabel.append(bullet); 1493 lineLabel.append(thinSpace); 1494 lineLabel.append(lineLabelParts[i]); 1495 } 1442 1496 // FIXME: <webkit.org/b/221972> Layout labels can be drawn outside the viewport, and a best effort should be made to keep them in the viewport while the grid is in the viewport. 1443 drawLayoutLabel(context, String::number(i + 1), FloatPoint(labelX, gridBoundingBox.y()), LabelArrowDirection::Down); 1444 drawLayoutLabel(context, String::number(-static_cast<int>(columnPositions.size() - i)), FloatPoint(labelX, gridBoundingBox.y() + gridBoundingBox.height()), LabelArrowDirection::Up); 1497 drawLayoutLabel(context, lineLabel, FloatPoint(labelX, gridBoundingBox.y()), LabelArrowDirection::Down); 1445 1498 } 1446 1499 } 1447 1500 1448 1501 auto rowHeights = renderGrid->trackSizesForComputedStyle(GridTrackSizingDirection::ForRows); 1502 auto rowLineNames = gridLineNames(node->renderStyle(), GridTrackSizingDirection::ForRows, rowPositions.size()); 1449 1503 auto authoredTrackRowSizes = authoredGridTrackSizes(node, GridTrackSizingDirection::ForRows, rowHeights.size()); 1450 1504 float previousRowY = 0; … … 1490 1544 context.strokePath(rowPaths); 1491 1545 1546 Vector<String> lineLabelParts; 1492 1547 if (gridOverlay.config.showLineNumbers) { 1548 lineLabelParts.append(String::number(i + 1)); 1549 lineLabelParts.append(String::number(-static_cast<int>(rowPositions.size() - i))); 1550 } 1551 if (gridOverlay.config.showLineNames && rowLineNames.contains(i)) 1552 lineLabelParts.appendVector(rowLineNames.get(i)); 1553 if (lineLabelParts.size()) { 1554 auto lineLabel = lineLabelParts[0]; 1555 for (size_t i = 1; i < lineLabelParts.size(); ++i) { 1556 lineLabel.append(thinSpace); 1557 lineLabel.append(bullet); 1558 lineLabel.append(thinSpace); 1559 lineLabel.append(lineLabelParts[i]); 1560 } 1493 1561 // FIXME: <webkit.org/b/221972> Layout labels can be drawn outside the viewport, and a best effort should be made to keep them in the viewport while the grid is in the viewport. 1494 drawLayoutLabel(context, String::number(i + 1), FloatPoint(gridBoundingBox.x(), labelY), LabelArrowDirection::Right); 1495 drawLayoutLabel(context, String::number(-static_cast<int>(rowPositions.size() - i)), FloatPoint(gridBoundingBox.x() + gridBoundingBox.width(), labelY), LabelArrowDirection::Left); 1562 drawLayoutLabel(context, lineLabel, FloatPoint(gridBoundingBox.x(), labelY), LabelArrowDirection::Right); 1496 1563 } 1497 1564 }
Note: See TracChangeset
for help on using the changeset viewer.