Changeset 273185 in webkit
- Timestamp:
- Feb 19, 2021 4:55:59 PM (17 months ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
inspector/InspectorOverlay.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r273184 r273185 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 Followup for r273155 related to `WTF::String::append` performance. 10 11 * inspector/InspectorOverlay.cpp: 12 (WebCore::gridLineNames): 13 - Use `const Vector<String>&` to avoid copying the entire Vector and churning the reference count on the strings. 14 (WebCore::InspectorOverlay::drawGridOverlay): 15 - Use `WTF::StringBuilder` instead of `WTF::String::append` for line label contents. 16 1 17 2021-02-19 Wenson Hsieh <wenson_hsieh@apple.com> 2 18 -
trunk/Source/WebCore/inspector/InspectorOverlay.cpp
r273155 r273185 1339 1339 1340 1340 OrderedNamedGridLinesMap combinedGridLineNames; 1341 auto appendLineNames = [&](unsigned index, Vector<String>newNames) {1341 auto appendLineNames = [&](unsigned index, const Vector<String>& newNames) { 1342 1342 if (combinedGridLineNames.contains(index)) { 1343 1343 auto names = combinedGridLineNames.take(index); … … 1479 1479 context.strokePath(columnPaths); 1480 1480 1481 Vector<String> lineLabelParts; 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]); 1481 StringBuilder lineLabel; 1482 if (gridOverlay.config.showLineNumbers) 1483 lineLabel.append(i + 1, thinSpace, bullet, thinSpace, -static_cast<int>(columnPositions.size() - i)); 1484 if (gridOverlay.config.showLineNames && columnLineNames.contains(i)) { 1485 for (auto lineName : columnLineNames.get(i)) { 1486 if (!lineLabel.isEmpty()) 1487 lineLabel.append(thinSpace, bullet, thinSpace); 1488 lineLabel.append(lineName); 1495 1489 } 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. 1497 drawLayoutLabel(context, lineLabel, FloatPoint(labelX, gridBoundingBox.y()), LabelArrowDirection::Down); 1498 } 1490 } 1491 // 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. 1492 if (!lineLabel.isEmpty()) 1493 drawLayoutLabel(context, lineLabel.toString(), FloatPoint(labelX, gridBoundingBox.y()), LabelArrowDirection::Down); 1499 1494 } 1500 1495 … … 1544 1539 context.strokePath(rowPaths); 1545 1540 1546 Vector<String> lineLabelParts; 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]); 1541 StringBuilder lineLabel; 1542 if (gridOverlay.config.showLineNumbers) 1543 lineLabel.append(i + 1, thinSpace, bullet, thinSpace, -static_cast<int>(rowPositions.size() - i)); 1544 if (gridOverlay.config.showLineNames && rowLineNames.contains(i)) { 1545 for (auto lineName : rowLineNames.get(i)) { 1546 if (!lineLabel.isEmpty()) 1547 lineLabel.append(thinSpace, bullet, thinSpace); 1548 lineLabel.append(lineName); 1560 1549 } 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. 1562 drawLayoutLabel(context, lineLabel, FloatPoint(gridBoundingBox.x(), labelY), LabelArrowDirection::Right); 1563 } 1550 } 1551 // 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. 1552 if (!lineLabel.isEmpty()) 1553 drawLayoutLabel(context, lineLabel.toString(), FloatPoint(gridBoundingBox.x(), labelY), LabelArrowDirection::Right); 1564 1554 } 1565 1555
Note: See TracChangeset
for help on using the changeset viewer.