#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/html/parser/text_resource_decoder.h"
#include "base/numerics/safe_conversions.h"
#include "base/trace_event/trace_event.h"
#include "third_party/blink/renderer/core/dom/dom_implementation.h"
#include "third_party/blink/renderer/core/html/parser/html_meta_charset_parser.h"
#include "third_party/blink/renderer/platform/text/text_encoding_detector.h"
#include "third_party/blink/renderer/platform/wtf/text/string_view.h"
#include "third_party/blink/renderer/platform/wtf/text/text_codec.h"
#include "third_party/blink/renderer/platform/wtf/text/text_encoding_registry.h"
namespace blink {
const int kMinimumLengthOfXMLDeclaration = …;
static inline bool BytesEqual(const char* p,
char b0,
char b1,
char b2,
char b3,
char b4) { … }
static inline bool BytesEqual(const char* p,
char b0,
char b1,
char b2,
char b3,
char b4,
char b5) { … }
static inline bool BytesEqual(const char* p,
char b0,
char b1,
char b2,
char b3,
char b4,
char b5,
char b6,
char b7,
char b8,
char b9) { … }
static int Find(const char* subject, int subject_length, const char* target) { … }
static WTF::TextEncoding FindTextEncoding(const char* encoding_name,
wtf_size_t length) { … }
const WTF::TextEncoding& TextResourceDecoder::DefaultEncoding(
TextResourceDecoderOptions::ContentType content_type,
const WTF::TextEncoding& specified_default_encoding) { … }
TextResourceDecoder::TextResourceDecoder(
const TextResourceDecoderOptions& options)
: … { … }
TextResourceDecoder::~TextResourceDecoder() = default;
void TextResourceDecoder::AddToBuffer(const char* data,
wtf_size_t data_length) { … }
void TextResourceDecoder::AddToBufferIfEmpty(const char* data,
wtf_size_t data_length) { … }
void TextResourceDecoder::SetEncoding(const WTF::TextEncoding& encoding,
EncodingSource source) { … }
static int FindXMLEncoding(const char* str, int len, int& encoding_length) { … }
wtf_size_t TextResourceDecoder::CheckForBOM(const char* data, wtf_size_t len) { … }
bool TextResourceDecoder::CheckForCSSCharset(const char* data, wtf_size_t len) { … }
bool TextResourceDecoder::CheckForXMLCharset(const char* data, wtf_size_t len) { … }
void TextResourceDecoder::CheckForMetaCharset(const char* data,
wtf_size_t length) { … }
void TextResourceDecoder::AutoDetectEncodingIfAllowed(const char* data,
wtf_size_t len) { … }
String TextResourceDecoder::Decode(const char* data, size_t data_len) { … }
String TextResourceDecoder::Flush() { … }
WebEncodingData TextResourceDecoder::GetEncodingData() const { … }
}