Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
(pre-commit run --show-diff-on-failure --color=always --all-files)
  • Loading branch information
artemp committed Apr 30, 2024
1 parent e412e12 commit 3176749
Showing 1 changed file with 83 additions and 84 deletions.
167 changes: 83 additions & 84 deletions src/svg/svg_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
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())
case rapidxml::node_element:
parser.font_sizes_.push_back(parser.font_sizes_.back());
switch (name)
{
if (parser.path_.cur_attr().opacity < 1.0)
case "defs"_case: {
if (node->first_node() != nullptr)
{
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();
parse_element(parser, node->name(), node);
if (parser.path_.cur_attr().opacity < 1.0)
parser.path_.end_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;
}
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 ("style"_case == name)
{
if (child->type() == rapidxml::node_data || child->type() == rapidxml::node_cdata)
// <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())
{
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())
if (child->type() == rapidxml::node_data || child->type() == rapidxml::node_cdata)
{
parser.css_style_ = true;
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;
}
}

Expand All @@ -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)
{
Expand Down

0 comments on commit 3176749

Please sign in to comment.