|
2 | 2 | * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
|
3 | 3 | * (C) 1999 Antti Koivisto (koivisto@kde.org)
|
4 | 4 | * (C) 2001 Dirk Mueller (mueller@kde.org)
|
5 |
| - * Copyright (C) 2003, 2010 Apple Inc. All rights reserved. |
| 5 | + * Copyright (C) 2003-2023 Apple Inc. All rights reserved. |
| 6 | + * Copyright (C) 2013 Google Inc. All rights reserved. |
6 | 7 | *
|
7 | 8 | * This library is free software; you can redistribute it and/or
|
8 | 9 | * modify it under the terms of the GNU Library General Public
|
@@ -160,32 +161,41 @@ void HTMLMetaElement::process()
|
160 | 161 | if (!isInDocumentTree())
|
161 | 162 | return;
|
162 | 163 |
|
| 164 | + // https://html.spec.whatwg.org/multipage/semantics.html#the-meta-element |
| 165 | + // All below situations require a content attribute (which can be the empty string). |
163 | 166 | const AtomString& contentValue = attributeWithoutSynchronization(contentAttr);
|
164 | 167 | if (contentValue.isNull())
|
165 | 168 | return;
|
| 169 | + |
| 170 | + const AtomString& httpEquivValue = attributeWithoutSynchronization(http_equivAttr); |
| 171 | + // Get the document to process the tag, but only if we're actually part of DOM |
| 172 | + // tree (changing a meta tag while it's not in the tree shouldn't have any effect |
| 173 | + // on the document) |
| 174 | + if (!httpEquivValue.isNull()) |
| 175 | + document().processMetaHttpEquiv(httpEquivValue, contentValue, isDescendantOf(document().head())); |
| 176 | + |
| 177 | + const AtomString& nameValue = attributeWithoutSynchronization(nameAttr); |
| 178 | + if (nameValue.isNull()) |
| 179 | + return; |
166 | 180 |
|
167 |
| - if (equalLettersIgnoringASCIICase(name(), "viewport"_s)) |
| 181 | + if (equalLettersIgnoringASCIICase(nameValue, "viewport"_s)) |
168 | 182 | document().processViewport(contentValue, ViewportArguments::ViewportMeta);
|
169 |
| - else if (document().settings().disabledAdaptationsMetaTagEnabled() && equalLettersIgnoringASCIICase(name(), "disabled-adaptations"_s)) |
| 183 | + else if (document().settings().disabledAdaptationsMetaTagEnabled() && equalLettersIgnoringASCIICase(nameValue, "disabled-adaptations"_s)) |
170 | 184 | document().processDisabledAdaptations(contentValue);
|
171 | 185 | #if ENABLE(DARK_MODE_CSS)
|
172 |
| - else if (equalLettersIgnoringASCIICase(name(), "color-scheme"_s) || equalLettersIgnoringASCIICase(name(), "supported-color-schemes"_s)) |
| 186 | + else if (equalLettersIgnoringASCIICase(nameValue, "color-scheme"_s) || equalLettersIgnoringASCIICase(nameValue, "supported-color-schemes"_s)) |
173 | 187 | document().processColorScheme(contentValue);
|
174 | 188 | #endif
|
175 |
| - else if (equalLettersIgnoringASCIICase(name(), "theme-color"_s)) |
| 189 | + else if (equalLettersIgnoringASCIICase(nameValue, "theme-color"_s)) |
176 | 190 | document().metaElementThemeColorChanged(*this);
|
177 | 191 | #if PLATFORM(IOS_FAMILY)
|
178 |
| - else if (equalLettersIgnoringASCIICase(name(), "format-detection"_s)) |
| 192 | + else if (equalLettersIgnoringASCIICase(nameValue, "format-detection"_s)) |
179 | 193 | document().processFormatDetection(contentValue);
|
180 |
| - else if (equalLettersIgnoringASCIICase(name(), "apple-mobile-web-app-orientations"_s)) |
| 194 | + else if (equalLettersIgnoringASCIICase(nameValue, "apple-mobile-web-app-orientations"_s)) |
181 | 195 | document().processWebAppOrientations();
|
182 | 196 | #endif
|
183 |
| - else if (equalLettersIgnoringASCIICase(name(), "referrer"_s)) |
| 197 | + else if (equalLettersIgnoringASCIICase(nameValue, "referrer"_s)) |
184 | 198 | document().processReferrerPolicy(contentValue, ReferrerPolicySource::MetaTag);
|
185 |
| - |
186 |
| - const AtomString& httpEquivValue = attributeWithoutSynchronization(http_equivAttr); |
187 |
| - if (!httpEquivValue.isNull()) |
188 |
| - document().processMetaHttpEquiv(httpEquivValue, contentValue, isDescendantOf(document().head())); |
189 | 199 | }
|
190 | 200 |
|
191 | 201 | const AtomString& HTMLMetaElement::content() const
|
|
0 commit comments