spanification: HTMLMetaCharsetParser

Bug: 351564777
Change-Id: I02761b95cfee5e3af20f044abe7e19e33e7a7b5d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5867212
Auto-Submit: Fredrik Söderquist <fs@opera.com>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Reviewed-by: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1356783}
diff --git a/third_party/blink/renderer/core/html/parser/html_meta_charset_parser.cc b/third_party/blink/renderer/core/html/parser/html_meta_charset_parser.cc
index 7dbedadc..df2fa68 100644
--- a/third_party/blink/renderer/core/html/parser/html_meta_charset_parser.cc
+++ b/third_party/blink/renderer/core/html/parser/html_meta_charset_parser.cc
@@ -60,8 +60,7 @@
 // is over.
 static const int kBytesToCheckUnconditionally = 1024;
 
-bool HTMLMetaCharsetParser::CheckForMetaCharset(const char* data,
-                                                wtf_size_t length) {
+bool HTMLMetaCharsetParser::CheckForMetaCharset(base::span<const char> data) {
   if (done_checking_)
     return true;
 
@@ -84,7 +83,8 @@
   // are disallowed in <head>, we don't bail out until we've checked at least
   // bytesToCheckUnconditionally bytes of input.
 
-  input_.Append(SegmentedString(assumed_codec_->Decode(data, length)));
+  input_.Append(SegmentedString(assumed_codec_->Decode(
+      data.data(), base::checked_cast<wtf_size_t>(data.size()))));
 
   while (HTMLToken* token = tokenizer_->NextToken(input_)) {
     bool end = token->GetType() == HTMLToken::kEndTag;
diff --git a/third_party/blink/renderer/core/html/parser/html_meta_charset_parser.h b/third_party/blink/renderer/core/html/parser/html_meta_charset_parser.h
index 3d4036c..0793601 100644
--- a/third_party/blink/renderer/core/html/parser/html_meta_charset_parser.h
+++ b/third_party/blink/renderer/core/html/parser/html_meta_charset_parser.h
@@ -48,7 +48,7 @@
   ~HTMLMetaCharsetParser();
 
   // Returns true if done checking, regardless whether an encoding is found.
-  bool CheckForMetaCharset(const char*, wtf_size_t);
+  bool CheckForMetaCharset(base::span<const char> data);
 
   const WTF::TextEncoding& Encoding() { return encoding_; }
 
diff --git a/third_party/blink/renderer/core/html/parser/text_resource_decoder.cc b/third_party/blink/renderer/core/html/parser/text_resource_decoder.cc
index 77685ed..18be26c 100644
--- a/third_party/blink/renderer/core/html/parser/text_resource_decoder.cc
+++ b/third_party/blink/renderer/core/html/parser/text_resource_decoder.cc
@@ -304,8 +304,7 @@
   if (!charset_parser_)
     charset_parser_ = std::make_unique<HTMLMetaCharsetParser>();
 
-  if (!charset_parser_->CheckForMetaCharset(
-          data.data(), base::checked_cast<wtf_size_t>(data.size()))) {
+  if (!charset_parser_->CheckForMetaCharset(data)) {
     return;
   }