blob: 2d164c6d2e18faadb3522095984cf2fd05410bc9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
// Copyright 2017 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_CSSOM_CSS_MATH_INVERT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSSOM_CSS_MATH_INVERT_H_
#include "base/macros.h"
#include "third_party/blink/renderer/core/css/cssom/css_math_value.h"
namespace blink {
// Represents the inverse of a CSSNumericValue.
// See CSSMathInvert.idl for more information about this class.
class CORE_EXPORT CSSMathInvert : public CSSMathValue {
DEFINE_WRAPPERTYPEINFO();
public:
// The constructor defined in the IDL.
static CSSMathInvert* Create(const CSSNumberish& arg) {
return Create(CSSNumericValue::FromNumberish(arg));
}
// Blink-internal constructor
static CSSMathInvert* Create(CSSNumericValue* value) {
return new CSSMathInvert(
value, CSSNumericValueType::NegateExponents(value->Type()));
}
String getOperator() const final { return "invert"; }
void value(CSSNumberish& value) { value.SetCSSNumericValue(value_); }
// Blink-internal methods
const CSSNumericValue& Value() const { return *value_; }
// From CSSStyleValue.
StyleValueType GetType() const final { return CSSStyleValue::kInvertType; }
void Trace(Visitor* visitor) override {
visitor->Trace(value_);
CSSMathValue::Trace(visitor);
}
bool Equals(const CSSNumericValue& other) const final {
if (other.GetType() != kNegateType)
return false;
// We can safely cast here as we know 'other' has the same type as us.
const auto& other_invert = static_cast<const CSSMathInvert&>(other);
return value_->Equals(*other_invert.value_);
}
CSSCalcExpressionNode* ToCalcExpressionNode() const final {
// TODO(crbug.com/782103): Implement.
return nullptr;
}
private:
CSSMathInvert(CSSNumericValue* value, const CSSNumericValueType& type)
: CSSMathValue(type), value_(value) {}
// From CSSNumericValue
CSSNumericValue* Invert() final { return value_.Get(); }
base::Optional<CSSNumericSumValue> SumValue() const final;
void BuildCSSText(Nested, ParenLess, StringBuilder&) const final;
Member<CSSNumericValue> value_;
DISALLOW_COPY_AND_ASSIGN(CSSMathInvert);
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSSOM_CSS_MATH_INVERT_H_
|