Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / layout / style / MappedDeclarationsBuilder.cpp
blobbfb1eedff1e64a9f98938416afd0f21ee2887ece
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/. */
7 #include "MappedDeclarationsBuilder.h"
9 #include "nsAttrValue.h"
10 #include "nsAttrValueInlines.h"
11 #include "mozilla/dom/Document.h"
12 #include "nsPresContext.h"
14 namespace mozilla {
16 void MappedDeclarationsBuilder::SetIdentAtomValue(nsCSSPropertyID aId,
17 nsAtom* aValue) {
18 Servo_DeclarationBlock_SetIdentStringValue(&EnsureDecls(), aId, aValue);
19 if (aId == eCSSProperty__x_lang) {
20 // This forces the lang prefs result to be cached so that we can access them
21 // off main thread during traversal.
23 // FIXME(emilio): Can we move mapped attribute declarations across
24 // documents? Isn't this wrong in that case? This is pretty out of place
25 // anyway.
26 mDocument.ForceCacheLang(aValue);
30 void MappedDeclarationsBuilder::SetBackgroundImage(const nsAttrValue& aValue) {
31 if (aValue.Type() != nsAttrValue::eURL) {
32 return;
34 nsAutoString str;
35 aValue.ToString(str);
36 nsAutoCString utf8;
37 CopyUTF16toUTF8(str, utf8);
38 Servo_DeclarationBlock_SetBackgroundImage(
39 &EnsureDecls(), &utf8, mDocument.DefaultStyleAttrURLData());
42 } // namespace mozilla