-
Notifications
You must be signed in to change notification settings - Fork 894
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modify HTMLHtmlElement to reject async-hide when set by JS fixes brav…
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
patches/third_party-blink-renderer-core-html-html_html_element.cc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
diff --git a/third_party/blink/renderer/core/html/html_html_element.cc b/third_party/blink/renderer/core/html/html_html_element.cc | ||
index 7cc4857d439f055e3e3ed24d0f8ebd29a9a93fb9..082be842010cf84110d5b310490110f5b212a237 100644 | ||
--- a/third_party/blink/renderer/core/html/html_html_element.cc | ||
+++ b/third_party/blink/renderer/core/html/html_html_element.cc | ||
@@ -64,6 +64,36 @@ void HTMLHtmlElement::InsertedByParser() { | ||
} | ||
} | ||
|
||
+void HTMLHtmlElement::AttributeChanged(const AttributeModificationParams& params) { | ||
+ // Check to see if the following conditions are true, to work around | ||
+ // the google tag manager (and related) block-the-screen stuff. | ||
+ // 1) The element being modified is the <html> element | ||
+ // 2) The change is not made by the parser | ||
+ // 3) The class being added includes "async-hide" | ||
+ // https://github.com/brave/brave-browser/issues/4402 | ||
+ #if defined(BRAVE_CHROMIUM_BUILD) | ||
+ const StringView async_hide_class_token = StringView("async-hide"); | ||
+ const bool should_strip_async_hide_class = ( | ||
+ params.name == kClassAttr && | ||
+ params.reason == AttributeModificationReason::kDirectly && | ||
+ params.new_value.Find(async_hide_class_token) != kNotFound); | ||
+ | ||
+ if (!should_strip_async_hide_class) { | ||
+ HTMLElement::AttributeChanged(params); | ||
+ return; | ||
+ } | ||
+ | ||
+ String prev_attr_value = params.new_value.GetString(); | ||
+ AtomicString new_value = AtomicString(prev_attr_value.Replace( | ||
+ async_hide_class_token, StringView(""))); | ||
+ | ||
+ HTMLElement::AttributeChanged(AttributeModificationParams( | ||
+ params.name, params.old_value, new_value, params.reason)); | ||
+#else | ||
+ HTMLElement::AttributeChanged(params); | ||
+#endif | ||
+} | ||
+ | ||
void HTMLHtmlElement::MaybeSetupApplicationCache() { | ||
if (!GetDocument().GetFrame()) | ||
return; |
13 changes: 13 additions & 0 deletions
13
patches/third_party-blink-renderer-core-html-html_html_element.h.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/third_party/blink/renderer/core/html/html_html_element.h b/third_party/blink/renderer/core/html/html_html_element.h | ||
index 1ba669ce9ea95c8623d10c3f9e52237d61bd1e7a..bb7bbf5ad04e63a15e35b657e71a17554c972cf5 100644 | ||
--- a/third_party/blink/renderer/core/html/html_html_element.h | ||
+++ b/third_party/blink/renderer/core/html/html_html_element.h | ||
@@ -41,6 +41,8 @@ class CORE_EXPORT HTMLHtmlElement final : public HTMLElement { | ||
|
||
bool HasNonInBodyInsertionMode() const override { return true; } | ||
|
||
+ void AttributeChanged(const AttributeModificationParams&) override; | ||
+ | ||
private: | ||
void MaybeSetupApplicationCache(); | ||
|