-
Notifications
You must be signed in to change notification settings - Fork 6.6k
/
css_length_resolver.h
99 lines (85 loc) · 3.65 KB
/
css_length_resolver.h
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Copyright 2022 The Chromium Authors
// 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_LENGTH_RESOLVER_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_LENGTH_RESOLVER_H_
#include <limits>
#include "base/check_op.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/css/css_primitive_value.h"
#include "third_party/blink/renderer/platform/text/writing_mode.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
namespace blink {
class CORE_EXPORT CSSLengthResolver {
public:
explicit CSSLengthResolver(float zoom) : zoom_(zoom) {}
// Font-relative sizes handle the target zoom themselves. This is because
// font-relative sizes may be pre-zoomed (with a factor potentially different
// from the target zoom).
virtual float EmFontSize(float zoom) const = 0;
virtual float RemFontSize(float zoom) const = 0;
virtual float ExFontSize(float zoom) const = 0;
virtual float RexFontSize(float zoom) const = 0;
virtual float ChFontSize(float zoom) const = 0;
virtual float RchFontSize(float zoom) const = 0;
virtual float IcFontSize(float zoom) const = 0;
virtual float RicFontSize(float zoom) const = 0;
virtual float LineHeight(float zoom) const = 0;
virtual float RootLineHeight(float zoom) const = 0;
// Other sizes are not pre-zoomed.
virtual double ViewportWidth() const = 0;
virtual double ViewportHeight() const = 0;
virtual double SmallViewportWidth() const = 0;
virtual double SmallViewportHeight() const = 0;
virtual double LargeViewportWidth() const = 0;
virtual double LargeViewportHeight() const = 0;
virtual double DynamicViewportWidth() const = 0;
virtual double DynamicViewportHeight() const = 0;
virtual double ContainerWidth() const = 0;
virtual double ContainerHeight() const = 0;
virtual WritingMode GetWritingMode() const = 0;
float Zoom() const { return zoom_; }
void SetZoom(float zoom) {
DCHECK(std::isfinite(zoom));
DCHECK_GT(zoom, 0);
zoom_ = zoom;
}
double ZoomedComputedPixels(double value, CSSPrimitiveValue::UnitType) const;
private:
bool IsHorizontalWritingMode() const {
return blink::IsHorizontalWritingMode(GetWritingMode());
}
double ViewportWidthPercent() const;
double ViewportHeightPercent() const;
double ViewportInlineSizePercent() const;
double ViewportBlockSizePercent() const;
double ViewportMinPercent() const;
double ViewportMaxPercent() const;
double SmallViewportWidthPercent() const;
double SmallViewportHeightPercent() const;
double SmallViewportInlineSizePercent() const;
double SmallViewportBlockSizePercent() const;
double SmallViewportMinPercent() const;
double SmallViewportMaxPercent() const;
double LargeViewportWidthPercent() const;
double LargeViewportHeightPercent() const;
double LargeViewportInlineSizePercent() const;
double LargeViewportBlockSizePercent() const;
double LargeViewportMinPercent() const;
double LargeViewportMaxPercent() const;
double DynamicViewportWidthPercent() const;
double DynamicViewportHeightPercent() const;
double DynamicViewportInlineSizePercent() const;
double DynamicViewportBlockSizePercent() const;
double DynamicViewportMinPercent() const;
double DynamicViewportMaxPercent() const;
double ContainerWidthPercent() const;
double ContainerHeightPercent() const;
double ContainerInlineSizePercent() const;
double ContainerBlockSizePercent() const;
double ContainerMinPercent() const;
double ContainerMaxPercent() const;
float zoom_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_LENGTH_RESOLVER_H_