Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use HashMap::add in SVGTextLayoutAttributesBuilder #32358

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Ahmad-S792
Copy link
Contributor

@Ahmad-S792 Ahmad-S792 commented Aug 18, 2024

7afd778

Use HashMap::add in SVGTextLayoutAttributesBuilder
https://bugs.webkit.org/show_bug.cgi?id=278292
rdar://134186468

Reviewed by NOBODY (OOPS!).

Merge: https://chromium.googlesource.com/chromium/src.git/+/0f6c84977fee3a56a328e9baa1134b668a316569

Removes some redundancies and eliminates double-hashing.
Do the update of default values last.

* Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp:
(WebCore::SVGTextLayoutAttributesBuilder::buildCharacterDataMap):
(WebCore::SVGTextLayoutAttributesBuilder::fillCharacterDataMap):

7afd778

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ✅ 🧪 wincairo-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🧪 vision-wk2
✅ 🛠 tv
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

https://bugs.webkit.org/show_bug.cgi?id=278292
rdar://134186468

Reviewed by NOBODY (OOPS!).

Merge: https://chromium.googlesource.com/chromium/src.git/+/0f6c84977fee3a56a328e9baa1134b668a316569

Removes some redundancies and eliminates double-hashing.
Do the update of default values last.

* Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp:
(WebCore::SVGTextLayoutAttributesBuilder::buildCharacterDataMap):
(WebCore::SVGTextLayoutAttributesBuilder::fillCharacterDataMap):
@Ahmad-S792 Ahmad-S792 self-assigned this Aug 18, 2024
@Ahmad-S792 Ahmad-S792 added the SVG For bugs in the SVG implementation. label Aug 18, 2024
}

updateCharacterData(i, lastRotation, it->value, lengthContext, xListPtr, yListPtr, dxListPtr, dyListPtr, rotateListPtr);
auto& data = m_characterDataMap.add((position.start + i + 1), SVGCharacterData()).iterator->value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use HashMap::ensure() to avoid creating a useless SVGCharacterData() object when the key is already there.

}

it->value.rotate = lastRotation;
auto& data = m_characterDataMap.add((position.start + i + 1), SVGCharacterData()).iterator->value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

// Fill character data map using child text positioning elements in top-down order.
unsigned size = m_textPositions.size();
for (unsigned i = 0; i < size; ++i)
fillCharacterDataMap(m_textPositions[i]);

// Handle x/y default attributes.
auto& data = m_characterDataMap.add((1), SVGCharacterData()).iterator->value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

SVGCharacterData data;
updateCharacterData(i, lastRotation, data, lengthContext, xListPtr, yListPtr, dxListPtr, dyListPtr, rotateListPtr);
m_characterDataMap.set(position.start + i + 1, data);
continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic has changed. You might want to check if isNewEntry when using HashMap::add and if so, continue to the next step of the loop.

SVGCharacterData data;
data.rotate = lastRotation;
m_characterDataMap.set(position.start + i + 1, data);
continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

@Ahmad-S792 Ahmad-S792 marked this pull request as draft August 19, 2024 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SVG For bugs in the SVG implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants