Commit d8fab434 authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

Return scoped_refptr<CSSVariableData> from ValueFromCustomProperty.

In the near future, it will be necessary for ValueForCustomProperty
to return a CSSVariableData which may not be stored elsewhere. This
is because we need to do a "non-destructive" pre-resolve of registered
custom properties that are used before high priority properties are
applied.

R=futhark@chromium.org

Bug: 641877
Change-Id: Idb1ab4ba7aae77187a4fd86877a0246e56fc82a4
Reviewed-on: https://chromium-review.googlesource.com/1235936Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592784}
parent 6ae67a15
......@@ -66,7 +66,7 @@ bool CSSVariableResolver::ResolveFallback(CSSParserTokenRange range,
return ResolveTokenRange(range, options, result);
}
CSSVariableData* CSSVariableResolver::ValueForCustomProperty(
scoped_refptr<CSSVariableData> CSSVariableResolver::ValueForCustomProperty(
AtomicString name) {
if (variables_seen_.Contains(name)) {
cycle_start_points_.insert(name);
......@@ -98,7 +98,7 @@ CSSVariableData* CSSVariableResolver::ValueForCustomProperty(
name, *variable_data, resolve_urls, unused_cycle_detected);
if (!registration) {
inherited_variables_->SetVariable(name, new_variable_data);
return new_variable_data.get();
return new_variable_data;
}
const CSSValue* parsed_value = nullptr;
......@@ -117,7 +117,7 @@ CSSVariableData* CSSVariableResolver::ValueForCustomProperty(
}
if (!new_variable_data)
return registration->InitialVariableData();
return new_variable_data.get();
return new_variable_data;
}
scoped_refptr<CSSVariableData> CSSVariableResolver::ResolveCustomProperty(
......@@ -220,7 +220,7 @@ bool CSSVariableResolver::ResolveVariableReference(CSSParserTokenRange range,
inherited_variables_ = state_.Style()->InheritedVariables();
non_inherited_variables_ = state_.Style()->NonInheritedVariables();
}
CSSVariableData* variable_data =
scoped_refptr<CSSVariableData> variable_data =
is_env_variable ? ValueForEnvironmentVariable(variable_name)
: ValueForCustomProperty(variable_name);
......@@ -246,7 +246,7 @@ bool CSSVariableResolver::ResolveVariableReference(CSSParserTokenRange range,
return true;
}
CSSVariableData* CSSVariableResolver::ValueForEnvironmentVariable(
scoped_refptr<CSSVariableData> CSSVariableResolver::ValueForEnvironmentVariable(
const AtomicString& name) {
// If we are in a User Agent Shadow DOM then we should not record metrics.
ContainerNode& scope_root = state_.GetTreeScope().RootNode();
......
......@@ -117,10 +117,11 @@ class CORE_EXPORT CSSVariableResolver {
// These return null if the custom property is invalid.
// Returns the CSSVariableData for an environment variable.
CSSVariableData* ValueForEnvironmentVariable(const AtomicString& name);
scoped_refptr<CSSVariableData> ValueForEnvironmentVariable(
const AtomicString& name);
// Returns the CSSVariableData for a custom property, resolving and storing it
// if necessary.
CSSVariableData* ValueForCustomProperty(AtomicString name);
scoped_refptr<CSSVariableData> ValueForCustomProperty(AtomicString name);
// Resolves the CSSVariableData from a custom property declaration.
scoped_refptr<CSSVariableData> ResolveCustomProperty(AtomicString name,
const CSSVariableData&,
......
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