clang-format
(pre-commit run --show-diff-on-failure --color=always --all-files)
This commit is contained in:
parent
e412e12599
commit
3176749613
1 changed files with 88 additions and 89 deletions
|
@ -500,102 +500,102 @@ void traverse_tree(svg_parser& parser, rapidxml::xml_node<char> const* node)
|
|||
|
||||
switch (node->type())
|
||||
{
|
||||
case rapidxml::node_element:
|
||||
parser.font_sizes_.push_back(parser.font_sizes_.back());
|
||||
switch (name)
|
||||
{
|
||||
case "defs"_case: {
|
||||
if (node->first_node() != nullptr)
|
||||
case rapidxml::node_element:
|
||||
parser.font_sizes_.push_back(parser.font_sizes_.back());
|
||||
switch (name)
|
||||
{
|
||||
parser.is_defs_ = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "clipPath"_case:
|
||||
case "symbol"_case:
|
||||
case "pattern"_case: {
|
||||
parser.ignore_ = true;
|
||||
break;
|
||||
}
|
||||
// the gradient tags *should* be in defs, but illustrator seems not to put them in there so
|
||||
// accept them anywhere
|
||||
case "linearGradient"_case:
|
||||
parse_linear_gradient(parser, node);
|
||||
break;
|
||||
case "radialGradient"_case:
|
||||
parse_radial_gradient(parser, node);
|
||||
break;
|
||||
case "g"_case:
|
||||
parser.path_.push_attr();
|
||||
parse_id(parser, node);
|
||||
if (parser.css_style_)
|
||||
process_css(parser, node);
|
||||
parse_attr(parser, node);
|
||||
parser.path_.begin_group();
|
||||
break;
|
||||
case "use"_case:
|
||||
parser.path_.push_attr();
|
||||
parse_id(parser, node);
|
||||
if (parser.css_style_)
|
||||
process_css(parser, node);
|
||||
parse_attr(parser, node);
|
||||
if (parser.path_.cur_attr().opacity < 1.0)
|
||||
parser.path_.begin_group();
|
||||
parse_use(parser, node);
|
||||
if (parser.path_.cur_attr().opacity < 1.0)
|
||||
parser.path_.end_group();
|
||||
parser.path_.pop_attr();
|
||||
break;
|
||||
default:
|
||||
parser.path_.push_attr();
|
||||
parse_id(parser, node);
|
||||
if (parser.css_style_)
|
||||
process_css(parser, node);
|
||||
parse_attr(parser, node);
|
||||
if (parser.path_.display())
|
||||
{
|
||||
if (parser.path_.cur_attr().opacity < 1.0)
|
||||
parser.path_.begin_group();
|
||||
parse_element(parser, node->name(), node);
|
||||
if (parser.path_.cur_attr().opacity < 1.0)
|
||||
parser.path_.end_group();
|
||||
}
|
||||
parser.path_.pop_attr();
|
||||
break;
|
||||
}
|
||||
|
||||
if ("style"_case == name)
|
||||
{
|
||||
// <style> element is not expected to have nested elements
|
||||
// we're only interested in DATA or CDATA
|
||||
for (auto const* child = node->first_node(); child; child = child->next_sibling())
|
||||
{
|
||||
if (child->type() == rapidxml::node_data || child->type() == rapidxml::node_cdata)
|
||||
{
|
||||
auto const grammar = mapnik::grammar();
|
||||
auto const skipper = mapnik::skipper();
|
||||
char const* first = child->value();
|
||||
char const* last = first + child->value_size();
|
||||
bool result = boost::spirit::x3::phrase_parse(first, last, grammar, skipper, parser.css_data_);
|
||||
if (result && first == last && !parser.css_data_.empty())
|
||||
case "defs"_case: {
|
||||
if (node->first_node() != nullptr)
|
||||
{
|
||||
parser.css_style_ = true;
|
||||
parser.is_defs_ = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "clipPath"_case:
|
||||
case "symbol"_case:
|
||||
case "pattern"_case: {
|
||||
parser.ignore_ = true;
|
||||
break;
|
||||
}
|
||||
// the gradient tags *should* be in defs, but illustrator seems not to put them in there so
|
||||
// accept them anywhere
|
||||
case "linearGradient"_case:
|
||||
parse_linear_gradient(parser, node);
|
||||
break;
|
||||
case "radialGradient"_case:
|
||||
parse_radial_gradient(parser, node);
|
||||
break;
|
||||
case "g"_case:
|
||||
parser.path_.push_attr();
|
||||
parse_id(parser, node);
|
||||
if (parser.css_style_)
|
||||
process_css(parser, node);
|
||||
parse_attr(parser, node);
|
||||
parser.path_.begin_group();
|
||||
break;
|
||||
case "use"_case:
|
||||
parser.path_.push_attr();
|
||||
parse_id(parser, node);
|
||||
if (parser.css_style_)
|
||||
process_css(parser, node);
|
||||
parse_attr(parser, node);
|
||||
if (parser.path_.cur_attr().opacity < 1.0)
|
||||
parser.path_.begin_group();
|
||||
parse_use(parser, node);
|
||||
if (parser.path_.cur_attr().opacity < 1.0)
|
||||
parser.path_.end_group();
|
||||
parser.path_.pop_attr();
|
||||
break;
|
||||
default:
|
||||
parser.path_.push_attr();
|
||||
parse_id(parser, node);
|
||||
if (parser.css_style_)
|
||||
process_css(parser, node);
|
||||
parse_attr(parser, node);
|
||||
if (parser.path_.display())
|
||||
{
|
||||
if (parser.path_.cur_attr().opacity < 1.0)
|
||||
parser.path_.begin_group();
|
||||
parse_element(parser, node->name(), node);
|
||||
if (parser.path_.cur_attr().opacity < 1.0)
|
||||
parser.path_.end_group();
|
||||
}
|
||||
parser.path_.pop_attr();
|
||||
break;
|
||||
}
|
||||
|
||||
if ("style"_case == name)
|
||||
{
|
||||
// <style> element is not expected to have nested elements
|
||||
// we're only interested in DATA or CDATA
|
||||
for (auto const* child = node->first_node(); child; child = child->next_sibling())
|
||||
{
|
||||
if (child->type() == rapidxml::node_data || child->type() == rapidxml::node_cdata)
|
||||
{
|
||||
auto const grammar = mapnik::grammar();
|
||||
auto const skipper = mapnik::skipper();
|
||||
char const* first = child->value();
|
||||
char const* last = first + child->value_size();
|
||||
bool result = boost::spirit::x3::phrase_parse(first, last, grammar, skipper, parser.css_data_);
|
||||
if (result && first == last && !parser.css_data_.empty())
|
||||
{
|
||||
parser.css_style_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto const* child = node->first_node(); child; child = child->next_sibling())
|
||||
else
|
||||
{
|
||||
traverse_tree(parser, child);
|
||||
for (auto const* child = node->first_node(); child; child = child->next_sibling())
|
||||
{
|
||||
traverse_tree(parser, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end_element(parser, node);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
end_element(parser, node);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -607,7 +607,6 @@ void end_element(svg_parser& parser, rapidxml::xml_node<char> const* node)
|
|||
{
|
||||
parser.path_.end_group();
|
||||
parser.path_.pop_attr();
|
||||
|
||||
}
|
||||
else if (name == "svg"_case)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue