/src/mozilla-central/layout/style/ServoBindings.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "mozilla/ServoBindings.h" |
8 | | |
9 | | #include "ChildIterator.h" |
10 | | #include "ErrorReporter.h" |
11 | | #include "GeckoProfiler.h" |
12 | | #include "gfxFontFamilyList.h" |
13 | | #include "gfxFontFeatures.h" |
14 | | #include "nsAnimationManager.h" |
15 | | #include "nsAttrValueInlines.h" |
16 | | #include "nsCSSFrameConstructor.h" |
17 | | #include "nsCSSProps.h" |
18 | | #include "nsCSSPseudoElements.h" |
19 | | #include "nsContentUtils.h" |
20 | | #include "nsDOMTokenList.h" |
21 | | #include "nsDeviceContext.h" |
22 | | #include "nsIContentInlines.h" |
23 | | #include "nsICrashReporter.h" |
24 | | #include "nsIDocumentInlines.h" |
25 | | #include "nsILoadContext.h" |
26 | | #include "nsIFrame.h" |
27 | | #include "nsIMemoryReporter.h" |
28 | | #include "nsIMozBrowserFrame.h" |
29 | | #include "nsINode.h" |
30 | | #include "nsIPresShell.h" |
31 | | #include "nsIPresShellInlines.h" |
32 | | #include "nsIPrincipal.h" |
33 | | #include "nsIURI.h" |
34 | | #include "nsFontMetrics.h" |
35 | | #include "nsHTMLStyleSheet.h" |
36 | | #include "nsMappedAttributes.h" |
37 | | #include "nsMediaFeatures.h" |
38 | | #include "nsNameSpaceManager.h" |
39 | | #include "nsNetUtil.h" |
40 | | #include "nsProxyRelease.h" |
41 | | #include "nsString.h" |
42 | | #include "nsStyleStruct.h" |
43 | | #include "nsStyleUtil.h" |
44 | | #include "nsSVGElement.h" |
45 | | #include "nsTArray.h" |
46 | | #include "nsTransitionManager.h" |
47 | | #include "nsWindowSizes.h" |
48 | | |
49 | | #include "mozilla/CORSMode.h" |
50 | | #include "mozilla/DeclarationBlock.h" |
51 | | #include "mozilla/EffectCompositor.h" |
52 | | #include "mozilla/EffectSet.h" |
53 | | #include "mozilla/EventStates.h" |
54 | | #include "mozilla/FontPropertyTypes.h" |
55 | | #include "mozilla/Keyframe.h" |
56 | | #include "mozilla/Mutex.h" |
57 | | #include "mozilla/Preferences.h" |
58 | | #include "mozilla/ServoElementSnapshot.h" |
59 | | #include "mozilla/StaticPrefs.h" |
60 | | #include "mozilla/RestyleManager.h" |
61 | | #include "mozilla/SizeOfState.h" |
62 | | #include "mozilla/StyleAnimationValue.h" |
63 | | #include "mozilla/SystemGroup.h" |
64 | | #include "mozilla/ServoTraversalStatistics.h" |
65 | | #include "mozilla/Telemetry.h" |
66 | | #include "mozilla/RWLock.h" |
67 | | #include "mozilla/dom/Element.h" |
68 | | #include "mozilla/dom/ElementInlines.h" |
69 | | #include "mozilla/dom/HTMLTableCellElement.h" |
70 | | #include "mozilla/dom/HTMLBodyElement.h" |
71 | | #include "mozilla/dom/HTMLSlotElement.h" |
72 | | #include "mozilla/dom/MediaList.h" |
73 | | #include "mozilla/LookAndFeel.h" |
74 | | #include "mozilla/URLExtraData.h" |
75 | | #include "mozilla/dom/CSSMozDocumentRule.h" |
76 | | |
77 | | #if defined(MOZ_MEMORY) |
78 | | # include "mozmemory.h" |
79 | | #endif |
80 | | |
81 | | using namespace mozilla; |
82 | | using namespace mozilla::css; |
83 | | using namespace mozilla::dom; |
84 | | |
85 | | #define SERVO_ARC_TYPE(name_, type_) \ |
86 | | already_AddRefed<type_> \ |
87 | 0 | type_##Strong::Consume() { \ |
88 | 0 | RefPtr<type_> result; \ |
89 | 0 | result.swap(mPtr); \ |
90 | 0 | return result.forget(); \ |
91 | 0 | } Unexecuted instantiation: ServoCssRulesStrong::Consume() Unexecuted instantiation: RawServoStyleSheetContentsStrong::Consume() Unexecuted instantiation: RawServoDeclarationBlockStrong::Consume() Unexecuted instantiation: RawServoStyleRuleStrong::Consume() Unexecuted instantiation: RawServoImportRuleStrong::Consume() Unexecuted instantiation: RawServoAnimationValueStrong::Consume() Unexecuted instantiation: RawServoKeyframeStrong::Consume() Unexecuted instantiation: RawServoKeyframesRuleStrong::Consume() Unexecuted instantiation: RawServoMediaListStrong::Consume() Unexecuted instantiation: RawServoMediaRuleStrong::Consume() Unexecuted instantiation: RawServoNamespaceRuleStrong::Consume() Unexecuted instantiation: RawServoPageRuleStrong::Consume() Unexecuted instantiation: RawServoSupportsRuleStrong::Consume() Unexecuted instantiation: RawServoMozDocumentRuleStrong::Consume() Unexecuted instantiation: RawServoFontFeatureValuesRuleStrong::Consume() Unexecuted instantiation: RawServoRuleNodeStrong::Consume() Unexecuted instantiation: RawServoFontFaceRuleStrong::Consume() Unexecuted instantiation: RawServoCounterStyleRuleStrong::Consume() Unexecuted instantiation: ComputedStyleStrong::Consume() |
92 | | #include "mozilla/ServoArcTypeList.h" |
93 | | SERVO_ARC_TYPE(ComputedStyle, ComputedStyle) |
94 | | #undef SERVO_ARC_TYPE |
95 | | |
96 | | // Definitions of the global traversal stats. |
97 | | bool ServoTraversalStatistics::sActive = false; |
98 | | ServoTraversalStatistics ServoTraversalStatistics::sSingleton; |
99 | | |
100 | | static RWLock* sServoFFILock = nullptr; |
101 | | |
102 | | static |
103 | | const nsFont* |
104 | | ThreadSafeGetDefaultFontHelper(const nsPresContext* aPresContext, |
105 | | nsAtom* aLanguage, uint8_t aGenericId) |
106 | 0 | { |
107 | 0 | bool needsCache = false; |
108 | 0 | const nsFont* retval; |
109 | 0 |
|
110 | 0 | { |
111 | 0 | AutoReadLock guard(*sServoFFILock); |
112 | 0 | retval = aPresContext->GetDefaultFont(aGenericId, aLanguage, &needsCache); |
113 | 0 | } |
114 | 0 | if (!needsCache) { |
115 | 0 | return retval; |
116 | 0 | } |
117 | 0 | { |
118 | 0 | AutoWriteLock guard(*sServoFFILock); |
119 | 0 | retval = aPresContext->GetDefaultFont(aGenericId, aLanguage, nullptr); |
120 | 0 | } |
121 | 0 | return retval; |
122 | 0 | } |
123 | | |
124 | | void |
125 | | AssertIsMainThreadOrServoLangFontPrefsCacheLocked() |
126 | 0 | { |
127 | 0 | MOZ_ASSERT(NS_IsMainThread() || sServoFFILock->LockedForWritingByCurrentThread()); |
128 | 0 | } |
129 | | |
130 | | |
131 | | /* |
132 | | * Does this child count as significant for selector matching? |
133 | | * |
134 | | * See nsStyleUtil::IsSignificantChild for details. |
135 | | */ |
136 | | bool |
137 | | Gecko_IsSignificantChild(RawGeckoNodeBorrowed aNode, |
138 | | bool aWhitespaceIsSignificant) |
139 | 0 | { |
140 | 0 | return nsStyleUtil::ThreadSafeIsSignificantChild(aNode->AsContent(), |
141 | 0 | aWhitespaceIsSignificant); |
142 | 0 | } |
143 | | |
144 | | RawGeckoNodeBorrowedOrNull |
145 | | Gecko_GetLastChild(RawGeckoNodeBorrowed aNode) |
146 | 0 | { |
147 | 0 | return aNode->GetLastChild(); |
148 | 0 | } |
149 | | |
150 | | RawGeckoNodeBorrowedOrNull |
151 | | Gecko_GetPreviousSibling(RawGeckoNodeBorrowed aNode) |
152 | 0 | { |
153 | 0 | return aNode->GetPreviousSibling(); |
154 | 0 | } |
155 | | |
156 | | RawGeckoNodeBorrowedOrNull |
157 | | Gecko_GetFlattenedTreeParentNode(RawGeckoNodeBorrowed aNode) |
158 | 0 | { |
159 | 0 | return aNode->GetFlattenedTreeParentNodeForStyle(); |
160 | 0 | } |
161 | | |
162 | | RawGeckoElementBorrowedOrNull |
163 | | Gecko_GetBeforeOrAfterPseudo(RawGeckoElementBorrowed aElement, bool aIsBefore) |
164 | 0 | { |
165 | 0 | MOZ_ASSERT(aElement); |
166 | 0 | MOZ_ASSERT(aElement->HasProperties()); |
167 | 0 |
|
168 | 0 | return aIsBefore |
169 | 0 | ? nsLayoutUtils::GetBeforePseudo(aElement) |
170 | 0 | : nsLayoutUtils::GetAfterPseudo(aElement); |
171 | 0 | } |
172 | | |
173 | | nsTArray<nsIContent*>* |
174 | | Gecko_GetAnonymousContentForElement(RawGeckoElementBorrowed aElement) |
175 | 0 | { |
176 | 0 | nsIAnonymousContentCreator* ac = do_QueryFrame(aElement->GetPrimaryFrame()); |
177 | 0 | if (!ac) { |
178 | 0 | return nullptr; |
179 | 0 | } |
180 | 0 | |
181 | 0 | auto* array = new nsTArray<nsIContent*>(); |
182 | 0 | nsContentUtils::AppendNativeAnonymousChildren(aElement, *array, 0); |
183 | 0 | return array; |
184 | 0 | } |
185 | | |
186 | | void |
187 | | Gecko_DestroyAnonymousContentList(nsTArray<nsIContent*>* aAnonContent) |
188 | 0 | { |
189 | 0 | MOZ_ASSERT(aAnonContent); |
190 | 0 | delete aAnonContent; |
191 | 0 | } |
192 | | |
193 | | const nsTArray<RefPtr<nsINode>>* |
194 | | Gecko_GetAssignedNodes(RawGeckoElementBorrowed aElement) |
195 | 0 | { |
196 | 0 | MOZ_ASSERT(HTMLSlotElement::FromNode(aElement)); |
197 | 0 | return &static_cast<const HTMLSlotElement*>(aElement)->AssignedNodes(); |
198 | 0 | } |
199 | | |
200 | | void |
201 | | Gecko_ComputedStyle_Init(mozilla::ComputedStyle* aStyle, |
202 | | RawGeckoPresContextBorrowed aPresContext, |
203 | | const ServoComputedData* aValues, |
204 | | mozilla::CSSPseudoElementType aPseudoType, |
205 | | nsAtom* aPseudoTag) |
206 | 0 | { |
207 | 0 | auto* presContext = const_cast<nsPresContext*>(aPresContext); |
208 | 0 | new (KnownNotNull, aStyle) mozilla::ComputedStyle( |
209 | 0 | presContext, aPseudoTag, aPseudoType, |
210 | 0 | ServoComputedDataForgotten(aValues)); |
211 | 0 | } |
212 | | |
213 | | ServoComputedData::ServoComputedData( |
214 | | const ServoComputedDataForgotten aValue) |
215 | 0 | { |
216 | 0 | PodAssign(this, aValue.mPtr); |
217 | 0 | } |
218 | | |
219 | | MOZ_DEFINE_MALLOC_ENCLOSING_SIZE_OF(ServoStyleStructsMallocEnclosingSizeOf) |
220 | | |
221 | | void |
222 | | ServoComputedData::AddSizeOfExcludingThis(nsWindowSizes& aSizes) const |
223 | 0 | { |
224 | 0 | // Note: GetStyleFoo() returns a pointer to an nsStyleFoo that sits within a |
225 | 0 | // servo_arc::Arc, i.e. it is preceded by a word-sized refcount. So we need |
226 | 0 | // to measure it with a function that can handle an interior pointer. We use |
227 | 0 | // ServoStyleStructsEnclosingMallocSizeOf to clearly identify in DMD's |
228 | 0 | // output the memory measured here. |
229 | 0 | #define STYLE_STRUCT(name_) \ |
230 | 0 | static_assert(alignof(nsStyle##name_) <= sizeof(size_t), \ |
231 | 0 | "alignment will break AddSizeOfExcludingThis()"); \ |
232 | 0 | const void* p##name_ = GetStyle##name_(); \ |
233 | 0 | if (!aSizes.mState.HaveSeenPtr(p##name_)) { \ |
234 | 0 | aSizes.mStyleSizes.NS_STYLE_SIZES_FIELD(name_) += \ |
235 | 0 | ServoStyleStructsMallocEnclosingSizeOf(p##name_); \ |
236 | 0 | } |
237 | 0 | #include "nsStyleStructList.h" |
238 | 0 | #undef STYLE_STRUCT |
239 | 0 |
|
240 | 0 | if (visited_style.mPtr && !aSizes.mState.HaveSeenPtr(visited_style.mPtr)) { |
241 | 0 | visited_style.mPtr->AddSizeOfIncludingThis( |
242 | 0 | aSizes, &aSizes.mLayoutComputedValuesVisited); |
243 | 0 | } |
244 | 0 |
|
245 | 0 | // Measurement of the following members may be added later if DMD finds it is |
246 | 0 | // worthwhile: |
247 | 0 | // - custom_properties |
248 | 0 | // - writing_mode |
249 | 0 | // - rules |
250 | 0 | // - font_computation_data |
251 | 0 | } |
252 | | |
253 | | void |
254 | | Gecko_ComputedStyle_Destroy(mozilla::ComputedStyle* aStyle) |
255 | 0 | { |
256 | 0 | aStyle->~ComputedStyle(); |
257 | 0 | } |
258 | | |
259 | | void |
260 | | Gecko_ConstructStyleChildrenIterator( |
261 | | RawGeckoElementBorrowed aElement, |
262 | | RawGeckoStyleChildrenIteratorBorrowedMut aIterator) |
263 | 0 | { |
264 | 0 | MOZ_ASSERT(aElement); |
265 | 0 | MOZ_ASSERT(aIterator); |
266 | 0 | new (aIterator) StyleChildrenIterator(aElement); |
267 | 0 | } |
268 | | |
269 | | void |
270 | | Gecko_DestroyStyleChildrenIterator( |
271 | | RawGeckoStyleChildrenIteratorBorrowedMut aIterator) |
272 | 0 | { |
273 | 0 | MOZ_ASSERT(aIterator); |
274 | 0 |
|
275 | 0 | aIterator->~StyleChildrenIterator(); |
276 | 0 | } |
277 | | |
278 | | RawGeckoNodeBorrowed |
279 | | Gecko_GetNextStyleChild(RawGeckoStyleChildrenIteratorBorrowedMut aIterator) |
280 | 0 | { |
281 | 0 | MOZ_ASSERT(aIterator); |
282 | 0 | return aIterator->GetNextChild(); |
283 | 0 | } |
284 | | |
285 | | bool |
286 | | Gecko_VisitedStylesEnabled(const nsIDocument* aDoc) |
287 | 0 | { |
288 | 0 | MOZ_ASSERT(aDoc); |
289 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
290 | 0 |
|
291 | 0 | if (!StaticPrefs::layout_css_visited_links_enabled()) { |
292 | 0 | return false; |
293 | 0 | } |
294 | 0 | |
295 | 0 | if (aDoc->IsBeingUsedAsImage()) { |
296 | 0 | return false; |
297 | 0 | } |
298 | 0 | |
299 | 0 | nsILoadContext* loadContext = aDoc->GetLoadContext(); |
300 | 0 | if (loadContext && loadContext->UsePrivateBrowsing()) { |
301 | 0 | return false; |
302 | 0 | } |
303 | 0 | |
304 | 0 | return true; |
305 | 0 | } |
306 | | |
307 | | EventStates::ServoType |
308 | | Gecko_ElementState(RawGeckoElementBorrowed aElement) |
309 | 0 | { |
310 | 0 | return aElement->StyleState().ServoValue(); |
311 | 0 | } |
312 | | |
313 | | bool |
314 | | Gecko_IsRootElement(RawGeckoElementBorrowed aElement) |
315 | 0 | { |
316 | 0 | return aElement->OwnerDoc()->GetRootElement() == aElement; |
317 | 0 | } |
318 | | |
319 | | // Dirtiness tracking. |
320 | | void |
321 | | Gecko_SetNodeFlags(RawGeckoNodeBorrowed aNode, uint32_t aFlags) |
322 | 0 | { |
323 | 0 | const_cast<nsINode*>(aNode)->SetFlags(aFlags); |
324 | 0 | } |
325 | | |
326 | | void |
327 | | Gecko_UnsetNodeFlags(RawGeckoNodeBorrowed aNode, uint32_t aFlags) |
328 | 0 | { |
329 | 0 | const_cast<nsINode*>(aNode)->UnsetFlags(aFlags); |
330 | 0 | } |
331 | | |
332 | | void |
333 | | Gecko_NoteDirtyElement(RawGeckoElementBorrowed aElement) |
334 | 0 | { |
335 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
336 | 0 | const_cast<Element*>(aElement)->NoteDirtyForServo(); |
337 | 0 | } |
338 | | |
339 | | void |
340 | | Gecko_NoteDirtySubtreeForInvalidation(RawGeckoElementBorrowed aElement) |
341 | 0 | { |
342 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
343 | 0 | const_cast<Element*>(aElement)->NoteDirtySubtreeForServo(); |
344 | 0 | } |
345 | | |
346 | | void |
347 | | Gecko_NoteAnimationOnlyDirtyElement(RawGeckoElementBorrowed aElement) |
348 | 0 | { |
349 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
350 | 0 | const_cast<Element*>(aElement)->NoteAnimationOnlyDirtyForServo(); |
351 | 0 | } |
352 | | |
353 | | bool Gecko_AnimationNameMayBeReferencedFromStyle( |
354 | | RawGeckoPresContextBorrowed aPresContext, |
355 | | nsAtom* aName) |
356 | 0 | { |
357 | 0 | MOZ_ASSERT(aPresContext); |
358 | 0 | return aPresContext->AnimationManager()->AnimationMayBeReferenced(aName); |
359 | 0 | } |
360 | | |
361 | | CSSPseudoElementType |
362 | | Gecko_GetImplementedPseudo(RawGeckoElementBorrowed aElement) |
363 | 0 | { |
364 | 0 | return aElement->GetPseudoElementType(); |
365 | 0 | } |
366 | | |
367 | | uint32_t |
368 | | Gecko_CalcStyleDifference(ComputedStyleBorrowed aOldStyle, |
369 | | ComputedStyleBorrowed aNewStyle, |
370 | | bool* aAnyStyleStructChanged, |
371 | | bool* aOnlyResetStructsChanged) |
372 | 0 | { |
373 | 0 | MOZ_ASSERT(aOldStyle); |
374 | 0 | MOZ_ASSERT(aNewStyle); |
375 | 0 |
|
376 | 0 | uint32_t equalStructs; |
377 | 0 | nsChangeHint result = const_cast<ComputedStyle*>(aOldStyle)-> |
378 | 0 | CalcStyleDifference(const_cast<ComputedStyle*>(aNewStyle), &equalStructs); |
379 | 0 |
|
380 | 0 | *aAnyStyleStructChanged = |
381 | 0 | equalStructs != StyleStructConstants::kAllStructsMask; |
382 | 0 |
|
383 | 0 | const auto kInheritedStructsMask = StyleStructConstants::kInheritedStructsMask; |
384 | 0 | *aOnlyResetStructsChanged = |
385 | 0 | (equalStructs & kInheritedStructsMask) == kInheritedStructsMask; |
386 | 0 |
|
387 | 0 | return result; |
388 | 0 | } |
389 | | |
390 | | const ServoElementSnapshot* |
391 | | Gecko_GetElementSnapshot(const ServoElementSnapshotTable* aTable, |
392 | | const Element* aElement) |
393 | 0 | { |
394 | 0 | MOZ_ASSERT(aTable); |
395 | 0 | MOZ_ASSERT(aElement); |
396 | 0 |
|
397 | 0 | return aTable->Get(const_cast<Element*>(aElement)); |
398 | 0 | } |
399 | | |
400 | | bool |
401 | | Gecko_HaveSeenPtr(SeenPtrs* aTable, const void* aPtr) |
402 | 0 | { |
403 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
404 | 0 | MOZ_ASSERT(aTable); |
405 | 0 | // Empty Rust allocations are indicated by small values up to the alignment |
406 | 0 | // of the relevant type. We shouldn't see anything like that here. |
407 | 0 | MOZ_ASSERT(uintptr_t(aPtr) > 16); |
408 | 0 |
|
409 | 0 | return aTable->HaveSeenPtr(aPtr); |
410 | 0 | } |
411 | | |
412 | | RawServoDeclarationBlockStrongBorrowedOrNull |
413 | | Gecko_GetStyleAttrDeclarationBlock(RawGeckoElementBorrowed aElement) |
414 | 0 | { |
415 | 0 | DeclarationBlock* decl = aElement->GetInlineStyleDeclaration(); |
416 | 0 | if (!decl) { |
417 | 0 | return nullptr; |
418 | 0 | } |
419 | 0 | return decl->RefRawStrong(); |
420 | 0 | } |
421 | | |
422 | | void |
423 | | Gecko_UnsetDirtyStyleAttr(RawGeckoElementBorrowed aElement) |
424 | 0 | { |
425 | 0 | DeclarationBlock* decl = aElement->GetInlineStyleDeclaration(); |
426 | 0 | if (!decl) { |
427 | 0 | return; |
428 | 0 | } |
429 | 0 | decl->UnsetDirty(); |
430 | 0 | } |
431 | | |
432 | | static const RawServoDeclarationBlockStrong* |
433 | | AsRefRawStrong(const RefPtr<RawServoDeclarationBlock>& aDecl) |
434 | 0 | { |
435 | 0 | static_assert(sizeof(RefPtr<RawServoDeclarationBlock>) == |
436 | 0 | sizeof(RawServoDeclarationBlockStrong), |
437 | 0 | "RefPtr should just be a pointer"); |
438 | 0 | return reinterpret_cast<const RawServoDeclarationBlockStrong*>(&aDecl); |
439 | 0 | } |
440 | | |
441 | | RawServoDeclarationBlockStrongBorrowedOrNull |
442 | | Gecko_GetHTMLPresentationAttrDeclarationBlock(RawGeckoElementBorrowed aElement) |
443 | 0 | { |
444 | 0 | const nsMappedAttributes* attrs = aElement->GetMappedAttributes(); |
445 | 0 | if (!attrs) { |
446 | 0 | auto* svg = nsSVGElement::FromNodeOrNull(aElement); |
447 | 0 | if (svg) { |
448 | 0 | if (auto decl = svg->GetContentDeclarationBlock()) { |
449 | 0 | return decl->RefRawStrong(); |
450 | 0 | } |
451 | 0 | } |
452 | 0 | return nullptr; |
453 | 0 | } |
454 | 0 | |
455 | 0 | return AsRefRawStrong(attrs->GetServoStyle()); |
456 | 0 | } |
457 | | |
458 | | RawServoDeclarationBlockStrongBorrowedOrNull |
459 | | Gecko_GetExtraContentStyleDeclarations(RawGeckoElementBorrowed aElement) |
460 | 0 | { |
461 | 0 | if (!aElement->IsAnyOfHTMLElements(nsGkAtoms::td, nsGkAtoms::th)) { |
462 | 0 | return nullptr; |
463 | 0 | } |
464 | 0 | const HTMLTableCellElement* cell = static_cast<const HTMLTableCellElement*>(aElement); |
465 | 0 | if (nsMappedAttributes* attrs = cell->GetMappedAttributesInheritedFromTable()) { |
466 | 0 | return AsRefRawStrong(attrs->GetServoStyle()); |
467 | 0 | } |
468 | 0 | return nullptr; |
469 | 0 | } |
470 | | |
471 | | RawServoDeclarationBlockStrongBorrowedOrNull |
472 | | Gecko_GetUnvisitedLinkAttrDeclarationBlock(RawGeckoElementBorrowed aElement) |
473 | 0 | { |
474 | 0 | nsHTMLStyleSheet* sheet = aElement->OwnerDoc()->GetAttributeStyleSheet(); |
475 | 0 | if (!sheet) { |
476 | 0 | return nullptr; |
477 | 0 | } |
478 | 0 | |
479 | 0 | return AsRefRawStrong(sheet->GetServoUnvisitedLinkDecl()); |
480 | 0 | } |
481 | | |
482 | | StyleSheet* Gecko_StyleSheet_Clone( |
483 | | const StyleSheet* aSheet, |
484 | | const StyleSheet* aNewParentSheet) |
485 | 0 | { |
486 | 0 | MOZ_ASSERT(aSheet); |
487 | 0 | MOZ_ASSERT(aSheet->GetParentSheet(), "Should only be used for @import"); |
488 | 0 | MOZ_ASSERT(aNewParentSheet, "Wat"); |
489 | 0 |
|
490 | 0 | RefPtr<StyleSheet> newSheet = |
491 | 0 | aSheet->Clone(nullptr, nullptr, nullptr, nullptr); |
492 | 0 |
|
493 | 0 | // NOTE(emilio): This code runs in the StylesheetInner constructor, which |
494 | 0 | // means that the inner pointer of `aNewParentSheet` still points to the old |
495 | 0 | // one. |
496 | 0 | // |
497 | 0 | // So we _don't_ update neither the parent pointer of the stylesheet, nor the |
498 | 0 | // child list (yet). This is fixed up in that same constructor. |
499 | 0 | return static_cast<StyleSheet*>(newSheet.forget().take()); |
500 | 0 | } |
501 | | |
502 | | void |
503 | | Gecko_StyleSheet_AddRef(const StyleSheet* aSheet) |
504 | 0 | { |
505 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
506 | 0 | const_cast<StyleSheet*>(aSheet)->AddRef(); |
507 | 0 | } |
508 | | |
509 | | void |
510 | | Gecko_StyleSheet_Release(const StyleSheet* aSheet) |
511 | 0 | { |
512 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
513 | 0 | const_cast<StyleSheet*>(aSheet)->Release(); |
514 | 0 | } |
515 | | |
516 | | RawServoDeclarationBlockStrongBorrowedOrNull |
517 | | Gecko_GetVisitedLinkAttrDeclarationBlock(RawGeckoElementBorrowed aElement) |
518 | 0 | { |
519 | 0 | nsHTMLStyleSheet* sheet = aElement->OwnerDoc()->GetAttributeStyleSheet(); |
520 | 0 | if (!sheet) { |
521 | 0 | return nullptr; |
522 | 0 | } |
523 | 0 | |
524 | 0 | return AsRefRawStrong(sheet->GetServoVisitedLinkDecl()); |
525 | 0 | } |
526 | | |
527 | | RawServoDeclarationBlockStrongBorrowedOrNull |
528 | | Gecko_GetActiveLinkAttrDeclarationBlock(RawGeckoElementBorrowed aElement) |
529 | 0 | { |
530 | 0 | nsHTMLStyleSheet* sheet = aElement->OwnerDoc()->GetAttributeStyleSheet(); |
531 | 0 | if (!sheet) { |
532 | 0 | return nullptr; |
533 | 0 | } |
534 | 0 | |
535 | 0 | return AsRefRawStrong(sheet->GetServoActiveLinkDecl()); |
536 | 0 | } |
537 | | |
538 | | static CSSPseudoElementType |
539 | 0 | GetPseudoTypeFromElementForAnimation(const Element*& aElementOrPseudo) { |
540 | 0 | if (aElementOrPseudo->IsGeneratedContentContainerForBefore()) { |
541 | 0 | aElementOrPseudo = aElementOrPseudo->GetParent()->AsElement(); |
542 | 0 | return CSSPseudoElementType::before; |
543 | 0 | } |
544 | 0 | |
545 | 0 | if (aElementOrPseudo->IsGeneratedContentContainerForAfter()) { |
546 | 0 | aElementOrPseudo = aElementOrPseudo->GetParent()->AsElement(); |
547 | 0 | return CSSPseudoElementType::after; |
548 | 0 | } |
549 | 0 | |
550 | 0 | return CSSPseudoElementType::NotPseudo; |
551 | 0 | } |
552 | | |
553 | | bool |
554 | | Gecko_GetAnimationRule(RawGeckoElementBorrowed aElement, |
555 | | EffectCompositor::CascadeLevel aCascadeLevel, |
556 | | RawServoAnimationValueMapBorrowedMut aAnimationValues) |
557 | 0 | { |
558 | 0 | MOZ_ASSERT(aElement); |
559 | 0 |
|
560 | 0 | nsIDocument* doc = aElement->GetComposedDoc(); |
561 | 0 | if (!doc) { |
562 | 0 | return false; |
563 | 0 | } |
564 | 0 | nsPresContext* presContext = doc->GetPresContext(); |
565 | 0 | if (!presContext || !presContext->IsDynamic()) { |
566 | 0 | // For print or print preview, ignore animations. |
567 | 0 | return false; |
568 | 0 | } |
569 | 0 | |
570 | 0 | CSSPseudoElementType pseudoType = |
571 | 0 | GetPseudoTypeFromElementForAnimation(aElement); |
572 | 0 |
|
573 | 0 | return presContext->EffectCompositor() |
574 | 0 | ->GetServoAnimationRule(aElement, |
575 | 0 | pseudoType, |
576 | 0 | aCascadeLevel, |
577 | 0 | aAnimationValues); |
578 | 0 | } |
579 | | |
580 | | bool |
581 | | Gecko_StyleAnimationsEquals(RawGeckoStyleAnimationListBorrowed aA, |
582 | | RawGeckoStyleAnimationListBorrowed aB) |
583 | 0 | { |
584 | 0 | return *aA == *aB; |
585 | 0 | } |
586 | | |
587 | | void |
588 | | Gecko_CopyAnimationNames(RawGeckoStyleAnimationListBorrowedMut aDest, |
589 | | RawGeckoStyleAnimationListBorrowed aSrc) |
590 | 0 | { |
591 | 0 | size_t srcLength = aSrc->Length(); |
592 | 0 | aDest->EnsureLengthAtLeast(srcLength); |
593 | 0 |
|
594 | 0 | for (size_t index = 0; index < srcLength; index++) { |
595 | 0 | (*aDest)[index].SetName((*aSrc)[index].GetName()); |
596 | 0 | } |
597 | 0 | } |
598 | | |
599 | | void |
600 | | Gecko_SetAnimationName(StyleAnimation* aStyleAnimation, |
601 | | nsAtom* aAtom) |
602 | 0 | { |
603 | 0 | MOZ_ASSERT(aStyleAnimation); |
604 | 0 |
|
605 | 0 | aStyleAnimation->SetName(already_AddRefed<nsAtom>(aAtom)); |
606 | 0 | } |
607 | | |
608 | | void |
609 | | Gecko_UpdateAnimations(RawGeckoElementBorrowed aElement, |
610 | | ComputedStyleBorrowedOrNull aOldComputedData, |
611 | | ComputedStyleBorrowedOrNull aComputedData, |
612 | | UpdateAnimationsTasks aTasks) |
613 | 0 | { |
614 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
615 | 0 | MOZ_ASSERT(aElement); |
616 | 0 |
|
617 | 0 | if (!aElement->IsInComposedDoc()) { |
618 | 0 | return; |
619 | 0 | } |
620 | 0 | |
621 | 0 | nsPresContext* presContext = nsContentUtils::GetContextForContent(aElement); |
622 | 0 | if (!presContext || !presContext->IsDynamic()) { |
623 | 0 | return; |
624 | 0 | } |
625 | 0 | |
626 | 0 | nsAutoAnimationMutationBatch mb(aElement->OwnerDoc()); |
627 | 0 |
|
628 | 0 | CSSPseudoElementType pseudoType = |
629 | 0 | GetPseudoTypeFromElementForAnimation(aElement); |
630 | 0 |
|
631 | 0 | if (aTasks & UpdateAnimationsTasks::CSSAnimations) { |
632 | 0 | presContext->AnimationManager()-> |
633 | 0 | UpdateAnimations(const_cast<dom::Element*>(aElement), pseudoType, |
634 | 0 | aComputedData); |
635 | 0 | } |
636 | 0 |
|
637 | 0 | // aComputedData might be nullptr if the target element is now in a |
638 | 0 | // display:none subtree. We still call Gecko_UpdateAnimations in this case |
639 | 0 | // because we need to stop CSS animations in the display:none subtree. |
640 | 0 | // However, we don't need to update transitions since they are stopped by |
641 | 0 | // RestyleManager::AnimationsWithDestroyedFrame so we just return early |
642 | 0 | // here. |
643 | 0 | if (!aComputedData) { |
644 | 0 | return; |
645 | 0 | } |
646 | 0 | |
647 | 0 | if (aTasks & UpdateAnimationsTasks::CSSTransitions) { |
648 | 0 | MOZ_ASSERT(aOldComputedData); |
649 | 0 | presContext->TransitionManager()-> |
650 | 0 | UpdateTransitions(const_cast<dom::Element*>(aElement), pseudoType, |
651 | 0 | *aOldComputedData, |
652 | 0 | *aComputedData); |
653 | 0 | } |
654 | 0 |
|
655 | 0 | if (aTasks & UpdateAnimationsTasks::EffectProperties) { |
656 | 0 | presContext->EffectCompositor()->UpdateEffectProperties( |
657 | 0 | aComputedData, const_cast<dom::Element*>(aElement), pseudoType); |
658 | 0 | } |
659 | 0 |
|
660 | 0 | if (aTasks & UpdateAnimationsTasks::CascadeResults) { |
661 | 0 | EffectSet* effectSet = EffectSet::GetEffectSet(aElement, pseudoType); |
662 | 0 | // CSS animations/transitions might have been destroyed as part of the above |
663 | 0 | // steps so before updating cascade results, we check if there are still any |
664 | 0 | // animations to update. |
665 | 0 | if (effectSet) { |
666 | 0 | // We call UpdateCascadeResults directly (intead of |
667 | 0 | // MaybeUpdateCascadeResults) since we know for sure that the cascade has |
668 | 0 | // changed, but we were unable to call MarkCascadeUpdated when we noticed |
669 | 0 | // it since we avoid mutating state as part of the Servo parallel |
670 | 0 | // traversal. |
671 | 0 | presContext->EffectCompositor() |
672 | 0 | ->UpdateCascadeResults(*effectSet, |
673 | 0 | const_cast<Element*>(aElement), |
674 | 0 | pseudoType); |
675 | 0 | } |
676 | 0 | } |
677 | 0 |
|
678 | 0 | if (aTasks & UpdateAnimationsTasks::DisplayChangedFromNone) { |
679 | 0 | presContext->EffectCompositor() |
680 | 0 | ->RequestRestyle(const_cast<Element*>(aElement), |
681 | 0 | pseudoType, |
682 | 0 | EffectCompositor::RestyleType::Standard, |
683 | 0 | EffectCompositor::CascadeLevel::Animations); |
684 | 0 | } |
685 | 0 | } |
686 | | |
687 | | size_t |
688 | | Gecko_GetAnimationEffectCount(RawGeckoElementBorrowed aElementOrPseudo) |
689 | 0 | { |
690 | 0 | CSSPseudoElementType pseudoType = |
691 | 0 | GetPseudoTypeFromElementForAnimation(aElementOrPseudo); |
692 | 0 |
|
693 | 0 | EffectSet* effectSet = EffectSet::GetEffectSet(aElementOrPseudo, pseudoType); |
694 | 0 | return effectSet ? effectSet->Count() : 0; |
695 | 0 | } |
696 | | |
697 | | bool |
698 | | Gecko_ElementHasAnimations(RawGeckoElementBorrowed aElement) |
699 | 0 | { |
700 | 0 | CSSPseudoElementType pseudoType = |
701 | 0 | GetPseudoTypeFromElementForAnimation(aElement); |
702 | 0 |
|
703 | 0 | return !!EffectSet::GetEffectSet(aElement, pseudoType); |
704 | 0 | } |
705 | | |
706 | | bool |
707 | | Gecko_ElementHasCSSAnimations(RawGeckoElementBorrowed aElement) |
708 | 0 | { |
709 | 0 | CSSPseudoElementType pseudoType = |
710 | 0 | GetPseudoTypeFromElementForAnimation(aElement); |
711 | 0 | nsAnimationManager::CSSAnimationCollection* collection = |
712 | 0 | nsAnimationManager::CSSAnimationCollection |
713 | 0 | ::GetAnimationCollection(aElement, pseudoType); |
714 | 0 |
|
715 | 0 | return collection && !collection->mAnimations.IsEmpty(); |
716 | 0 | } |
717 | | |
718 | | bool |
719 | | Gecko_ElementHasCSSTransitions(RawGeckoElementBorrowed aElement) |
720 | 0 | { |
721 | 0 | CSSPseudoElementType pseudoType = |
722 | 0 | GetPseudoTypeFromElementForAnimation(aElement); |
723 | 0 | nsTransitionManager::CSSTransitionCollection* collection = |
724 | 0 | nsTransitionManager::CSSTransitionCollection |
725 | 0 | ::GetAnimationCollection(aElement, pseudoType); |
726 | 0 |
|
727 | 0 | return collection && !collection->mAnimations.IsEmpty(); |
728 | 0 | } |
729 | | |
730 | | size_t |
731 | | Gecko_ElementTransitions_Length(RawGeckoElementBorrowed aElement) |
732 | 0 | { |
733 | 0 | CSSPseudoElementType pseudoType = |
734 | 0 | GetPseudoTypeFromElementForAnimation(aElement); |
735 | 0 | nsTransitionManager::CSSTransitionCollection* collection = |
736 | 0 | nsTransitionManager::CSSTransitionCollection |
737 | 0 | ::GetAnimationCollection(aElement, pseudoType); |
738 | 0 |
|
739 | 0 | return collection ? collection->mAnimations.Length() : 0; |
740 | 0 | } |
741 | | |
742 | | static CSSTransition* |
743 | | GetCurrentTransitionAt(RawGeckoElementBorrowed aElement, size_t aIndex) |
744 | 0 | { |
745 | 0 | CSSPseudoElementType pseudoType = |
746 | 0 | GetPseudoTypeFromElementForAnimation(aElement); |
747 | 0 | nsTransitionManager::CSSTransitionCollection* collection = |
748 | 0 | nsTransitionManager::CSSTransitionCollection |
749 | 0 | ::GetAnimationCollection(aElement, pseudoType); |
750 | 0 | if (!collection) { |
751 | 0 | return nullptr; |
752 | 0 | } |
753 | 0 | nsTArray<RefPtr<CSSTransition>>& transitions = collection->mAnimations; |
754 | 0 | return aIndex < transitions.Length() |
755 | 0 | ? transitions[aIndex].get() |
756 | 0 | : nullptr; |
757 | 0 | } |
758 | | |
759 | | nsCSSPropertyID |
760 | | Gecko_ElementTransitions_PropertyAt(RawGeckoElementBorrowed aElement, |
761 | | size_t aIndex) |
762 | 0 | { |
763 | 0 | CSSTransition* transition = GetCurrentTransitionAt(aElement, aIndex); |
764 | 0 | return transition ? transition->TransitionProperty() |
765 | 0 | : nsCSSPropertyID::eCSSProperty_UNKNOWN; |
766 | 0 | } |
767 | | |
768 | | RawServoAnimationValueBorrowedOrNull |
769 | | Gecko_ElementTransitions_EndValueAt(RawGeckoElementBorrowed aElement, |
770 | | size_t aIndex) |
771 | 0 | { |
772 | 0 | CSSTransition* transition = GetCurrentTransitionAt(aElement, |
773 | 0 | aIndex); |
774 | 0 | return transition ? transition->ToValue().mServo.get() : nullptr; |
775 | 0 | } |
776 | | |
777 | | double |
778 | | Gecko_GetProgressFromComputedTiming(RawGeckoComputedTimingBorrowed aComputedTiming) |
779 | 0 | { |
780 | 0 | return aComputedTiming->mProgress.Value(); |
781 | 0 | } |
782 | | |
783 | | double |
784 | | Gecko_GetPositionInSegment(RawGeckoAnimationPropertySegmentBorrowed aSegment, |
785 | | double aProgress, |
786 | | ComputedTimingFunction::BeforeFlag aBeforeFlag) |
787 | 0 | { |
788 | 0 | MOZ_ASSERT(aSegment->mFromKey < aSegment->mToKey, |
789 | 0 | "The segment from key should be less than to key"); |
790 | 0 |
|
791 | 0 | double positionInSegment = (aProgress - aSegment->mFromKey) / |
792 | 0 | // To avoid floating precision inaccuracies, make |
793 | 0 | // sure we calculate both the numerator and |
794 | 0 | // denominator using double precision. |
795 | 0 | (double(aSegment->mToKey) - aSegment->mFromKey); |
796 | 0 |
|
797 | 0 | return ComputedTimingFunction::GetPortion(aSegment->mTimingFunction, |
798 | 0 | positionInSegment, |
799 | 0 | aBeforeFlag); |
800 | 0 | } |
801 | | |
802 | | RawServoAnimationValueBorrowedOrNull |
803 | | Gecko_AnimationGetBaseStyle(void* aBaseStyles, nsCSSPropertyID aProperty) |
804 | 0 | { |
805 | 0 | auto base = |
806 | 0 | static_cast<nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>*> |
807 | 0 | (aBaseStyles); |
808 | 0 | return base->GetWeak(aProperty); |
809 | 0 | } |
810 | | |
811 | | void |
812 | | Gecko_FillAllImageLayers(nsStyleImageLayers* aLayers, uint32_t aMaxLen) |
813 | 0 | { |
814 | 0 | aLayers->FillAllLayers(aMaxLen); |
815 | 0 | } |
816 | | |
817 | | bool |
818 | | Gecko_IsDocumentBody(RawGeckoElementBorrowed aElement) |
819 | 0 | { |
820 | 0 | nsIDocument* doc = aElement->GetUncomposedDoc(); |
821 | 0 | return doc && doc->GetBodyElement() == aElement; |
822 | 0 | } |
823 | | |
824 | | nscolor |
825 | | Gecko_GetLookAndFeelSystemColor(int32_t aId, |
826 | | RawGeckoPresContextBorrowed aPresContext) |
827 | 0 | { |
828 | 0 | bool useStandinsForNativeColors = aPresContext && !aPresContext->IsChrome(); |
829 | 0 | nscolor result; |
830 | 0 | LookAndFeel::ColorID colorId = static_cast<LookAndFeel::ColorID>(aId); |
831 | 0 | AutoWriteLock guard(*sServoFFILock); |
832 | 0 | LookAndFeel::GetColor(colorId, useStandinsForNativeColors, &result); |
833 | 0 | return result; |
834 | 0 | } |
835 | | |
836 | | bool |
837 | | Gecko_MatchLang(RawGeckoElementBorrowed aElement, |
838 | | nsAtom* aOverrideLang, |
839 | | bool aHasOverrideLang, |
840 | | const char16_t* aValue) |
841 | 0 | { |
842 | 0 | MOZ_ASSERT(!(aOverrideLang && !aHasOverrideLang), |
843 | 0 | "aHasOverrideLang should only be set when aOverrideLang is null"); |
844 | 0 | MOZ_ASSERT(aValue, "null lang parameter"); |
845 | 0 | if (!aValue || !*aValue) { |
846 | 0 | return false; |
847 | 0 | } |
848 | 0 | |
849 | 0 | // We have to determine the language of the current element. Since |
850 | 0 | // this is currently no property and since the language is inherited |
851 | 0 | // from the parent we have to be prepared to look at all parent |
852 | 0 | // nodes. The language itself is encoded in the LANG attribute. |
853 | 0 | if (auto* language = aHasOverrideLang ? aOverrideLang : aElement->GetLang()) { |
854 | 0 | return nsStyleUtil::DashMatchCompare(nsDependentAtomString(language), |
855 | 0 | nsDependentString(aValue), |
856 | 0 | nsASCIICaseInsensitiveStringComparator()); |
857 | 0 | } |
858 | 0 | |
859 | 0 | // Try to get the language from the HTTP header or if this |
860 | 0 | // is missing as well from the preferences. |
861 | 0 | // The content language can be a comma-separated list of |
862 | 0 | // language codes. |
863 | 0 | nsAutoString language; |
864 | 0 | aElement->OwnerDoc()->GetContentLanguage(language); |
865 | 0 |
|
866 | 0 | nsDependentString langString(aValue); |
867 | 0 | language.StripWhitespace(); |
868 | 0 | for (auto const& lang : language.Split(char16_t(','))) { |
869 | 0 | if (nsStyleUtil::DashMatchCompare(lang, |
870 | 0 | langString, |
871 | 0 | nsASCIICaseInsensitiveStringComparator())) { |
872 | 0 | return true; |
873 | 0 | } |
874 | 0 | } |
875 | 0 | return false; |
876 | 0 | } |
877 | | |
878 | | nsAtom* |
879 | | Gecko_GetXMLLangValue(RawGeckoElementBorrowed aElement) |
880 | 0 | { |
881 | 0 | const nsAttrValue* attr = |
882 | 0 | aElement->GetParsedAttr(nsGkAtoms::lang, kNameSpaceID_XML); |
883 | 0 |
|
884 | 0 | if (!attr) { |
885 | 0 | return nullptr; |
886 | 0 | } |
887 | 0 | |
888 | 0 | MOZ_ASSERT(attr->Type() == nsAttrValue::eAtom); |
889 | 0 |
|
890 | 0 | RefPtr<nsAtom> atom = attr->GetAtomValue(); |
891 | 0 | return atom.forget().take(); |
892 | 0 | } |
893 | | |
894 | | nsIDocument::DocumentTheme |
895 | | Gecko_GetDocumentLWTheme(const nsIDocument* aDocument) |
896 | 0 | { |
897 | 0 | return aDocument->ThreadSafeGetDocumentLWTheme(); |
898 | 0 | } |
899 | | |
900 | | bool |
901 | | Gecko_IsTableBorderNonzero(RawGeckoElementBorrowed aElement) |
902 | 0 | { |
903 | 0 | if (!aElement->IsHTMLElement(nsGkAtoms::table)) { |
904 | 0 | return false; |
905 | 0 | } |
906 | 0 | const nsAttrValue *val = aElement->GetParsedAttr(nsGkAtoms::border); |
907 | 0 | return val && (val->Type() != nsAttrValue::eInteger || |
908 | 0 | val->GetIntegerValue() != 0); |
909 | 0 | } |
910 | | |
911 | | bool |
912 | | Gecko_IsBrowserFrame(RawGeckoElementBorrowed aElement) |
913 | 0 | { |
914 | 0 | nsIMozBrowserFrame* browserFrame = |
915 | 0 | const_cast<Element*>(aElement)->GetAsMozBrowserFrame(); |
916 | 0 | return browserFrame && browserFrame->GetReallyIsBrowser(); |
917 | 0 | } |
918 | | |
919 | | template <typename Implementor> |
920 | | static nsAtom* |
921 | | LangValue(Implementor* aElement) |
922 | 0 | { |
923 | 0 | // TODO(emilio): Deduplicate a bit with nsIContent::GetLang(). |
924 | 0 | const nsAttrValue* attr = |
925 | 0 | aElement->GetParsedAttr(nsGkAtoms::lang, kNameSpaceID_XML); |
926 | 0 | if (!attr && aElement->SupportsLangAttr()) { |
927 | 0 | attr = aElement->GetParsedAttr(nsGkAtoms::lang); |
928 | 0 | } |
929 | 0 |
|
930 | 0 | if (!attr) { |
931 | 0 | return nullptr; |
932 | 0 | } |
933 | 0 | |
934 | 0 | MOZ_ASSERT(attr->Type() == nsAttrValue::eAtom); |
935 | 0 | RefPtr<nsAtom> atom = attr->GetAtomValue(); |
936 | 0 | return atom.forget().take(); |
937 | 0 | } Unexecuted instantiation: Unified_cpp_layout_style2.cpp:nsAtom* LangValue<mozilla::dom::Element const>(mozilla::dom::Element const*) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:nsAtom* LangValue<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*) |
938 | | |
939 | | template <typename Implementor, typename MatchFn> |
940 | | static bool |
941 | | DoMatch(Implementor* aElement, nsAtom* aNS, nsAtom* aName, MatchFn aMatch) |
942 | 0 | { |
943 | 0 | if (MOZ_LIKELY(aNS)) { |
944 | 0 | int32_t ns = aNS == nsGkAtoms::_empty |
945 | 0 | ? kNameSpaceID_None |
946 | 0 | : nsContentUtils::NameSpaceManager()->GetNameSpaceID( |
947 | 0 | aNS, aElement->IsInChromeDocument()); |
948 | 0 |
|
949 | 0 | MOZ_ASSERT(ns == nsContentUtils::NameSpaceManager()->GetNameSpaceID( |
950 | 0 | aNS, aElement->IsInChromeDocument())); |
951 | 0 | NS_ENSURE_TRUE(ns != kNameSpaceID_Unknown, false); |
952 | 0 | const nsAttrValue* value = aElement->GetParsedAttr(aName, ns); |
953 | 0 | return value && aMatch(value); |
954 | 0 | } |
955 | 0 | |
956 | 0 | // No namespace means any namespace - we have to check them all. :-( |
957 | 0 | BorrowedAttrInfo attrInfo; |
958 | 0 | for (uint32_t i = 0; (attrInfo = aElement->GetAttrInfoAt(i)); ++i) { |
959 | 0 | if (attrInfo.mName->LocalName() != aName) { |
960 | 0 | continue; |
961 | 0 | } |
962 | 0 | if (aMatch(attrInfo.mValue)) { |
963 | 0 | return true; |
964 | 0 | } |
965 | 0 | } |
966 | 0 | return false; |
967 | 0 | } Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool DoMatch<mozilla::dom::Element const, bool HasAttr<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*)::{lambda(nsAttrValue const*)#1}>(mozilla::dom::Element const*, nsAtom*, nsAtom*, bool HasAttr<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*)::{lambda(nsAttrValue const*)#1}) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool DoMatch<mozilla::dom::Element const, bool AttrEquals<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}>(mozilla::dom::Element const*, nsAtom*, nsAtom*, bool AttrEquals<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool DoMatch<mozilla::dom::Element const, bool AttrDashEquals<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}>(mozilla::dom::Element const*, nsAtom*, nsAtom*, bool AttrDashEquals<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool DoMatch<mozilla::dom::Element const, bool AttrIncludes<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}>(mozilla::dom::Element const*, nsAtom*, nsAtom*, bool AttrIncludes<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool DoMatch<mozilla::dom::Element const, bool AttrHasSubstring<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}>(mozilla::dom::Element const*, nsAtom*, nsAtom*, bool AttrHasSubstring<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool DoMatch<mozilla::dom::Element const, bool AttrHasPrefix<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}>(mozilla::dom::Element const*, nsAtom*, nsAtom*, bool AttrHasPrefix<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool DoMatch<mozilla::dom::Element const, bool AttrHasSuffix<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}>(mozilla::dom::Element const*, nsAtom*, nsAtom*, bool AttrHasSuffix<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool DoMatch<mozilla::ServoElementSnapshot const, bool HasAttr<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*)::{lambda(nsAttrValue const*)#1}>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, bool HasAttr<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*)::{lambda(nsAttrValue const*)#1}) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool DoMatch<mozilla::ServoElementSnapshot const, bool AttrEquals<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, bool AttrEquals<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool DoMatch<mozilla::ServoElementSnapshot const, bool AttrDashEquals<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, bool AttrDashEquals<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool DoMatch<mozilla::ServoElementSnapshot const, bool AttrIncludes<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, bool AttrIncludes<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool DoMatch<mozilla::ServoElementSnapshot const, bool AttrHasSubstring<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, bool AttrHasSubstring<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool DoMatch<mozilla::ServoElementSnapshot const, bool AttrHasPrefix<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, bool AttrHasPrefix<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool DoMatch<mozilla::ServoElementSnapshot const, bool AttrHasSuffix<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, bool AttrHasSuffix<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}) |
968 | | |
969 | | template <typename Implementor> |
970 | | static bool |
971 | | HasAttr(Implementor* aElement, nsAtom* aNS, nsAtom* aName) |
972 | 0 | { |
973 | 0 | auto match = [](const nsAttrValue* aValue) { return true; }; Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool HasAttr<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*)::{lambda(nsAttrValue const*)#1}::operator()(nsAttrValue const*) const Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool HasAttr<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*)::{lambda(nsAttrValue const*)#1}::operator()(nsAttrValue const*) const |
974 | 0 | return DoMatch(aElement, aNS, aName, match); |
975 | 0 | } Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool HasAttr<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool HasAttr<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*) |
976 | | |
977 | | template <typename Implementor> |
978 | | static bool |
979 | | AttrEquals(Implementor* aElement, nsAtom* aNS, nsAtom* aName, nsAtom* aStr, |
980 | | bool aIgnoreCase) |
981 | 0 | { |
982 | 0 | auto match = [aStr, aIgnoreCase](const nsAttrValue* aValue) { |
983 | 0 | return aValue->Equals(aStr, aIgnoreCase ? eIgnoreCase : eCaseMatters); |
984 | 0 | }; Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrEquals<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}::operator()(nsAttrValue const*) const Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrEquals<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}::operator()(nsAttrValue const*) const |
985 | 0 | return DoMatch(aElement, aNS, aName, match); |
986 | 0 | } Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrEquals<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrEquals<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool) |
987 | | |
988 | | #define WITH_COMPARATOR(ignore_case_, c_, expr_) \ |
989 | 0 | if (ignore_case_) { \ |
990 | 0 | const nsCaseInsensitiveStringComparator c_ \ |
991 | 0 | = nsCaseInsensitiveStringComparator(); \ |
992 | 0 | return expr_; \ |
993 | 0 | } else { \ |
994 | 0 | const nsDefaultStringComparator c_; \ |
995 | 0 | return expr_; \ |
996 | 0 | } |
997 | | |
998 | | |
999 | | template <typename Implementor> |
1000 | | static bool |
1001 | | AttrDashEquals(Implementor* aElement, nsAtom* aNS, nsAtom* aName, |
1002 | | nsAtom* aStr, bool aIgnoreCase) |
1003 | 0 | { |
1004 | 0 | auto match = [aStr, aIgnoreCase](const nsAttrValue* aValue) { |
1005 | 0 | nsAutoString str; |
1006 | 0 | aValue->ToString(str); |
1007 | 0 | WITH_COMPARATOR(aIgnoreCase, c, |
1008 | 0 | nsStyleUtil::DashMatchCompare(str, nsDependentAtomString(aStr), c)) |
1009 | 0 | }; Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrDashEquals<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}::operator()(nsAttrValue const*) const Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrDashEquals<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}::operator()(nsAttrValue const*) const |
1010 | 0 | return DoMatch(aElement, aNS, aName, match); |
1011 | 0 | } Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrDashEquals<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrDashEquals<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool) |
1012 | | |
1013 | | template <typename Implementor> |
1014 | | static bool |
1015 | | AttrIncludes(Implementor* aElement, nsAtom* aNS, nsAtom* aName, |
1016 | | nsAtom* aStr, bool aIgnoreCase) |
1017 | 0 | { |
1018 | 0 | auto match = [aStr, aIgnoreCase](const nsAttrValue* aValue) { |
1019 | 0 | nsAutoString str; |
1020 | 0 | aValue->ToString(str); |
1021 | 0 | WITH_COMPARATOR(aIgnoreCase, c, |
1022 | 0 | nsStyleUtil::ValueIncludes(str, nsDependentAtomString(aStr), c)) |
1023 | 0 | }; Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrIncludes<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}::operator()(nsAttrValue const*) const Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrIncludes<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}::operator()(nsAttrValue const*) const |
1024 | 0 | return DoMatch(aElement, aNS, aName, match); |
1025 | 0 | } Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrIncludes<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrIncludes<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool) |
1026 | | |
1027 | | template <typename Implementor> |
1028 | | static bool |
1029 | | AttrHasSubstring(Implementor* aElement, nsAtom* aNS, nsAtom* aName, |
1030 | | nsAtom* aStr, bool aIgnoreCase) |
1031 | 0 | { |
1032 | 0 | auto match = [aStr, aIgnoreCase](const nsAttrValue* aValue) { |
1033 | 0 | nsAutoString str; |
1034 | 0 | aValue->ToString(str); |
1035 | 0 | WITH_COMPARATOR(aIgnoreCase, c, |
1036 | 0 | FindInReadable(nsDependentAtomString(aStr), str, c)) |
1037 | 0 | }; Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrHasSubstring<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}::operator()(nsAttrValue const*) const Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrHasSubstring<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}::operator()(nsAttrValue const*) const |
1038 | 0 | return DoMatch(aElement, aNS, aName, match); |
1039 | 0 | } Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrHasSubstring<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrHasSubstring<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool) |
1040 | | |
1041 | | template <typename Implementor> |
1042 | | static bool |
1043 | | AttrHasPrefix(Implementor* aElement, nsAtom* aNS, nsAtom* aName, |
1044 | | nsAtom* aStr, bool aIgnoreCase) |
1045 | 0 | { |
1046 | 0 | auto match = [aStr, aIgnoreCase](const nsAttrValue* aValue) { |
1047 | 0 | nsAutoString str; |
1048 | 0 | aValue->ToString(str); |
1049 | 0 | WITH_COMPARATOR(aIgnoreCase, c, |
1050 | 0 | StringBeginsWith(str, nsDependentAtomString(aStr), c)) |
1051 | 0 | }; Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrHasPrefix<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}::operator()(nsAttrValue const*) const Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrHasPrefix<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}::operator()(nsAttrValue const*) const |
1052 | 0 | return DoMatch(aElement, aNS, aName, match); |
1053 | 0 | } Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrHasPrefix<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrHasPrefix<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool) |
1054 | | |
1055 | | template <typename Implementor> |
1056 | | static bool |
1057 | | AttrHasSuffix(Implementor* aElement, nsAtom* aNS, nsAtom* aName, |
1058 | | nsAtom* aStr, bool aIgnoreCase) |
1059 | 0 | { |
1060 | 0 | auto match = [aStr, aIgnoreCase](const nsAttrValue* aValue) { |
1061 | 0 | nsAutoString str; |
1062 | 0 | aValue->ToString(str); |
1063 | 0 | WITH_COMPARATOR(aIgnoreCase, c, |
1064 | 0 | StringEndsWith(str, nsDependentAtomString(aStr), c)) |
1065 | 0 | }; Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrHasSuffix<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}::operator()(nsAttrValue const*) const Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrHasSuffix<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool)::{lambda(nsAttrValue const*)#1}::operator()(nsAttrValue const*) const |
1066 | 0 | return DoMatch(aElement, aNS, aName, match); |
1067 | 0 | } Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrHasSuffix<mozilla::dom::Element const>(mozilla::dom::Element const*, nsAtom*, nsAtom*, nsAtom*, bool) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:bool AttrHasSuffix<mozilla::ServoElementSnapshot const>(mozilla::ServoElementSnapshot const*, nsAtom*, nsAtom*, nsAtom*, bool) |
1068 | | |
1069 | | #define SERVO_IMPL_ELEMENT_ATTR_MATCHING_FUNCTIONS(prefix_, implementor_) \ |
1070 | | nsAtom* prefix_##LangValue(implementor_ aElement) \ |
1071 | 0 | { \ |
1072 | 0 | return LangValue(aElement); \ |
1073 | 0 | } \ Unexecuted instantiation: Gecko_LangValue Unexecuted instantiation: Gecko_SnapshotLangValue |
1074 | | bool prefix_##HasAttr(implementor_ aElement, nsAtom* aNS, nsAtom* aName) \ |
1075 | 0 | { \ |
1076 | 0 | return HasAttr(aElement, aNS, aName); \ |
1077 | 0 | } \ Unexecuted instantiation: Gecko_HasAttr Unexecuted instantiation: Gecko_SnapshotHasAttr |
1078 | | bool prefix_##AttrEquals(implementor_ aElement, nsAtom* aNS, \ |
1079 | | nsAtom* aName, nsAtom* aStr, bool aIgnoreCase) \ |
1080 | 0 | { \ |
1081 | 0 | return AttrEquals(aElement, aNS, aName, aStr, aIgnoreCase); \ |
1082 | 0 | } \ Unexecuted instantiation: Gecko_AttrEquals Unexecuted instantiation: Gecko_SnapshotAttrEquals |
1083 | | bool prefix_##AttrDashEquals(implementor_ aElement, nsAtom* aNS, \ |
1084 | | nsAtom* aName, nsAtom* aStr, bool aIgnoreCase) \ |
1085 | 0 | { \ |
1086 | 0 | return AttrDashEquals(aElement, aNS, aName, aStr, aIgnoreCase); \ |
1087 | 0 | } \ Unexecuted instantiation: Gecko_AttrDashEquals Unexecuted instantiation: Gecko_SnapshotAttrDashEquals |
1088 | | bool prefix_##AttrIncludes(implementor_ aElement, nsAtom* aNS, \ |
1089 | | nsAtom* aName, nsAtom* aStr, bool aIgnoreCase) \ |
1090 | 0 | { \ |
1091 | 0 | return AttrIncludes(aElement, aNS, aName, aStr, aIgnoreCase); \ |
1092 | 0 | } \ Unexecuted instantiation: Gecko_AttrIncludes Unexecuted instantiation: Gecko_SnapshotAttrIncludes |
1093 | | bool prefix_##AttrHasSubstring(implementor_ aElement, nsAtom* aNS, \ |
1094 | | nsAtom* aName, nsAtom* aStr, bool aIgnoreCase) \ |
1095 | 0 | { \ |
1096 | 0 | return AttrHasSubstring(aElement, aNS, aName, aStr, aIgnoreCase); \ |
1097 | 0 | } \ Unexecuted instantiation: Gecko_AttrHasSubstring Unexecuted instantiation: Gecko_SnapshotAttrHasSubstring |
1098 | | bool prefix_##AttrHasPrefix(implementor_ aElement, nsAtom* aNS, \ |
1099 | | nsAtom* aName, nsAtom* aStr, bool aIgnoreCase) \ |
1100 | 0 | { \ |
1101 | 0 | return AttrHasPrefix(aElement, aNS, aName, aStr, aIgnoreCase); \ |
1102 | 0 | } \ Unexecuted instantiation: Gecko_AttrHasPrefix Unexecuted instantiation: Gecko_SnapshotAttrHasPrefix |
1103 | | bool prefix_##AttrHasSuffix(implementor_ aElement, nsAtom* aNS, \ |
1104 | | nsAtom* aName, nsAtom* aStr, bool aIgnoreCase) \ |
1105 | 0 | { \ |
1106 | 0 | return AttrHasSuffix(aElement, aNS, aName, aStr, aIgnoreCase); \ |
1107 | 0 | } Unexecuted instantiation: Gecko_AttrHasSuffix Unexecuted instantiation: Gecko_SnapshotAttrHasSuffix |
1108 | | |
1109 | | |
1110 | | SERVO_IMPL_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_, RawGeckoElementBorrowed) |
1111 | | SERVO_IMPL_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_Snapshot, const ServoElementSnapshot*) |
1112 | | |
1113 | | #undef SERVO_IMPL_ELEMENT_ATTR_MATCHING_FUNCTIONS |
1114 | | |
1115 | | nsAtom* |
1116 | | Gecko_Atomize(const char* aString, uint32_t aLength) |
1117 | 0 | { |
1118 | 0 | return NS_Atomize(nsDependentCSubstring(aString, aLength)).take(); |
1119 | 0 | } |
1120 | | |
1121 | | nsAtom* |
1122 | | Gecko_Atomize16(const nsAString* aString) |
1123 | 0 | { |
1124 | 0 | return NS_Atomize(*aString).take(); |
1125 | 0 | } |
1126 | | |
1127 | | void |
1128 | | Gecko_AddRefAtom(nsAtom* aAtom) |
1129 | 0 | { |
1130 | 0 | NS_ADDREF(aAtom); |
1131 | 0 | } |
1132 | | |
1133 | | void |
1134 | | Gecko_ReleaseAtom(nsAtom* aAtom) |
1135 | 0 | { |
1136 | 0 | NS_RELEASE(aAtom); |
1137 | 0 | } |
1138 | | |
1139 | | void |
1140 | | Gecko_nsTArray_FontFamilyName_AppendNamed(nsTArray<FontFamilyName>* aNames, |
1141 | | nsAtom* aName, |
1142 | | bool aQuoted) |
1143 | 0 | { |
1144 | 0 | aNames->AppendElement(FontFamilyName(aName, aQuoted ? eQuotedName : eUnquotedName)); |
1145 | 0 | } |
1146 | | |
1147 | | void |
1148 | | Gecko_nsTArray_FontFamilyName_AppendGeneric(nsTArray<FontFamilyName>* aNames, |
1149 | | FontFamilyType aType) |
1150 | 0 | { |
1151 | 0 | aNames->AppendElement(FontFamilyName(aType)); |
1152 | 0 | } |
1153 | | |
1154 | | SharedFontList* |
1155 | | Gecko_SharedFontList_Create() |
1156 | 0 | { |
1157 | 0 | RefPtr<SharedFontList> fontlist = new SharedFontList(); |
1158 | 0 | return fontlist.forget().take(); |
1159 | 0 | } |
1160 | | |
1161 | | MOZ_DEFINE_MALLOC_SIZE_OF(GeckoSharedFontListMallocSizeOf) |
1162 | | |
1163 | | size_t |
1164 | | Gecko_SharedFontList_SizeOfIncludingThisIfUnshared(SharedFontList* aFontlist) |
1165 | 0 | { |
1166 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
1167 | 0 | return aFontlist->SizeOfIncludingThisIfUnshared(GeckoSharedFontListMallocSizeOf); |
1168 | 0 | } |
1169 | | |
1170 | | size_t |
1171 | | Gecko_SharedFontList_SizeOfIncludingThis(SharedFontList* aFontlist) |
1172 | 0 | { |
1173 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
1174 | 0 | return aFontlist->SizeOfIncludingThis(GeckoSharedFontListMallocSizeOf); |
1175 | 0 | } |
1176 | | |
1177 | | NS_IMPL_THREADSAFE_FFI_REFCOUNTING(mozilla::SharedFontList, SharedFontList); |
1178 | | |
1179 | | void |
1180 | | Gecko_CopyFontFamilyFrom(nsFont* dst, const nsFont* src) |
1181 | 0 | { |
1182 | 0 | dst->fontlist = src->fontlist; |
1183 | 0 | } |
1184 | | |
1185 | | void |
1186 | | Gecko_nsFont_InitSystem(nsFont* aDest, int32_t aFontId, |
1187 | | const nsStyleFont* aFont, RawGeckoPresContextBorrowed aPresContext) |
1188 | 0 | { |
1189 | 0 | const nsFont* defaultVariableFont = ThreadSafeGetDefaultFontHelper(aPresContext, aFont->mLanguage, |
1190 | 0 | kPresContext_DefaultVariableFont_ID); |
1191 | 0 |
|
1192 | 0 | // We have passed uninitialized memory to this function, |
1193 | 0 | // initialize it. We can't simply return an nsFont because then |
1194 | 0 | // we need to know its size beforehand. Servo cannot initialize nsFont |
1195 | 0 | // itself, so this will do. |
1196 | 0 | nsFont* system = new (aDest) nsFont(*defaultVariableFont); |
1197 | 0 |
|
1198 | 0 | MOZ_RELEASE_ASSERT(system); |
1199 | 0 |
|
1200 | 0 | *aDest = *defaultVariableFont; |
1201 | 0 | LookAndFeel::FontID fontID = static_cast<LookAndFeel::FontID>(aFontId); |
1202 | 0 |
|
1203 | 0 | AutoWriteLock guard(*sServoFFILock); |
1204 | 0 | nsLayoutUtils::ComputeSystemFont(aDest, fontID, aPresContext, |
1205 | 0 | defaultVariableFont); |
1206 | 0 | } |
1207 | | |
1208 | | void |
1209 | | Gecko_nsFont_Destroy(nsFont* aDest) |
1210 | 0 | { |
1211 | 0 | aDest->~nsFont(); |
1212 | 0 | } |
1213 | | |
1214 | | gfxFontFeatureValueSet* |
1215 | | Gecko_ConstructFontFeatureValueSet() |
1216 | 0 | { |
1217 | 0 | return new gfxFontFeatureValueSet(); |
1218 | 0 | } |
1219 | | |
1220 | | nsTArray<unsigned int>* |
1221 | | Gecko_AppendFeatureValueHashEntry(gfxFontFeatureValueSet* aFontFeatureValues, |
1222 | | nsAtom* aFamily, uint32_t aAlternate, nsAtom* aName) |
1223 | 0 | { |
1224 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
1225 | 0 | static_assert(sizeof(unsigned int) == sizeof(uint32_t), |
1226 | 0 | "sizeof unsigned int and uint32_t must be the same"); |
1227 | 0 | return aFontFeatureValues->AppendFeatureValueHashEntry( |
1228 | 0 | nsAtomCString(aFamily), |
1229 | 0 | nsDependentAtomString(aName), |
1230 | 0 | aAlternate |
1231 | 0 | ); |
1232 | 0 | } |
1233 | | |
1234 | | void |
1235 | | Gecko_nsFont_SetFontFeatureValuesLookup(nsFont* aFont, |
1236 | | const RawGeckoPresContext* aPresContext) |
1237 | 0 | { |
1238 | 0 | aFont->featureValueLookup = aPresContext->GetFontFeatureValuesLookup(); |
1239 | 0 | } |
1240 | | |
1241 | | float |
1242 | | Gecko_FontStretch_ToFloat(mozilla::FontStretch aStretch) |
1243 | 0 | { |
1244 | 0 | // Servo represents percentages with 1. being 100%. |
1245 | 0 | return aStretch.Percentage() / 100.0f; |
1246 | 0 | } |
1247 | | |
1248 | | void |
1249 | | Gecko_FontStretch_SetFloat(mozilla::FontStretch* aStretch, float aFloat) |
1250 | 0 | { |
1251 | 0 | // Servo represents percentages with 1. being 100%. |
1252 | 0 | // |
1253 | 0 | // Also, the font code assumes a given maximum that style doesn't really need |
1254 | 0 | // to know about. So clamp here at the boundary. |
1255 | 0 | *aStretch = FontStretch(std::min(aFloat * 100.0f, float(FontStretch::kMax))); |
1256 | 0 | } |
1257 | | |
1258 | | void |
1259 | | Gecko_FontSlantStyle_SetNormal(mozilla::FontSlantStyle* aStyle) |
1260 | 0 | { |
1261 | 0 | *aStyle = mozilla::FontSlantStyle::Normal(); |
1262 | 0 | } |
1263 | | |
1264 | | void |
1265 | | Gecko_FontSlantStyle_SetItalic(mozilla::FontSlantStyle* aStyle) |
1266 | 0 | { |
1267 | 0 | *aStyle = mozilla::FontSlantStyle::Italic(); |
1268 | 0 | } |
1269 | | |
1270 | | void |
1271 | | Gecko_FontSlantStyle_SetOblique(mozilla::FontSlantStyle* aStyle, |
1272 | | float aAngleInDegrees) |
1273 | 0 | { |
1274 | 0 | *aStyle = mozilla::FontSlantStyle::Oblique(aAngleInDegrees); |
1275 | 0 | } |
1276 | | |
1277 | | void |
1278 | | Gecko_FontSlantStyle_Get(mozilla::FontSlantStyle aStyle, |
1279 | | bool* aNormal, |
1280 | | bool* aItalic, |
1281 | | float* aObliqueAngle) |
1282 | 0 | { |
1283 | 0 | *aNormal = aStyle.IsNormal(); |
1284 | 0 | *aItalic = aStyle.IsItalic(); |
1285 | 0 | if (aStyle.IsOblique()) { |
1286 | 0 | *aObliqueAngle = aStyle.ObliqueAngle(); |
1287 | 0 | } |
1288 | 0 | } |
1289 | | |
1290 | | float |
1291 | | Gecko_FontWeight_ToFloat(mozilla::FontWeight aWeight) |
1292 | 0 | { |
1293 | 0 | return aWeight.ToFloat(); |
1294 | 0 | } |
1295 | | |
1296 | | void |
1297 | | Gecko_FontWeight_SetFloat(mozilla::FontWeight* aWeight, |
1298 | | float aFloat) |
1299 | 0 | { |
1300 | 0 | *aWeight = mozilla::FontWeight(aFloat); |
1301 | 0 | } |
1302 | | |
1303 | | void |
1304 | | Gecko_nsFont_ResetFontFeatureValuesLookup(nsFont* aFont) |
1305 | 0 | { |
1306 | 0 | aFont->featureValueLookup = nullptr; |
1307 | 0 | } |
1308 | | |
1309 | | |
1310 | | void |
1311 | | Gecko_ClearAlternateValues(nsFont* aFont, size_t aLength) |
1312 | 0 | { |
1313 | 0 | aFont->alternateValues.Clear(); |
1314 | 0 | aFont->alternateValues.SetCapacity(aLength); |
1315 | 0 | } |
1316 | | |
1317 | | void |
1318 | | Gecko_AppendAlternateValues(nsFont* aFont, uint32_t aAlternateName, nsAtom* aAtom) |
1319 | 0 | { |
1320 | 0 | aFont->alternateValues.AppendElement(gfxAlternateValue { |
1321 | 0 | aAlternateName, |
1322 | 0 | nsDependentAtomString(aAtom) |
1323 | 0 | }); |
1324 | 0 | } |
1325 | | |
1326 | | void |
1327 | | Gecko_CopyAlternateValuesFrom(nsFont* aDest, const nsFont* aSrc) |
1328 | 0 | { |
1329 | 0 | aDest->alternateValues.Clear(); |
1330 | 0 | aDest->alternateValues.AppendElements(aSrc->alternateValues); |
1331 | 0 | aDest->featureValueLookup = aSrc->featureValueLookup; |
1332 | 0 | } |
1333 | | |
1334 | | void |
1335 | | Gecko_SetCounterStyleToName(CounterStylePtr* aPtr, nsAtom* aName, |
1336 | | RawGeckoPresContextBorrowed aPresContext) |
1337 | 0 | { |
1338 | 0 | // Try resolving the counter style if possible, and keep it unresolved |
1339 | 0 | // otherwise. |
1340 | 0 | CounterStyleManager* manager = aPresContext->CounterStyleManager(); |
1341 | 0 | RefPtr<nsAtom> name = already_AddRefed<nsAtom>(aName); |
1342 | 0 | if (CounterStyle* style = manager->GetCounterStyle(name)) { |
1343 | 0 | *aPtr = style; |
1344 | 0 | } else { |
1345 | 0 | *aPtr = name.forget(); |
1346 | 0 | } |
1347 | 0 | } |
1348 | | |
1349 | | void |
1350 | | Gecko_SetCounterStyleToSymbols(CounterStylePtr* aPtr, uint8_t aSymbolsType, |
1351 | | nsACString const* const* aSymbols, |
1352 | | uint32_t aSymbolsCount) |
1353 | 0 | { |
1354 | 0 | nsTArray<nsString> symbols(aSymbolsCount); |
1355 | 0 | for (uint32_t i = 0; i < aSymbolsCount; i++) { |
1356 | 0 | symbols.AppendElement(NS_ConvertUTF8toUTF16(*aSymbols[i])); |
1357 | 0 | } |
1358 | 0 | *aPtr = new AnonymousCounterStyle(aSymbolsType, std::move(symbols)); |
1359 | 0 | } |
1360 | | |
1361 | | void |
1362 | | Gecko_SetCounterStyleToString(CounterStylePtr* aPtr, const nsACString* aSymbol) |
1363 | 0 | { |
1364 | 0 | *aPtr = new AnonymousCounterStyle(NS_ConvertUTF8toUTF16(*aSymbol)); |
1365 | 0 | } |
1366 | | |
1367 | | void |
1368 | | Gecko_CopyCounterStyle(CounterStylePtr* aDst, const CounterStylePtr* aSrc) |
1369 | 0 | { |
1370 | 0 | *aDst = *aSrc; |
1371 | 0 | } |
1372 | | |
1373 | | nsAtom* |
1374 | | Gecko_CounterStyle_GetName(const CounterStylePtr* aPtr) |
1375 | 0 | { |
1376 | 0 | if (!aPtr->IsResolved()) { |
1377 | 0 | return aPtr->AsAtom(); |
1378 | 0 | } |
1379 | 0 | return (*aPtr)->GetStyleName(); |
1380 | 0 | } |
1381 | | |
1382 | | const AnonymousCounterStyle* |
1383 | | Gecko_CounterStyle_GetAnonymous(const CounterStylePtr* aPtr) |
1384 | 0 | { |
1385 | 0 | return aPtr->AsAnonymous(); |
1386 | 0 | } |
1387 | | |
1388 | | already_AddRefed<css::URLValue> |
1389 | | ServoBundledURI::IntoCssUrl() |
1390 | 0 | { |
1391 | 0 | MOZ_ASSERT(mExtraData->GetReferrer()); |
1392 | 0 | MOZ_ASSERT(mExtraData->GetPrincipal()); |
1393 | 0 |
|
1394 | 0 | RefPtr<css::URLValue> urlValue = |
1395 | 0 | new css::URLValue(mURLString, do_AddRef(mExtraData)); |
1396 | 0 | return urlValue.forget(); |
1397 | 0 | } |
1398 | | |
1399 | | already_AddRefed<css::ImageValue> |
1400 | | ServoBundledURI::IntoCssImage(mozilla::CORSMode aCorsMode) |
1401 | 0 | { |
1402 | 0 | RefPtr<css::ImageValue> urlValue = |
1403 | 0 | new css::ImageValue(mURLString, do_AddRef(mExtraData), aCorsMode); |
1404 | 0 | return urlValue.forget(); |
1405 | 0 | } |
1406 | | |
1407 | | void |
1408 | | Gecko_SetNullImageValue(nsStyleImage* aImage) |
1409 | 0 | { |
1410 | 0 | MOZ_ASSERT(aImage); |
1411 | 0 | aImage->SetNull(); |
1412 | 0 | } |
1413 | | |
1414 | | void |
1415 | | Gecko_SetGradientImageValue(nsStyleImage* aImage, nsStyleGradient* aGradient) |
1416 | 0 | { |
1417 | 0 | MOZ_ASSERT(aImage); |
1418 | 0 | aImage->SetGradientData(aGradient); |
1419 | 0 | } |
1420 | | |
1421 | | NS_IMPL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::ImageValue, ImageValue); |
1422 | | |
1423 | | static already_AddRefed<nsStyleImageRequest> |
1424 | | CreateStyleImageRequest(nsStyleImageRequest::Mode aModeFlags, |
1425 | | mozilla::css::ImageValue* aImageValue) |
1426 | 0 | { |
1427 | 0 | RefPtr<nsStyleImageRequest> req = |
1428 | 0 | new nsStyleImageRequest(aModeFlags, aImageValue); |
1429 | 0 | return req.forget(); |
1430 | 0 | } |
1431 | | |
1432 | | mozilla::css::ImageValue* |
1433 | | Gecko_ImageValue_Create(ServoBundledURI aURI, mozilla::CORSMode aCORSMode) |
1434 | 0 | { |
1435 | 0 | return aURI.IntoCssImage(aCORSMode).take(); |
1436 | 0 | } |
1437 | | |
1438 | | MOZ_DEFINE_MALLOC_SIZE_OF(GeckoImageValueMallocSizeOf) |
1439 | | |
1440 | | size_t |
1441 | | Gecko_ImageValue_SizeOfIncludingThis(mozilla::css::ImageValue* aImageValue) |
1442 | 0 | { |
1443 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
1444 | 0 | return aImageValue->SizeOfIncludingThis(GeckoImageValueMallocSizeOf); |
1445 | 0 | } |
1446 | | |
1447 | | void |
1448 | | Gecko_SetLayerImageImageValue(nsStyleImage* aImage, |
1449 | | mozilla::css::ImageValue* aImageValue) |
1450 | 0 | { |
1451 | 0 | MOZ_ASSERT(aImage && aImageValue); |
1452 | 0 |
|
1453 | 0 | RefPtr<nsStyleImageRequest> req = |
1454 | 0 | CreateStyleImageRequest(nsStyleImageRequest::Mode::Track, aImageValue); |
1455 | 0 | aImage->SetImageRequest(req.forget()); |
1456 | 0 | } |
1457 | | |
1458 | | void |
1459 | 0 | Gecko_SetImageElement(nsStyleImage* aImage, nsAtom* aAtom) { |
1460 | 0 | MOZ_ASSERT(aImage); |
1461 | 0 | aImage->SetElementId(do_AddRef(aAtom)); |
1462 | 0 | } |
1463 | | |
1464 | | void |
1465 | | Gecko_CopyImageValueFrom(nsStyleImage* aImage, const nsStyleImage* aOther) |
1466 | 0 | { |
1467 | 0 | MOZ_ASSERT(aImage); |
1468 | 0 | MOZ_ASSERT(aOther); |
1469 | 0 |
|
1470 | 0 | *aImage = *aOther; |
1471 | 0 | } |
1472 | | |
1473 | | void |
1474 | | Gecko_InitializeImageCropRect(nsStyleImage* aImage) |
1475 | 0 | { |
1476 | 0 | MOZ_ASSERT(aImage); |
1477 | 0 | aImage->SetCropRect(MakeUnique<nsStyleSides>()); |
1478 | 0 | } |
1479 | | |
1480 | | void |
1481 | | Gecko_SetCursorArrayLength(nsStyleUI* aStyleUI, size_t aLen) |
1482 | 0 | { |
1483 | 0 | aStyleUI->mCursorImages.Clear(); |
1484 | 0 | aStyleUI->mCursorImages.SetLength(aLen); |
1485 | 0 | } |
1486 | | |
1487 | | void |
1488 | | Gecko_SetCursorImageValue(nsCursorImage* aCursor, |
1489 | | mozilla::css::ImageValue* aImageValue) |
1490 | 0 | { |
1491 | 0 | MOZ_ASSERT(aCursor && aImageValue); |
1492 | 0 |
|
1493 | 0 | aCursor->mImage = |
1494 | 0 | CreateStyleImageRequest(nsStyleImageRequest::Mode::Discard, aImageValue); |
1495 | 0 | } |
1496 | | |
1497 | | void |
1498 | | Gecko_CopyCursorArrayFrom(nsStyleUI* aDest, const nsStyleUI* aSrc) |
1499 | 0 | { |
1500 | 0 | aDest->mCursorImages = aSrc->mCursorImages; |
1501 | 0 | } |
1502 | | |
1503 | | void |
1504 | | Gecko_SetContentDataImageValue(nsStyleContentData* aContent, |
1505 | | mozilla::css::ImageValue* aImageValue) |
1506 | 0 | { |
1507 | 0 | MOZ_ASSERT(aContent && aImageValue); |
1508 | 0 |
|
1509 | 0 | RefPtr<nsStyleImageRequest> req = |
1510 | 0 | CreateStyleImageRequest(nsStyleImageRequest::Mode::Track, aImageValue); |
1511 | 0 | aContent->SetImageRequest(req.forget()); |
1512 | 0 | } |
1513 | | |
1514 | | nsStyleContentData::CounterFunction* |
1515 | | Gecko_SetCounterFunction(nsStyleContentData* aContent, StyleContentType aType) |
1516 | 0 | { |
1517 | 0 | auto counterFunc = MakeRefPtr<nsStyleContentData::CounterFunction>(); |
1518 | 0 | auto* ptr = counterFunc.get(); |
1519 | 0 | aContent->SetCounters(aType, counterFunc.forget()); |
1520 | 0 | return ptr; |
1521 | 0 | } |
1522 | | |
1523 | | nsStyleGradient* |
1524 | | Gecko_CreateGradient(uint8_t aShape, |
1525 | | uint8_t aSize, |
1526 | | bool aRepeating, |
1527 | | bool aLegacySyntax, |
1528 | | bool aMozLegacySyntax, |
1529 | | uint32_t aStopCount) |
1530 | 0 | { |
1531 | 0 | nsStyleGradient* result = new nsStyleGradient(); |
1532 | 0 |
|
1533 | 0 | result->mShape = aShape; |
1534 | 0 | result->mSize = aSize; |
1535 | 0 | result->mRepeating = aRepeating; |
1536 | 0 | result->mLegacySyntax = aLegacySyntax; |
1537 | 0 | result->mMozLegacySyntax = aMozLegacySyntax; |
1538 | 0 |
|
1539 | 0 | result->mAngle.SetNoneValue(); |
1540 | 0 | result->mBgPosX.SetNoneValue(); |
1541 | 0 | result->mBgPosY.SetNoneValue(); |
1542 | 0 | result->mRadiusX.SetNoneValue(); |
1543 | 0 | result->mRadiusY.SetNoneValue(); |
1544 | 0 |
|
1545 | 0 | nsStyleGradientStop dummyStop = { |
1546 | 0 | nsStyleCoord(eStyleUnit_None), |
1547 | 0 | StyleComplexColor::Black(), |
1548 | 0 | 0 |
1549 | 0 | }; |
1550 | 0 |
|
1551 | 0 | for (uint32_t i = 0; i < aStopCount; i++) { |
1552 | 0 | result->mStops.AppendElement(dummyStop); |
1553 | 0 | } |
1554 | 0 |
|
1555 | 0 | return result; |
1556 | 0 | } |
1557 | | |
1558 | | const nsStyleImageRequest* |
1559 | | Gecko_GetImageRequest(const nsStyleImage* aImage) |
1560 | 0 | { |
1561 | 0 | MOZ_ASSERT(aImage); |
1562 | 0 | return aImage->ImageRequest(); |
1563 | 0 | } |
1564 | | |
1565 | | nsAtom* |
1566 | | Gecko_GetImageElement(const nsStyleImage* aImage) |
1567 | 0 | { |
1568 | 0 | MOZ_ASSERT(aImage && aImage->GetType() == eStyleImageType_Element); |
1569 | 0 | return const_cast<nsAtom*>(aImage->GetElementId()); |
1570 | 0 | } |
1571 | | |
1572 | | const nsStyleGradient* |
1573 | | Gecko_GetGradientImageValue(const nsStyleImage* aImage) |
1574 | 0 | { |
1575 | 0 | MOZ_ASSERT(aImage && aImage->GetType() == eStyleImageType_Gradient); |
1576 | 0 | return aImage->GetGradientData(); |
1577 | 0 | } |
1578 | | |
1579 | | void |
1580 | | Gecko_SetListStyleImageNone(nsStyleList* aList) |
1581 | 0 | { |
1582 | 0 | aList->mListStyleImage = nullptr; |
1583 | 0 | } |
1584 | | |
1585 | | void |
1586 | | Gecko_SetListStyleImageImageValue(nsStyleList* aList, |
1587 | | mozilla::css::ImageValue* aImageValue) |
1588 | 0 | { |
1589 | 0 | MOZ_ASSERT(aList && aImageValue); |
1590 | 0 |
|
1591 | 0 | aList->mListStyleImage = |
1592 | 0 | CreateStyleImageRequest(nsStyleImageRequest::Mode(0), aImageValue); |
1593 | 0 | } |
1594 | | |
1595 | | void |
1596 | | Gecko_CopyListStyleImageFrom(nsStyleList* aList, const nsStyleList* aSource) |
1597 | 0 | { |
1598 | 0 | aList->mListStyleImage = aSource->mListStyleImage; |
1599 | 0 | } |
1600 | | |
1601 | | void |
1602 | | Gecko_EnsureTArrayCapacity(void* aArray, size_t aCapacity, size_t aElemSize) |
1603 | 0 | { |
1604 | 0 | auto base = |
1605 | 0 | reinterpret_cast<nsTArray_base<nsTArrayInfallibleAllocator, |
1606 | 0 | nsTArray_CopyWithMemutils>*>(aArray); |
1607 | 0 |
|
1608 | 0 | base->EnsureCapacity<nsTArrayInfallibleAllocator>(aCapacity, aElemSize); |
1609 | 0 | } |
1610 | | |
1611 | | void |
1612 | | Gecko_ClearPODTArray(void* aArray, size_t aElementSize, size_t aElementAlign) |
1613 | 0 | { |
1614 | 0 | auto base = |
1615 | 0 | reinterpret_cast<nsTArray_base<nsTArrayInfallibleAllocator, |
1616 | 0 | nsTArray_CopyWithMemutils>*>(aArray); |
1617 | 0 |
|
1618 | 0 | base->template ShiftData<nsTArrayInfallibleAllocator>(0, base->Length(), 0, |
1619 | 0 | aElementSize, aElementAlign); |
1620 | 0 | } |
1621 | | |
1622 | | void Gecko_ResizeTArrayForStrings(nsTArray<nsString>* aArray, uint32_t aLength) |
1623 | 0 | { |
1624 | 0 | aArray->SetLength(aLength); |
1625 | 0 | } |
1626 | | |
1627 | | void |
1628 | | Gecko_SetStyleGridTemplate(UniquePtr<nsStyleGridTemplate>* aGridTemplate, |
1629 | | nsStyleGridTemplate* aValue) |
1630 | 0 | { |
1631 | 0 | aGridTemplate->reset(aValue); |
1632 | 0 | } |
1633 | | |
1634 | | nsStyleGridTemplate* |
1635 | | Gecko_CreateStyleGridTemplate(uint32_t aTrackSizes, uint32_t aNameSize) |
1636 | 0 | { |
1637 | 0 | nsStyleGridTemplate* result = new nsStyleGridTemplate; |
1638 | 0 | result->mMinTrackSizingFunctions.SetLength(aTrackSizes); |
1639 | 0 | result->mMaxTrackSizingFunctions.SetLength(aTrackSizes); |
1640 | 0 | result->mLineNameLists.SetLength(aNameSize); |
1641 | 0 | return result; |
1642 | 0 | } |
1643 | | |
1644 | | void |
1645 | | Gecko_CopyStyleGridTemplateValues(UniquePtr<nsStyleGridTemplate>* aGridTemplate, |
1646 | | const nsStyleGridTemplate* aOther) |
1647 | 0 | { |
1648 | 0 | if (aOther) { |
1649 | 0 | *aGridTemplate = MakeUnique<nsStyleGridTemplate>(*aOther); |
1650 | 0 | } else { |
1651 | 0 | *aGridTemplate = nullptr; |
1652 | 0 | } |
1653 | 0 | } |
1654 | | |
1655 | | mozilla::css::GridTemplateAreasValue* |
1656 | | Gecko_NewGridTemplateAreasValue(uint32_t aAreas, uint32_t aTemplates, uint32_t aColumns) |
1657 | 0 | { |
1658 | 0 | RefPtr<mozilla::css::GridTemplateAreasValue> value = new mozilla::css::GridTemplateAreasValue; |
1659 | 0 | value->mNamedAreas.SetLength(aAreas); |
1660 | 0 | value->mTemplates.SetLength(aTemplates); |
1661 | 0 | value->mNColumns = aColumns; |
1662 | 0 | return value.forget().take(); |
1663 | 0 | } |
1664 | | |
1665 | | NS_IMPL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::GridTemplateAreasValue, GridTemplateAreasValue); |
1666 | | |
1667 | | void |
1668 | | Gecko_ClearAndResizeStyleContents(nsStyleContent* aContent, uint32_t aHowMany) |
1669 | 0 | { |
1670 | 0 | aContent->AllocateContents(aHowMany); |
1671 | 0 | } |
1672 | | |
1673 | | void |
1674 | | Gecko_CopyStyleContentsFrom(nsStyleContent* aContent, const nsStyleContent* aOther) |
1675 | 0 | { |
1676 | 0 | uint32_t count = aOther->ContentCount(); |
1677 | 0 |
|
1678 | 0 | aContent->AllocateContents(count); |
1679 | 0 |
|
1680 | 0 | for (uint32_t i = 0; i < count; ++i) { |
1681 | 0 | aContent->ContentAt(i) = aOther->ContentAt(i); |
1682 | 0 | } |
1683 | 0 | } |
1684 | | |
1685 | | void |
1686 | | Gecko_ClearAndResizeCounterIncrements(nsStyleContent* aContent, uint32_t aHowMany) |
1687 | 0 | { |
1688 | 0 | aContent->AllocateCounterIncrements(aHowMany); |
1689 | 0 | } |
1690 | | |
1691 | | void |
1692 | | Gecko_CopyCounterIncrementsFrom(nsStyleContent* aContent, const nsStyleContent* aOther) |
1693 | 0 | { |
1694 | 0 | uint32_t count = aOther->CounterIncrementCount(); |
1695 | 0 |
|
1696 | 0 | aContent->AllocateCounterIncrements(count); |
1697 | 0 |
|
1698 | 0 | for (uint32_t i = 0; i < count; ++i) { |
1699 | 0 | const nsStyleCounterData& data = aOther->CounterIncrementAt(i); |
1700 | 0 | aContent->SetCounterIncrementAt(i, data.mCounter, data.mValue); |
1701 | 0 | } |
1702 | 0 | } |
1703 | | |
1704 | | void |
1705 | | Gecko_ClearAndResizeCounterResets(nsStyleContent* aContent, uint32_t aHowMany) |
1706 | 0 | { |
1707 | 0 | aContent->AllocateCounterResets(aHowMany); |
1708 | 0 | } |
1709 | | |
1710 | | void |
1711 | | Gecko_CopyCounterResetsFrom(nsStyleContent* aContent, const nsStyleContent* aOther) |
1712 | 0 | { |
1713 | 0 | uint32_t count = aOther->CounterResetCount(); |
1714 | 0 |
|
1715 | 0 | aContent->AllocateCounterResets(count); |
1716 | 0 |
|
1717 | 0 | for (uint32_t i = 0; i < count; ++i) { |
1718 | 0 | const nsStyleCounterData& data = aOther->CounterResetAt(i); |
1719 | 0 | aContent->SetCounterResetAt(i, data.mCounter, data.mValue); |
1720 | 0 | } |
1721 | 0 | } |
1722 | | |
1723 | | void |
1724 | | Gecko_EnsureImageLayersLength(nsStyleImageLayers* aLayers, size_t aLen, |
1725 | | nsStyleImageLayers::LayerType aLayerType) |
1726 | 0 | { |
1727 | 0 | size_t oldLength = aLayers->mLayers.Length(); |
1728 | 0 |
|
1729 | 0 | aLayers->mLayers.EnsureLengthAtLeast(aLen); |
1730 | 0 |
|
1731 | 0 | for (size_t i = oldLength; i < aLen; ++i) { |
1732 | 0 | aLayers->mLayers[i].Initialize(aLayerType); |
1733 | 0 | } |
1734 | 0 | } |
1735 | | |
1736 | | template <typename StyleType> |
1737 | | static void |
1738 | | EnsureStyleAutoArrayLength(StyleType* aArray, size_t aLen) |
1739 | 0 | { |
1740 | 0 | size_t oldLength = aArray->Length(); |
1741 | 0 |
|
1742 | 0 | aArray->EnsureLengthAtLeast(aLen); |
1743 | 0 |
|
1744 | 0 | for (size_t i = oldLength; i < aLen; ++i) { |
1745 | 0 | (*aArray)[i].SetInitialValues(); |
1746 | 0 | } |
1747 | 0 | } Unexecuted instantiation: Unified_cpp_layout_style2.cpp:void EnsureStyleAutoArrayLength<nsStyleAutoArray<mozilla::StyleAnimation> >(nsStyleAutoArray<mozilla::StyleAnimation>*, unsigned long) Unexecuted instantiation: Unified_cpp_layout_style2.cpp:void EnsureStyleAutoArrayLength<nsStyleAutoArray<mozilla::StyleTransition> >(nsStyleAutoArray<mozilla::StyleTransition>*, unsigned long) |
1748 | | |
1749 | | void |
1750 | | Gecko_EnsureStyleAnimationArrayLength(void* aArray, size_t aLen) |
1751 | 0 | { |
1752 | 0 | auto base = |
1753 | 0 | static_cast<nsStyleAutoArray<StyleAnimation>*>(aArray); |
1754 | 0 | EnsureStyleAutoArrayLength(base, aLen); |
1755 | 0 | } |
1756 | | |
1757 | | void |
1758 | | Gecko_EnsureStyleTransitionArrayLength(void* aArray, size_t aLen) |
1759 | 0 | { |
1760 | 0 | auto base = |
1761 | 0 | reinterpret_cast<nsStyleAutoArray<StyleTransition>*>(aArray); |
1762 | 0 | EnsureStyleAutoArrayLength(base, aLen); |
1763 | 0 | } |
1764 | | |
1765 | | void |
1766 | | Gecko_ClearWillChange(nsStyleDisplay* aDisplay, size_t aLength) |
1767 | 0 | { |
1768 | 0 | aDisplay->mWillChange.Clear(); |
1769 | 0 | aDisplay->mWillChange.SetCapacity(aLength); |
1770 | 0 | } |
1771 | | |
1772 | | void |
1773 | | Gecko_AppendWillChange(nsStyleDisplay* aDisplay, nsAtom* aAtom) |
1774 | 0 | { |
1775 | 0 | aDisplay->mWillChange.AppendElement(aAtom); |
1776 | 0 | } |
1777 | | |
1778 | | void |
1779 | | Gecko_CopyWillChangeFrom(nsStyleDisplay* aDest, nsStyleDisplay* aSrc) |
1780 | 0 | { |
1781 | 0 | aDest->mWillChange.Clear(); |
1782 | 0 | aDest->mWillChange.AppendElements(aSrc->mWillChange); |
1783 | 0 | } |
1784 | | |
1785 | | enum class KeyframeSearchDirection { |
1786 | | Forwards, |
1787 | | Backwards, |
1788 | | }; |
1789 | | |
1790 | | enum class KeyframeInsertPosition { |
1791 | | Prepend, |
1792 | | LastForOffset, |
1793 | | }; |
1794 | | |
1795 | | static Keyframe* |
1796 | | GetOrCreateKeyframe(nsTArray<Keyframe>* aKeyframes, |
1797 | | float aOffset, |
1798 | | const nsTimingFunction* aTimingFunction, |
1799 | | KeyframeSearchDirection aSearchDirection, |
1800 | | KeyframeInsertPosition aInsertPosition) |
1801 | 0 | { |
1802 | 0 | MOZ_ASSERT(aKeyframes, "The keyframe array should be valid"); |
1803 | 0 | MOZ_ASSERT(aTimingFunction, "The timing function should be valid"); |
1804 | 0 | MOZ_ASSERT(aOffset >= 0. && aOffset <= 1., |
1805 | 0 | "The offset should be in the range of [0.0, 1.0]"); |
1806 | 0 |
|
1807 | 0 | size_t keyframeIndex; |
1808 | 0 | switch (aSearchDirection) { |
1809 | 0 | case KeyframeSearchDirection::Forwards: |
1810 | 0 | if (nsAnimationManager::FindMatchingKeyframe(*aKeyframes, |
1811 | 0 | aOffset, |
1812 | 0 | *aTimingFunction, |
1813 | 0 | keyframeIndex)) { |
1814 | 0 | return &(*aKeyframes)[keyframeIndex]; |
1815 | 0 | } |
1816 | 0 | break; |
1817 | 0 | case KeyframeSearchDirection::Backwards: |
1818 | 0 | if (nsAnimationManager::FindMatchingKeyframe(Reversed(*aKeyframes), |
1819 | 0 | aOffset, |
1820 | 0 | *aTimingFunction, |
1821 | 0 | keyframeIndex)) { |
1822 | 0 | return &(*aKeyframes)[aKeyframes->Length() - 1 - keyframeIndex]; |
1823 | 0 | } |
1824 | 0 | keyframeIndex = aKeyframes->Length() - 1; |
1825 | 0 | break; |
1826 | 0 | } |
1827 | 0 | |
1828 | 0 | Keyframe* keyframe = |
1829 | 0 | aKeyframes->InsertElementAt( |
1830 | 0 | aInsertPosition == KeyframeInsertPosition::Prepend |
1831 | 0 | ? 0 |
1832 | 0 | : keyframeIndex); |
1833 | 0 | keyframe->mOffset.emplace(aOffset); |
1834 | 0 | if (aTimingFunction->mType != nsTimingFunction::Type::Linear) { |
1835 | 0 | keyframe->mTimingFunction.emplace(); |
1836 | 0 | keyframe->mTimingFunction->Init(*aTimingFunction); |
1837 | 0 | } |
1838 | 0 |
|
1839 | 0 | return keyframe; |
1840 | 0 | } |
1841 | | |
1842 | | Keyframe* |
1843 | | Gecko_GetOrCreateKeyframeAtStart(nsTArray<Keyframe>* aKeyframes, |
1844 | | float aOffset, |
1845 | | const nsTimingFunction* aTimingFunction) |
1846 | 0 | { |
1847 | 0 | MOZ_ASSERT(aKeyframes->IsEmpty() || |
1848 | 0 | aKeyframes->ElementAt(0).mOffset.value() >= aOffset, |
1849 | 0 | "The offset should be less than or equal to the first keyframe's " |
1850 | 0 | "offset if there are exisiting keyframes"); |
1851 | 0 |
|
1852 | 0 | return GetOrCreateKeyframe(aKeyframes, |
1853 | 0 | aOffset, |
1854 | 0 | aTimingFunction, |
1855 | 0 | KeyframeSearchDirection::Forwards, |
1856 | 0 | KeyframeInsertPosition::Prepend); |
1857 | 0 | } |
1858 | | |
1859 | | Keyframe* |
1860 | | Gecko_GetOrCreateInitialKeyframe(nsTArray<Keyframe>* aKeyframes, |
1861 | | const nsTimingFunction* aTimingFunction) |
1862 | 0 | { |
1863 | 0 | return GetOrCreateKeyframe(aKeyframes, |
1864 | 0 | 0., |
1865 | 0 | aTimingFunction, |
1866 | 0 | KeyframeSearchDirection::Forwards, |
1867 | 0 | KeyframeInsertPosition::LastForOffset); |
1868 | 0 | } |
1869 | | |
1870 | | Keyframe* |
1871 | | Gecko_GetOrCreateFinalKeyframe(nsTArray<Keyframe>* aKeyframes, |
1872 | | const nsTimingFunction* aTimingFunction) |
1873 | 0 | { |
1874 | 0 | return GetOrCreateKeyframe(aKeyframes, |
1875 | 0 | 1., |
1876 | 0 | aTimingFunction, |
1877 | 0 | KeyframeSearchDirection::Backwards, |
1878 | 0 | KeyframeInsertPosition::LastForOffset); |
1879 | 0 | } |
1880 | | |
1881 | | PropertyValuePair* |
1882 | | Gecko_AppendPropertyValuePair(nsTArray<PropertyValuePair>* aProperties, |
1883 | | nsCSSPropertyID aProperty) |
1884 | 0 | { |
1885 | 0 | MOZ_ASSERT(aProperties); |
1886 | 0 | MOZ_ASSERT(aProperty == eCSSPropertyExtra_variable || |
1887 | 0 | !nsCSSProps::PropHasFlags(aProperty, CSSPropFlags::IsLogical)); |
1888 | 0 | return aProperties->AppendElement(PropertyValuePair { aProperty }); |
1889 | 0 | } |
1890 | | |
1891 | | void |
1892 | | Gecko_ResetStyleCoord(nsStyleUnit* aUnit, nsStyleUnion* aValue) |
1893 | 0 | { |
1894 | 0 | nsStyleCoord::Reset(*aUnit, *aValue); |
1895 | 0 | } |
1896 | | |
1897 | | void |
1898 | | Gecko_SetStyleCoordCalcValue(nsStyleUnit* aUnit, nsStyleUnion* aValue, nsStyleCoord::CalcValue aCalc) |
1899 | 0 | { |
1900 | 0 | // Calc units should be cleaned up first |
1901 | 0 | MOZ_ASSERT(*aUnit != nsStyleUnit::eStyleUnit_Calc); |
1902 | 0 | nsStyleCoord::Calc* calcRef = new nsStyleCoord::Calc(); |
1903 | 0 | calcRef->mLength = aCalc.mLength; |
1904 | 0 | calcRef->mPercent = aCalc.mPercent; |
1905 | 0 | calcRef->mHasPercent = aCalc.mHasPercent; |
1906 | 0 | *aUnit = nsStyleUnit::eStyleUnit_Calc; |
1907 | 0 | aValue->mPointer = calcRef; |
1908 | 0 | calcRef->AddRef(); |
1909 | 0 | } |
1910 | | |
1911 | | void |
1912 | | Gecko_CopyShapeSourceFrom(mozilla::StyleShapeSource* aDst, const mozilla::StyleShapeSource* aSrc) |
1913 | 0 | { |
1914 | 0 | MOZ_ASSERT(aDst); |
1915 | 0 | MOZ_ASSERT(aSrc); |
1916 | 0 |
|
1917 | 0 | *aDst = *aSrc; |
1918 | 0 | } |
1919 | | |
1920 | | void |
1921 | | Gecko_DestroyShapeSource(mozilla::StyleShapeSource* aShape) |
1922 | 0 | { |
1923 | 0 | aShape->~StyleShapeSource(); |
1924 | 0 | } |
1925 | | |
1926 | | void |
1927 | | Gecko_StyleShapeSource_SetURLValue(StyleShapeSource* aShape, URLValue* aURL) |
1928 | 0 | { |
1929 | 0 | aShape->SetURL(aURL); |
1930 | 0 | } |
1931 | | |
1932 | | void |
1933 | | Gecko_NewBasicShape(mozilla::StyleShapeSource* aShape, |
1934 | | mozilla::StyleBasicShapeType aType) |
1935 | 0 | { |
1936 | 0 | aShape->SetBasicShape(MakeUnique<mozilla::StyleBasicShape>(aType), |
1937 | 0 | StyleGeometryBox::NoBox); |
1938 | 0 | } |
1939 | | |
1940 | | void |
1941 | | Gecko_NewShapeImage(mozilla::StyleShapeSource* aShape) |
1942 | 0 | { |
1943 | 0 | aShape->SetShapeImage(MakeUnique<nsStyleImage>()); |
1944 | 0 | } |
1945 | | |
1946 | | void |
1947 | | Gecko_NewStyleSVGPath(mozilla::StyleShapeSource* aShape) |
1948 | 0 | { |
1949 | 0 | MOZ_ASSERT(aShape); |
1950 | 0 | aShape->SetPath(MakeUnique<mozilla::StyleSVGPath>()); |
1951 | 0 | } |
1952 | | |
1953 | | void |
1954 | | Gecko_SetStyleMotion(UniquePtr<mozilla::StyleMotion>* aMotion, |
1955 | | mozilla::StyleMotion* aValue) |
1956 | 0 | { |
1957 | 0 | MOZ_ASSERT(aMotion); |
1958 | 0 | aMotion->reset(aValue); |
1959 | 0 | } |
1960 | | |
1961 | | mozilla::StyleMotion* |
1962 | | Gecko_NewStyleMotion() |
1963 | 0 | { |
1964 | 0 | return new StyleMotion(); |
1965 | 0 | } |
1966 | | |
1967 | | void |
1968 | | Gecko_CopyStyleMotions(mozilla::UniquePtr<mozilla::StyleMotion>* aMotion, |
1969 | | const mozilla::StyleMotion* aOther) |
1970 | 0 | { |
1971 | 0 | MOZ_ASSERT(aMotion); |
1972 | 0 | *aMotion = aOther ? MakeUnique<StyleMotion>(*aOther) : nullptr; |
1973 | 0 | } |
1974 | | |
1975 | | void |
1976 | | Gecko_ResetFilters(nsStyleEffects* effects, size_t new_len) |
1977 | 0 | { |
1978 | 0 | effects->mFilters.Clear(); |
1979 | 0 | effects->mFilters.SetLength(new_len); |
1980 | 0 | } |
1981 | | |
1982 | | void |
1983 | | Gecko_CopyFiltersFrom(nsStyleEffects* aSrc, nsStyleEffects* aDest) |
1984 | 0 | { |
1985 | 0 | aDest->mFilters = aSrc->mFilters; |
1986 | 0 | } |
1987 | | |
1988 | | void |
1989 | | Gecko_nsStyleFilter_SetURLValue(nsStyleFilter* aEffects, URLValue* aURL) |
1990 | 0 | { |
1991 | 0 | aEffects->SetURL(aURL); |
1992 | 0 | } |
1993 | | |
1994 | | void |
1995 | | Gecko_nsStyleSVGPaint_CopyFrom(nsStyleSVGPaint* aDest, const nsStyleSVGPaint* aSrc) |
1996 | 0 | { |
1997 | 0 | *aDest = *aSrc; |
1998 | 0 | } |
1999 | | |
2000 | | void |
2001 | | Gecko_nsStyleSVGPaint_SetURLValue(nsStyleSVGPaint* aPaint, URLValue* aURL) |
2002 | 0 | { |
2003 | 0 | aPaint->SetPaintServer(aURL); |
2004 | 0 | } |
2005 | | |
2006 | | void Gecko_nsStyleSVGPaint_Reset(nsStyleSVGPaint* aPaint) |
2007 | 0 | { |
2008 | 0 | aPaint->SetNone(); |
2009 | 0 | } |
2010 | | |
2011 | | void |
2012 | | Gecko_nsStyleSVG_SetDashArrayLength(nsStyleSVG* aSvg, uint32_t aLen) |
2013 | 0 | { |
2014 | 0 | aSvg->mStrokeDasharray.Clear(); |
2015 | 0 | aSvg->mStrokeDasharray.SetLength(aLen); |
2016 | 0 | } |
2017 | | |
2018 | | void |
2019 | | Gecko_nsStyleSVG_CopyDashArray(nsStyleSVG* aDst, const nsStyleSVG* aSrc) |
2020 | 0 | { |
2021 | 0 | aDst->mStrokeDasharray = aSrc->mStrokeDasharray; |
2022 | 0 | } |
2023 | | |
2024 | | void |
2025 | | Gecko_nsStyleSVG_SetContextPropertiesLength(nsStyleSVG* aSvg, uint32_t aLen) |
2026 | 0 | { |
2027 | 0 | aSvg->mContextProps.Clear(); |
2028 | 0 | aSvg->mContextProps.SetLength(aLen); |
2029 | 0 | } |
2030 | | |
2031 | | void |
2032 | | Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* aDst, const nsStyleSVG* aSrc) |
2033 | 0 | { |
2034 | 0 | aDst->mContextProps = aSrc->mContextProps; |
2035 | 0 | aDst->mContextPropsBits = aSrc->mContextPropsBits; |
2036 | 0 | } |
2037 | | |
2038 | | |
2039 | | css::URLValue* |
2040 | | Gecko_NewURLValue(ServoBundledURI aURI) |
2041 | 0 | { |
2042 | 0 | RefPtr<css::URLValue> url = aURI.IntoCssUrl(); |
2043 | 0 | return url.forget().take(); |
2044 | 0 | } |
2045 | | |
2046 | | MOZ_DEFINE_MALLOC_SIZE_OF(GeckoURLValueMallocSizeOf) |
2047 | | |
2048 | | size_t |
2049 | | Gecko_URLValue_SizeOfIncludingThis(URLValue* aURL) |
2050 | 0 | { |
2051 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
2052 | 0 | return aURL->SizeOfIncludingThis(GeckoURLValueMallocSizeOf); |
2053 | 0 | } |
2054 | | |
2055 | | void |
2056 | | Gecko_GetComputedURLSpec(const URLValueData* aURL, nsCString* aOut) |
2057 | 0 | { |
2058 | 0 | MOZ_ASSERT(aURL); |
2059 | 0 | MOZ_ASSERT(aOut); |
2060 | 0 | if (aURL->IsLocalRef()) { |
2061 | 0 | aOut->Assign(aURL->GetString()); |
2062 | 0 | return; |
2063 | 0 | } |
2064 | 0 | if (nsIURI* uri = aURL->GetURI()) { |
2065 | 0 | nsresult rv = uri->GetSpec(*aOut); |
2066 | 0 | if (NS_SUCCEEDED(rv)) { |
2067 | 0 | return; |
2068 | 0 | } |
2069 | 0 | } |
2070 | 0 | |
2071 | 0 | aOut->AssignLiteral("about:invalid"); |
2072 | 0 | } |
2073 | | |
2074 | | void |
2075 | | Gecko_nsIURI_Debug(nsIURI* aURI, nsCString* aOut) |
2076 | 0 | { |
2077 | 0 | // TODO(emilio): Do we have more useful stuff to put here, maybe? |
2078 | 0 | if (aURI) { |
2079 | 0 | *aOut = aURI->GetSpecOrDefault(); |
2080 | 0 | } |
2081 | 0 | } |
2082 | | |
2083 | | template <typename ElementLike> |
2084 | | void |
2085 | | DebugListAttributes(const ElementLike& aElement, nsCString& aOut) |
2086 | 0 | { |
2087 | 0 | const uint32_t kMaxAttributeLength = 40; |
2088 | 0 |
|
2089 | 0 | uint32_t i = 0; |
2090 | 0 | while (BorrowedAttrInfo info = aElement.GetAttrInfoAt(i++)) { |
2091 | 0 | aOut.AppendLiteral(" "); |
2092 | 0 | if (nsAtom* prefix = info.mName->GetPrefix()) { |
2093 | 0 | aOut.Append(NS_ConvertUTF16toUTF8(nsDependentAtomString(prefix))); |
2094 | 0 | aOut.AppendLiteral(":"); |
2095 | 0 | } |
2096 | 0 | aOut.Append( |
2097 | 0 | NS_ConvertUTF16toUTF8(nsDependentAtomString(info.mName->LocalName()))); |
2098 | 0 | if (!info.mValue) { |
2099 | 0 | continue; |
2100 | 0 | } |
2101 | 0 | aOut.AppendLiteral("=\""); |
2102 | 0 | nsAutoString value; |
2103 | 0 | info.mValue->ToString(value); |
2104 | 0 | if (value.Length() > kMaxAttributeLength) { |
2105 | 0 | value.Truncate(kMaxAttributeLength - 3); |
2106 | 0 | value.AppendLiteral("..."); |
2107 | 0 | } |
2108 | 0 | aOut.Append(NS_ConvertUTF16toUTF8(value)); |
2109 | 0 | aOut.AppendLiteral("\""); |
2110 | 0 | } |
2111 | 0 | } Unexecuted instantiation: void DebugListAttributes<mozilla::dom::Element>(mozilla::dom::Element const&, nsTString<char>&) Unexecuted instantiation: void DebugListAttributes<mozilla::ServoElementSnapshot>(mozilla::ServoElementSnapshot const&, nsTString<char>&) |
2112 | | |
2113 | | void |
2114 | | Gecko_Element_DebugListAttributes(RawGeckoElementBorrowed aElement, nsCString* aOut) |
2115 | 0 | { |
2116 | 0 | DebugListAttributes(*aElement, *aOut); |
2117 | 0 | } |
2118 | | |
2119 | | void |
2120 | | Gecko_Snapshot_DebugListAttributes(const ServoElementSnapshot* aSnapshot, |
2121 | | nsCString* aOut) |
2122 | 0 | { |
2123 | 0 | DebugListAttributes(*aSnapshot, *aOut); |
2124 | 0 | } |
2125 | | |
2126 | | NS_IMPL_THREADSAFE_FFI_REFCOUNTING(css::URLValue, CSSURLValue); |
2127 | | |
2128 | | NS_IMPL_THREADSAFE_FFI_REFCOUNTING(URLExtraData, URLExtraData); |
2129 | | |
2130 | | NS_IMPL_THREADSAFE_FFI_REFCOUNTING(nsStyleCoord::Calc, Calc); |
2131 | | |
2132 | | nsCSSShadowArray* |
2133 | | Gecko_NewCSSShadowArray(uint32_t aLen) |
2134 | 0 | { |
2135 | 0 | RefPtr<nsCSSShadowArray> arr = new(aLen) nsCSSShadowArray(aLen); |
2136 | 0 | return arr.forget().take(); |
2137 | 0 | } |
2138 | | |
2139 | | NS_IMPL_THREADSAFE_FFI_REFCOUNTING(nsCSSShadowArray, CSSShadowArray); |
2140 | | |
2141 | | nsStyleQuoteValues* |
2142 | | Gecko_NewStyleQuoteValues(uint32_t aLen) |
2143 | 0 | { |
2144 | 0 | RefPtr<nsStyleQuoteValues> values = new nsStyleQuoteValues; |
2145 | 0 | values->mQuotePairs.SetLength(aLen); |
2146 | 0 | return values.forget().take(); |
2147 | 0 | } |
2148 | | |
2149 | | NS_IMPL_THREADSAFE_FFI_REFCOUNTING(nsStyleQuoteValues, QuoteValues); |
2150 | | |
2151 | | nsCSSValueSharedList* |
2152 | | Gecko_NewCSSValueSharedList(uint32_t aLen) |
2153 | 0 | { |
2154 | 0 | RefPtr<nsCSSValueSharedList> list = new nsCSSValueSharedList; |
2155 | 0 | if (aLen == 0) { |
2156 | 0 | return list.forget().take(); |
2157 | 0 | } |
2158 | 0 | |
2159 | 0 | list->mHead = new nsCSSValueList; |
2160 | 0 | nsCSSValueList* cur = list->mHead; |
2161 | 0 | for (uint32_t i = 0; i < aLen - 1; i++) { |
2162 | 0 | cur->mNext = new nsCSSValueList; |
2163 | 0 | cur = cur->mNext; |
2164 | 0 | } |
2165 | 0 |
|
2166 | 0 | return list.forget().take(); |
2167 | 0 | } |
2168 | | |
2169 | | nsCSSValueSharedList* |
2170 | | Gecko_NewNoneTransform() |
2171 | 0 | { |
2172 | 0 | RefPtr<nsCSSValueSharedList> list = new nsCSSValueSharedList; |
2173 | 0 | list->mHead = new nsCSSValueList; |
2174 | 0 | list->mHead->mValue.SetNoneValue(); |
2175 | 0 | return list.forget().take(); |
2176 | 0 | } |
2177 | | |
2178 | | void |
2179 | | Gecko_CSSValue_SetNumber(nsCSSValueBorrowedMut aCSSValue, float aNumber) |
2180 | 0 | { |
2181 | 0 | aCSSValue->SetFloatValue(aNumber, eCSSUnit_Number); |
2182 | 0 | } |
2183 | | |
2184 | | float |
2185 | | Gecko_CSSValue_GetNumber(nsCSSValueBorrowed aCSSValue) |
2186 | 0 | { |
2187 | 0 | return aCSSValue->GetFloatValue(); |
2188 | 0 | } |
2189 | | |
2190 | | void |
2191 | | Gecko_CSSValue_SetKeyword(nsCSSValueBorrowedMut aCSSValue, nsCSSKeyword aKeyword) |
2192 | 0 | { |
2193 | 0 | aCSSValue->SetEnumValue(aKeyword); |
2194 | 0 | } |
2195 | | |
2196 | | nsCSSKeyword |
2197 | | Gecko_CSSValue_GetKeyword(nsCSSValueBorrowed aCSSValue) |
2198 | 0 | { |
2199 | 0 | return aCSSValue->GetKeywordValue(); |
2200 | 0 | } |
2201 | | |
2202 | | void |
2203 | | Gecko_CSSValue_SetPercentage(nsCSSValueBorrowedMut aCSSValue, float aPercent) |
2204 | 0 | { |
2205 | 0 | aCSSValue->SetPercentValue(aPercent); |
2206 | 0 | } |
2207 | | |
2208 | | float |
2209 | | Gecko_CSSValue_GetPercentage(nsCSSValueBorrowed aCSSValue) |
2210 | 0 | { |
2211 | 0 | return aCSSValue->GetPercentValue(); |
2212 | 0 | } |
2213 | | |
2214 | | void |
2215 | | Gecko_CSSValue_SetPixelLength(nsCSSValueBorrowedMut aCSSValue, float aLen) |
2216 | 0 | { |
2217 | 0 | MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null || |
2218 | 0 | aCSSValue->GetUnit() == eCSSUnit_Pixel); |
2219 | 0 | aCSSValue->SetFloatValue(aLen, eCSSUnit_Pixel); |
2220 | 0 | } |
2221 | | |
2222 | | void |
2223 | | Gecko_CSSValue_SetCalc(nsCSSValueBorrowedMut aCSSValue, nsStyleCoord::CalcValue aCalc) |
2224 | 0 | { |
2225 | 0 | aCSSValue->SetCalcValue(&aCalc); |
2226 | 0 | } |
2227 | | |
2228 | | nsStyleCoord::CalcValue |
2229 | | Gecko_CSSValue_GetCalc(nsCSSValueBorrowed aCSSValue) |
2230 | 0 | { |
2231 | 0 | return aCSSValue->GetCalcValue(); |
2232 | 0 | } |
2233 | | |
2234 | | void |
2235 | | Gecko_CSSValue_SetFunction(nsCSSValueBorrowedMut aCSSValue, int32_t aLen) |
2236 | 0 | { |
2237 | 0 | nsCSSValue::Array* arr = nsCSSValue::Array::Create(aLen); |
2238 | 0 | aCSSValue->SetArrayValue(arr, eCSSUnit_Function); |
2239 | 0 | } |
2240 | | |
2241 | | void |
2242 | | Gecko_CSSValue_SetString(nsCSSValueBorrowedMut aCSSValue, |
2243 | | const uint8_t* aString, uint32_t aLength, |
2244 | | nsCSSUnit aUnit) |
2245 | 0 | { |
2246 | 0 | MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null); |
2247 | 0 | nsString string; |
2248 | 0 | nsDependentCSubstring slice(reinterpret_cast<const char*>(aString), |
2249 | 0 | aLength); |
2250 | 0 | AppendUTF8toUTF16(slice, string); |
2251 | 0 | aCSSValue->SetStringValue(string, aUnit); |
2252 | 0 | } |
2253 | | |
2254 | | void |
2255 | | Gecko_CSSValue_SetStringFromAtom(nsCSSValueBorrowedMut aCSSValue, |
2256 | | nsAtom* aAtom, nsCSSUnit aUnit) |
2257 | 0 | { |
2258 | 0 | aCSSValue->SetStringValue(nsDependentAtomString(aAtom), aUnit); |
2259 | 0 | } |
2260 | | |
2261 | | void |
2262 | | Gecko_CSSValue_SetAtomIdent(nsCSSValueBorrowedMut aCSSValue, nsAtom* aAtom) |
2263 | 0 | { |
2264 | 0 | aCSSValue->SetAtomIdentValue(already_AddRefed<nsAtom>(aAtom)); |
2265 | 0 | } |
2266 | | |
2267 | | void |
2268 | | Gecko_CSSValue_SetArray(nsCSSValueBorrowedMut aCSSValue, int32_t aLength) |
2269 | 0 | { |
2270 | 0 | MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null); |
2271 | 0 | RefPtr<nsCSSValue::Array> array |
2272 | 0 | = nsCSSValue::Array::Create(aLength); |
2273 | 0 | aCSSValue->SetArrayValue(array, eCSSUnit_Array); |
2274 | 0 | } |
2275 | | |
2276 | | void |
2277 | | Gecko_CSSValue_SetURL(nsCSSValueBorrowedMut aCSSValue, URLValue* aURL) |
2278 | 0 | { |
2279 | 0 | MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null); |
2280 | 0 | aCSSValue->SetURLValue(aURL); |
2281 | 0 | } |
2282 | | |
2283 | | void |
2284 | | Gecko_CSSValue_SetInt(nsCSSValueBorrowedMut aCSSValue, |
2285 | | int32_t aInteger, nsCSSUnit aUnit) |
2286 | 0 | { |
2287 | 0 | aCSSValue->SetIntValue(aInteger, aUnit); |
2288 | 0 | } |
2289 | | |
2290 | | void |
2291 | | Gecko_CSSValue_SetFloat(nsCSSValueBorrowedMut aCSSValue, |
2292 | | float aValue, nsCSSUnit aUnit) |
2293 | 0 | { |
2294 | 0 | aCSSValue->SetFloatValue(aValue, aUnit); |
2295 | 0 | } |
2296 | | |
2297 | | nsCSSValueBorrowedMut |
2298 | | Gecko_CSSValue_GetArrayItem(nsCSSValueBorrowedMut aCSSValue, int32_t aIndex) |
2299 | 0 | { |
2300 | 0 | return &aCSSValue->GetArrayValue()->Item(aIndex); |
2301 | 0 | } |
2302 | | |
2303 | | nsCSSValueBorrowed |
2304 | | Gecko_CSSValue_GetArrayItemConst(nsCSSValueBorrowed aCSSValue, int32_t aIndex) |
2305 | 0 | { |
2306 | 0 | return &aCSSValue->GetArrayValue()->Item(aIndex); |
2307 | 0 | } |
2308 | | |
2309 | | void |
2310 | | Gecko_CSSValue_SetPair(nsCSSValueBorrowedMut aCSSValue, |
2311 | | nsCSSValueBorrowed aXValue, nsCSSValueBorrowed aYValue) |
2312 | 0 | { |
2313 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
2314 | 0 | aCSSValue->SetPairValue(*aXValue, *aYValue); |
2315 | 0 | } |
2316 | | |
2317 | | void |
2318 | | Gecko_CSSValue_SetList(nsCSSValueBorrowedMut aCSSValue, uint32_t aLen) |
2319 | 0 | { |
2320 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
2321 | 0 | nsCSSValueList* item = aCSSValue->SetListValue(); |
2322 | 0 | for (uint32_t i = 1; i < aLen; ++i) { |
2323 | 0 | item->mNext = new nsCSSValueList; |
2324 | 0 | item = item->mNext; |
2325 | 0 | } |
2326 | 0 | } |
2327 | | |
2328 | | void |
2329 | | Gecko_CSSValue_SetPairList(nsCSSValueBorrowedMut aCSSValue, uint32_t aLen) |
2330 | 0 | { |
2331 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
2332 | 0 | nsCSSValuePairList* item = aCSSValue->SetPairListValue(); |
2333 | 0 | for (uint32_t i = 1; i < aLen; ++i) { |
2334 | 0 | item->mNext = new nsCSSValuePairList; |
2335 | 0 | item = item->mNext; |
2336 | 0 | } |
2337 | 0 | } |
2338 | | |
2339 | | void |
2340 | | Gecko_CSSValue_InitSharedList(nsCSSValueBorrowedMut aCSSValue, |
2341 | | uint32_t aLen) |
2342 | 0 | { |
2343 | 0 | MOZ_ASSERT(aLen > 0, "Must create at least one nsCSSValueList (mHead)"); |
2344 | 0 |
|
2345 | 0 | nsCSSValueSharedList* list = new nsCSSValueSharedList; |
2346 | 0 | aCSSValue->SetSharedListValue(list); |
2347 | 0 | list->mHead = new nsCSSValueList; |
2348 | 0 | nsCSSValueList* cur = list->mHead; |
2349 | 0 | for (uint32_t i = 1; i < aLen; ++i) { |
2350 | 0 | cur->mNext = new nsCSSValueList; |
2351 | 0 | cur = cur->mNext; |
2352 | 0 | } |
2353 | 0 | } |
2354 | | |
2355 | | void |
2356 | | Gecko_CSSValue_Drop(nsCSSValueBorrowedMut aCSSValue) |
2357 | 0 | { |
2358 | 0 | aCSSValue->~nsCSSValue(); |
2359 | 0 | } |
2360 | | |
2361 | | void |
2362 | | Gecko_CSSValue_SetFontStretch(nsCSSValueBorrowedMut aCSSValue, |
2363 | | float stretch) |
2364 | 0 | { |
2365 | 0 | aCSSValue->SetFontStretch( |
2366 | 0 | FontStretch(std::min(stretch * 100.0f, float(FontStretch::kMax)))); |
2367 | 0 | } |
2368 | | |
2369 | | // FIXME(emilio): This function should probably have `Oblique` in its name. |
2370 | | void |
2371 | | Gecko_CSSValue_SetFontSlantStyle(nsCSSValueBorrowedMut aCSSValue, |
2372 | | float aAngle) |
2373 | 0 | { |
2374 | 0 | aCSSValue->SetFontSlantStyle(mozilla::FontSlantStyle::Oblique(aAngle)); |
2375 | 0 | } |
2376 | | |
2377 | | void |
2378 | | Gecko_CSSValue_SetFontWeight(nsCSSValueBorrowedMut aCSSValue, |
2379 | | float weight) |
2380 | 0 | { |
2381 | 0 | aCSSValue->SetFontWeight(mozilla::FontWeight(weight)); |
2382 | 0 | } |
2383 | | |
2384 | | void |
2385 | | Gecko_nsStyleFont_SetLang(nsStyleFont* aFont, nsAtom* aAtom) |
2386 | 0 | { |
2387 | 0 | aFont->mLanguage = dont_AddRef(aAtom); |
2388 | 0 | aFont->mExplicitLanguage = true; |
2389 | 0 | } |
2390 | | |
2391 | | void |
2392 | | Gecko_nsStyleFont_CopyLangFrom(nsStyleFont* aFont, const nsStyleFont* aSource) |
2393 | 0 | { |
2394 | 0 | aFont->mLanguage = aSource->mLanguage; |
2395 | 0 | } |
2396 | | |
2397 | | void |
2398 | | Gecko_nsStyleFont_FixupNoneGeneric(nsStyleFont* aFont, |
2399 | | RawGeckoPresContextBorrowed aPresContext) |
2400 | 0 | { |
2401 | 0 | const nsFont* defaultVariableFont = |
2402 | 0 | ThreadSafeGetDefaultFontHelper(aPresContext, aFont->mLanguage, |
2403 | 0 | kPresContext_DefaultVariableFont_ID); |
2404 | 0 | nsLayoutUtils::FixupNoneGeneric(&aFont->mFont, aPresContext, |
2405 | 0 | aFont->mGenericID, defaultVariableFont); |
2406 | 0 | } |
2407 | | |
2408 | | void |
2409 | | Gecko_nsStyleFont_PrefillDefaultForGeneric(nsStyleFont* aFont, |
2410 | | RawGeckoPresContextBorrowed aPresContext, |
2411 | | uint8_t aGenericId) |
2412 | 0 | { |
2413 | 0 | const nsFont* defaultFont = ThreadSafeGetDefaultFontHelper(aPresContext, aFont->mLanguage, |
2414 | 0 | aGenericId); |
2415 | 0 | // In case of just the language changing, the parent could have had no generic, |
2416 | 0 | // which Gecko just does regular cascading with. Do the same. |
2417 | 0 | // This can only happen in the case where the language changed but the family did not |
2418 | 0 | if (aGenericId != kGenericFont_NONE) { |
2419 | 0 | aFont->mFont.fontlist = defaultFont->fontlist; |
2420 | 0 | } else { |
2421 | 0 | aFont->mFont.fontlist.SetDefaultFontType(defaultFont->fontlist.GetDefaultFontType()); |
2422 | 0 | } |
2423 | 0 | } |
2424 | | |
2425 | | void |
2426 | | Gecko_nsStyleFont_FixupMinFontSize(nsStyleFont* aFont, |
2427 | | RawGeckoPresContextBorrowed aPresContext) |
2428 | 0 | { |
2429 | 0 | nscoord minFontSize; |
2430 | 0 | bool needsCache = false; |
2431 | 0 |
|
2432 | 0 | { |
2433 | 0 | AutoReadLock guard(*sServoFFILock); |
2434 | 0 | minFontSize = aPresContext->MinFontSize(aFont->mLanguage, &needsCache); |
2435 | 0 | } |
2436 | 0 |
|
2437 | 0 | if (needsCache) { |
2438 | 0 | AutoWriteLock guard(*sServoFFILock); |
2439 | 0 | minFontSize = aPresContext->MinFontSize(aFont->mLanguage, nullptr); |
2440 | 0 | } |
2441 | 0 |
|
2442 | 0 | nsLayoutUtils::ApplyMinFontSize(aFont, aPresContext, minFontSize); |
2443 | 0 | } |
2444 | | |
2445 | | void |
2446 | | FontSizePrefs::CopyFrom(const LangGroupFontPrefs& prefs) |
2447 | 0 | { |
2448 | 0 | mDefaultVariableSize = prefs.mDefaultVariableFont.size; |
2449 | 0 | mDefaultFixedSize = prefs.mDefaultFixedFont.size; |
2450 | 0 | mDefaultSerifSize = prefs.mDefaultSerifFont.size; |
2451 | 0 | mDefaultSansSerifSize = prefs.mDefaultSansSerifFont.size; |
2452 | 0 | mDefaultMonospaceSize = prefs.mDefaultMonospaceFont.size; |
2453 | 0 | mDefaultCursiveSize = prefs.mDefaultCursiveFont.size; |
2454 | 0 | mDefaultFantasySize = prefs.mDefaultFantasyFont.size; |
2455 | 0 | } |
2456 | | |
2457 | | FontSizePrefs |
2458 | | Gecko_GetBaseSize(nsAtom* aLanguage) |
2459 | 0 | { |
2460 | 0 | LangGroupFontPrefs prefs; |
2461 | 0 | RefPtr<nsAtom> langGroupAtom = StaticPresData::Get()->GetUncachedLangGroup(aLanguage); |
2462 | 0 |
|
2463 | 0 | prefs.Initialize(langGroupAtom); |
2464 | 0 | FontSizePrefs sizes; |
2465 | 0 | sizes.CopyFrom(prefs); |
2466 | 0 |
|
2467 | 0 | return sizes; |
2468 | 0 | } |
2469 | | |
2470 | | RawGeckoElementBorrowedOrNull |
2471 | | Gecko_GetBindingParent(RawGeckoElementBorrowed aElement) |
2472 | 0 | { |
2473 | 0 | nsIContent* parent = aElement->GetBindingParent(); |
2474 | 0 | return parent ? parent->AsElement() : nullptr; |
2475 | 0 | } |
2476 | | |
2477 | | RawServoAuthorStylesBorrowedOrNull |
2478 | | Gecko_XBLBinding_GetRawServoStyles(RawGeckoXBLBindingBorrowed aXBLBinding) |
2479 | 0 | { |
2480 | 0 | return aXBLBinding->GetServoStyles(); |
2481 | 0 | } |
2482 | | |
2483 | | bool |
2484 | | Gecko_XBLBinding_InheritsStyle(RawGeckoXBLBindingBorrowed aXBLBinding) |
2485 | 0 | { |
2486 | 0 | return aXBLBinding->InheritsStyle(); |
2487 | 0 | } |
2488 | | |
2489 | | static StaticRefPtr<UACacheReporter> gUACacheReporter; |
2490 | | |
2491 | | void |
2492 | | InitializeServo() |
2493 | 3 | { |
2494 | 3 | URLExtraData::InitDummy(); |
2495 | 3 | Servo_Initialize(URLExtraData::Dummy()); |
2496 | 3 | |
2497 | 3 | gUACacheReporter = new UACacheReporter(); |
2498 | 3 | RegisterWeakMemoryReporter(gUACacheReporter); |
2499 | 3 | |
2500 | 3 | sServoFFILock = new RWLock("Servo::FFILock"); |
2501 | 3 | } |
2502 | | |
2503 | | void |
2504 | | ShutdownServo() |
2505 | 0 | { |
2506 | 0 | MOZ_ASSERT(sServoFFILock); |
2507 | 0 |
|
2508 | 0 | UnregisterWeakMemoryReporter(gUACacheReporter); |
2509 | 0 | gUACacheReporter = nullptr; |
2510 | 0 |
|
2511 | 0 | delete sServoFFILock; |
2512 | 0 | Servo_Shutdown(); |
2513 | 0 | } |
2514 | | |
2515 | | namespace mozilla { |
2516 | | |
2517 | | void |
2518 | | AssertIsMainThreadOrServoFontMetricsLocked() |
2519 | 0 | { |
2520 | 0 | if (!NS_IsMainThread()) { |
2521 | 0 | MOZ_ASSERT(sServoFFILock && |
2522 | 0 | sServoFFILock->LockedForWritingByCurrentThread()); |
2523 | 0 | } |
2524 | 0 | } |
2525 | | |
2526 | | } // namespace mozilla |
2527 | | |
2528 | | GeckoFontMetrics |
2529 | | Gecko_GetFontMetrics(RawGeckoPresContextBorrowed aPresContext, |
2530 | | bool aIsVertical, |
2531 | | const nsStyleFont* aFont, |
2532 | | nscoord aFontSize, |
2533 | | bool aUseUserFontSet) |
2534 | 0 | { |
2535 | 0 | AutoWriteLock guard(*sServoFFILock); |
2536 | 0 | GeckoFontMetrics ret; |
2537 | 0 |
|
2538 | 0 | // Getting font metrics can require some main thread only work to be |
2539 | 0 | // done, such as work that needs to touch non-threadsafe refcounted |
2540 | 0 | // objects (like the DOM FontFace/FontFaceSet objects), network loads, etc. |
2541 | 0 | // |
2542 | 0 | // To handle this work, font code checks whether we are in a Servo traversal |
2543 | 0 | // and if so, appends PostTraversalTasks to the current ServoStyleSet |
2544 | 0 | // to be performed immediately after the traversal is finished. This |
2545 | 0 | // works well for starting downloadable font loads, since we don't have |
2546 | 0 | // those fonts available to get metrics for anyway. Platform fonts and |
2547 | 0 | // ArrayBuffer-backed FontFace objects are handled synchronously. |
2548 | 0 |
|
2549 | 0 | nsPresContext* presContext = const_cast<nsPresContext*>(aPresContext); |
2550 | 0 | presContext->SetUsesExChUnits(true); |
2551 | 0 | RefPtr<nsFontMetrics> fm = nsLayoutUtils::GetMetricsFor( |
2552 | 0 | presContext, aIsVertical, aFont, aFontSize, aUseUserFontSet, |
2553 | 0 | nsLayoutUtils::FlushUserFontSet::No); |
2554 | 0 |
|
2555 | 0 | ret.mXSize = fm->XHeight(); |
2556 | 0 | gfxFloat zeroWidth = fm->GetThebesFontGroup()->GetFirstValidFont()-> |
2557 | 0 | GetMetrics(fm->Orientation()).zeroOrAveCharWidth; |
2558 | 0 | ret.mChSize = NS_round(aPresContext->AppUnitsPerDevPixel() * zeroWidth); |
2559 | 0 | return ret; |
2560 | 0 | } |
2561 | | |
2562 | | int32_t |
2563 | | Gecko_GetAppUnitsPerPhysicalInch(RawGeckoPresContextBorrowed aPresContext) |
2564 | 0 | { |
2565 | 0 | nsPresContext* presContext = const_cast<nsPresContext*>(aPresContext); |
2566 | 0 | return presContext->DeviceContext()->AppUnitsPerPhysicalInch(); |
2567 | 0 | } |
2568 | | |
2569 | | NS_IMPL_THREADSAFE_FFI_REFCOUNTING(SheetLoadDataHolder, SheetLoadDataHolder); |
2570 | | |
2571 | | void |
2572 | | Gecko_StyleSheet_FinishAsyncParse(SheetLoadDataHolder* aData, |
2573 | | RawServoStyleSheetContentsStrong aSheetContents, |
2574 | | StyleUseCountersOwned aUseCounters) |
2575 | 0 | { |
2576 | 0 | UniquePtr<StyleUseCounters> useCounters(aUseCounters); |
2577 | 0 | RefPtr<SheetLoadDataHolder> loadData = aData; |
2578 | 0 | RefPtr<RawServoStyleSheetContents> sheetContents = aSheetContents.Consume(); |
2579 | 0 | NS_DispatchToMainThread(NS_NewRunnableFunction(__func__, |
2580 | 0 | [d = std::move(loadData), |
2581 | 0 | contents = std::move(sheetContents), |
2582 | 0 | counters = std::move(useCounters)]() mutable { |
2583 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
2584 | 0 | SheetLoadData* data = d->get(); |
2585 | 0 | if (nsIDocument* doc = data->mLoader->GetDocument()) { |
2586 | 0 | if (const StyleUseCounters* docCounters = doc->GetStyleUseCounters()) { |
2587 | 0 | Servo_UseCounters_Merge(docCounters, counters.get()); |
2588 | 0 | } |
2589 | 0 | } |
2590 | 0 | data->mSheet->FinishAsyncParse(contents.forget()); |
2591 | 0 | })); |
2592 | 0 | } |
2593 | | |
2594 | | static already_AddRefed<StyleSheet> |
2595 | | LoadImportSheet(css::Loader* aLoader, |
2596 | | StyleSheet* aParent, |
2597 | | SheetLoadData* aParentLoadData, |
2598 | | css::LoaderReusableStyleSheets* aReusableSheets, |
2599 | | css::URLValue* aURL, |
2600 | | already_AddRefed<RawServoMediaList> aMediaList) |
2601 | 0 | { |
2602 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
2603 | 0 | MOZ_ASSERT(aLoader, "Should've catched this before"); |
2604 | 0 | MOZ_ASSERT(aParent, "Only used for @import, so parent should exist!"); |
2605 | 0 | MOZ_ASSERT(aURL, "Invalid URLs shouldn't be loaded!"); |
2606 | 0 |
|
2607 | 0 | RefPtr<dom::MediaList> media = new MediaList(std::move(aMediaList)); |
2608 | 0 | nsCOMPtr<nsIURI> uri = aURL->GetURI(); |
2609 | 0 | nsresult rv = uri ? NS_OK : NS_ERROR_FAILURE; |
2610 | 0 |
|
2611 | 0 | StyleSheet* previousFirstChild = aParent->GetFirstChild(); |
2612 | 0 | if (NS_SUCCEEDED(rv)) { |
2613 | 0 | rv = aLoader->LoadChildSheet(aParent, aParentLoadData, uri, media, aReusableSheets); |
2614 | 0 | } |
2615 | 0 |
|
2616 | 0 | if (NS_FAILED(rv) || |
2617 | 0 | !aParent->GetFirstChild() || |
2618 | 0 | aParent->GetFirstChild() == previousFirstChild) { |
2619 | 0 | // Servo and Gecko have different ideas of what a valid URL is, so we might |
2620 | 0 | // get in here with a URL string that NS_NewURI can't handle. We may also |
2621 | 0 | // reach here via an import cycle. For the import cycle case, we need some |
2622 | 0 | // sheet object per spec, even if its empty. DevTools uses the URI to |
2623 | 0 | // realize it has hit an import cycle, so we mark it complete to make the |
2624 | 0 | // sheet readable from JS. |
2625 | 0 | RefPtr<StyleSheet> emptySheet = |
2626 | 0 | aParent->CreateEmptyChildSheet(media.forget()); |
2627 | 0 | // Make a dummy URI if we don't have one because some methods assume |
2628 | 0 | // non-null URIs. |
2629 | 0 | if (!uri) { |
2630 | 0 | NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING("about:invalid")); |
2631 | 0 | } |
2632 | 0 | emptySheet->SetURIs(uri, uri, uri); |
2633 | 0 | emptySheet->SetPrincipal(aURL->mExtraData->GetPrincipal()); |
2634 | 0 | emptySheet->SetComplete(); |
2635 | 0 | aParent->PrependStyleSheet(emptySheet); |
2636 | 0 | return emptySheet.forget(); |
2637 | 0 | } |
2638 | 0 |
|
2639 | 0 | RefPtr<StyleSheet> sheet = |
2640 | 0 | static_cast<StyleSheet*>(aParent->GetFirstChild()); |
2641 | 0 | return sheet.forget(); |
2642 | 0 | } |
2643 | | |
2644 | | StyleSheet* |
2645 | | Gecko_LoadStyleSheet(css::Loader* aLoader, |
2646 | | StyleSheet* aParent, |
2647 | | SheetLoadData* aParentLoadData, |
2648 | | css::LoaderReusableStyleSheets* aReusableSheets, |
2649 | | ServoBundledURI aServoURL, |
2650 | | RawServoMediaListStrong aMediaList) |
2651 | 0 | { |
2652 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
2653 | 0 | RefPtr<css::URLValue> url = aServoURL.IntoCssUrl(); |
2654 | 0 | return LoadImportSheet(aLoader, aParent, aParentLoadData, aReusableSheets, |
2655 | 0 | url, aMediaList.Consume()).take(); |
2656 | 0 | } |
2657 | | |
2658 | | void |
2659 | | Gecko_LoadStyleSheetAsync(css::SheetLoadDataHolder* aParentData, |
2660 | | ServoBundledURI aServoURL, |
2661 | | RawServoMediaListStrong aMediaList, |
2662 | | RawServoImportRuleStrong aImportRule) |
2663 | 0 | { |
2664 | 0 | RefPtr<SheetLoadDataHolder> loadData = aParentData; |
2665 | 0 | RefPtr<css::URLValue> urlVal = aServoURL.IntoCssUrl(); |
2666 | 0 | RefPtr<RawServoMediaList> mediaList = aMediaList.Consume(); |
2667 | 0 | RefPtr<RawServoImportRule> importRule = aImportRule.Consume(); |
2668 | 0 | NS_DispatchToMainThread(NS_NewRunnableFunction(__func__, |
2669 | 0 | [data = std::move(loadData), |
2670 | 0 | url = std::move(urlVal), |
2671 | 0 | media = std::move(mediaList), |
2672 | 0 | import = std::move(importRule)]() mutable { |
2673 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
2674 | 0 | SheetLoadData* d = data->get(); |
2675 | 0 | RefPtr<StyleSheet> sheet = |
2676 | 0 | LoadImportSheet(d->mLoader, d->mSheet, d, nullptr, url, media.forget()); |
2677 | 0 | Servo_ImportRule_SetSheet(import, sheet); |
2678 | 0 | })); |
2679 | 0 | } |
2680 | | |
2681 | | nsCSSKeyword |
2682 | | Gecko_LookupCSSKeyword(const uint8_t* aString, uint32_t aLength) |
2683 | 0 | { |
2684 | 0 | nsDependentCSubstring keyword(reinterpret_cast<const char*>(aString), aLength); |
2685 | 0 | return nsCSSKeywords::LookupKeyword(keyword); |
2686 | 0 | } |
2687 | | |
2688 | | const char* |
2689 | | Gecko_CSSKeywordString(nsCSSKeyword aKeyword, uint32_t* aLength) |
2690 | 0 | { |
2691 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
2692 | 0 | MOZ_ASSERT(aLength); |
2693 | 0 | const nsCString& value = nsCSSKeywords::GetStringValue(aKeyword); |
2694 | 0 | *aLength = value.Length(); |
2695 | 0 | return value.get(); |
2696 | 0 | } |
2697 | | |
2698 | | void |
2699 | | Gecko_AddPropertyToSet(nsCSSPropertyIDSetBorrowedMut aPropertySet, |
2700 | | nsCSSPropertyID aProperty) |
2701 | 0 | { |
2702 | 0 | aPropertySet->AddProperty(aProperty); |
2703 | 0 | } |
2704 | | |
2705 | | NS_IMPL_THREADSAFE_FFI_REFCOUNTING(nsCSSValueSharedList, CSSValueSharedList); |
2706 | | |
2707 | | #define STYLE_STRUCT(name) \ |
2708 | | \ |
2709 | | void \ |
2710 | | Gecko_Construct_Default_nsStyle##name(nsStyle##name* ptr, \ |
2711 | 0 | const nsPresContext* pres_context) \ |
2712 | 0 | { \ |
2713 | 0 | new (ptr) nsStyle##name(pres_context); \ |
2714 | 0 | } \ Unexecuted instantiation: Gecko_Construct_Default_nsStyleFont Unexecuted instantiation: Gecko_Construct_Default_nsStyleColor Unexecuted instantiation: Gecko_Construct_Default_nsStyleList Unexecuted instantiation: Gecko_Construct_Default_nsStyleText Unexecuted instantiation: Gecko_Construct_Default_nsStyleVisibility Unexecuted instantiation: Gecko_Construct_Default_nsStyleUI Unexecuted instantiation: Gecko_Construct_Default_nsStyleTableBorder Unexecuted instantiation: Gecko_Construct_Default_nsStyleSVG Unexecuted instantiation: Gecko_Construct_Default_nsStyleBackground Unexecuted instantiation: Gecko_Construct_Default_nsStylePosition Unexecuted instantiation: Gecko_Construct_Default_nsStyleTextReset Unexecuted instantiation: Gecko_Construct_Default_nsStyleDisplay Unexecuted instantiation: Gecko_Construct_Default_nsStyleContent Unexecuted instantiation: Gecko_Construct_Default_nsStyleUIReset Unexecuted instantiation: Gecko_Construct_Default_nsStyleTable Unexecuted instantiation: Gecko_Construct_Default_nsStyleMargin Unexecuted instantiation: Gecko_Construct_Default_nsStylePadding Unexecuted instantiation: Gecko_Construct_Default_nsStyleBorder Unexecuted instantiation: Gecko_Construct_Default_nsStyleOutline Unexecuted instantiation: Gecko_Construct_Default_nsStyleXUL Unexecuted instantiation: Gecko_Construct_Default_nsStyleSVGReset Unexecuted instantiation: Gecko_Construct_Default_nsStyleColumn Unexecuted instantiation: Gecko_Construct_Default_nsStyleEffects |
2715 | | \ |
2716 | | void \ |
2717 | | Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr, \ |
2718 | 0 | const nsStyle##name* other) \ |
2719 | 0 | { \ |
2720 | 0 | new (ptr) nsStyle##name(*other); \ |
2721 | 0 | } \ Unexecuted instantiation: Gecko_CopyConstruct_nsStyleFont Unexecuted instantiation: Gecko_CopyConstruct_nsStyleColor Unexecuted instantiation: Gecko_CopyConstruct_nsStyleList Unexecuted instantiation: Gecko_CopyConstruct_nsStyleText Unexecuted instantiation: Gecko_CopyConstruct_nsStyleVisibility Unexecuted instantiation: Gecko_CopyConstruct_nsStyleUI Unexecuted instantiation: Gecko_CopyConstruct_nsStyleTableBorder Unexecuted instantiation: Gecko_CopyConstruct_nsStyleSVG Unexecuted instantiation: Gecko_CopyConstruct_nsStyleBackground Unexecuted instantiation: Gecko_CopyConstruct_nsStylePosition Unexecuted instantiation: Gecko_CopyConstruct_nsStyleTextReset Unexecuted instantiation: Gecko_CopyConstruct_nsStyleDisplay Unexecuted instantiation: Gecko_CopyConstruct_nsStyleContent Unexecuted instantiation: Gecko_CopyConstruct_nsStyleUIReset Unexecuted instantiation: Gecko_CopyConstruct_nsStyleTable Unexecuted instantiation: Gecko_CopyConstruct_nsStyleMargin Unexecuted instantiation: Gecko_CopyConstruct_nsStylePadding Unexecuted instantiation: Gecko_CopyConstruct_nsStyleBorder Unexecuted instantiation: Gecko_CopyConstruct_nsStyleOutline Unexecuted instantiation: Gecko_CopyConstruct_nsStyleXUL Unexecuted instantiation: Gecko_CopyConstruct_nsStyleSVGReset Unexecuted instantiation: Gecko_CopyConstruct_nsStyleColumn Unexecuted instantiation: Gecko_CopyConstruct_nsStyleEffects |
2722 | | \ |
2723 | | void \ |
2724 | 0 | Gecko_Destroy_nsStyle##name(nsStyle##name* ptr) \ |
2725 | 0 | { \ |
2726 | 0 | ptr->~nsStyle##name(); \ |
2727 | 0 | } Unexecuted instantiation: Gecko_Destroy_nsStyleFont Unexecuted instantiation: Gecko_Destroy_nsStyleColor Unexecuted instantiation: Gecko_Destroy_nsStyleList Unexecuted instantiation: Gecko_Destroy_nsStyleText Unexecuted instantiation: Gecko_Destroy_nsStyleVisibility Unexecuted instantiation: Gecko_Destroy_nsStyleUI Unexecuted instantiation: Gecko_Destroy_nsStyleTableBorder Unexecuted instantiation: Gecko_Destroy_nsStyleSVG Unexecuted instantiation: Gecko_Destroy_nsStyleBackground Unexecuted instantiation: Gecko_Destroy_nsStylePosition Unexecuted instantiation: Gecko_Destroy_nsStyleTextReset Unexecuted instantiation: Gecko_Destroy_nsStyleDisplay Unexecuted instantiation: Gecko_Destroy_nsStyleContent Unexecuted instantiation: Gecko_Destroy_nsStyleUIReset Unexecuted instantiation: Gecko_Destroy_nsStyleTable Unexecuted instantiation: Gecko_Destroy_nsStyleMargin Unexecuted instantiation: Gecko_Destroy_nsStylePadding Unexecuted instantiation: Gecko_Destroy_nsStyleBorder Unexecuted instantiation: Gecko_Destroy_nsStyleOutline Unexecuted instantiation: Gecko_Destroy_nsStyleXUL Unexecuted instantiation: Gecko_Destroy_nsStyleSVGReset Unexecuted instantiation: Gecko_Destroy_nsStyleColumn Unexecuted instantiation: Gecko_Destroy_nsStyleEffects |
2728 | | |
2729 | | void |
2730 | | Gecko_RegisterProfilerThread(const char* name) |
2731 | 0 | { |
2732 | 0 | PROFILER_REGISTER_THREAD(name); |
2733 | 0 | } |
2734 | | |
2735 | | void |
2736 | | Gecko_UnregisterProfilerThread() |
2737 | 0 | { |
2738 | 0 | PROFILER_UNREGISTER_THREAD(); |
2739 | 0 | } |
2740 | | |
2741 | | bool |
2742 | | Gecko_DocumentRule_UseForPresentation(RawGeckoPresContextBorrowed aPresContext, |
2743 | | const nsACString* aPattern, |
2744 | | css::DocumentMatchingFunction aMatchingFunction) |
2745 | 0 | { |
2746 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
2747 | 0 |
|
2748 | 0 | nsIDocument *doc = aPresContext->Document(); |
2749 | 0 | nsIURI *docURI = doc->GetDocumentURI(); |
2750 | 0 | nsAutoCString docURISpec; |
2751 | 0 | if (docURI) { |
2752 | 0 | // If GetSpec fails (due to OOM) just skip these URI-specific CSS rules. |
2753 | 0 | nsresult rv = docURI->GetSpec(docURISpec); |
2754 | 0 | NS_ENSURE_SUCCESS(rv, false); |
2755 | 0 | } |
2756 | 0 |
|
2757 | 0 | return CSSMozDocumentRule::Match(doc, docURI, docURISpec, *aPattern, |
2758 | 0 | aMatchingFunction); |
2759 | 0 | } |
2760 | | |
2761 | | void |
2762 | | Gecko_SetJemallocThreadLocalArena(bool enabled) |
2763 | 0 | { |
2764 | | #if defined(MOZ_MEMORY) |
2765 | | jemalloc_thread_local_arena(enabled); |
2766 | | #endif |
2767 | | } |
2768 | | |
2769 | | #include "nsStyleStructList.h" |
2770 | | |
2771 | | #undef STYLE_STRUCT |
2772 | | |
2773 | | bool |
2774 | | Gecko_ErrorReportingEnabled(const StyleSheet* aSheet, const Loader* aLoader) |
2775 | 0 | { |
2776 | 0 | return ErrorReporter::ShouldReportErrors(aSheet, aLoader); |
2777 | 0 | } |
2778 | | |
2779 | | void |
2780 | | Gecko_ReportUnexpectedCSSError(const StyleSheet* aSheet, |
2781 | | const Loader* aLoader, |
2782 | | nsIURI* aURI, |
2783 | | const char* message, |
2784 | | const char* param, |
2785 | | uint32_t paramLen, |
2786 | | const char* prefix, |
2787 | | const char* prefixParam, |
2788 | | uint32_t prefixParamLen, |
2789 | | const char* suffix, |
2790 | | const char* source, |
2791 | | uint32_t sourceLen, |
2792 | | uint32_t lineNumber, |
2793 | | uint32_t colNumber) |
2794 | 0 | { |
2795 | 0 | MOZ_RELEASE_ASSERT(NS_IsMainThread()); |
2796 | 0 |
|
2797 | 0 | ErrorReporter reporter(aSheet, aLoader, aURI); |
2798 | 0 |
|
2799 | 0 | if (prefix) { |
2800 | 0 | if (prefixParam) { |
2801 | 0 | nsDependentCSubstring paramValue(prefixParam, prefixParamLen); |
2802 | 0 | nsAutoString wideParam = NS_ConvertUTF8toUTF16(paramValue); |
2803 | 0 | reporter.ReportUnexpectedUnescaped(prefix, wideParam); |
2804 | 0 | } else { |
2805 | 0 | reporter.ReportUnexpected(prefix); |
2806 | 0 | } |
2807 | 0 | } |
2808 | 0 |
|
2809 | 0 | if (param) { |
2810 | 0 | nsDependentCSubstring paramValue(param, paramLen); |
2811 | 0 | nsAutoString wideParam = NS_ConvertUTF8toUTF16(paramValue); |
2812 | 0 | reporter.ReportUnexpectedUnescaped(message, wideParam); |
2813 | 0 | } else { |
2814 | 0 | reporter.ReportUnexpected(message); |
2815 | 0 | } |
2816 | 0 |
|
2817 | 0 | if (suffix) { |
2818 | 0 | reporter.ReportUnexpected(suffix); |
2819 | 0 | } |
2820 | 0 | nsDependentCSubstring sourceValue(source, sourceLen); |
2821 | 0 | reporter.OutputError(lineNumber, colNumber, sourceValue); |
2822 | 0 | } |
2823 | | |
2824 | | void |
2825 | | Gecko_AddBufferToCrashReport(const void* addr, size_t len) |
2826 | 0 | { |
2827 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
2828 | 0 | nsCOMPtr<nsICrashReporter> cr = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); |
2829 | 0 | NS_ENSURE_TRUE_VOID(cr); |
2830 | 0 | cr->RegisterAppMemory((uint64_t) addr, len); |
2831 | 0 | } |
2832 | | |
2833 | | void |
2834 | | Gecko_AnnotateCrashReport(const char* key_str, const char* value_str) |
2835 | 0 | { |
2836 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
2837 | 0 | nsDependentCString key(key_str); |
2838 | 0 | nsDependentCString value(value_str); |
2839 | 0 | nsCOMPtr<nsICrashReporter> cr = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); |
2840 | 0 | NS_ENSURE_TRUE_VOID(cr); |
2841 | 0 | cr->AnnotateCrashReport(key, value); |
2842 | 0 | } |
2843 | | |
2844 | | void |
2845 | | Gecko_ContentList_AppendAll( |
2846 | | nsSimpleContentList* aList, |
2847 | | const Element** aElements, |
2848 | | size_t aLength) |
2849 | 0 | { |
2850 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
2851 | 0 | MOZ_ASSERT(aElements); |
2852 | 0 | MOZ_ASSERT(aLength); |
2853 | 0 | MOZ_ASSERT(aList); |
2854 | 0 |
|
2855 | 0 | aList->SetCapacity(aLength); |
2856 | 0 |
|
2857 | 0 | for (size_t i = 0; i < aLength; ++i) { |
2858 | 0 | aList->AppendElement(const_cast<Element*>(aElements[i])); |
2859 | 0 | } |
2860 | 0 | } |
2861 | | |
2862 | | const nsTArray<Element*>* |
2863 | | Gecko_Document_GetElementsWithId(const nsIDocument* aDoc, nsAtom* aId) |
2864 | 0 | { |
2865 | 0 | MOZ_ASSERT(aDoc); |
2866 | 0 | MOZ_ASSERT(aId); |
2867 | 0 |
|
2868 | 0 | return aDoc->GetAllElementsForId(nsDependentAtomString(aId)); |
2869 | 0 | } |
2870 | | |
2871 | | const nsTArray<Element*>* |
2872 | | Gecko_ShadowRoot_GetElementsWithId(const ShadowRoot* aShadowRoot, nsAtom* aId) |
2873 | 0 | { |
2874 | 0 | MOZ_ASSERT(aShadowRoot); |
2875 | 0 | MOZ_ASSERT(aId); |
2876 | 0 |
|
2877 | 0 | return aShadowRoot->GetAllElementsForId(nsDependentAtomString(aId)); |
2878 | 0 | } |
2879 | | |
2880 | | bool |
2881 | | Gecko_GetBoolPrefValue(const char* aPrefName) |
2882 | 0 | { |
2883 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
2884 | 0 | return Preferences::GetBool(aPrefName); |
2885 | 0 | } |
2886 | | |
2887 | | bool |
2888 | | Gecko_IsInServoTraversal() |
2889 | 0 | { |
2890 | 0 | return ServoStyleSet::IsInServoTraversal(); |
2891 | 0 | } |
2892 | | |
2893 | | bool |
2894 | | Gecko_IsMainThread() |
2895 | 0 | { |
2896 | 0 | return NS_IsMainThread(); |
2897 | 0 | } |
2898 | | |
2899 | | const nsAttrValue* |
2900 | | Gecko_GetSVGAnimatedClass(RawGeckoElementBorrowed aElement) |
2901 | 0 | { |
2902 | 0 | MOZ_ASSERT(aElement->IsSVGElement()); |
2903 | 0 | return static_cast<const nsSVGElement*>(aElement)->GetAnimatedClassName(); |
2904 | 0 | } |
2905 | | |
2906 | | bool |
2907 | | Gecko_AssertClassAttrValueIsSane(const nsAttrValue* aValue) |
2908 | 0 | { |
2909 | 0 | MOZ_ASSERT(aValue->Type() == nsAttrValue::eAtom || |
2910 | 0 | aValue->Type() == nsAttrValue::eString || |
2911 | 0 | aValue->Type() == nsAttrValue::eAtomArray); |
2912 | 0 | MOZ_ASSERT_IF(aValue->Type() == nsAttrValue::eString, |
2913 | 0 | nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespace>( |
2914 | 0 | aValue->GetStringValue()).IsEmpty()); |
2915 | 0 | return true; |
2916 | 0 | } |