# HG changeset patch
# User Martin Gieseking <martin.gieseking@uos.de>
# Date 1555578878 -7200
# Thu Apr 18 11:14:38 2019 +0200
# Node ID 4fa1e45d2e2a5b50e385244813b3b8a34629a1f5
# Parent 736ab658460f07a5019a7cf049465ac1e14a3a2c
removed util::make_array() due to compatibility issues
diff --git a/src/optimizer/AttributeExtractor.cpp b/src/optimizer/AttributeExtractor.cpp
|
a
|
b
|
|
| 113 | 113 | * @return true if the element is groupable */ |
| 114 | 114 | bool AttributeExtractor::groupable (const XMLElement &elem) { |
| 115 | 115 | // https://www.w3.org/TR/SVG/struct.html#GElement |
| 116 | | static constexpr auto names = util::make_array( |
| | 116 | static const char *names[] = { |
| 117 | 117 | "a", "altGlyphDef", "animate", "animateColor", "animateMotion", "animateTransform", |
| 118 | 118 | "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "filter", |
| 119 | 119 | "font", "font-face", "foreignObject", "g", "image", "line", "linearGradient", "marker", |
| 120 | 120 | "mask", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "set", |
| 121 | 121 | "style", "switch", "symbol", "text", "title", "use", "view" |
| 122 | | ); |
| 123 | | return binary_search(names.begin(), names.end(), elem.name(), [](const string &name1, const string &name2) { |
| | 122 | }; |
| | 123 | return binary_search(begin(names), end(names), elem.name(), [](const string &name1, const string &name2) { |
| 124 | 124 | return name1 < name2; |
| 125 | 125 | }); |
| 126 | 126 | } |
| … |
… |
|
| 136 | 136 | // clip-path is not inheritable but can be moved to the parent element as long as |
| 137 | 137 | // no child gets an different clip-path attribute |
| 138 | 138 | // https://www.w3.org/TR/SVG11/styling.html#Inheritance |
| 139 | | static constexpr auto names = util::make_array( |
| | 139 | static const char *names[] = { |
| 140 | 140 | "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", |
| 141 | 141 | "color-rendering", "direction", "fill", "fill-opacity", "fill-rule", "font", "font-family", "font-size", |
| 142 | 142 | "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "glyph-orientation-horizontal", |
| 143 | 143 | "glyph-orientation-vertical", "letter-spacing", "paint-order", "stroke", "stroke-dasharray", "stroke-dashoffset", |
| 144 | 144 | "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "transform", |
| 145 | 145 | "visibility", "word-spacing", "writing-mode" |
| 146 | | ); |
| 147 | | return binary_search(names.begin(), names.end(), attrib.name, [](const string &name1, const string &name2) { |
| | 146 | }; |
| | 147 | return binary_search(begin(names), end(names), attrib.name, [](const string &name1, const string &name2) { |
| 148 | 148 | return name1 < name2; |
| 149 | 149 | }); |
| 150 | 150 | } |
| … |
… |
|
| 159 | 159 | // the 'fill' attribute of animation elements has different semantics than |
| 160 | 160 | // that of graphics elements => don't extract it from animation nodes |
| 161 | 161 | // https://www.w3.org/TR/SVG11/animate.html#TimingAttributes |
| 162 | | static constexpr auto names = util::make_array( |
| | 162 | static const char *names[] = { |
| 163 | 163 | "animate", "animateColor", "animateMotion", "animateTransform", "set" |
| 164 | | ); |
| 165 | | auto it = find_if(names.begin(), names.end(), [&](const string &name) { |
| | 164 | }; |
| | 165 | auto it = find_if(begin(names), end(names), [&](const string &name) { |
| 166 | 166 | return element.name() == name; |
| 167 | 167 | }); |
| 168 | | return it == names.end(); |
| | 168 | return it == end(names); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | |
diff --git a/src/optimizer/GroupCollapser.cpp b/src/optimizer/GroupCollapser.cpp
|
a
|
b
|
|
| 132 | 132 | bool GroupCollapser::collapsible (const XMLElement &element) { |
| 133 | 133 | // the 'fill' attribute of animation elements has different semantics than |
| 134 | 134 | // that of graphics elements => don't collapse them |
| 135 | | static constexpr auto names = util::make_array( |
| | 135 | static const char *names[] = { |
| 136 | 136 | "animate", "animateColor", "animateMotion", "animateTransform", "set" |
| 137 | | ); |
| 138 | | auto it = find_if(names.begin(), names.end(), [&](const string &name) { |
| | 137 | }; |
| | 138 | auto it = find_if(begin(names), end(names), [&](const string &name) { |
| 139 | 139 | return element.name() == name; |
| 140 | 140 | }); |
| 141 | | return it == names.end(); |
| | 141 | return it == end(names); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | |
| … |
… |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | // these attributes prevent a group from being unwrapped |
| 158 | | static constexpr auto attribs = util::make_array( |
| | 158 | static const char *attribs[] = { |
| 159 | 159 | "class", "id", "filter", "mask", "style" |
| 160 | | ); |
| 161 | | auto it = find_if(attribs.begin(), attribs.end(), [&](const string &name) { |
| | 160 | }; |
| | 161 | auto it = find_if(begin(attribs), end(attribs), [&](const string &name) { |
| 162 | 162 | return source.hasAttribute(name) || dest.hasAttribute(name); |
| 163 | 163 | }); |
| 164 | | return it == attribs.end(); |
| | 164 | return it == end(attribs); |
| 165 | 165 | } |
diff --git a/src/utility.hpp b/src/utility.hpp
|
a
|
b
|
|
| 103 | 103 | return std::unique_ptr<T>{static_cast<T*>(old.release())}; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | | |
| 107 | | template <typename... T> |
| 108 | | constexpr auto make_array (T&&... values) -> |
| 109 | | std::array<typename std::decay<typename std::common_type<T...>::type>::type, sizeof...(T)> { |
| 110 | | return std::array<typename std::decay<typename std::common_type<T...>::type>::type, sizeof...(T)>{ |
| 111 | | std::forward<T>(values)... |
| 112 | | }; |
| 113 | | } |
| 114 | | |
| 115 | 106 | } // namespace util |
| 116 | 107 | |
| 117 | 108 | #endif |