Issue #1118 - Part 5: Change the way document.open() works

This changes the work we do for document.open() in the following ways:
- We no longer create a new Window when doing document.open().
  We use the same Window but remove all the event listeners on the
  existing DOM tree and Window before removing the document's existing
  children to provide a clean slate document to use for .write().
- We no longer create a session history entry (previously would be a
  wyciwyg URI). We now replace the current one, effectively losing the
  entry for the original document.
- We now support document.open() on windowless documents.
This commit is contained in:
wolfbeast 2019-12-22 19:57:30 +01:00 committed by Roy Tam
commit fc5d61608c
9 changed files with 400 additions and 297 deletions

View file

@ -109,6 +109,8 @@ public:
unsigned long mNotifyMask;
};
void SetDocumentOpenedButNotLoaded() { mDocumentOpenedButNotLoaded = true; }
protected:
virtual ~nsDocLoader();
@ -302,6 +304,15 @@ protected:
bool mIsFlushingLayout;
private:
/**
* This flag indicates that the loader is waiting for completion of
* a document.open-triggered "document load". This is set when
* document.open() happens and sets up a new parser and cleared out
* when we go to fire our load event or end up with a new document
* channel.
*/
bool mDocumentOpenedButNotLoaded;
static const PLDHashTableOps sRequestInfoHashOps;
// A list of kids that are in the middle of their onload calls and will let
@ -324,10 +335,20 @@ private:
nsRequestInfo *GetRequestInfo(nsIRequest* aRequest);
void ClearRequestInfoHash();
int64_t CalculateMaxProgress();
/// void DumpChannelInfo(void);
/// void DumpChannelInfo(void);
// used to clear our internal progress state between loads...
void ClearInternalProgress();
/**
* Used to test whether we might need to fire a load event. This
* can happen when we have a document load going on, or when we've
* had document.open() called and haven't fired the corresponding
* load event yet.
*/
bool IsBlockingLoadEvent() const {
return mIsLoadingDocument || mDocumentOpenedButNotLoaded;
}
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsDocLoader, NS_THIS_DOCLOADER_IMPL_CID)