Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #include "mozilla/ServoDeclarationBlock.h"
7 :
8 : #include "mozilla/ServoBindings.h"
9 :
10 : #include "nsCSSProps.h"
11 :
12 : namespace mozilla {
13 :
14 : /* static */ already_AddRefed<ServoDeclarationBlock>
15 0 : ServoDeclarationBlock::FromCssText(const nsAString& aCssText,
16 : URLExtraData* aExtraData,
17 : nsCompatibility aMode,
18 : css::Loader* aLoader)
19 : {
20 0 : NS_ConvertUTF16toUTF8 value(aCssText);
21 : // FIXME (bug 1343964): Figure out a better solution for sending the base uri to servo
22 : RefPtr<RawServoDeclarationBlock>
23 0 : raw = Servo_ParseStyleAttribute(&value, aExtraData, aMode, aLoader).Consume();
24 0 : RefPtr<ServoDeclarationBlock> decl = new ServoDeclarationBlock(raw.forget());
25 0 : return decl.forget();
26 : }
27 :
28 : void
29 0 : ServoDeclarationBlock::GetPropertyValue(const nsAString& aProperty,
30 : nsAString& aValue) const
31 : {
32 0 : NS_ConvertUTF16toUTF8 property(aProperty);
33 0 : Servo_DeclarationBlock_GetPropertyValue(mRaw, &property, &aValue);
34 0 : }
35 :
36 : void
37 0 : ServoDeclarationBlock::GetPropertyValueByID(nsCSSPropertyID aPropID,
38 : nsAString& aValue) const
39 : {
40 0 : Servo_DeclarationBlock_GetPropertyValueById(mRaw, aPropID, &aValue);
41 0 : }
42 :
43 : bool
44 0 : ServoDeclarationBlock::GetPropertyIsImportant(const nsAString& aProperty) const
45 : {
46 0 : NS_ConvertUTF16toUTF8 property(aProperty);
47 0 : return Servo_DeclarationBlock_GetPropertyIsImportant(mRaw, &property);
48 : }
49 :
50 : void
51 0 : ServoDeclarationBlock::RemoveProperty(const nsAString& aProperty)
52 : {
53 0 : AssertMutable();
54 0 : NS_ConvertUTF16toUTF8 property(aProperty);
55 0 : Servo_DeclarationBlock_RemoveProperty(mRaw, &property);
56 0 : }
57 :
58 : void
59 0 : ServoDeclarationBlock::RemovePropertyByID(nsCSSPropertyID aPropID)
60 : {
61 0 : AssertMutable();
62 0 : Servo_DeclarationBlock_RemovePropertyById(mRaw, aPropID);
63 0 : }
64 :
65 : } // namespace mozilla
|