/////// computed_style_base.h class StyleHighlightData final : public RefCounted { public: using PassKey = base::PassKey; using PkComputedStyle = base::PassKey; StyleHighlightData(PkComputedStyle); StyleHighlightData(PkComputedStyle, const StyleHighlightData& other); static scoped_refptr Create(PkComputedStyle); scoped_refptr Copy(PkComputedStyle) const; CORE_EXPORT void InheritFrom(const ComputedStyle& inherit_parent, ComputedStyleBase::IsAtShadowBoundary = ComputedStyleBase::kNotAtShadowBoundary); absl::optional Custom(AtomicString& key) const; absl::optional MutableCustom(AtomicString& key); const ComputedStyle* Selection() const; ComputedStyle* MutableSelection(); const ComputedStyle* TargetText() const; ComputedStyle* MutableTargetText(); const ComputedStyle* SpellingError() const; ComputedStyle* MutableSpellingError(); const ComputedStyle* GrammarError() const; ComputedStyle* MutableGrammarError(); private: StyleHighlightData(); StyleHighlightData(const StyleHighlightData& other); StyleHighlightData(StyleHighlightData&& other) = delete; StyleHighlightData& operator=(const StyleHighlightData& other) = delete; StyleHighlightData& operator=(StyleHighlightData&& other) = delete; HashMap> custom_; DataRef selection_; DataRef target_text_; DataRef spelling_error_; DataRef grammar_error_; }; /////// computed_style_base.cc StyleHighlightData::StyleHighlightData(PkComputedStyle) : StyleHighlightData() {} StyleHighlightData::StyleHighlightData(PkComputedStyle, const StyleHighlightData& other) : StyleHighlightData(other) {} scoped_refptr StyleHighlightData::Create(PkComputedStyle) { return base::AdoptRef(new StyleHighlightData); } scoped_refptr StyleHighlightData::Copy(PkComputedStyle) const { return base::AdoptRef(new StyleHighlightData(*this)); } StyleHighlightData::StyleHighlightData() : custom_() { selection_.Init(PassKey()); target_text_.Init(PassKey()); spelling_error_.Init(PassKey()); grammar_error_.Init(PassKey()); } StyleHighlightData::StyleHighlightData(const StyleHighlightData& other) : custom_(other.custom_) , selection_(other.selection_) , target_text_(other.target_text_) , spelling_error_(other.spelling_error_) , grammar_error_(other.grammar_error_) {} void StyleHighlightData::InheritFrom(const ComputedStyle& inherit_parent, ComputedStyleBase::IsAtShadowBoundary is_at_shadow_boundary) { custom_ = inherit_parent.highlight_data_->custom_; selection_ = inherit_parent.highlight_data_->selection_; target_text_ = inherit_parent.highlight_data_->target_text_; spelling_error_ = inherit_parent.highlight_data_->spelling_error_; grammar_error_ = inherit_parent.highlight_data_->grammar_error_; } absl::optional StyleHighlightData::Custom(AtomicString& key) const { auto result = custom_.find(key); if (result == custom_.end()) return absl::nullopt; return result->value.Get(); } absl::optional StyleHighlightData::MutableCustom(AtomicString& key) { auto result = custom_.find(key); if (result == custom_.end()) return absl::nullopt; return result->value.Access(PassKey()); } const ComputedStyle* StyleHighlightData::Selection() const { return selection_.Get(); } ComputedStyle* StyleHighlightData::MutableSelection() { return selection_.Access(PassKey()); } const ComputedStyle* StyleHighlightData::TargetText() const { return target_text_.Get(); } ComputedStyle* StyleHighlightData::MutableTargetText() { return target_text_.Access(PassKey()); } const ComputedStyle* StyleHighlightData::SpellingError() const { return spelling_error_.Get(); } ComputedStyle* StyleHighlightData::MutableSpellingError() { return spelling_error_.Access(PassKey()); } const ComputedStyle* StyleHighlightData::GrammarError() const { return grammar_error_.Get(); } ComputedStyle* StyleHighlightData::MutableGrammarError() { return grammar_error_.Access(PassKey()); }