summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/html/parser
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/html/parser')
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/OWNERS2
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/background_html_parser.cc7
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/background_html_parser.h3
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_construction_site.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_construction_site.h6
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_document_parser.cc24
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_document_parser.h2
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_document_parser_loading_test.cc53
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_document_parser_test.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_element_stack.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_element_stack.h4
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_formatting_element_list.h4
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_parser_options.cc3
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_parser_options.h7
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_parser_scheduler.cc19
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_parser_scheduler.h3
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_preload_scanner.cc92
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_preload_scanner.h9
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_resource_preloader.cc8
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_resource_preloader.h4
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_stack_item.h2
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_tokenizer_fuzzer.cc8
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_tree_builder.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/html_tree_builder.h4
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/preload_request.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/preload_request.h2
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/text_resource_decoder.cc6
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/text_resource_decoder.h4
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/text_resource_decoder_for_fuzzing.h3
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/xss_auditor.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/xss_auditor_delegate.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/html/parser/xss_auditor_delegate.h2
32 files changed, 166 insertions, 139 deletions
diff --git a/chromium/third_party/blink/renderer/core/html/parser/OWNERS b/chromium/third_party/blink/renderer/core/html/parser/OWNERS
index d9dc40ecfa7..23b641cfa1f 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/OWNERS
+++ b/chromium/third_party/blink/renderer/core/html/parser/OWNERS
@@ -1,5 +1,5 @@
kouhei@chromium.org
-yoav@yoav.ws
+yoavweiss@chromium.org
csharrison@chromium.org
# TEAM: loading-dev@chromium.org
diff --git a/chromium/third_party/blink/renderer/core/html/parser/background_html_parser.cc b/chromium/third_party/blink/renderer/core/html/parser/background_html_parser.cc
index 8818320915a..43a805e7a18 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/background_html_parser.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/background_html_parser.cc
@@ -76,11 +76,12 @@ base::WeakPtr<BackgroundHTMLParser> BackgroundHTMLParser::Create(
void BackgroundHTMLParser::Init(
const KURL& document_url,
std::unique_ptr<CachedDocumentParameters> cached_document_parameters,
- const MediaValuesCached::MediaValuesCachedData& media_values_cached_data) {
+ const MediaValuesCached::MediaValuesCachedData& media_values_cached_data,
+ bool priority_hints_origin_trial_enabled) {
preload_scanner_.reset(new TokenPreloadScanner(
document_url, std::move(cached_document_parameters),
- media_values_cached_data,
- TokenPreloadScanner::ScannerType::kMainDocument));
+ media_values_cached_data, TokenPreloadScanner::ScannerType::kMainDocument,
+ priority_hints_origin_trial_enabled));
}
BackgroundHTMLParser::Configuration::Configuration() {}
diff --git a/chromium/third_party/blink/renderer/core/html/parser/background_html_parser.h b/chromium/third_party/blink/renderer/core/html/parser/background_html_parser.h
index 5579a54bcbf..474f5717c33 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/background_html_parser.h
+++ b/chromium/third_party/blink/renderer/core/html/parser/background_html_parser.h
@@ -68,7 +68,8 @@ class BackgroundHTMLParser {
scoped_refptr<base::SingleThreadTaskRunner>);
void Init(const KURL& document_url,
std::unique_ptr<CachedDocumentParameters>,
- const MediaValuesCached::MediaValuesCachedData&);
+ const MediaValuesCached::MediaValuesCachedData&,
+ bool priority_hints_origin_trial_enabled);
struct Checkpoint {
USING_FAST_MALLOC(Checkpoint);
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_construction_site.cc b/chromium/third_party/blink/renderer/core/html/parser/html_construction_site.cc
index 65faae0350f..d7f729c777b 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_construction_site.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_construction_site.cc
@@ -385,7 +385,7 @@ HTMLConstructionSite::~HTMLConstructionSite() {
DCHECK(pending_text_.IsEmpty());
}
-void HTMLConstructionSite::Trace(blink::Visitor* visitor) {
+void HTMLConstructionSite::Trace(Visitor* visitor) {
visitor->Trace(document_);
visitor->Trace(attachment_root_);
visitor->Trace(head_);
@@ -1106,7 +1106,7 @@ void HTMLConstructionSite::FosterParent(Node* node) {
QueueTask(task);
}
-void HTMLConstructionSite::PendingText::Trace(blink::Visitor* visitor) {
+void HTMLConstructionSite::PendingText::Trace(Visitor* visitor) {
visitor->Trace(parent);
visitor->Trace(next_child);
}
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_construction_site.h b/chromium/third_party/blink/renderer/core/html/parser/html_construction_site.h
index b0d8394321f..05dfa7bced1 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_construction_site.h
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_construction_site.h
@@ -53,7 +53,7 @@ struct HTMLConstructionSiteTask {
explicit HTMLConstructionSiteTask(Operation op)
: operation(op), self_closing(false) {}
- void Trace(blink::Visitor* visitor) {
+ void Trace(Visitor* visitor) {
visitor->Trace(parent);
visitor->Trace(next_child);
visitor->Trace(child);
@@ -111,7 +111,7 @@ class HTMLConstructionSite final {
Document&,
ParserContentPolicy);
~HTMLConstructionSite();
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
void InitFragmentParsing(DocumentFragment*, Element* context_element);
@@ -324,7 +324,7 @@ class HTMLConstructionSite final {
return string_builder.IsEmpty();
}
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
Member<ContainerNode> parent;
Member<Node> next_child;
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_document_parser.cc b/chromium/third_party/blink/renderer/core/html/parser/html_document_parser.cc
index 6624165f061..10d1a09ba55 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_document_parser.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_document_parser.cc
@@ -47,8 +47,9 @@
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/inspector/inspector_trace_events.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
-#include "third_party/blink/renderer/core/loader/link_loader.h"
#include "third_party/blink/renderer/core/loader/navigation_scheduler.h"
+#include "third_party/blink/renderer/core/loader/preload_helper.h"
+#include "third_party/blink/renderer/core/origin_trials/origin_trials.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/script/html_parser_script_runner.h"
#include "third_party/blink/renderer/platform/bindings/runtime_call_stats.h"
@@ -166,7 +167,7 @@ void HTMLDocumentParser::Dispose() {
StopBackgroundParser();
}
-void HTMLDocumentParser::Trace(blink::Visitor* visitor) {
+void HTMLDocumentParser::Trace(Visitor* visitor) {
visitor->Trace(tree_builder_);
visitor->Trace(parser_scheduler_);
visitor->Trace(xss_auditor_delegate_);
@@ -322,7 +323,7 @@ void HTMLDocumentParser::EnqueueTokenizedChunk(
// Note that on commit, the loader dispatched preloads for all the non-media
// links.
GetDocument()->Loader()->DispatchLinkHeaderPreloads(
- &chunk->viewport, LinkLoader::kOnlyLoadMedia);
+ &chunk->viewport, PreloadHelper::kOnlyLoadMedia);
tried_loading_link_headers_ = true;
}
@@ -807,9 +808,18 @@ void HTMLDocumentParser::StartBackgroundParser() {
BackgroundHTMLParser::Create(std::move(config), loading_task_runner_);
// TODO(csharrison): This is a hack to initialize MediaValuesCached on the
// correct thread. We should get rid of it.
+
+ // TODO(domfarolino): Remove this once Priority Hints is no longer in Origin
+ // Trial. This currently exists because the TokenPreloadScanner needs to know
+ // the status of the Priority Hints Origin Trial, and has no way of figuring
+ // this out on its own. See https://crbug.com/821464.
+ bool priority_hints_origin_trial_enabled =
+ origin_trials::PriorityHintsEnabled(GetDocument());
+
background_parser_->Init(
GetDocument()->Url(), CachedDocumentParameters::Create(GetDocument()),
- MediaValuesCached::MediaValuesCachedData(*GetDocument()));
+ MediaValuesCached::MediaValuesCachedData(*GetDocument()),
+ priority_hints_origin_trial_enabled);
}
void HTMLDocumentParser::StopBackgroundParser() {
@@ -1028,10 +1038,16 @@ void HTMLDocumentParser::ResumeParsingAfterPause() {
return;
if (have_background_parser_) {
+ // If we paused in the middle of processing a token chunk,
+ // deal with that before starting to pump.
if (last_chunk_before_pause_) {
ValidateSpeculations(std::move(last_chunk_before_pause_));
DCHECK(!last_chunk_before_pause_);
PumpPendingSpeculations();
+ } else if (!IsScheduledForUnpause()) {
+ // Otherwise, start pumping if we're not already scheduled to unpause
+ // already.
+ PumpPendingSpeculations();
}
return;
}
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_document_parser.h b/chromium/third_party/blink/renderer/core/html/parser/html_document_parser.h
index 4ed141fb82b..6ee149a789c 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_document_parser.h
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_document_parser.h
@@ -84,7 +84,7 @@ class CORE_EXPORT HTMLDocumentParser : public ScriptableDocumentParser,
Element* context_element,
ParserContentPolicy);
~HTMLDocumentParser() override;
- void Trace(blink::Visitor*) override;
+ void Trace(Visitor*) override;
// TODO(alexclarke): Remove when background parser goes away.
void Dispose();
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_document_parser_loading_test.cc b/chromium/third_party/blink/renderer/core/html/parser/html_document_parser_loading_test.cc
index 2c95e30b151..586cfc41cc7 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_document_parser_loading_test.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_document_parser_loading_test.cc
@@ -39,7 +39,8 @@ INSTANTIATE_TEST_CASE_P(NotThreaded,
TEST_P(HTMLDocumentParserLoadingTest,
ShouldNotPauseParsingForExternalStylesheetsInHead) {
SimRequest main_resource("https://example.com/test.html", "text/html");
- SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
+ SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+ "text/css");
LoadURL("https://example.com/test.html");
@@ -62,7 +63,8 @@ TEST_P(HTMLDocumentParserLoadingTest,
TEST_P(HTMLDocumentParserLoadingTest,
ShouldNotPauseParsingForExternalStylesheetsImportedInHead) {
SimRequest main_resource("https://example.com/test.html", "text/html");
- SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
+ SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+ "text/css");
LoadURL("https://example.com/test.html");
@@ -87,8 +89,10 @@ TEST_P(HTMLDocumentParserLoadingTest,
TEST_P(HTMLDocumentParserLoadingTest,
ShouldPauseParsingForExternalStylesheetsInBody) {
SimRequest main_resource("https://example.com/test.html", "text/html");
- SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
- SimRequest css_body_resource("https://example.com/testBody.css", "text/css");
+ SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+ "text/css");
+ SimSubresourceRequest css_body_resource("https://example.com/testBody.css",
+ "text/css");
LoadURL("https://example.com/test.html");
@@ -124,17 +128,17 @@ TEST_P(HTMLDocumentParserLoadingTest,
TEST_P(HTMLDocumentParserLoadingTest,
ShouldPauseParsingForExternalStylesheetsInBodyIncremental) {
SimRequest main_resource("https://example.com/test.html", "text/html");
- SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
- SimRequest css_body_resource1("https://example.com/testBody1.css",
- "text/css");
- SimRequest css_body_resource2("https://example.com/testBody2.css",
- "text/css");
- SimRequest css_body_resource3("https://example.com/testBody3.css",
- "text/css");
+ SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+ "text/css");
+ SimSubresourceRequest css_body_resource1("https://example.com/testBody1.css",
+ "text/css");
+ SimSubresourceRequest css_body_resource2("https://example.com/testBody2.css",
+ "text/css");
+ SimSubresourceRequest css_body_resource3("https://example.com/testBody3.css",
+ "text/css");
LoadURL("https://example.com/test.html");
- main_resource.Start();
main_resource.Write(R"HTML(
<!DOCTYPE html>
<html><head>
@@ -211,7 +215,8 @@ TEST_P(HTMLDocumentParserLoadingTest,
TEST_P(HTMLDocumentParserLoadingTest,
ShouldNotPauseParsingForExternalNonMatchingStylesheetsInBody) {
SimRequest main_resource("https://example.com/test.html", "text/html");
- SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
+ SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+ "text/css");
LoadURL("https://example.com/test.html");
@@ -237,8 +242,10 @@ TEST_P(HTMLDocumentParserLoadingTest,
TEST_P(HTMLDocumentParserLoadingTest,
ShouldPauseParsingForExternalStylesheetsImportedInBody) {
SimRequest main_resource("https://example.com/test.html", "text/html");
- SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
- SimRequest css_body_resource("https://example.com/testBody.css", "text/css");
+ SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+ "text/css");
+ SimSubresourceRequest css_body_resource("https://example.com/testBody.css",
+ "text/css");
LoadURL("https://example.com/test.html");
@@ -276,8 +283,10 @@ TEST_P(HTMLDocumentParserLoadingTest,
TEST_P(HTMLDocumentParserLoadingTest,
ShouldPauseParsingForExternalStylesheetsWrittenInBody) {
SimRequest main_resource("https://example.com/test.html", "text/html");
- SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
- SimRequest css_body_resource("https://example.com/testBody.css", "text/css");
+ SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+ "text/css");
+ SimSubresourceRequest css_body_resource("https://example.com/testBody.css",
+ "text/css");
LoadURL("https://example.com/test.html");
@@ -315,7 +324,8 @@ TEST_P(HTMLDocumentParserLoadingTest,
TEST_P(HTMLDocumentParserLoadingTest,
PendingHeadStylesheetShouldNotBlockParserForBodyInlineStyle) {
SimRequest main_resource("https://example.com/test.html", "text/html");
- SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
+ SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+ "text/css");
LoadURL("https://example.com/test.html");
@@ -340,7 +350,8 @@ TEST_P(HTMLDocumentParserLoadingTest,
TEST_P(HTMLDocumentParserLoadingTest,
PendingHeadStylesheetShouldNotBlockParserForBodyShadowDom) {
SimRequest main_resource("https://example.com/test.html", "text/html");
- SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
+ SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+ "text/css");
LoadURL("https://example.com/test.html");
@@ -365,8 +376,8 @@ TEST_P(HTMLDocumentParserLoadingTest,
TEST_P(HTMLDocumentParserLoadingTest,
ShouldNotPauseParsingForExternalStylesheetsAttachedInBody) {
SimRequest main_resource("https://example.com/test.html", "text/html");
- SimRequest css_async_resource("https://example.com/testAsync.css",
- "text/css");
+ SimSubresourceRequest css_async_resource("https://example.com/testAsync.css",
+ "text/css");
LoadURL("https://example.com/test.html");
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_document_parser_test.cc b/chromium/third_party/blink/renderer/core/html/parser/html_document_parser_test.cc
index 12294237383..325fbbdf552 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_document_parser_test.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_document_parser_test.cc
@@ -74,7 +74,7 @@ TEST_F(HTMLDocumentParserTest, AppendPrefetch) {
HTMLDocument& document = ToHTMLDocument(GetDocument());
ProvidePrerendererClientTo(
*document.GetPage(),
- new MockPrerendererClient(*document.GetPage(), true));
+ MakeGarbageCollected<MockPrerendererClient>(*document.GetPage(), true));
EXPECT_TRUE(document.IsPrefetchOnly());
HTMLDocumentParser* parser = CreateParser(document);
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_element_stack.cc b/chromium/third_party/blink/renderer/core/html/parser/html_element_stack.cc
index 4e98af78265..87d6b262b20 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_element_stack.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_element_stack.cc
@@ -118,7 +118,7 @@ bool HTMLElementStack::ElementRecord::IsAbove(ElementRecord* other) const {
return false;
}
-void HTMLElementStack::ElementRecord::Trace(blink::Visitor* visitor) {
+void HTMLElementStack::ElementRecord::Trace(Visitor* visitor) {
visitor->Trace(item_);
visitor->Trace(next_);
}
@@ -536,7 +536,7 @@ HTMLElementStack::FurthestBlockForFormattingElement(
return nullptr;
}
-void HTMLElementStack::Trace(blink::Visitor* visitor) {
+void HTMLElementStack::Trace(Visitor* visitor) {
visitor->Trace(top_);
visitor->Trace(root_node_);
visitor->Trace(head_element_);
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_element_stack.h b/chromium/third_party/blink/renderer/core/html/parser/html_element_stack.h
index cdcfeea06c6..b34290c531b 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_element_stack.h
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_element_stack.h
@@ -61,7 +61,7 @@ class HTMLElementStack {
ElementRecord* Next() const { return next_.Get(); }
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
friend class HTMLElementStack;
@@ -165,7 +165,7 @@ class HTMLElementStack {
ContainerNode* RootNode() const;
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
#ifndef NDEBUG
void Show();
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_formatting_element_list.h b/chromium/third_party/blink/renderer/core/html/parser/html_formatting_element_list.h
index fe0a6e3582a..168b2cfff78 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_formatting_element_list.h
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_formatting_element_list.h
@@ -76,7 +76,7 @@ class HTMLFormattingElementList {
return !item_ ? !!element : item_->GetElement() != element;
}
- void Trace(blink::Visitor* visitor) { visitor->Trace(item_); }
+ void Trace(Visitor* visitor) { visitor->Trace(item_); }
private:
Member<HTMLStackItem> item_;
@@ -121,7 +121,7 @@ class HTMLFormattingElementList {
const Entry& at(wtf_size_t i) const { return entries_[i]; }
Entry& at(wtf_size_t i) { return entries_[i]; }
- void Trace(blink::Visitor* visitor) { visitor->Trace(entries_); }
+ void Trace(Visitor* visitor) { visitor->Trace(entries_); }
#ifndef NDEBUG
void Show();
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_parser_options.cc b/chromium/third_party/blink/renderer/core/html/parser/html_parser_options.cc
index fe9ef5812e5..1946079fa22 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_parser_options.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_parser_options.cc
@@ -30,6 +30,7 @@
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/loader/frame_loader.h"
+#include "third_party/blink/renderer/core/origin_trials/origin_trials.h"
namespace blink {
@@ -41,6 +42,8 @@ HTMLParserOptions::HTMLParserOptions(Document* document) {
script_enabled = document->CanExecuteScripts(kNotAboutToExecuteScript);
plugins_enabled =
frame->Loader().AllowPlugins(kNotAboutToInstantiatePlugin);
+ priority_hints_origin_trial_enabled =
+ origin_trials::PriorityHintsEnabled(document);
}
}
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_parser_options.h b/chromium/third_party/blink/renderer/core/html/parser/html_parser_options.h
index 33630e22051..912415efca7 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_parser_options.h
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_parser_options.h
@@ -40,6 +40,13 @@ class CORE_EXPORT HTMLParserOptions {
bool script_enabled = false;
bool plugins_enabled = false;
+ // TODO(domfarolino): Remove this when Priority Hints is no longer in an
+ // Origin Trial. See https://crbug.com/821464.
+ // This flag is here because HTMLPreloadScanner needs to know whether or not
+ // the Priority Hints origin trial is enabled or not, and it does not have
+ // access to an ExecutionContext*, but HTMLParserOptions does.
+ bool priority_hints_origin_trial_enabled = false;
+
explicit HTMLParserOptions(Document* = nullptr);
};
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_parser_scheduler.cc b/chromium/third_party/blink/renderer/core/html/parser/html_parser_scheduler.cc
index 19c929216af..646d97aaea9 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_parser_scheduler.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_parser_scheduler.cc
@@ -25,8 +25,6 @@
#include "third_party/blink/renderer/core/html/parser/html_parser_scheduler.h"
-#include "base/feature_list.h"
-#include "base/metrics/field_trial_params.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
@@ -37,10 +35,6 @@
namespace blink {
-const base::Feature kHTMLParsingYieldTime {
- "HTMLParsingYieldTime", base::FEATURE_DISABLED_BY_DEFAULT
-};
-
PumpSession::PumpSession(unsigned& nesting_level)
: NestingLevelIncrementer(nesting_level) {}
@@ -61,22 +55,16 @@ void SpeculationsPumpSession::AddedElementTokens(size_t count) {
processed_element_tokens_ += count;
}
-const double kDefaultParserTimeLimit = 0.5;
-
HTMLParserScheduler::HTMLParserScheduler(
HTMLDocumentParser* parser,
scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner)
: parser_(parser),
loading_task_runner_(std::move(loading_task_runner)),
- is_paused_with_active_timer_(false),
- parser_time_limit_(
- base::GetFieldTrialParamByFeatureAsDouble(kHTMLParsingYieldTime,
- "limit",
- kDefaultParserTimeLimit)) {}
+ is_paused_with_active_timer_(false) {}
HTMLParserScheduler::~HTMLParserScheduler() = default;
-void HTMLParserScheduler::Trace(blink::Visitor* visitor) {
+void HTMLParserScheduler::Trace(Visitor* visitor) {
visitor->Trace(parser_);
}
@@ -120,7 +108,8 @@ inline bool HTMLParserScheduler::ShouldYield(
if (ThreadScheduler::Current()->ShouldYieldForHighPriorityWork())
return true;
- if (session.ElapsedTime() > parser_time_limit_)
+ const double kParserTimeLimit = 0.5;
+ if (session.ElapsedTime() > kParserTimeLimit)
return true;
// Yield if a lot of DOM work has been done in this session and a script tag
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_parser_scheduler.h b/chromium/third_party/blink/renderer/core/html/parser/html_parser_scheduler.h
index f555db1e1c1..dd8ca0a39c2 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_parser_scheduler.h
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_parser_scheduler.h
@@ -95,7 +95,7 @@ class HTMLParserScheduler final
void Detach(); // Clear active tasks if any.
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
bool ShouldYield(const SpeculationsPumpSession&, bool starting_script) const;
@@ -106,7 +106,6 @@ class HTMLParserScheduler final
TaskHandle cancellable_continue_parse_task_handle_;
bool is_paused_with_active_timer_;
- const double parser_time_limit_;
DISALLOW_COPY_AND_ASSIGN(HTMLParserScheduler);
};
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_preload_scanner.cc b/chromium/third_party/blink/renderer/core/html/parser/html_preload_scanner.cc
index 0c9a40302f3..365db5fa361 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_preload_scanner.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_preload_scanner.cc
@@ -29,8 +29,8 @@
#include <memory>
#include "base/optional.h"
+#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-shared.h"
#include "third_party/blink/public/mojom/script/script_type.mojom-blink.h"
-#include "third_party/blink/public/platform/modules/fetch/fetch_api_request.mojom-shared.h"
#include "third_party/blink/renderer/core/css/css_primitive_value.h"
#include "third_party/blink/renderer/core/css/css_property_name.h"
#include "third_party/blink/renderer/core/css/media_list.h"
@@ -53,8 +53,9 @@
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/input_type_names.h"
#include "third_party/blink/renderer/core/loader/importance_attribute.h"
-#include "third_party/blink/renderer/core/loader/link_loader.h"
+#include "third_party/blink/renderer/core/loader/preload_helper.h"
#include "third_party/blink/renderer/core/loader/subresource_integrity_helper.h"
+#include "third_party/blink/renderer/core/origin_trials/origin_trials.h"
#include "third_party/blink/renderer/core/script/script_loader.h"
#include "third_party/blink/renderer/platform/histogram.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
@@ -120,37 +121,6 @@ static bool MediaAttributeMatches(const MediaValuesCached& media_values,
return media_query_evaluator.Eval(*media_queries);
}
-static bool IsDimensionSmallAndAbsoluteForLazyLoad(
- const String& attribute_value) {
- // Minimum height or width of the image to start lazyloading.
- const unsigned kMinDimensionToLazyLoad = 10;
- HTMLDimension dimension;
- return ParseDimensionValue(attribute_value, dimension) &&
- dimension.IsAbsolute() && dimension.Value() <= kMinDimensionToLazyLoad;
-}
-
-static bool IsInlineStyleDimensionsSmall(const String& style_value,
- bool strict_mode) {
- // Minimum height or width of the image to start lazyloading.
- const unsigned kMinDimensionToLazyLoad = 10;
- CSSParserMode mode = strict_mode ? kHTMLStandardMode : kHTMLQuirksMode;
- const ImmutableCSSPropertyValueSet* property_set =
- CSSParser::ParseInlineStyleDeclaration(
- style_value, mode, SecureContextMode::kInsecureContext);
- const CSSValue* height = property_set->GetPropertyCSSValue(CSSPropertyHeight);
- const CSSValue* width = property_set->GetPropertyCSSValue(CSSPropertyWidth);
-
- if (!height || !height->IsPrimitiveValue() || !width ||
- !width->IsPrimitiveValue())
- return false;
- const CSSPrimitiveValue* width_prim = ToCSSPrimitiveValue(width);
- const CSSPrimitiveValue* height_prim = ToCSSPrimitiveValue(height);
- return height_prim->IsPx() &&
- (height_prim->GetDoubleValue() <= kMinDimensionToLazyLoad) &&
- width_prim->IsPx() &&
- (width_prim->GetDoubleValue() <= kMinDimensionToLazyLoad);
-}
-
class TokenPreloadScanner::StartTagScanner {
STACK_ALLOCATED();
@@ -158,7 +128,8 @@ class TokenPreloadScanner::StartTagScanner {
StartTagScanner(const StringImpl* tag_impl,
MediaValuesCached* media_values,
SubresourceIntegrity::IntegrityFeatures features,
- TokenPreloadScanner::ScannerType scanner_type)
+ TokenPreloadScanner::ScannerType scanner_type,
+ bool priority_hints_origin_trial_enabled)
: tag_impl_(tag_impl),
link_is_style_sheet_(false),
link_is_preconnect_(false),
@@ -183,13 +154,16 @@ class TokenPreloadScanner::StartTagScanner {
width_attr_small_absolute_(false),
height_attr_small_absolute_(false),
inline_style_dimensions_small_(false),
- scanner_type_(scanner_type) {
- if (Match(tag_impl_, kImgTag) || Match(tag_impl_, kSourceTag)) {
+ scanner_type_(scanner_type),
+ priority_hints_origin_trial_enabled_(
+ priority_hints_origin_trial_enabled) {
+ if (Match(tag_impl_, kImgTag) || Match(tag_impl_, kSourceTag) ||
+ Match(tag_impl_, kLinkTag)) {
source_size_ = SizesAttributeParser(media_values_, String()).length();
return;
}
- if (!Match(tag_impl_, kInputTag) && !Match(tag_impl_, kLinkTag) &&
- !Match(tag_impl_, kScriptTag) && !Match(tag_impl_, kVideoTag))
+ if (!Match(tag_impl_, kInputTag) && !Match(tag_impl_, kScriptTag) &&
+ !Match(tag_impl_, kVideoTag))
tag_impl_ = nullptr;
}
@@ -365,6 +339,10 @@ class TokenPreloadScanner::StartTagScanner {
!attribute_value.IsNull()) {
SetReferrerPolicy(attribute_value,
kDoNotSupportReferrerPolicyLegacyKeywords);
+ } else if (!importance_mode_set_ &&
+ Match(attribute_name, kImportanceAttr) &&
+ priority_hints_origin_trial_enabled_) {
+ SetImportance(attribute_value);
}
}
@@ -386,7 +364,7 @@ class TokenPreloadScanner::StartTagScanner {
SetReferrerPolicy(attribute_value, kSupportReferrerPolicyLegacyKeywords);
} else if (!importance_mode_set_ &&
Match(attribute_name, kImportanceAttr) &&
- RuntimeEnabledFeatures::PriorityHintsEnabled()) {
+ priority_hints_origin_trial_enabled_) {
SetImportance(attribute_value);
} else if (!lazyload_attr_set_to_off_ &&
Match(attribute_name, kLazyloadAttr) &&
@@ -397,17 +375,24 @@ class TokenPreloadScanner::StartTagScanner {
Match(attribute_name, kWidthAttr) &&
RuntimeEnabledFeatures::LazyImageLoadingEnabled()) {
width_attr_small_absolute_ =
- IsDimensionSmallAndAbsoluteForLazyLoad(attribute_value);
+ HTMLImageElement::IsDimensionSmallAndAbsoluteForLazyLoad(
+ attribute_value);
} else if (!height_attr_small_absolute_ &&
Match(attribute_name, kHeightAttr) &&
RuntimeEnabledFeatures::LazyImageLoadingEnabled()) {
height_attr_small_absolute_ =
- IsDimensionSmallAndAbsoluteForLazyLoad(attribute_value);
+ HTMLImageElement::IsDimensionSmallAndAbsoluteForLazyLoad(
+ attribute_value);
} else if (!inline_style_dimensions_small_ &&
Match(attribute_name, kStyleAttr) &&
RuntimeEnabledFeatures::LazyImageLoadingEnabled()) {
- inline_style_dimensions_small_ = IsInlineStyleDimensionsSmall(
- attribute_value, media_values_->StrictMode());
+ CSSParserMode mode =
+ media_values_->StrictMode() ? kHTMLStandardMode : kHTMLQuirksMode;
+ const ImmutableCSSPropertyValueSet* property_set =
+ CSSParser::ParseInlineStyleDeclaration(
+ attribute_value, mode, SecureContextMode::kInsecureContext);
+ inline_style_dimensions_small_ =
+ HTMLImageElement::IsInlineStyleDimensionsSmall(property_set);
}
}
@@ -464,7 +449,7 @@ class TokenPreloadScanner::StartTagScanner {
ParseSourceSize(attribute_value);
} else if (!importance_mode_set_ &&
Match(attribute_name, kImportanceAttr) &&
- RuntimeEnabledFeatures::PriorityHintsEnabled()) {
+ priority_hints_origin_trial_enabled_) {
SetImportance(attribute_value);
}
}
@@ -555,7 +540,7 @@ class TokenPreloadScanner::StartTagScanner {
base::Optional<ResourceType> ResourceTypeForLinkPreload() const {
DCHECK(link_is_preload_);
- return LinkLoader::GetResourceTypeFromAsAttribute(as_attribute_value_);
+ return PreloadHelper::GetResourceTypeFromAsAttribute(as_attribute_value_);
}
ResourceType GetResourceType() const {
@@ -660,7 +645,7 @@ class TokenPreloadScanner::StartTagScanner {
}
void SetImportance(const String& importance) {
- DCHECK(RuntimeEnabledFeatures::PriorityHintsEnabled());
+ DCHECK(priority_hints_origin_trial_enabled_);
importance_mode_set_ = true;
importance_ = GetFetchImportanceAttributeValue(importance);
}
@@ -706,13 +691,16 @@ class TokenPreloadScanner::StartTagScanner {
bool height_attr_small_absolute_;
bool inline_style_dimensions_small_;
TokenPreloadScanner::ScannerType scanner_type_;
+ // For explanation, see TokenPreloadScanner's declaration.
+ bool priority_hints_origin_trial_enabled_;
};
TokenPreloadScanner::TokenPreloadScanner(
const KURL& document_url,
std::unique_ptr<CachedDocumentParameters> document_parameters,
const MediaValuesCached::MediaValuesCachedData& media_values_cached_data,
- const ScannerType scanner_type)
+ const ScannerType scanner_type,
+ bool priority_hints_origin_trial_enabled)
: document_url_(document_url),
in_style_(false),
in_picture_(false),
@@ -721,6 +709,7 @@ TokenPreloadScanner::TokenPreloadScanner(
document_parameters_(std::move(document_parameters)),
media_values_(MediaValuesCached::Create(media_values_cached_data)),
scanner_type_(scanner_type),
+ priority_hints_origin_trial_enabled_(priority_hints_origin_trial_enabled),
did_rewind_(false) {
DCHECK(document_parameters_.get());
DCHECK(media_values_.Get());
@@ -931,9 +920,9 @@ void TokenPreloadScanner::ScanCommon(const Token& token,
return;
}
- StartTagScanner scanner(tag_impl, media_values_,
- document_parameters_->integrity_features,
- scanner_type_);
+ StartTagScanner scanner(
+ tag_impl, media_values_, document_parameters_->integrity_features,
+ scanner_type_, priority_hints_origin_trial_enabled_);
scanner.ProcessAttributes(token.Attributes());
// TODO(yoav): ViewportWidth is currently racy and might be zero in some
// cases, at least in tests. That problem will go away once
@@ -972,7 +961,8 @@ HTMLPreloadScanner::HTMLPreloadScanner(
: scanner_(document_url,
std::move(document_parameters),
media_values_cached_data,
- scanner_type),
+ scanner_type,
+ options.priority_hints_origin_trial_enabled),
tokenizer_(HTMLTokenizer::Create(options)) {}
HTMLPreloadScanner::~HTMLPreloadScanner() = default;
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_preload_scanner.h b/chromium/third_party/blink/renderer/core/html/parser/html_preload_scanner.h
index 881c54bded9..9dc91e1357b 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_preload_scanner.h
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_preload_scanner.h
@@ -90,7 +90,8 @@ class TokenPreloadScanner {
TokenPreloadScanner(const KURL& document_url,
std::unique_ptr<CachedDocumentParameters>,
const MediaValuesCached::MediaValuesCachedData&,
- const ScannerType);
+ const ScannerType,
+ bool priority_hints_origin_trial_enabled);
~TokenPreloadScanner();
void Scan(const HTMLToken&,
@@ -162,6 +163,12 @@ class TokenPreloadScanner {
Persistent<MediaValuesCached> media_values_;
ClientHintsPreferences client_hints_preferences_;
ScannerType scanner_type_;
+ // TODO(domfarolino): Remove this once Priority Hints is no longer in Origin
+ // Trial (see https://crbug.com/821464). This member exists because
+ // HTMLPreloadScanner has no access to an ExecutionContext*, and therefore
+ // cannot determine an Origin Trial's status, so we accept this information in
+ // the constructor and set this flag accordingly.
+ bool priority_hints_origin_trial_enabled_;
bool did_rewind_ = false;
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_resource_preloader.cc b/chromium/third_party/blink/renderer/core/html/parser/html_resource_preloader.cc
index d0485f78c89..074049f3e8c 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_resource_preloader.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_resource_preloader.cc
@@ -42,16 +42,10 @@ HTMLResourcePreloader* HTMLResourcePreloader::Create(Document& document) {
return MakeGarbageCollected<HTMLResourcePreloader>(document);
}
-void HTMLResourcePreloader::Trace(blink::Visitor* visitor) {
+void HTMLResourcePreloader::Trace(Visitor* visitor) {
visitor->Trace(document_);
}
-int HTMLResourcePreloader::CountPreloads() {
- if (document_->Loader())
- return document_->Loader()->Fetcher()->CountPreloads();
- return 0;
-}
-
static void PreconnectHost(
PreloadRequest* request,
const NetworkHintsInterface& network_hints_interface) {
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_resource_preloader.h b/chromium/third_party/blink/renderer/core/html/parser/html_resource_preloader.h
index 3c431cabb2f..3dad651d22c 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_resource_preloader.h
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_resource_preloader.h
@@ -50,9 +50,7 @@ class CORE_EXPORT HTMLResourcePreloader
explicit HTMLResourcePreloader(Document&);
- int CountPreloads();
- Document* GetDocument() { return document_.Get(); }
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
protected:
void Preload(std::unique_ptr<PreloadRequest>,
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_stack_item.h b/chromium/third_party/blink/renderer/core/html/parser/html_stack_item.h
index d25fe96a9dd..d2778afd1d0 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_stack_item.h
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_stack_item.h
@@ -218,7 +218,7 @@ class HTMLStackItem : public GarbageCollectedFinalized<HTMLStackItem> {
tag_name == html_names::kWbrTag || tag_name == html_names::kXmpTag;
}
- void Trace(blink::Visitor* visitor) { visitor->Trace(node_); }
+ void Trace(Visitor* visitor) { visitor->Trace(node_); }
private:
Member<ContainerNode> node_;
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_tokenizer_fuzzer.cc b/chromium/third_party/blink/renderer/core/html/parser/html_tokenizer_fuzzer.cc
index e927e6bb24c..64364a8af7d 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_tokenizer_fuzzer.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_tokenizer_fuzzer.cc
@@ -30,9 +30,8 @@ int FuzzTokenizer(const uint8_t* data, size_t size) {
// The tokenizer deals with incremental strings as they are received.
// Split the input into a bunch of small chunks to throw partial tokens
// at the tokenizer and exercise the state machine and resumption.
- CString chunk = fuzzed_data_provider.ConsumeBytesInRange(1, 32);
- SegmentedString segment(String(chunk.data(), chunk.length()));
- input.Append(segment);
+ String chunk = fuzzed_data_provider.ConsumeRandomLengthString(32);
+ input.Append(SegmentedString(chunk));
// If a token was generated from the input then the next call
// needs to use a fresh token for output. If a token is not generated
// then the same token instance needs to be reused in the next calls
@@ -48,7 +47,8 @@ int FuzzTokenizer(const uint8_t* data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// Need at least 2 bytes for the options flags and one byte of test data.
- if (size >= 3)
+ // Avoid huge inputs which can cause non-actionable timeout crashes.
+ if (size >= 3 && size <= 16384)
blink::FuzzTokenizer(data, size);
return 0;
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_tree_builder.cc b/chromium/third_party/blink/renderer/core/html/parser/html_tree_builder.cc
index 4d0b1346265..7075f10d6c8 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_tree_builder.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_tree_builder.cc
@@ -269,12 +269,12 @@ void HTMLTreeBuilder::FragmentParsingContext::Init(DocumentFragment* fragment,
context_element, HTMLStackItem::kItemForContextElement);
}
-void HTMLTreeBuilder::FragmentParsingContext::Trace(blink::Visitor* visitor) {
+void HTMLTreeBuilder::FragmentParsingContext::Trace(Visitor* visitor) {
visitor->Trace(fragment_);
visitor->Trace(context_element_stack_item_);
}
-void HTMLTreeBuilder::Trace(blink::Visitor* visitor) {
+void HTMLTreeBuilder::Trace(Visitor* visitor) {
visitor->Trace(fragment_context_);
visitor->Trace(tree_);
visitor->Trace(parser_);
diff --git a/chromium/third_party/blink/renderer/core/html/parser/html_tree_builder.h b/chromium/third_party/blink/renderer/core/html/parser/html_tree_builder.h
index 8615b67c5fa..20a49fc3fda 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/html_tree_builder.h
+++ b/chromium/third_party/blink/renderer/core/html/parser/html_tree_builder.h
@@ -78,7 +78,7 @@ class HTMLTreeBuilder final
ParserContentPolicy,
const HTMLParserOptions&);
~HTMLTreeBuilder();
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
const HTMLElementStack* OpenElements() const { return tree_.OpenElements(); }
@@ -233,7 +233,7 @@ class HTMLTreeBuilder final
return context_element_stack_item_.Get();
}
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
private:
Member<DocumentFragment> fragment_;
diff --git a/chromium/third_party/blink/renderer/core/html/parser/preload_request.cc b/chromium/third_party/blink/renderer/core/html/parser/preload_request.cc
index 892cf94dece..889dbb732dd 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/preload_request.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/preload_request.cc
@@ -8,6 +8,7 @@
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
+#include "third_party/blink/renderer/core/loader/preload_helper.h"
#include "third_party/blink/renderer/core/script/document_write_intervention.h"
#include "third_party/blink/renderer/core/script/script_loader.h"
#include "third_party/blink/renderer/platform/cross_origin_attribute_value.h"
@@ -113,7 +114,8 @@ Resource* PreloadRequest::Start(Document* document) {
}
}
- return document->Loader()->StartPreload(resource_type_, params);
+ return PreloadHelper::StartPreload(resource_type_, params,
+ document->Fetcher());
}
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/html/parser/preload_request.h b/chromium/third_party/blink/renderer/core/html/parser/preload_request.h
index dbe82c976f8..82bf24aae89 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/preload_request.h
+++ b/chromium/third_party/blink/renderer/core/html/parser/preload_request.h
@@ -8,8 +8,8 @@
#include <memory>
#include "base/memory/ptr_util.h"
+#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-shared.h"
#include "third_party/blink/public/mojom/script/script_type.mojom-blink.h"
-#include "third_party/blink/public/platform/modules/fetch/fetch_api_request.mojom-shared.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/script/script.h"
#include "third_party/blink/renderer/platform/cross_origin_attribute_value.h"
diff --git a/chromium/third_party/blink/renderer/core/html/parser/text_resource_decoder.cc b/chromium/third_party/blink/renderer/core/html/parser/text_resource_decoder.cc
index 8ff95d82df8..d5c6c8ef231 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/text_resource_decoder.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/text_resource_decoder.cc
@@ -203,6 +203,12 @@ static int FindXMLEncoding(const char* str, int len, int& encoding_length) {
wtf_size_t TextResourceDecoder::CheckForBOM(const char* data, wtf_size_t len) {
// Check for UTF-16 or UTF-8 BOM mark at the beginning, which is a sure
// sign of a Unicode encoding. We let it override even a user-chosen encoding.
+
+ // if |options_|'s value corresponds to #decode or #utf-8-decode,
+ // CheckForBOM() corresponds to
+ // - Steps 1-6 of https://encoding.spec.whatwg.org/#decode or
+ // - Steps 1-3 of https://encoding.spec.whatwg.org/#utf-8-decode,
+ // respectively.
DCHECK(!checked_for_bom_);
wtf_size_t length_of_bom = 0;
diff --git a/chromium/third_party/blink/renderer/core/html/parser/text_resource_decoder.h b/chromium/third_party/blink/renderer/core/html/parser/text_resource_decoder.h
index dd03aaa2a8f..f05f096ea40 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/text_resource_decoder.h
+++ b/chromium/third_party/blink/renderer/core/html/parser/text_resource_decoder.h
@@ -36,6 +36,10 @@ namespace blink {
class HTMLMetaCharsetParser;
+// Implements https://encoding.spec.whatwg.org/#decode or
+// https://encoding.spec.whatwg.org/#utf-8-decode when an appropriate
+// TextResourceDecoderOptions is given.
+// See comments in text_resource_decoder_options.h.
class CORE_EXPORT TextResourceDecoder {
USING_FAST_MALLOC(TextResourceDecoder);
diff --git a/chromium/third_party/blink/renderer/core/html/parser/text_resource_decoder_for_fuzzing.h b/chromium/third_party/blink/renderer/core/html/parser/text_resource_decoder_for_fuzzing.h
index d71506c9ede..02487b84e56 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/text_resource_decoder_for_fuzzing.h
+++ b/chromium/third_party/blink/renderer/core/html/parser/text_resource_decoder_for_fuzzing.h
@@ -51,8 +51,7 @@ class TextResourceDecoderForFuzzing : public TextResourceDecoder {
// Note: Charsets can be long (see the various encodings in
// wtf/text). For instance: "unicode-1-1-utf-8". To ensure good coverage,
// set a generous max limit for these sizes (32 bytes should be good).
- return WTF::TextEncoding(
- String::FromUTF8(fuzzed_data.ConsumeBytesInRange(0, 32)));
+ return WTF::TextEncoding(fuzzed_data.ConsumeRandomLengthString(32));
}
};
diff --git a/chromium/third_party/blink/renderer/core/html/parser/xss_auditor.cc b/chromium/third_party/blink/renderer/core/html/parser/xss_auditor.cc
index 0ed6267168d..05e8e9fbd6d 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/xss_auditor.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/xss_auditor.cc
@@ -454,7 +454,7 @@ void XSSAuditor::Init(Document* document,
if (auditor_delegate)
auditor_delegate->SetReportURL(xss_protection_report_url.Copy());
- EncodedFormData* http_body = document_loader->GetRequest().HttpBody();
+ EncodedFormData* http_body = document_loader->HttpBody();
if (http_body && !http_body->IsEmpty())
http_body_as_string_ = http_body->FlattenToString();
}
diff --git a/chromium/third_party/blink/renderer/core/html/parser/xss_auditor_delegate.cc b/chromium/third_party/blink/renderer/core/html/parser/xss_auditor_delegate.cc
index 609c93215fb..240cc29c9bb 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/xss_auditor_delegate.cc
+++ b/chromium/third_party/blink/renderer/core/html/parser/xss_auditor_delegate.cc
@@ -72,7 +72,7 @@ XSSAuditorDelegate::XSSAuditorDelegate(Document* document)
DCHECK(document_);
}
-void XSSAuditorDelegate::Trace(blink::Visitor* visitor) {
+void XSSAuditorDelegate::Trace(Visitor* visitor) {
visitor->Trace(document_);
}
@@ -84,7 +84,7 @@ scoped_refptr<EncodedFormData> XSSAuditorDelegate::GenerateViolationReport(
String http_body;
if (frame_loader.GetDocumentLoader()) {
if (EncodedFormData* form_data =
- frame_loader.GetDocumentLoader()->OriginalRequest().HttpBody())
+ frame_loader.GetDocumentLoader()->HttpBody())
http_body = form_data->FlattenToString();
}
diff --git a/chromium/third_party/blink/renderer/core/html/parser/xss_auditor_delegate.h b/chromium/third_party/blink/renderer/core/html/parser/xss_auditor_delegate.h
index 261edde516d..4379dbb48c8 100644
--- a/chromium/third_party/blink/renderer/core/html/parser/xss_auditor_delegate.h
+++ b/chromium/third_party/blink/renderer/core/html/parser/xss_auditor_delegate.h
@@ -75,7 +75,7 @@ class XSSAuditorDelegate final {
public:
explicit XSSAuditorDelegate(Document*);
- void Trace(blink::Visitor*);
+ void Trace(Visitor*);
void DidBlockScript(const XSSInfo&);
void SetReportURL(const KURL& url) { report_url_ = url; }