Commit 5ad5b3fd authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Chromium LUCI CQ

Replace WriteQuotedSVGResource with WriteSVGResourceReferencePrefix

The former is only used once, but we have similar code sequences for the
the other two resources handled in WriteResources(). Move this sequence
into a new WriteSVGResourceReferencePrefix() function and reuse that for
all three.

Bug: 1028063
Change-Id: If557d447d3e14702def8b99d8fee659cc316d355
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2575030
Auto-Submit: Fredrik Söderquist <fs@opera.com>
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834486}
parent e856849f
...@@ -129,16 +129,6 @@ static void WriteNameAndQuotedValue(WTF::TextStream& ts, ...@@ -129,16 +129,6 @@ static void WriteNameAndQuotedValue(WTF::TextStream& ts,
ts << " [" << name << "=\"" << value << "\"]"; ts << " [" << name << "=\"" << value << "\"]";
} }
static void WriteQuotedSVGResource(WTF::TextStream& ts,
const char* name,
const StyleSVGResource* value,
TreeScope& tree_scope) {
DCHECK(value);
AtomicString id = SVGURIReference::FragmentIdentifierFromIRIString(
value->Url(), tree_scope);
WriteNameAndQuotedValue(ts, name, id);
}
template <typename ValueType> template <typename ValueType>
static void WriteIfNotDefault(WTF::TextStream& ts, static void WriteIfNotDefault(WTF::TextStream& ts,
const char* name, const char* name,
...@@ -711,6 +701,22 @@ void Write(WTF::TextStream& ts, const LayoutSVGShape& shape, int indent) { ...@@ -711,6 +701,22 @@ void Write(WTF::TextStream& ts, const LayoutSVGShape& shape, int indent) {
WriteResources(ts, shape, indent); WriteResources(ts, shape, indent);
} }
static void WriteSVGResourceReferencePrefix(
WTF::TextStream& ts,
const char* resource_name,
const LayoutSVGResourceContainer* resource_object,
const AtomicString& url,
const TreeScope& tree_scope,
int indent) {
AtomicString id =
SVGURIReference::FragmentIdentifierFromIRIString(url, tree_scope);
WriteIndent(ts, indent);
ts << " ";
WriteNameAndQuotedValue(ts, resource_name, id);
ts << " ";
WriteStandardPrefix(ts, *resource_object, 0);
}
void WriteResources(WTF::TextStream& ts, void WriteResources(WTF::TextStream& ts,
const LayoutObject& object, const LayoutObject& object,
int indent) { int indent) {
...@@ -722,12 +728,9 @@ void WriteResources(WTF::TextStream& ts, ...@@ -722,12 +728,9 @@ void WriteResources(WTF::TextStream& ts,
const ComputedStyle& style = object.StyleRef(); const ComputedStyle& style = object.StyleRef();
TreeScope& tree_scope = object.GetDocument(); TreeScope& tree_scope = object.GetDocument();
if (LayoutSVGResourceMasker* masker = resources->Masker()) { if (LayoutSVGResourceMasker* masker = resources->Masker()) {
WriteIndent(ts, indent); WriteSVGResourceReferencePrefix(ts, "masker", masker,
ts << " "; style.SvgStyle().MaskerResource()->Url(),
WriteQuotedSVGResource(ts, "masker", style.SvgStyle().MaskerResource(), tree_scope, indent);
tree_scope);
ts << " ";
WriteStandardPrefix(ts, *masker, 0);
ts << " " << masker->ResourceBoundingBox(reference_box, 1) << "\n"; ts << " " << masker->ResourceBoundingBox(reference_box, 1) << "\n";
} }
if (LayoutSVGResourceClipper* clipper = resources->Clipper()) { if (LayoutSVGResourceClipper* clipper = resources->Clipper()) {
...@@ -735,13 +738,8 @@ void WriteResources(WTF::TextStream& ts, ...@@ -735,13 +738,8 @@ void WriteResources(WTF::TextStream& ts,
DCHECK_EQ(style.ClipPath()->GetType(), ClipPathOperation::REFERENCE); DCHECK_EQ(style.ClipPath()->GetType(), ClipPathOperation::REFERENCE);
const ReferenceClipPathOperation& clip_path_reference = const ReferenceClipPathOperation& clip_path_reference =
To<ReferenceClipPathOperation>(*style.ClipPath()); To<ReferenceClipPathOperation>(*style.ClipPath());
AtomicString id = SVGURIReference::FragmentIdentifierFromIRIString( WriteSVGResourceReferencePrefix(
clip_path_reference.Url(), tree_scope); ts, "clipPath", clipper, clip_path_reference.Url(), tree_scope, indent);
WriteIndent(ts, indent);
ts << " ";
WriteNameAndQuotedValue(ts, "clipPath", id);
ts << " ";
WriteStandardPrefix(ts, *clipper, 0);
ts << " " << clipper->ResourceBoundingBox(reference_box) << "\n"; ts << " " << clipper->ResourceBoundingBox(reference_box) << "\n";
} }
if (LayoutSVGResourceFilter* filter = GetFilterResourceForSVG(style)) { if (LayoutSVGResourceFilter* filter = GetFilterResourceForSVG(style)) {
...@@ -751,13 +749,9 @@ void WriteResources(WTF::TextStream& ts, ...@@ -751,13 +749,9 @@ void WriteResources(WTF::TextStream& ts,
DCHECK_EQ(filter_operation.GetType(), FilterOperation::REFERENCE); DCHECK_EQ(filter_operation.GetType(), FilterOperation::REFERENCE);
const auto& reference_filter_operation = const auto& reference_filter_operation =
To<ReferenceFilterOperation>(filter_operation); To<ReferenceFilterOperation>(filter_operation);
AtomicString id = SVGURIReference::FragmentIdentifierFromIRIString( WriteSVGResourceReferencePrefix(ts, "filter", filter,
reference_filter_operation.Url(), tree_scope); reference_filter_operation.Url(),
WriteIndent(ts, indent); tree_scope, indent);
ts << " ";
WriteNameAndQuotedValue(ts, "filter", id);
ts << " ";
WriteStandardPrefix(ts, *filter, 0);
ts << " " << filter->ResourceBoundingBox(reference_box) << "\n"; ts << " " << filter->ResourceBoundingBox(reference_box) << "\n";
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment