-
Notifications
You must be signed in to change notification settings - Fork 48
/
types.go
180 lines (154 loc) · 9.63 KB
/
types.go
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// Code generated by cdpgen. DO NOT EDIT.
package css
import (
"github.com/mafredri/cdp/protocol/dom"
)
// StyleSheetID
type StyleSheetID string
// StyleSheetOrigin Stylesheet type: "injected" for stylesheets injected via extension, "user-agent" for user-agent stylesheets, "inspector" for stylesheets created by the inspector (i.e. those holding the "via inspector" rules), "regular" for regular stylesheets.
type StyleSheetOrigin string
// StyleSheetOrigin as enums.
const (
StyleSheetOriginNotSet StyleSheetOrigin = ""
StyleSheetOriginInjected StyleSheetOrigin = "injected"
StyleSheetOriginUserAgent StyleSheetOrigin = "user-agent"
StyleSheetOriginInspector StyleSheetOrigin = "inspector"
StyleSheetOriginRegular StyleSheetOrigin = "regular"
)
func (e StyleSheetOrigin) Valid() bool {
switch e {
case "injected", "user-agent", "inspector", "regular":
return true
default:
return false
}
}
func (e StyleSheetOrigin) String() string {
return string(e)
}
// PseudoElementMatches CSS rule collection for a single pseudo style.
type PseudoElementMatches struct {
PseudoType dom.PseudoType `json:"pseudoType"` // Pseudo element type.
Matches []RuleMatch `json:"matches"` // Matches of CSS rules applicable to the pseudo style.
}
// InheritedStyleEntry Inherited CSS rule collection from ancestor node.
type InheritedStyleEntry struct {
InlineStyle *Style `json:"inlineStyle,omitempty"` // The ancestor node's inline style, if any, in the style inheritance chain.
MatchedCSSRules []RuleMatch `json:"matchedCSSRules"` // Matches of CSS rules matching the ancestor node in the style inheritance chain.
}
// RuleMatch Match data for a CSS rule.
type RuleMatch struct {
Rule Rule `json:"rule"` // CSS rule in the match.
MatchingSelectors []int `json:"matchingSelectors"` // Matching selector indices in the rule's selectorList selectors (0-based).
}
// Value Data for a simple selector (these are delimited by commas in a selector list).
type Value struct {
Text string `json:"text"` // Value text.
Range *SourceRange `json:"range,omitempty"` // Value range in the underlying resource (if available).
}
// SelectorList Selector list data.
type SelectorList struct {
Selectors []Value `json:"selectors"` // Selectors in the list.
Text string `json:"text"` // Rule selector text.
}
// Rule CSS rule representation.
type Rule struct {
StyleSheetID *StyleSheetID `json:"styleSheetId,omitempty"` // The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
SelectorList SelectorList `json:"selectorList"` // Rule selector data.
Origin StyleSheetOrigin `json:"origin"` // Parent stylesheet's origin.
Style Style `json:"style"` // Associated style declaration.
Media []Media `json:"media,omitempty"` // Media list array (for rules involving media queries). The array enumerates media queries starting with the innermost one, going outwards.
}
// RuleUsage CSS coverage information.
type RuleUsage struct {
StyleSheetID StyleSheetID `json:"styleSheetId"` // The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
StartOffset float64 `json:"startOffset"` // Offset of the start of the rule (including selector) from the beginning of the stylesheet.
EndOffset float64 `json:"endOffset"` // Offset of the end of the rule body from the beginning of the stylesheet.
Used bool `json:"used"` // Indicates whether the rule was actually used by some element in the page.
}
// SourceRange Text range within a resource. All numbers are zero-based.
type SourceRange struct {
StartLine int `json:"startLine"` // Start line of range.
StartColumn int `json:"startColumn"` // Start column of range (inclusive).
EndLine int `json:"endLine"` // End line of range
EndColumn int `json:"endColumn"` // End column of range (exclusive).
}
// ShorthandEntry
type ShorthandEntry struct {
Name string `json:"name"` // Shorthand name.
Value string `json:"value"` // Shorthand value.
Important *bool `json:"important,omitempty"` // Whether the property has "!important" annotation (implies false if absent).
}
// ComputedStyleProperty
type ComputedStyleProperty struct {
Name string `json:"name"` // Computed style property name.
Value string `json:"value"` // Computed style property value.
}
// Style CSS style representation.
type Style struct {
StyleSheetID *StyleSheetID `json:"styleSheetId,omitempty"` // The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
CSSProperties []Property `json:"cssProperties"` // CSS properties in the style.
ShorthandEntries []ShorthandEntry `json:"shorthandEntries"` // Computed values for all shorthands found in the style.
CSSText *string `json:"cssText,omitempty"` // Style declaration text (if available).
Range *SourceRange `json:"range,omitempty"` // Style declaration range in the enclosing stylesheet (if available).
}
// Property CSS property declaration data.
type Property struct {
Name string `json:"name"` // The property name.
Value string `json:"value"` // The property value.
Important *bool `json:"important,omitempty"` // Whether the property has "!important" annotation (implies false if absent).
Implicit *bool `json:"implicit,omitempty"` // Whether the property is implicit (implies false if absent).
Text *string `json:"text,omitempty"` // The full property text as specified in the style.
ParsedOk *bool `json:"parsedOk,omitempty"` // Whether the property is understood by the browser (implies true if absent).
Disabled *bool `json:"disabled,omitempty"` // Whether the property is disabled by the user (present for source-based properties only).
Range *SourceRange `json:"range,omitempty"` // The entire property range in the enclosing style declaration (if available).
}
// Media CSS media rule descriptor.
type Media struct {
Text string `json:"text"` // Media query text.
// Source Source of the media query: "mediaRule" if specified by a @media rule, "importRule" if specified by an @import rule, "linkedSheet" if specified by a "media" attribute in a linked stylesheet's LINK tag, "inlineSheet" if specified by a "media" attribute in an inline stylesheet's STYLE tag.
//
// Values: "mediaRule", "importRule", "linkedSheet", "inlineSheet".
Source string `json:"source"`
SourceURL *string `json:"sourceURL,omitempty"` // URL of the document containing the media query description.
Range *SourceRange `json:"range,omitempty"` // The associated rule (@media or @import) header range in the enclosing stylesheet (if available).
StyleSheetID *StyleSheetID `json:"styleSheetId,omitempty"` // Identifier of the stylesheet containing this object (if exists).
MediaList []MediaQuery `json:"mediaList,omitempty"` // Array of media queries.
}
// MediaQuery Media query descriptor.
type MediaQuery struct {
Expressions []MediaQueryExpression `json:"expressions"` // Array of media query expressions.
Active bool `json:"active"` // Whether the media query condition is satisfied.
}
// MediaQueryExpression Media query expression descriptor.
type MediaQueryExpression struct {
Value float64 `json:"value"` // Media query expression value.
Unit string `json:"unit"` // Media query expression units.
Feature string `json:"feature"` // Media query expression feature.
ValueRange *SourceRange `json:"valueRange,omitempty"` // The associated range of the value text in the enclosing stylesheet (if available).
ComputedLength *float64 `json:"computedLength,omitempty"` // Computed length of media query expression (if applicable).
}
// PlatformFontUsage Information about amount of glyphs that were rendered with given font.
type PlatformFontUsage struct {
FamilyName string `json:"familyName"` // Font's family name reported by platform.
IsCustomFont bool `json:"isCustomFont"` // Indicates if the font was downloaded or resolved locally.
GlyphCount float64 `json:"glyphCount"` // Amount of glyphs that were rendered with this font.
}
// KeyframesRule CSS keyframes rule representation.
type KeyframesRule struct {
AnimationName Value `json:"animationName"` // Animation name.
Keyframes []KeyframeRule `json:"keyframes"` // List of keyframes.
}
// KeyframeRule CSS keyframe rule representation.
type KeyframeRule struct {
StyleSheetID *StyleSheetID `json:"styleSheetId,omitempty"` // The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
Origin StyleSheetOrigin `json:"origin"` // Parent stylesheet's origin.
KeyText Value `json:"keyText"` // Associated key text.
Style Style `json:"style"` // Associated style declaration.
}
// StyleDeclarationEdit A descriptor of operation to mutate style declaration text.
type StyleDeclarationEdit struct {
StyleSheetID StyleSheetID `json:"styleSheetId"` // The css style sheet identifier.
Range SourceRange `json:"range"` // The range of the style text in the enclosing stylesheet.
Text string `json:"text"` // New style text.
}