summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/css/css_computed_style_declaration.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/css/css_computed_style_declaration.cc')
-rw-r--r--chromium/third_party/blink/renderer/core/css/css_computed_style_declaration.cc44
1 files changed, 26 insertions, 18 deletions
diff --git a/chromium/third_party/blink/renderer/core/css/css_computed_style_declaration.cc b/chromium/third_party/blink/renderer/core/css/css_computed_style_declaration.cc
index 729b37a3af3..4df6327a8ee 100644
--- a/chromium/third_party/blink/renderer/core/css/css_computed_style_declaration.cc
+++ b/chromium/third_party/blink/renderer/core/css/css_computed_style_declaration.cc
@@ -157,9 +157,7 @@ const CSSPropertyID kComputedPropertyArray[] = {
CSSPropertyID::kRowGap, CSSPropertyID::kWebkitHighlight,
CSSPropertyID::kHyphens, CSSPropertyID::kWebkitHyphenateCharacter,
CSSPropertyID::kWebkitLineBreak, CSSPropertyID::kWebkitLineClamp,
- CSSPropertyID::kWebkitLocale, CSSPropertyID::kWebkitMarginBeforeCollapse,
- CSSPropertyID::kWebkitMarginAfterCollapse,
- CSSPropertyID::kWebkitMaskBoxImage,
+ CSSPropertyID::kWebkitLocale, CSSPropertyID::kWebkitMaskBoxImage,
CSSPropertyID::kWebkitMaskBoxImageOutset,
CSSPropertyID::kWebkitMaskBoxImageRepeat,
CSSPropertyID::kWebkitMaskBoxImageSlice,
@@ -205,7 +203,7 @@ const CSSPropertyID kComputedPropertyArray[] = {
CSSPropertyID::kCy, CSSPropertyID::kX, CSSPropertyID::kY, CSSPropertyID::kR,
CSSPropertyID::kRx, CSSPropertyID::kRy, CSSPropertyID::kTranslate,
CSSPropertyID::kRotate, CSSPropertyID::kScale, CSSPropertyID::kCaretColor,
- CSSPropertyID::kLineBreak};
+ CSSPropertyID::kLineBreak, CSSPropertyID::kMathStyle};
CSSValueID CssIdentifierForFontSizeKeyword(int keyword_size) {
DCHECK_NE(keyword_size, 0);
@@ -228,11 +226,13 @@ void LogUnimplementedPropertyID(const CSSProperty& property) {
} // namespace
const Vector<const CSSProperty*>&
-CSSComputedStyleDeclaration::ComputableProperties() {
+CSSComputedStyleDeclaration::ComputableProperties(
+ const ExecutionContext* execution_context) {
DEFINE_STATIC_LOCAL(Vector<const CSSProperty*>, properties, ());
if (properties.IsEmpty()) {
CSSProperty::FilterWebExposedCSSPropertiesIntoVector(
- kComputedPropertyArray, base::size(kComputedPropertyArray), properties);
+ execution_context, kComputedPropertyArray,
+ base::size(kComputedPropertyArray), properties);
}
return properties;
}
@@ -241,7 +241,8 @@ CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(
Node* n,
bool allow_visited_style,
const String& pseudo_element_name)
- : node_(n),
+ : CSSStyleDeclaration(n ? n->GetExecutionContext() : nullptr),
+ node_(n),
pseudo_element_specifier_(
CSSSelector::ParsePseudoId(pseudo_element_name)),
allow_visited_style_(allow_visited_style) {}
@@ -250,7 +251,8 @@ CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration() = default;
String CSSComputedStyleDeclaration::cssText() const {
StringBuilder result;
- static const Vector<const CSSProperty*>& properties = ComputableProperties();
+ static const Vector<const CSSProperty*>& properties =
+ ComputableProperties(GetExecutionContext());
for (unsigned i = 0; i < properties.size(); i++) {
if (i)
@@ -277,7 +279,7 @@ CSSComputedStyleDeclaration::GetFontSizeCSSValuePreferringKeyword() const {
if (!node_)
return nullptr;
- node_->GetDocument().UpdateStyleAndLayout();
+ node_->GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kEditing);
const ComputedStyle* style =
node_->EnsureComputedStyle(pseudo_element_specifier_);
@@ -387,7 +389,8 @@ const CSSValue* CSSComputedStyleDeclaration::GetPropertyCSSValue(
CSSProperty::Get(property_name.Id()).IsLayoutDependentProperty();
if (is_layout_dependent_property ||
document.GetStyleEngine().HasViewportDependentMediaQueries()) {
- owner->GetDocument().UpdateStyleAndLayout();
+ owner->GetDocument().UpdateStyleAndLayout(
+ DocumentUpdateReason::kJavaScript);
// The style recalc could have caused the styled node to be discarded or
// replaced if it was a PseudoElement so we need to update it.
styled_node = StyledNode();
@@ -408,7 +411,8 @@ const CSSValue* CSSComputedStyleDeclaration::GetPropertyCSSValue(
const ComputedStyle* style = ComputeComputedStyle();
if (property_class.IsLayoutDependent(style, layout_object)) {
- document.UpdateStyleAndLayoutForNode(styled_node);
+ document.UpdateStyleAndLayoutForNode(styled_node,
+ DocumentUpdateReason::kJavaScript);
styled_node = StyledNode();
style = ComputeComputedStyle();
layout_object = StyledLayoutObject();
@@ -444,14 +448,15 @@ String CSSComputedStyleDeclaration::GetPropertyValue(
unsigned CSSComputedStyleDeclaration::length() const {
if (!node_ || !node_->InActiveDocument())
return 0;
- return ComputableProperties().size();
+ return ComputableProperties(GetExecutionContext()).size();
}
String CSSComputedStyleDeclaration::item(unsigned i) const {
if (i >= length())
return "";
- return ComputableProperties()[i]->GetPropertyNameString();
+ return ComputableProperties(GetExecutionContext())[i]
+ ->GetPropertyNameString();
}
bool CSSComputedStyleDeclaration::CssPropertyMatches(
@@ -461,7 +466,8 @@ bool CSSComputedStyleDeclaration::CssPropertyMatches(
(property_value.IsPrimitiveValue() ||
property_value.IsIdentifierValue()) &&
node_) {
- node_->GetDocument().UpdateStyleAndLayout();
+ // This is only used by editing code.
+ node_->GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kEditing);
const ComputedStyle* style =
node_->EnsureComputedStyle(pseudo_element_specifier_);
if (style && style->GetFontDescription().KeywordSize()) {
@@ -478,7 +484,7 @@ bool CSSComputedStyleDeclaration::CssPropertyMatches(
MutableCSSPropertyValueSet* CSSComputedStyleDeclaration::CopyProperties()
const {
- return CopyPropertiesInSet(ComputableProperties());
+ return CopyPropertiesInSet(ComputableProperties(GetExecutionContext()));
}
MutableCSSPropertyValueSet* CSSComputedStyleDeclaration::CopyPropertiesInSet(
@@ -501,7 +507,8 @@ CSSRule* CSSComputedStyleDeclaration::parentRule() const {
String CSSComputedStyleDeclaration::getPropertyValue(
const String& property_name) {
- CSSPropertyID property_id = cssPropertyID(property_name);
+ CSSPropertyID property_id =
+ cssPropertyID(GetExecutionContext(), property_name);
if (!isValidCSSPropertyID(property_id))
return String();
if (property_id == CSSPropertyID::kVariable) {
@@ -561,7 +568,8 @@ const CSSValue* CSSComputedStyleDeclaration::GetPropertyCSSValueInternal(
const CSSValue* CSSComputedStyleDeclaration::GetPropertyCSSValueInternal(
AtomicString custom_property_name) {
- DCHECK_EQ(CSSPropertyID::kVariable, cssPropertyID(custom_property_name));
+ DCHECK_EQ(CSSPropertyID::kVariable,
+ cssPropertyID(GetExecutionContext(), custom_property_name));
return GetPropertyCSSValue(custom_property_name);
}
@@ -584,7 +592,7 @@ void CSSComputedStyleDeclaration::SetPropertyInternal(
"' property is read-only.");
}
-void CSSComputedStyleDeclaration::Trace(blink::Visitor* visitor) {
+void CSSComputedStyleDeclaration::Trace(Visitor* visitor) {
visitor->Trace(node_);
CSSStyleDeclaration::Trace(visitor);
}