Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Unified Diff: third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp

Issue 1847333003: Use HashMap::add in SVGTextLayoutAttributesBuilder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix scoping of default value AddResult. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp b/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp
index 2be4dbc870e84d0d7a005a4c2bf77d72beea3346..326ddda335f5e773e7d90302a1fd0b72488fbfa0 100644
--- a/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp
@@ -149,25 +149,17 @@ void SVGTextLayoutAttributesBuilder::buildCharacterDataMap(LayoutSVGText& textRo
TextPosition wholeTextPosition(outermostTextElement, 0, m_textLength);
fillCharacterDataMap(wholeTextPosition);
- // Handle x/y default attributes.
- SVGCharacterDataMap::iterator it = m_characterDataMap.find(1);
- if (it == m_characterDataMap.end()) {
- SVGCharacterData data;
- data.x = 0;
- data.y = 0;
- m_characterDataMap.set(1, data);
- } else {
- SVGCharacterData& data = it->value;
- if (SVGTextLayoutAttributes::isEmptyValue(data.x))
- data.x = 0;
- if (SVGTextLayoutAttributes::isEmptyValue(data.y))
- data.y = 0;
- }
-
// 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.
+ SVGCharacterData& data = m_characterDataMap.add(1, SVGCharacterData()).storedValue->value;
+ if (SVGTextLayoutAttributes::isEmptyValue(data.x))
+ data.x = 0;
+ if (SVGTextLayoutAttributes::isEmptyValue(data.y))
+ data.y = 0;
}
static inline void updateCharacterData(unsigned i, float& lastRotation, SVGCharacterData& data, const SVGLengthContext& lengthContext, const SVGLengthList* xList, const SVGLengthList* yList, const SVGLengthList* dxList, const SVGLengthList* dyList, const SVGNumberList* rotateList)
@@ -213,15 +205,8 @@ void SVGTextLayoutAttributesBuilder::fillCharacterDataMap(const TextPosition& po
if (!xListPtr && !yListPtr && !dxListPtr && !dyListPtr && !rotateListPtr)
break;
- SVGCharacterDataMap::iterator it = m_characterDataMap.find(position.start + i + 1);
- if (it == m_characterDataMap.end()) {
- SVGCharacterData data;
- updateCharacterData(i, lastRotation, data, lengthContext, xListPtr, yListPtr, dxListPtr, dyListPtr, rotateListPtr);
- m_characterDataMap.set(position.start + i + 1, data);
- continue;
- }
-
- updateCharacterData(i, lastRotation, it->value, lengthContext, xListPtr, yListPtr, dxListPtr, dyListPtr, rotateListPtr);
+ SVGCharacterData& data = m_characterDataMap.add(position.start + i + 1, SVGCharacterData()).storedValue->value;
+ updateCharacterData(i, lastRotation, data, lengthContext, xListPtr, yListPtr, dxListPtr, dyListPtr, rotateListPtr);
}
// The last rotation value always spans the whole scope.
@@ -229,15 +214,8 @@ void SVGTextLayoutAttributesBuilder::fillCharacterDataMap(const TextPosition& po
return;
for (unsigned i = rotateList->length(); i < position.length; ++i) {
- SVGCharacterDataMap::iterator it = m_characterDataMap.find(position.start + i + 1);
- if (it == m_characterDataMap.end()) {
- SVGCharacterData data;
- data.rotate = lastRotation;
- m_characterDataMap.set(position.start + i + 1, data);
- continue;
- }
-
- it->value.rotate = lastRotation;
+ SVGCharacterData& data = m_characterDataMap.add(position.start + i + 1, SVGCharacterData()).storedValue->value;
+ data.rotate = lastRotation;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698