tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

MappedDeclarationsBuilder.cpp (1477B)


      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 "MappedDeclarationsBuilder.h"
      8 
      9 #include "mozilla/dom/Document.h"
     10 #include "nsAttrValue.h"
     11 #include "nsAttrValueInlines.h"
     12 #include "nsPresContext.h"
     13 
     14 namespace mozilla {
     15 
     16 void MappedDeclarationsBuilder::SetIdentAtomValue(NonCustomCSSPropertyId 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.
     22    //
     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);
     27  }
     28 }
     29 
     30 void MappedDeclarationsBuilder::SetBackgroundImage(const nsAttrValue& aValue) {
     31  if (aValue.Type() != nsAttrValue::eURL) {
     32    return;
     33  }
     34  nsAutoString str;
     35  aValue.ToString(str);
     36  nsAutoCString utf8;
     37  CopyUTF16toUTF8(str, utf8);
     38  Servo_DeclarationBlock_SetBackgroundImage(
     39      &EnsureDecls(), &utf8, mDocument.DefaultStyleAttrURLData());
     40 }
     41 
     42 }  // namespace mozilla