mirror of
https://github.com/mozilla-firefox/firefox
synced 2026-08-10 11:48:50 +00:00
StaticPresData now has an internal lock. Simplify some of the code. Differential Revision: https://phabricator.services.mozilla.com/D296948
41 lines
1.4 KiB
C++
41 lines
1.4 KiB
C++
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "MappedDeclarationsBuilder.h"
|
|
|
|
#include "mozilla/dom/Document.h"
|
|
#include "nsAttrValue.h"
|
|
#include "nsAttrValueInlines.h"
|
|
#include "nsPresContext.h"
|
|
|
|
namespace mozilla {
|
|
|
|
void MappedDeclarationsBuilder::SetIdentAtomValue(NonCustomCSSPropertyId aId,
|
|
nsAtom* aValue) {
|
|
Servo_DeclarationBlock_SetIdentStringValue(&EnsureDecls(), aId, aValue);
|
|
}
|
|
|
|
void MappedDeclarationsBuilder::SetBackgroundImage(const nsAttrValue& aValue) {
|
|
if (aValue.Type() != nsAttrValue::eURL) {
|
|
return;
|
|
}
|
|
// Use the already-resolved absolute URI spec rather than the raw attribute
|
|
// string. The URI was resolved with the document's character encoding during
|
|
// attribute parsing (via nsContentUtils::NewURIWithDocumentCharset), so using
|
|
// its spec preserves the correct query encoding. If we used the raw string,
|
|
// it would be re-resolved in StyleCssUrl::GetURI() assuming UTF-8.
|
|
nsAutoCString utf8;
|
|
if (nsIURI* uri = aValue.GetURLValue()) {
|
|
uri->GetSpec(utf8);
|
|
} else {
|
|
nsAutoString str;
|
|
aValue.ToString(str);
|
|
CopyUTF16toUTF8(str, utf8);
|
|
}
|
|
Servo_DeclarationBlock_SetBackgroundImage(
|
|
&EnsureDecls(), &utf8, mDocument.DefaultStyleAttrURLData());
|
|
}
|
|
|
|
} // namespace mozilla
|