Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/style/ServoCSSParser.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
/* CSS parsing utility functions */
8
9
#include "ServoCSSParser.h"
10
11
#include "mozilla/ServoBindings.h"
12
#include "mozilla/ServoStyleSet.h"
13
#include "nsIDocument.h"
14
15
using namespace mozilla;
16
17
/* static */ bool
18
ServoCSSParser::IsValidCSSColor(const nsAString& aValue)
19
0
{
20
0
  return Servo_IsValidCSSColor(&aValue);
21
0
}
22
23
/* static */ bool
24
ServoCSSParser::ComputeColor(ServoStyleSet* aStyleSet,
25
                             nscolor aCurrentColor,
26
                             const nsAString& aValue,
27
                             nscolor* aResultColor,
28
                             bool* aWasCurrentColor,
29
                             css::Loader* aLoader)
30
0
{
31
0
  return Servo_ComputeColor(aStyleSet ? aStyleSet->RawSet() : nullptr,
32
0
                            aCurrentColor, &aValue, aResultColor,
33
0
                            aWasCurrentColor, aLoader);
34
0
}
35
36
/* static */ already_AddRefed<RawServoDeclarationBlock>
37
ServoCSSParser::ParseProperty(nsCSSPropertyID aProperty,
38
                              const nsAString& aValue,
39
                              const ParsingEnvironment& aParsingEnvironment,
40
                              ParsingMode aParsingMode)
41
0
{
42
0
  NS_ConvertUTF16toUTF8 value(aValue);
43
0
  return Servo_ParseProperty(aProperty,
44
0
                             &value,
45
0
                             aParsingEnvironment.mUrlExtraData,
46
0
                             aParsingMode,
47
0
                             aParsingEnvironment.mCompatMode,
48
0
                             aParsingEnvironment.mLoader).Consume();
49
0
}
50
51
/* static */ bool
52
ServoCSSParser::ParseEasing(const nsAString& aValue,
53
                            URLExtraData* aUrl,
54
                            nsTimingFunction& aResult)
55
0
{
56
0
  return Servo_ParseEasing(&aValue, aUrl, &aResult);
57
0
}
58
59
/* static */ bool
60
ServoCSSParser::ParseTransformIntoMatrix(const nsAString& aValue,
61
                                         bool& aContains3DTransform,
62
                                         RawGeckoGfxMatrix4x4& aResult)
63
0
{
64
0
  return Servo_ParseTransformIntoMatrix(&aValue,
65
0
                                        &aContains3DTransform,
66
0
                                        &aResult);
67
0
}
68
69
/* static */ bool
70
ServoCSSParser::ParseFontShorthandForMatching(const nsAString& aValue,
71
                                              URLExtraData* aUrl,
72
                                              RefPtr<SharedFontList>& aList,
73
                                              nsCSSValue& aStyle,
74
                                              nsCSSValue& aStretch,
75
                                              nsCSSValue& aWeight)
76
0
{
77
0
  return Servo_ParseFontShorthandForMatching(&aValue, aUrl, &aList,
78
0
                                             &aStyle, &aStretch, &aWeight);
79
0
}
80
81
/* static */ already_AddRefed<URLExtraData>
82
ServoCSSParser::GetURLExtraData(nsIDocument* aDocument)
83
0
{
84
0
  MOZ_ASSERT(aDocument);
85
0
86
0
  // FIXME this is using the wrong base uri (bug 1343919)
87
0
  RefPtr<URLExtraData> url = new URLExtraData(aDocument->GetDocumentURI(),
88
0
                                              aDocument->GetDocumentURI(),
89
0
                                              aDocument->NodePrincipal(),
90
0
                                              aDocument->GetReferrerPolicy());
91
0
  return url.forget();
92
0
}
93
94
/* static */ ServoCSSParser::ParsingEnvironment
95
ServoCSSParser::GetParsingEnvironment(nsIDocument* aDocument)
96
0
{
97
0
  return ParsingEnvironment(GetURLExtraData(aDocument),
98
0
                            aDocument->GetCompatibilityMode(),
99
0
                            aDocument->CSSLoader());
100
0
}