/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use std::borrow::Cow; use std::mem; use std::time::{Duration, Instant}; use encoding_rs::{Encoding, UTF_8, UTF_16BE, UTF_16LE, WINDOWS_1252, X_USER_DEFINED}; use tendril::fmt::UTF8; use tendril::stream::LossyDecoder; use tendril::{ByteTendril, StrTendril, TendrilSink}; use crate::dom::document::Document; #[derive(JSTraceable, MallocSizeOf)] pub(super) struct DetectingState { /// The `charset` that was specified in the `Content-Type` header, if any. #[no_trace] encoding_hint_from_content_type: Option<&'static Encoding>, /// The encoding of a same-origin container document, if this document is in an /// `