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

Unified Diff: experimental/svg/model/SkSVGDOM.cpp

Issue 2225623002: [SVGDom] Improve whitespace handling in style parsing (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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
Index: experimental/svg/model/SkSVGDOM.cpp
diff --git a/experimental/svg/model/SkSVGDOM.cpp b/experimental/svg/model/SkSVGDOM.cpp
index df589230e0daa370a6fd82a999fc1a97466fae28..a1ebedefaff1026c978168138faadb6fd32cf6fe 100644
--- a/experimental/svg/model/SkSVGDOM.cpp
+++ b/experimental/svg/model/SkSVGDOM.cpp
@@ -126,8 +126,8 @@ public:
const char* valueSep = strchr(fPos, ':');
if (valueSep && valueSep < sep) {
- name.set(fPos, valueSep - fPos);
- value.set(valueSep + 1, sep - valueSep - 1);
+ name = TrimmedString(fPos, valueSep - 1);
+ value = TrimmedString(valueSep + 1, sep - 1);
}
fPos = *sep ? sep + 1 : nullptr;
@@ -145,6 +145,18 @@ private:
return sep;
}
robertphillips 2016/08/08 12:39:30 Does this need to be class-scoped? It seems like t
f(malita) 2016/08/08 13:00:02 Done/moved out of the class.
+ static SkString TrimmedString(const char* first, const char* last) {
+ SkASSERT(first);
+ SkASSERT(last);
+ SkASSERT(first <= last);
+
+ while (first <= last && *first <= ' ') { first++; }
+ while (first <= last && *last <= ' ') { last--; }
+
+ SkASSERT(last - first + 1 >= 0);
+ return SkString(first, SkTo<size_t>(last - first + 1));
+ }
+
const char* fPos;
};

Powered by Google App Engine
This is Rietveld 408576698