mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
8a0a002cf2
- Bug 1148708: Add missing 'override' annotations in DocAccessibleChild.h. rs=ehsan (d606358545)
- Bug 1210408 - make nsMaiInterfaceAction work with proxies, r=tbsaunde (f7c819c6ae)
- Bug 1210407 - teach nsMaiInterfaceTable to use proxies, r=tbsaunde (4ca4f10b5f)
- bug 1185157 make sure we don't send an event to a destroyed ipc document r=billm (23acf53f75)
- bug 1214864 - make SetCarretOffset() async r=davidb (e3079e9b2d)
- missing of Bug 1139972 - IPC Proxy for charAt, r=tbsaunde (e9593ed752)
- bug 1191598 - Pass MOZ_CURRENT_PROJECT in environment when running post-build automation steps for universal mac builds. r=gps (fc342c6ced)
- Bug 1164596 - Add mach android-emulator command; r=ahal (afeb9b27d1)
- Bug 1223149 - Add basic usage documentation for mach build; r=glandium (bfb802d175)
- Bug 1182301 - Improve 'mach build' notifications. r=gps (2c65a122d1)
- Bug 1184696 - Add clobber targets to |mach clobber|; Ability to clobber compiled python files, r=gps (35d8be292e)
- Bug 1117958 - Allow any debugging options to the run or gtest mach subcommands to automatically enable debugging. r=gps (32f986af4b)
- Bug 1180081 - Properly rebuild gtest/libxul before running gtests. r=gps (80db9a3d49)
- Bug 1171647, part 1 - Define a new function to convert the mode to a string. r=njn (61ad16f5ba)
- Bug 1171647, part 2 - Remove redundant assertion for dark matter mode. r=njn (b5ac9519f3)
- Bug 1058178, part 1 - Implement DMD heap scanning mode. r=njn (60e1079536)
- Bug 1058178, part 2 - Implement address clamping analysis for DMD scan logs. r=njn (45c0326b93)
- Bug 1102388 - Fix DMD static constructor ordering dependency. r=mccr8 (59b87897a1)
- Bug 1128705 - Don't redefine PAGE_SIZE in DMD if it's already defined. r=erahm (49216348ee)
- Bug 1179042 - Add a script for analyzing memory blocks using a heap scan DMD log. r=njn DONTBUILD (1c08d2d66e)
- Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat (1c999d139b)
- Bug 1158772 - fix non-idiomatic memset call in nsDeque.cpp; r=erahm (de6b555245)
- Bug 1199400 - Part 1: Use CheckedInt when growing nsDeque capacity. r=froydnj (dfdf6814a3)
- Bug 1199400 - Part 0: Remove unused nsDequeIterator. r=froydnj (38d69d7f47)
- Bug 1199400 - Part 2: Add tests for possible nsDeque corner cases. r=froydnj (931baff195)
- Bug 1201997 - Part 1 - Converted compiled test to gtest for nsDeque class. Added tests to test untested methods. r=froydn (e893916651)
- Bug 1201997 - Part 2 - Removing unused methods from the nsDeque class. r=froydn (41595a90ac)
- Bug 1201997 - Part 3 - Make internally used methods private. r=froydn (8cd3afd96f)
- Bug 1201997 - Part 4 - Change size and offset variables to size_t.r=froydn (73eabc8d60)
- Bug 1215140 P1 Add an nsIConsoleReportCollector interface to support navigation channel logging. r=bz (8a41535e2b)
- Bug 1215140 P2 Make HttpBaseChannel implement nsIConsoleReportCollector. r=bz (75fca301f2)
- Bug 1197679 - If nsUnknownDecoder is involved in e10s DivertToParent can break. r=jduell (5d94a12504)
- Bug 1178991 - smartptr for http converter r=hurley (8e7fbc8443)
- bug 366559 - patch 2, fix nsHTTPCompressConv indentation r=bagder (ba762da587)
- bug 366559 - patch 3, fix nsHTTPCompressConv bracing style r=bagder (54195ab451)
- bits of bug 366559 - patch 7, content-encoding brotli for http (f0b4051022)
- Bug 1205112 - Make PushEvent.data nullable. r=mt,smaug (775db32856)
- Bug 1193414 - SharedWorkers thread should be kept alive also when the SharedWorker object is CCed, r=khuey (b77ea8125c)
- Bug 1206520: Add about:config prefs to enable throwing on asm.js validation failures; r=bz (c42126665d)
- Bug 1193414 - Telemetry for SharedWorker spawning. r=bkelly (77984b7bcc)
- Bug 1205676 - Enable WPT service-worker/unregister-then-register-new-script.https.html in e10s, r=nsm (ec24939cf6)
- Bug 1193133 - Throw when calling postMessage from a Service Worker dom object with no global. r=bkelly (526dcacfab)
- Bug 1181871 P1 Only enforce Cache Context shared data destruction on target thread after init. r=ehsan (cdbf3ed3a8)
- Bug 1181871 P2 Fix ServiceWorkerManager usage of stack-based ErrorResult. r=ehsan (c449195d90)
- minor cleanup and missing bit of 1198230 (02f459db05)
- Bug 1143717 - Implement the ServiceWorkerMessageEvent interface. r=baku (027b3465f2)
- fix misspatch (708eee4e84)
- Bug 1188545 - Disentangle service workers from shared workers and refactor event dispatching code into a separate class. r=nsm,mrbkap (fb5b5341c9)
- Bug 1205228 - Change PackagedAppVerifier to notify the verification result asynchronously. r=valentin. (9edda0fa00)
- Bug 1178518 - Packaged App Utils. r=valentin (f60f3b7a93)
- Bug 1213150 - Part 1: Add a nsContentUtils::IsNonSubresourceRequest helper; r=jdm (b509cc3cc9)
- Bug 1213150 - Part 2: Rework ShouldPrepareForIntercept() in terms of subresource requests; r=jdm (2e92fe8780)
- Bug 1213150 - Part 3: Remove nsIInterceptedChannel.isNavigation; r=jdm (becf1cc12f)
- Bug 1213150 follow-up: fix build bustage (8d73d6ca73)
- Bug 1198394 - Part 1: Allow interception of HSTS upgraded connections in non-e10s mode; r=mcmanus (f504c5be08)
- Bug 1198394 - Part 2: Add a test for interception of HSTS upgraded connections; r=jdm (054e984eef)
- Bug 1187011 - Don't allow response body with null body status. r=bkelly (b1860741d1)
- missing bit of 1140788 (29d319712e)
- Bug 1213436 - Reject core dumps with node IDs that don't fit in an IEEE 754 double; r=sfink (3c1f6fdda0)
- Bug 1211006 - Add Debugger.Source.prototype.canonicalId; r=ejpbruel (eef7b79fce)
- Bug 1199218 - Implement JS::ubi::Node::size for js::LazyScript referents; r=sfink (098a48d240)
- Bug 1220031 - Add JS::ubi::Node::scriptFilename; r=sfink (6b824ae680)
- Bug 1143575. Remove unused MediaQueue::Empty. r=cpearce (de737f3433)
- Bug 1209933 - Make sure all parent runtime pointers are the topmost parent, r=billm. (fe824d967d)
- Bug 1197012 - Fix ThrowTypeError in Notification. r=mccr8 (0b1a097526)
- Bug 1197893 - Check the number of arguments for ThrowTypeError() and ThrowRangeError() at compile time. r=peterv (d98c7d78a0)
- Bug 1142083 - Add test for IDN Unicode domain redirect. r=mcmanus (0c8961fe17)
- Bug 1187159 - Add mochitest for loading packaged apps (iframe+fetch+mozapp) r=jduell (ce90ea561b)
- Bug 1186290 - Notify TabParent to switch process when loading a signed package. r=honzab, r=kanru. (c58a14554a)
- fix (15e2df75eb)
- Bug 1206124 P1 Fix "same-origin" CORS credentials in FetchDriver. r=ehsan (fae1bb6ab3)
- Bug 1206124 P2 Test fetch() with credentials and redirects. r=ehsan (ffc6254112)
- Bug 1211751: Remove nsIChannelEventSink-forwarding from EventSource and FetchDriver. It's never needed. r=smaug (adafe5737a)
- Bug 1212433 Fail fetch() calls that require preflight and also redirect. r=sicking a=abillings (c0d6742b9e)
- Bug 1193128 - Fix base64 decoding when fetching data URIs. r=baku (80bafa291a)
- Bug 1195167 part 1: Let necko handle all protocols. r=bkelly (bb932b0ada)
- Bug 1195167 part 2: Remove redundant aCORSFlag argument and instead use mCORSFlagEverSet. r=bkelly (beadafcad0)
- Bug 1195167 part 3: Remove more scheme-specific handling from FetchDriver. r=bkelly (d00b38db9e)
- Bug 1195167 part 4: Remove FetchDriver::BasicFetch since it is empty. r=bkelly (c5ed097267)
- Bug 1210413 P2 Test CORS credentials on cross-origin redirects. r=sicking a=dveditz (b4eeb8aac0)
- Bug 1210413 P1 Propagate new channel load flags from child to parent on redirect. r=jduell a=dveditz (8b329af4fa)
- Bug 1195167 part 5: Make FetchDriver use AsyncOpen2. r=bkelly (cc217c4cc1)
- Bug 1195167 part 6: Some code simplification since necko handles fetch recursion. r=bkelly (f3b6da2262)
- Bug 1195167: Followup to fix test which I forgot to change (81e7439a2e)
- Bug 1215746: Remove RequestMode::Cors_with_forced_preflight. r=bkelly (0336e812b6)
- Bug 1211000: Move CORS preflight logic from nsCORSListenerProxy to nsCORSPreflightListener. r=ehsan (bf2f71cf22)
- missing bit of Bug 1211443 - Drop scheduled update if decoder initialization isn't done yet. r=jya (f6bc074e33)
- Bug 1182571: Fix nsILoadInfo->GetContentPolicyType API to be less ambigious. Audit and fix all users of it. r=ckerschb (5af6fa7442)
- fix (e40c8e7625)
- Bug 1173811 - Part 1: Propagate the response URL to intercepted channels when necessary (non-e10s). r=mayhemer,bkelly (26f4f13c28)
- Bug 1173811 - Part 2: Propagate the response URL to intercepted channels when necessary (e10s). r=mayhemer,bkelly (a603fe1df2)
- Bug 1154309 - Add New Resource Timing Fields r=bz,hurley (1d14eb6bef)
- Bug 1175685 - add OriginAttribute to LoadInfo. r=jonas, r=ckerschb, r=michal (a5d18bb637)
- Bug 1175685 - add OriginAttribute to LoadInfo. r=jonas, r=ckerschb, r=michal (fb07d2c8aa)
- Bug 1212904 P1 Add a LoadTainting enumeration. r=jduell (a1db8a3e99)
- Bug 1212904 P2 Add LoadTainting information to nsILoadInfo. r=jduell (2482e5e334)
- Bug 1221151 - use [infallible] in nsILoadInfo.idl instead of manual %{C++ blocks; r=jduell (aae73129b6)
- Bug 1045891 - CSP 2 child-src implementation r=ckerschb (792920aeb9)
- Bug 1219931 - CSP: Don't allow removing a policy (r=sicking) (9daaab4186)
- Bug 1208661 - Dump client-side layer textures. r=BenWa (1f2d17d515)
579 lines
17 KiB
C++
579 lines
17 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/* 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 http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef nsHtml5StreamParser_h
|
|
#define nsHtml5StreamParser_h
|
|
|
|
#include "nsAutoPtr.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "nsICharsetDetectionObserver.h"
|
|
#include "nsHtml5MetaScanner.h"
|
|
#include "nsIUnicodeDecoder.h"
|
|
#include "nsHtml5TreeOpExecutor.h"
|
|
#include "nsHtml5OwningUTF16Buffer.h"
|
|
#include "nsIInputStream.h"
|
|
#include "mozilla/Mutex.h"
|
|
#include "nsHtml5AtomTable.h"
|
|
#include "nsHtml5Speculation.h"
|
|
#include "nsITimer.h"
|
|
#include "nsICharsetDetector.h"
|
|
|
|
class nsHtml5Parser;
|
|
|
|
#define NS_HTML5_STREAM_PARSER_READ_BUFFER_SIZE 1024
|
|
#define NS_HTML5_STREAM_PARSER_SNIFFING_BUFFER_SIZE 1024
|
|
|
|
enum eParserMode {
|
|
/**
|
|
* Parse a document normally as HTML.
|
|
*/
|
|
NORMAL,
|
|
|
|
/**
|
|
* View document as HTML source.
|
|
*/
|
|
VIEW_SOURCE_HTML,
|
|
|
|
/**
|
|
* View document as XML source
|
|
*/
|
|
VIEW_SOURCE_XML,
|
|
|
|
/**
|
|
* View document as plain text source
|
|
*/
|
|
VIEW_SOURCE_PLAIN,
|
|
|
|
/**
|
|
* View document as plain text
|
|
*/
|
|
PLAIN_TEXT,
|
|
|
|
/**
|
|
* Load as data (XHR)
|
|
*/
|
|
LOAD_AS_DATA
|
|
};
|
|
|
|
enum eBomState {
|
|
/**
|
|
* BOM sniffing hasn't started.
|
|
*/
|
|
BOM_SNIFFING_NOT_STARTED = 0,
|
|
|
|
/**
|
|
* BOM sniffing is ongoing, and the first byte of an UTF-16LE BOM has been
|
|
* seen.
|
|
*/
|
|
SEEN_UTF_16_LE_FIRST_BYTE = 1,
|
|
|
|
/**
|
|
* BOM sniffing is ongoing, and the first byte of an UTF-16BE BOM has been
|
|
* seen.
|
|
*/
|
|
SEEN_UTF_16_BE_FIRST_BYTE = 2,
|
|
|
|
/**
|
|
* BOM sniffing is ongoing, and the first byte of an UTF-8 BOM has been
|
|
* seen.
|
|
*/
|
|
SEEN_UTF_8_FIRST_BYTE = 3,
|
|
|
|
/**
|
|
* BOM sniffing is ongoing, and the first and second bytes of an UTF-8 BOM
|
|
* have been seen.
|
|
*/
|
|
SEEN_UTF_8_SECOND_BYTE = 4,
|
|
|
|
/**
|
|
* BOM sniffing was started but is now over for whatever reason.
|
|
*/
|
|
BOM_SNIFFING_OVER = 5
|
|
};
|
|
|
|
enum eHtml5StreamState {
|
|
STREAM_NOT_STARTED = 0,
|
|
STREAM_BEING_READ = 1,
|
|
STREAM_ENDED = 2
|
|
};
|
|
|
|
class nsHtml5StreamParser : public nsICharsetDetectionObserver {
|
|
|
|
friend class nsHtml5RequestStopper;
|
|
friend class nsHtml5DataAvailable;
|
|
friend class nsHtml5StreamParserContinuation;
|
|
friend class nsHtml5TimerKungFu;
|
|
|
|
public:
|
|
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsHtml5StreamParser,
|
|
nsICharsetDetectionObserver)
|
|
|
|
static void InitializeStatics();
|
|
|
|
nsHtml5StreamParser(nsHtml5TreeOpExecutor* aExecutor,
|
|
nsHtml5Parser* aOwner,
|
|
eParserMode aMode);
|
|
|
|
// Methods that nsHtml5StreamListener calls
|
|
nsresult CheckListenerChain();
|
|
|
|
nsresult OnStartRequest(nsIRequest* aRequest, nsISupports* aContext);
|
|
|
|
nsresult OnDataAvailable(nsIRequest* aRequest,
|
|
nsISupports* aContext,
|
|
nsIInputStream* aInStream,
|
|
uint64_t aSourceOffset,
|
|
uint32_t aLength);
|
|
|
|
nsresult OnStopRequest(nsIRequest* aRequest,
|
|
nsISupports* aContext,
|
|
nsresult status);
|
|
|
|
// nsICharsetDetectionObserver
|
|
/**
|
|
* Chardet calls this to report the detection result
|
|
*/
|
|
NS_IMETHOD Notify(const char* aCharset, nsDetectionConfident aConf) override;
|
|
|
|
// EncodingDeclarationHandler
|
|
// http://hg.mozilla.org/projects/htmlparser/file/tip/src/nu/validator/htmlparser/common/EncodingDeclarationHandler.java
|
|
/**
|
|
* Tree builder uses this to report a late <meta charset>
|
|
*/
|
|
bool internalEncodingDeclaration(nsString* aEncoding);
|
|
|
|
// Not from an external interface
|
|
|
|
/**
|
|
* Call this method once you've created a parser, and want to instruct it
|
|
* about what charset to load
|
|
*
|
|
* @param aCharset the charset of a document
|
|
* @param aCharsetSource the source of the charset
|
|
*/
|
|
inline void SetDocumentCharset(const nsACString& aCharset, int32_t aSource) {
|
|
NS_PRECONDITION(mStreamState == STREAM_NOT_STARTED,
|
|
"SetDocumentCharset called too late.");
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
mCharset = aCharset;
|
|
mCharsetSource = aSource;
|
|
}
|
|
|
|
inline void SetObserver(nsIRequestObserver* aObserver) {
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
mObserver = aObserver;
|
|
}
|
|
|
|
nsresult GetChannel(nsIChannel** aChannel);
|
|
|
|
/**
|
|
* The owner parser must call this after script execution
|
|
* when no scripts are executing and the document.written
|
|
* buffer has been exhausted.
|
|
*/
|
|
void ContinueAfterScripts(nsHtml5Tokenizer* aTokenizer,
|
|
nsHtml5TreeBuilder* aTreeBuilder,
|
|
bool aLastWasCR);
|
|
|
|
/**
|
|
* Continues the stream parser if the charset switch failed.
|
|
*/
|
|
void ContinueAfterFailedCharsetSwitch();
|
|
|
|
void Terminate()
|
|
{
|
|
mozilla::MutexAutoLock autoLock(mTerminatedMutex);
|
|
mTerminated = true;
|
|
}
|
|
|
|
void DropTimer();
|
|
|
|
/**
|
|
* Sets mCharset and mCharsetSource appropriately for the XML View Source
|
|
* case if aEncoding names a supported rough ASCII superset and sets
|
|
* the mCharset and mCharsetSource to the UTF-8 default otherwise.
|
|
*/
|
|
void SetEncodingFromExpat(const char16_t* aEncoding);
|
|
|
|
/**
|
|
* Sets the URL for View Source title in case this parser ends up being
|
|
* used for View Source. If aURL is a view-source: URL, takes the inner
|
|
* URL. data: URLs are shown with an ellipsis instead of the actual data.
|
|
*/
|
|
void SetViewSourceTitle(nsIURI* aURL);
|
|
|
|
private:
|
|
virtual ~nsHtml5StreamParser();
|
|
|
|
#ifdef DEBUG
|
|
bool IsParserThread() {
|
|
bool ret;
|
|
mThread->IsOnCurrentThread(&ret);
|
|
return ret;
|
|
}
|
|
#endif
|
|
|
|
void MarkAsBroken(nsresult aRv);
|
|
|
|
/**
|
|
* Marks the stream parser as interrupted. If you ever add calls to this
|
|
* method, be sure to review Uninterrupt usage very, very carefully to
|
|
* avoid having a previous in-flight runnable cancel your Interrupt()
|
|
* call on the other thread too soon.
|
|
*/
|
|
void Interrupt()
|
|
{
|
|
mozilla::MutexAutoLock autoLock(mTerminatedMutex);
|
|
mInterrupted = true;
|
|
}
|
|
|
|
void Uninterrupt()
|
|
{
|
|
NS_ASSERTION(IsParserThread(), "Wrong thread!");
|
|
mTokenizerMutex.AssertCurrentThreadOwns();
|
|
// Not acquiring mTerminatedMutex because mTokenizerMutex is already
|
|
// held at this point and is already stronger.
|
|
mInterrupted = false;
|
|
}
|
|
|
|
/**
|
|
* Flushes the tree ops from the tree builder and disarms the flush
|
|
* timer.
|
|
*/
|
|
void FlushTreeOpsAndDisarmTimer();
|
|
|
|
void ParseAvailableData();
|
|
|
|
void DoStopRequest();
|
|
|
|
void DoDataAvailable(const uint8_t* aBuffer, uint32_t aLength);
|
|
|
|
static NS_METHOD CopySegmentsToParser(nsIInputStream *aInStream,
|
|
void *aClosure,
|
|
const char *aFromSegment,
|
|
uint32_t aToOffset,
|
|
uint32_t aCount,
|
|
uint32_t *aWriteCount);
|
|
|
|
bool IsTerminatedOrInterrupted()
|
|
{
|
|
mozilla::MutexAutoLock autoLock(mTerminatedMutex);
|
|
return mTerminated || mInterrupted;
|
|
}
|
|
|
|
bool IsTerminated()
|
|
{
|
|
mozilla::MutexAutoLock autoLock(mTerminatedMutex);
|
|
return mTerminated;
|
|
}
|
|
|
|
/**
|
|
* True when there is a Unicode decoder already
|
|
*/
|
|
inline bool HasDecoder()
|
|
{
|
|
return !!mUnicodeDecoder;
|
|
}
|
|
|
|
/**
|
|
* Push bytes from network when there is no Unicode decoder yet
|
|
*/
|
|
nsresult SniffStreamBytes(const uint8_t* aFromSegment,
|
|
uint32_t aCount,
|
|
uint32_t* aWriteCount);
|
|
|
|
/**
|
|
* Push bytes from network when there is a Unicode decoder already
|
|
*/
|
|
nsresult WriteStreamBytes(const uint8_t* aFromSegment,
|
|
uint32_t aCount,
|
|
uint32_t* aWriteCount);
|
|
|
|
/**
|
|
* Check whether every other byte in the sniffing buffer is zero.
|
|
*/
|
|
void SniffBOMlessUTF16BasicLatin(const uint8_t* aFromSegment,
|
|
uint32_t aCountToSniffingLimit);
|
|
|
|
/**
|
|
* <meta charset> scan failed. Try chardet if applicable. After this, the
|
|
* the parser will have some encoding even if a last resolt fallback.
|
|
*
|
|
* @param aFromSegment The current network buffer or null if the sniffing
|
|
* buffer is being flushed due to network stream ending.
|
|
* @param aCount The number of bytes in aFromSegment (ignored if
|
|
* aFromSegment is null)
|
|
* @param aWriteCount Return value for how many bytes got read from the
|
|
* buffer.
|
|
* @param aCountToSniffingLimit The number of unfilled slots in
|
|
* mSniffingBuffer
|
|
*/
|
|
nsresult FinalizeSniffing(const uint8_t* aFromSegment,
|
|
uint32_t aCount,
|
|
uint32_t* aWriteCount,
|
|
uint32_t aCountToSniffingLimit);
|
|
|
|
/**
|
|
* Set up the Unicode decoder and write the sniffing buffer into it
|
|
* followed by the current network buffer.
|
|
*
|
|
* @param aFromSegment The current network buffer or null if the sniffing
|
|
* buffer is being flushed due to network stream ending.
|
|
* @param aCount The number of bytes in aFromSegment (ignored if
|
|
* aFromSegment is null)
|
|
* @param aWriteCount Return value for how many bytes got read from the
|
|
* buffer.
|
|
*/
|
|
nsresult SetupDecodingAndWriteSniffingBufferAndCurrentSegment(const uint8_t* aFromSegment,
|
|
uint32_t aCount,
|
|
uint32_t* aWriteCount);
|
|
|
|
/**
|
|
* Initialize the Unicode decoder, mark the BOM as the source and
|
|
* drop the sniffer.
|
|
*
|
|
* @param aDecoderCharsetName The name for the decoder's charset
|
|
* (UTF-16BE, UTF-16LE or UTF-8; the BOM has
|
|
* been swallowed)
|
|
*/
|
|
nsresult SetupDecodingFromBom(const char* aDecoderCharsetName);
|
|
|
|
/**
|
|
* Become confident or resolve and encoding name to its preferred form.
|
|
* @param aEncoding the value of an internal encoding decl. Acts as an
|
|
* out param, too, when the method returns true.
|
|
* @return true if the parser needs to start using the new value of
|
|
* aEncoding and false if the parser became confident or if
|
|
* the encoding name did not specify a usable encoding
|
|
*/
|
|
bool PreferredForInternalEncodingDecl(nsACString& aEncoding);
|
|
|
|
/**
|
|
* Callback for mFlushTimer.
|
|
*/
|
|
static void TimerCallback(nsITimer* aTimer, void* aClosure);
|
|
|
|
/**
|
|
* Parser thread entry point for (maybe) flushing the ops and posting
|
|
* a flush runnable back on the main thread.
|
|
*/
|
|
void TimerFlush();
|
|
|
|
/**
|
|
* Called when speculation fails.
|
|
*/
|
|
void MaybeDisableFutureSpeculation()
|
|
{
|
|
mSpeculationFailureCount++;
|
|
}
|
|
|
|
/**
|
|
* Used to check whether we're getting too many speculation failures and
|
|
* should just stop trying. The 100 is picked pretty randomly to be not too
|
|
* small (so most pages are not affected) but small enough that we don't end
|
|
* up with failed speculations over and over in pathological cases.
|
|
*/
|
|
bool IsSpeculationEnabled()
|
|
{
|
|
return mSpeculationFailureCount < 100;
|
|
}
|
|
|
|
nsCOMPtr<nsIRequest> mRequest;
|
|
nsCOMPtr<nsIRequestObserver> mObserver;
|
|
|
|
/**
|
|
* The document title to use if this turns out to be a View Source parser.
|
|
*/
|
|
nsCString mViewSourceTitle;
|
|
|
|
/**
|
|
* The Unicode decoder
|
|
*/
|
|
nsCOMPtr<nsIUnicodeDecoder> mUnicodeDecoder;
|
|
|
|
/**
|
|
* The buffer for sniffing the character encoding
|
|
*/
|
|
nsAutoArrayPtr<uint8_t> mSniffingBuffer;
|
|
|
|
/**
|
|
* The number of meaningful bytes in mSniffingBuffer
|
|
*/
|
|
uint32_t mSniffingLength;
|
|
|
|
/**
|
|
* BOM sniffing state
|
|
*/
|
|
eBomState mBomState;
|
|
|
|
/**
|
|
* <meta> prescan implementation
|
|
*/
|
|
nsAutoPtr<nsHtml5MetaScanner> mMetaScanner;
|
|
|
|
// encoding-related stuff
|
|
/**
|
|
* The source (confidence) of the character encoding in use
|
|
*/
|
|
int32_t mCharsetSource;
|
|
|
|
/**
|
|
* The character encoding in use
|
|
*/
|
|
nsCString mCharset;
|
|
|
|
/**
|
|
* Whether reparse is forbidden
|
|
*/
|
|
bool mReparseForbidden;
|
|
|
|
// Portable parser objects
|
|
/**
|
|
* The first buffer in the pending UTF-16 buffer queue
|
|
*/
|
|
RefPtr<nsHtml5OwningUTF16Buffer> mFirstBuffer;
|
|
|
|
/**
|
|
* The last buffer in the pending UTF-16 buffer queue
|
|
*/
|
|
nsHtml5OwningUTF16Buffer* mLastBuffer; // weak ref; always points to
|
|
// a buffer of the size NS_HTML5_STREAM_PARSER_READ_BUFFER_SIZE
|
|
|
|
/**
|
|
* The tree operation executor
|
|
*/
|
|
nsHtml5TreeOpExecutor* mExecutor;
|
|
|
|
/**
|
|
* The HTML5 tree builder
|
|
*/
|
|
nsAutoPtr<nsHtml5TreeBuilder> mTreeBuilder;
|
|
|
|
/**
|
|
* The HTML5 tokenizer
|
|
*/
|
|
nsAutoPtr<nsHtml5Tokenizer> mTokenizer;
|
|
|
|
/**
|
|
* Makes sure the main thread can't mess the tokenizer state while it's
|
|
* tokenizing. This mutex also protects the current speculation.
|
|
*/
|
|
mozilla::Mutex mTokenizerMutex;
|
|
|
|
/**
|
|
* The scoped atom table
|
|
*/
|
|
nsHtml5AtomTable mAtomTable;
|
|
|
|
/**
|
|
* The owner parser.
|
|
*/
|
|
RefPtr<nsHtml5Parser> mOwner;
|
|
|
|
/**
|
|
* Whether the last character tokenized was a carriage return (for CRLF)
|
|
*/
|
|
bool mLastWasCR;
|
|
|
|
/**
|
|
* For tracking stream life cycle
|
|
*/
|
|
eHtml5StreamState mStreamState;
|
|
|
|
/**
|
|
* Whether we are speculating.
|
|
*/
|
|
bool mSpeculating;
|
|
|
|
/**
|
|
* Whether the tokenizer has reached EOF. (Reset when stream rewinded.)
|
|
*/
|
|
bool mAtEOF;
|
|
|
|
/**
|
|
* The speculations. The mutex protects the nsTArray itself.
|
|
* To access the queue of current speculation, mTokenizerMutex must be
|
|
* obtained.
|
|
* The current speculation is the last element
|
|
*/
|
|
nsTArray<nsAutoPtr<nsHtml5Speculation> > mSpeculations;
|
|
mozilla::Mutex mSpeculationMutex;
|
|
|
|
/**
|
|
* Number of times speculation has failed for this parser.
|
|
*/
|
|
uint32_t mSpeculationFailureCount;
|
|
|
|
/**
|
|
* True to terminate early; protected by mTerminatedMutex
|
|
*/
|
|
bool mTerminated;
|
|
bool mInterrupted;
|
|
mozilla::Mutex mTerminatedMutex;
|
|
|
|
/**
|
|
* The thread this stream parser runs on.
|
|
*/
|
|
nsCOMPtr<nsIThread> mThread;
|
|
|
|
nsCOMPtr<nsIRunnable> mExecutorFlusher;
|
|
|
|
nsCOMPtr<nsIRunnable> mLoadFlusher;
|
|
|
|
/**
|
|
* The chardet instance if chardet is enabled.
|
|
*/
|
|
nsCOMPtr<nsICharsetDetector> mChardet;
|
|
|
|
/**
|
|
* If false, don't push data to chardet.
|
|
*/
|
|
bool mFeedChardet;
|
|
|
|
/**
|
|
* Whether the initial charset source was kCharsetFromParentFrame
|
|
*/
|
|
bool mInitialEncodingWasFromParentFrame;
|
|
|
|
/**
|
|
* Timer for flushing tree ops once in a while when not speculating.
|
|
*/
|
|
nsCOMPtr<nsITimer> mFlushTimer;
|
|
|
|
/**
|
|
* Keeps track whether mFlushTimer has been armed. Unfortunately,
|
|
* nsITimer doesn't enable querying this from the timer itself.
|
|
*/
|
|
bool mFlushTimerArmed;
|
|
|
|
/**
|
|
* False initially and true after the timer has fired at least once.
|
|
*/
|
|
bool mFlushTimerEverFired;
|
|
|
|
/**
|
|
* Whether the parser is doing a normal parse, view source or plain text.
|
|
*/
|
|
eParserMode mMode;
|
|
|
|
/**
|
|
* The pref html5.flushtimer.initialdelay: Time in milliseconds between
|
|
* the time a network buffer is seen and the timer firing when the
|
|
* timer hasn't fired previously in this parse.
|
|
*/
|
|
static int32_t sTimerInitialDelay;
|
|
|
|
/**
|
|
* The pref html5.flushtimer.subsequentdelay: Time in milliseconds between
|
|
* the time a network buffer is seen and the timer firing when the
|
|
* timer has already fired previously in this parse.
|
|
*/
|
|
static int32_t sTimerSubsequentDelay;
|
|
};
|
|
|
|
#endif // nsHtml5StreamParser_h
|