| Summary: | SVGTextQuery Performance Optimizations | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Ahmad Saleem <ahmad.saleem792> | ||||
| Component: | SVG | Assignee: | Nobody <webkit-unassigned> | ||||
| Status: | RESOLVED CONFIGURATION CHANGED | ||||||
| Severity: | Normal | CC: | heycam, sabouhallawa, webkit-bug-importer, zimmermann | ||||
| Priority: | P2 | Keywords: | InRadar | ||||
| Version: | Safari Technology Preview | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| See Also: |
https://bugs.webkit.org/show_bug.cgi?id=262347 https://bugs.webkit.org/show_bug.cgi?id=262373 https://bugs.webkit.org/show_bug.cgi?id=262382 https://bugs.webkit.org/show_bug.cgi?id=262457 https://bugs.webkit.org/show_bug.cgi?id=262458 https://bugs.webkit.org/show_bug.cgi?id=262488 |
||||||
| Attachments: |
|
||||||
|
Description
Ahmad Saleem
2023-09-17 04:33:55 PDT
Manage to sort out other as well:
void SVGTextQuery::modifyStartEndPositionsRespectingLigatures(Data* queryData, const SVGTextFragment& fragment, unsigned& startPosition, unsigned& endPosition) const
{
SVGTextLayoutAttributes* layoutAttributes = queryData->textRenderer->layoutAttributes();
Vector<SVGTextMetrics>& textMetricsValues = layoutAttributes->textMetricsValues();
unsigned textMetricsOffset = fragment.metricsListOffset;
// Compute the offset of the fragment within the box, since that's the
// space <startPosition, endPosition> is in (and that's what we need).
int fragmentOffsetInBox = fragment.characterOffset - queryData->textBox->start();
int fragmentEndInBox = fragmentOffsetInBox + fragment.length;
// Find the text metrics cell that start at or contain the character startPosition.
while (fragmentOffsetInBox < fragmentEndInBox) {
SVGTextMetrics& metrics = textMetricsValues[textMetricsOffset];
int glyphEnd = fragmentOffsetInBox + metrics.length();
if (static_cast<int>(startPosition) < glyphEnd)
break;
fragmentOffsetInBox = glyphEnd;
textMetricsOffset++;
}
startPosition = fragmentOffsetInBox;
// Find the text metrics cell that contain or ends at the character endPosition.
while (fragmentOffsetInBox < fragmentEndInBox) {
SVGTextMetrics& metrics = textMetricsValues[textMetricsOffset];
fragmentOffsetInBox += metrics.length();
if (fragmentOffsetInBox >= static_cast<int>(endPosition))
break;
textMetricsOffset++;
}
endPosition = fragmentOffsetInBox;
This is another simplification on top of one from here: https://src.chromium.org/viewvc/blink?view=revision&revision=193017 Created attachment 467724 [details]
SVGTextQuery.cpp local file with changes from Blink Commits
Change in `SVGInlineTextBox.cpp`:
bool SVGInlineTextBox::mapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment& fragment, unsigned& startPosition, unsigned& endPosition) const
{
int fragmentOffsetInBox = static_cast<int>(fragment.characterOffset) - start();
// Compute positions relative to the fragment.
startPosition -= fragmentOffsetInBox;
endPosition -= fragmentOffsetInBox;
// Intersect with the fragment range.
startPosition = std::max<unsigned>(startPosition, 0);
endPosition = std::min<unsigned>(endPosition, static_cast<int>(fragment.length));
return startPosition < endPosition;
}
and attaching 'SVGTextQuery.cpp' file with all my changes from this.
Pretty much everything is done here - only pending work is in 'See Also' and also has its own conclusion (issue) in 1-1 merge. Marking this as 'RESOLVED CONFIGURATION CHANGED'. Thanks! |