-
Notifications
You must be signed in to change notification settings - Fork 0
/
0008-1-output-warning.patch
163 lines (145 loc) · 7.25 KB
/
0008-1-output-warning.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# HG changeset patch
# User Kerem Kat <[email protected]>
# Date 1504449317 -10800
# Sun Sep 03 17:35:17 2017 +0300
# Node ID ffff5adaa4ddf09b69e612f9375026aee0bfd63a
# Parent 2d7b8b5dd174bd9db5894c6cb770e05f83e95ee3
Bug 37468 - Add parameter to nsCSSParser::ParseSelectorString to control whether to output console error message.
diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -2742,17 +2742,18 @@ nsINode::ParseSelectorList(const nsAStri
}
nsCSSParser parser(doc->CSSLoader());
nsCSSSelectorList* selectorList = nullptr;
aRv = parser.ParseSelectorString(aSelectorString,
doc->GetDocumentURI(),
0, // XXXbz get the line number!
- &selectorList);
+ &selectorList,
+ false);
if (aRv.Failed()) {
// We hit this for syntax errors, which are quite common, so don't
// use NS_ENSURE_SUCCESS. (For example, jQuery has an extended set
// of selectors, but it sees if we can parse them first.)
MOZ_ASSERT(aRv.ErrorCodeIs(NS_ERROR_DOM_SYNTAX_ERR),
"Unexpected error, so cached version won't return it");
// Change the error message to match above.
diff --git a/dom/html/HTMLContentElement.cpp b/dom/html/HTMLContentElement.cpp
--- a/dom/html/HTMLContentElement.cpp
+++ b/dom/html/HTMLContentElement.cpp
@@ -222,17 +222,18 @@ HTMLContentElement::AfterSetAttr(int32_t
mSelectorList = nullptr;
nsAutoString valueStr;
aValue->ToString(valueStr);
nsresult rv = parser.ParseSelectorString(valueStr,
doc->GetDocumentURI(),
// Bug 11240
0, // XXX get the line number!
- getter_Transfers(mSelectorList));
+ getter_Transfers(mSelectorList),
+ false);
// We don't want to return an exception if parsing failed because
// the spec does not define it as an exception case.
if (NS_SUCCEEDED(rv)) {
// Ensure that all the selectors are valid
nsCSSSelectorList* selectors = mSelectorList;
while (selectors) {
if (!IsValidContentSelectors(selectors->mSelectors)) {
diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -231,17 +231,18 @@ public:
nsIURI* aURL, // for error reporting
uint32_t aLineNumber, // for error reporting
nsCSSValue& aValue,
bool aSuppressErrors /* false */);
nsresult ParseSelectorString(const nsAString& aSelectorString,
nsIURI* aURL, // for error reporting
uint32_t aLineNumber, // for error reporting
- nsCSSSelectorList **aSelectorList);
+ nsCSSSelectorList **aSelectorList,
+ bool aDoOutputError);
already_AddRefed<nsCSSKeyframeRule>
ParseKeyframeRule(const nsAString& aBuffer,
nsIURI* aURL,
uint32_t aLineNumber);
bool ParseKeyframeSelectorString(const nsAString& aSelectorString,
nsIURI* aURL, // for error reporting
@@ -2174,33 +2175,35 @@ CSSParserImpl::ParseFontFamilyListString
ReleaseScanner();
return familyParsed;
}
nsresult
CSSParserImpl::ParseSelectorString(const nsAString& aSelectorString,
nsIURI* aURI, // for error reporting
uint32_t aLineNumber, // for error reporting
- nsCSSSelectorList **aSelectorList)
+ nsCSSSelectorList **aSelectorList,
+ bool aDoOutputError)
{
nsCSSScanner scanner(aSelectorString, aLineNumber);
css::ErrorReporter reporter(scanner, mSheet, mChildLoader, aURI);
InitScanner(scanner, reporter, aURI, aURI, nullptr);
bool success = ParseSelectorList(*aSelectorList, char16_t(0));
- // We deliberately do not call OUTPUT_ERROR here, because all our
+ // Except for StyleRule::setSelectorText method, which sets aDoOutputError,
+ // we deliberately do not call OUTPUT_ERROR here, because all our
// callers map a failure return to a JS exception, and if that JS
// exception is caught, people don't want to see parser diagnostics;
// see e.g. http://bugs.jquery.com/ticket/7535
// It would be nice to be able to save the parser diagnostics into
// the exception, so that if it _isn't_ caught we can report them
// along with the usual uncaught-exception message, but we don't
// have any way to do that at present; see bug 631621.
- CLEAR_ERROR();
+ aDoOutputError ? OUTPUT_ERROR() : CLEAR_ERROR();
ReleaseScanner();
if (success) {
NS_ASSERTION(*aSelectorList, "Should have list!");
return NS_OK;
}
NS_ASSERTION(!*aSelectorList, "Shouldn't have list!");
@@ -18052,20 +18055,21 @@ nsCSSParser::ParseMarginString(const nsA
return static_cast<CSSParserImpl*>(mImpl)->
ParseMarginString(aBuffer, aURI, aLineNumber, aValue, aSuppressErrors);
}
nsresult
nsCSSParser::ParseSelectorString(const nsAString& aSelectorString,
nsIURI* aURI,
uint32_t aLineNumber,
- nsCSSSelectorList** aSelectorList)
+ nsCSSSelectorList** aSelectorList,
+ bool aDoOutputError)
{
return static_cast<CSSParserImpl*>(mImpl)->
- ParseSelectorString(aSelectorString, aURI, aLineNumber, aSelectorList);
+ ParseSelectorString(aSelectorString, aURI, aLineNumber, aSelectorList, aDoOutputError);
}
already_AddRefed<nsCSSKeyframeRule>
nsCSSParser::ParseKeyframeRule(const nsAString& aBuffer,
nsIURI* aURI,
uint32_t aLineNumber)
{
return static_cast<CSSParserImpl*>(mImpl)->
diff --git a/layout/style/nsCSSParser.h b/layout/style/nsCSSParser.h
--- a/layout/style/nsCSSParser.h
+++ b/layout/style/nsCSSParser.h
@@ -219,17 +219,18 @@ public:
/**
* Parse aBuffer into a selector list. On success, caller must
* delete *aSelectorList when done with it.
*/
nsresult ParseSelectorString(const nsAString& aSelectorString,
nsIURI* aURL,
uint32_t aLineNumber,
- nsCSSSelectorList** aSelectorList);
+ nsCSSSelectorList** aSelectorList,
+ bool aDoOutputError);
/*
* Parse a keyframe rule (which goes inside an @keyframes rule).
* Return it if the parse was successful.
*/
already_AddRefed<nsCSSKeyframeRule>
ParseKeyframeRule(const nsAString& aBuffer,
nsIURI* aURL,