forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It is generally working, with the following omissions: * Unregistering properties is not implemented. This means we can't cascade @Property rules. The temporary behavior is that the first @Property rule seen wins (forever). It also means mutating the rule via CSSOM is not supported (as it effectively re-registers the property). * TreeScope is ignored (and untested). * CSSPropertyRule::cssText() returns an empty string, for now. Implementing this in a nice way requires a medium-ish refactor, so it's better to do this in a separate CL. Also, in my proposed PR for @Property, the CSSPropertyRule interface contains a name, and a CSSStyleDeclaration with the descriptors, and this CL matches that approach. After some GitHub discussion, I expect that this will change such that the CSSPropertyRule contains a name, syntax, inherits (bool) and initialValue instead. I would prefer to make the corresponding change in Blink separately, however. I2I=https://groups.google.com/a/chromium.org/d/msg/blink-dev/qoJkuLOMKqI/I3DGDTCRBQAJ BUG=973830 Change-Id: I813ce53bc279a2c0e40fe6ed3ec6ed3084004d9d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1303340 Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Rune Lillesveen <futhark@chromium.org> Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/master@{#673287}
- Loading branch information
Showing
40 changed files
with
869 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "third_party/blink/renderer/core/css/css_property_rule.h" | ||
|
||
#include "third_party/blink/renderer/core/css/css_property_value_set.h" | ||
#include "third_party/blink/renderer/core/css/style_rule.h" | ||
#include "third_party/blink/renderer/core/css/style_rule_css_style_declaration.h" | ||
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h" | ||
|
||
namespace blink { | ||
|
||
CSSPropertyRule::CSSPropertyRule(StyleRuleProperty* property_rule, | ||
CSSStyleSheet* sheet) | ||
: CSSRule(sheet), property_rule_(property_rule) {} | ||
|
||
CSSPropertyRule::~CSSPropertyRule() = default; | ||
|
||
CSSStyleDeclaration* CSSPropertyRule::style() const { | ||
if (!properties_cssom_wrapper_) { | ||
properties_cssom_wrapper_ = | ||
MakeGarbageCollected<StyleRuleCSSStyleDeclaration>( | ||
property_rule_->MutableProperties(), | ||
const_cast<CSSPropertyRule*>(this)); | ||
} | ||
|
||
return properties_cssom_wrapper_.Get(); | ||
} | ||
|
||
String CSSPropertyRule::cssText() const { | ||
// TODO(https://crbug.com/978783): Implement this. | ||
return ""; | ||
} | ||
|
||
void CSSPropertyRule::Reattach(StyleRuleBase* rule) { | ||
DCHECK(rule); | ||
property_rule_ = To<StyleRuleProperty>(rule); | ||
if (properties_cssom_wrapper_) | ||
properties_cssom_wrapper_->Reattach(property_rule_->MutableProperties()); | ||
} | ||
|
||
void CSSPropertyRule::Trace(blink::Visitor* visitor) { | ||
visitor->Trace(property_rule_); | ||
visitor->Trace(properties_cssom_wrapper_); | ||
CSSRule::Trace(visitor); | ||
} | ||
|
||
} // namespace blink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_PROPERTY_RULE_H_ | ||
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_PROPERTY_RULE_H_ | ||
|
||
#include "third_party/blink/renderer/core/css/css_rule.h" | ||
#include "third_party/blink/renderer/platform/heap/handle.h" | ||
#include "third_party/blink/renderer/platform/wtf/casting.h" | ||
|
||
namespace blink { | ||
|
||
class CSSStyleDeclaration; | ||
class StyleRuleProperty; | ||
class StyleRuleCSSStyleDeclaration; | ||
|
||
class CSSPropertyRule final : public CSSRule { | ||
DEFINE_WRAPPERTYPEINFO(); | ||
|
||
public: | ||
CSSPropertyRule(StyleRuleProperty*, CSSStyleSheet*); | ||
~CSSPropertyRule() override; | ||
|
||
String cssText() const override; | ||
void Reattach(StyleRuleBase*) override; | ||
|
||
CSSStyleDeclaration* style() const; | ||
|
||
void Trace(blink::Visitor*) override; | ||
|
||
private: | ||
CSSRule::Type type() const override { return kPropertyRule; } | ||
|
||
Member<StyleRuleProperty> property_rule_; | ||
mutable Member<StyleRuleCSSStyleDeclaration> properties_cssom_wrapper_; | ||
}; | ||
|
||
template <> | ||
struct DowncastTraits<CSSPropertyRule> { | ||
static bool AllowFrom(const CSSRule& rule) { | ||
return rule.type() == CSSRule::kPropertyRule; | ||
} | ||
}; | ||
|
||
} // namespace blink | ||
|
||
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_PROPERTY_RULE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
[ | ||
RuntimeEnabled=CSSVariables2AtProperty | ||
] interface CSSPropertyRule : CSSRule { | ||
readonly attribute CSSStyleDeclaration style; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.