2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
1998-04-14 00:24:54 +04:00
|
|
|
#ifndef nsHTMLDocument_h___
|
|
|
|
#define nsHTMLDocument_h___
|
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2018-12-26 05:35:30 +03:00
|
|
|
#include "nsContentList.h"
|
2019-01-02 16:05:23 +03:00
|
|
|
#include "mozilla/dom/Document.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIHTMLDocument.h"
|
2017-11-13 18:41:33 +03:00
|
|
|
#include "nsIHTMLCollection.h"
|
2006-01-24 04:25:14 +03:00
|
|
|
#include "nsIScriptElement.h"
|
2009-03-20 11:15:35 +03:00
|
|
|
#include "nsTArray.h"
|
2006-08-15 02:36:15 +04:00
|
|
|
|
2015-09-16 06:49:53 +03:00
|
|
|
#include "PLDHashTable.h"
|
2002-03-02 04:26:49 +03:00
|
|
|
#include "nsIHttpChannel.h"
|
2017-09-14 21:56:58 +03:00
|
|
|
#include "nsThreadUtils.h"
|
2013-02-08 16:20:11 +04:00
|
|
|
#include "mozilla/dom/HTMLSharedElement.h"
|
2016-11-15 08:18:33 +03:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2001-05-25 12:49:03 +04:00
|
|
|
|
2019-04-03 15:51:38 +03:00
|
|
|
class nsCommandManager;
|
2001-11-16 05:03:19 +03:00
|
|
|
class nsIURI;
|
2012-01-24 13:52:05 +04:00
|
|
|
class nsIDocShell;
|
2010-06-24 10:55:19 +04:00
|
|
|
class nsICachingChannel;
|
2013-06-11 04:18:29 +04:00
|
|
|
class nsILoadGroup;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2013-09-06 10:41:42 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class HTMLAllCollection;
|
2019-01-02 16:26:56 +03:00
|
|
|
template <typename T>
|
|
|
|
struct Nullable;
|
|
|
|
class WindowProxyHolder;
|
2013-09-06 10:41:42 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
class nsHTMLDocument : public mozilla::dom::Document, public nsIHTMLDocument {
|
|
|
|
protected:
|
2018-12-26 05:35:30 +03:00
|
|
|
typedef mozilla::net::ReferrerPolicy ReferrerPolicy;
|
2019-01-02 16:05:23 +03:00
|
|
|
typedef mozilla::dom::Document Document;
|
|
|
|
typedef mozilla::Encoding Encoding;
|
|
|
|
template <typename T>
|
|
|
|
using NotNull = mozilla::NotNull<T>;
|
2018-12-26 05:35:30 +03:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
public:
|
2019-01-02 16:05:23 +03:00
|
|
|
using Document::GetPlugins;
|
|
|
|
using Document::SetDocumentURI;
|
2011-03-26 19:06:27 +03:00
|
|
|
|
2013-05-06 17:42:00 +04:00
|
|
|
nsHTMLDocument();
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult Init() override;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2013-06-14 21:10:12 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2019-01-02 16:05:23 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLDocument, Document)
|
1998-07-23 03:32:19 +04:00
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
// Document
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) override;
|
2006-11-22 21:27:54 +03:00
|
|
|
virtual void ResetToURI(nsIURI* aURI, nsILoadGroup* aLoadGroup,
|
2019-04-11 22:48:49 +03:00
|
|
|
nsIPrincipal* aPrincipal) override;
|
2001-03-12 09:39:27 +03:00
|
|
|
|
2004-01-10 02:54:21 +03:00
|
|
|
virtual nsresult StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
|
|
|
|
nsILoadGroup* aLoadGroup,
|
|
|
|
nsISupports* aContainer,
|
|
|
|
nsIStreamListener** aDocListener,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aReset = true,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIContentSink* aSink = nullptr) override;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void BeginLoad() override;
|
|
|
|
virtual void EndLoad() override;
|
1998-07-24 02:06:05 +04:00
|
|
|
|
2019-02-24 19:32:08 +03:00
|
|
|
protected:
|
|
|
|
virtual bool UseWidthDeviceWidthFallbackViewport() const override;
|
|
|
|
|
|
|
|
public:
|
2013-06-12 10:55:00 +04:00
|
|
|
// nsIHTMLDocument
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void SetCompatibilityMode(nsCompatibility aMode) override;
|
1998-09-02 06:07:42 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual bool IsWriting() override { return mWriteLevel != uint32_t(0); }
|
2002-04-19 02:11:17 +04:00
|
|
|
|
2019-03-04 09:11:41 +03:00
|
|
|
virtual Element* GetUnfocusedKeyEventTarget() override;
|
2017-07-13 23:53:26 +03:00
|
|
|
|
2017-08-27 05:44:34 +03:00
|
|
|
nsContentList* GetExistingForms() const { return mForms; }
|
|
|
|
|
2014-02-09 12:02:45 +04:00
|
|
|
mozilla::dom::HTMLAllCollection* All();
|
2010-05-10 20:43:20 +04:00
|
|
|
|
2016-12-09 20:02:50 +03:00
|
|
|
// Returns whether an object was found for aName.
|
|
|
|
bool ResolveName(JSContext* aCx, const nsAString& aName,
|
|
|
|
JS::MutableHandle<JS::Value> aRetval,
|
|
|
|
mozilla::ErrorResult& aError);
|
2013-05-30 00:43:41 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void AddedForm() override;
|
|
|
|
virtual void RemovedForm() override;
|
|
|
|
virtual int32_t GetNumFormsSynchronous() override;
|
2017-08-07 08:25:52 +03:00
|
|
|
virtual void TearingDownEditor() override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void SetIsXHTML(bool aXHTML) override {
|
2014-05-24 23:28:48 +04:00
|
|
|
mType = (aXHTML ? eXHTML : eHTML);
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void SetDocWriteDisabled(bool aDisabled) override {
|
2009-11-06 07:27:30 +03:00
|
|
|
mDisableDocWrite = aDisabled;
|
|
|
|
}
|
2003-04-19 04:28:09 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
nsresult ChangeContentEditableCount(nsIContent* aElement,
|
|
|
|
int32_t aChange) override;
|
2010-05-13 02:21:24 +04:00
|
|
|
void DeferredContentEditableCountChange(nsIContent* aElement);
|
2007-06-28 06:48:16 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual EditingState GetEditingState() override { return mEditingState; }
|
2007-06-28 06:48:16 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DisableCookieAccess() override { mDisableCookieAccess = true; }
|
2008-10-01 04:49:30 +04:00
|
|
|
|
2008-09-18 06:32:44 +04:00
|
|
|
class nsAutoEditingState {
|
|
|
|
public:
|
|
|
|
nsAutoEditingState(nsHTMLDocument* aDoc, EditingState aState)
|
|
|
|
: mDoc(aDoc), mSavedState(aDoc->mEditingState) {
|
|
|
|
aDoc->mEditingState = aState;
|
|
|
|
}
|
|
|
|
~nsAutoEditingState() { mDoc->mEditingState = mSavedState; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2008-09-18 06:32:44 +04:00
|
|
|
private:
|
|
|
|
nsHTMLDocument* mDoc;
|
|
|
|
EditingState mSavedState;
|
|
|
|
};
|
|
|
|
friend class nsAutoEditingState;
|
2008-02-19 21:47:34 +03:00
|
|
|
|
2018-05-15 16:56:38 +03:00
|
|
|
void EndUpdate() override;
|
2007-10-26 14:30:44 +04:00
|
|
|
|
2017-03-15 07:22:06 +03:00
|
|
|
virtual void SetMayStartLayout(bool aMayStartLayout) override;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult SetEditingState(EditingState aState) override;
|
2008-04-24 01:36:17 +04:00
|
|
|
|
2018-08-09 02:58:44 +03:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo*,
|
|
|
|
nsINode** aResult) const override;
|
2008-09-18 15:15:47 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void RemovedFromDocShell() override;
|
2017-12-21 01:29:21 +03:00
|
|
|
using mozilla::dom::DocumentOrShadowRoot::GetElementById;
|
2010-04-19 19:41:38 +04:00
|
|
|
|
2017-08-10 07:13:22 +03:00
|
|
|
virtual void DocAddSizeOfExcludingThis(
|
|
|
|
nsWindowSizes& aWindowSizes) const override;
|
2019-01-02 16:05:23 +03:00
|
|
|
// DocAddSizeOfIncludingThis is inherited from Document.
|
2012-02-02 01:58:01 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool WillIgnoreCharsetOverride() override;
|
2013-01-18 18:27:03 +04:00
|
|
|
|
2012-12-26 06:00:47 +04:00
|
|
|
// WebIDL API
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2018-01-26 09:00:04 +03:00
|
|
|
void GetDomain(nsAString& aDomain);
|
2012-12-26 06:00:47 +04:00
|
|
|
void SetDomain(const nsAString& aDomain, mozilla::ErrorResult& rv);
|
2017-03-07 19:37:34 +03:00
|
|
|
bool IsRegistrableDomainSuffixOfOrEqualTo(const nsAString& aHostSuffixString,
|
|
|
|
const nsACString& aOrigHost);
|
2012-12-26 06:00:47 +04:00
|
|
|
void GetCookie(nsAString& aCookie, mozilla::ErrorResult& rv);
|
|
|
|
void SetCookie(const nsAString& aCookie, mozilla::ErrorResult& rv);
|
2014-06-12 00:26:52 +04:00
|
|
|
void NamedGetter(JSContext* cx, const nsAString& aName, bool& aFound,
|
|
|
|
JS::MutableHandle<JSObject*> aRetval,
|
2016-12-09 20:02:50 +03:00
|
|
|
mozilla::ErrorResult& rv) {
|
|
|
|
JS::Rooted<JS::Value> v(cx);
|
|
|
|
if ((aFound = ResolveName(cx, aName, &v, rv))) {
|
|
|
|
aRetval.set(v.toObjectOrNull());
|
|
|
|
}
|
|
|
|
}
|
2016-05-10 05:25:40 +03:00
|
|
|
void GetSupportedNames(nsTArray<nsString>& aNames);
|
2019-02-27 08:12:13 +03:00
|
|
|
Document* Open(const mozilla::dom::Optional<nsAString>& /* unused */,
|
Bug 1489308 part 5. Align the work we do on document.open with the spec. r=mccr8,smaug
The main behavior changes are:
1) We no longer create a new Window when doing document.open(). We use the
same Window but remove all the event listeners on it and on the existing DOM
tree before removing the document's existing kids.
2) We no longer create a new session history entry. The existing one always
gets replaced instead.
3) We now support document.open on documents that are not in a Window.
The reasons for the various test changes are as follows:
The change to browser_modifiedclick_inherit_principal.js is because we no
longer set the docshell to a wyciwyg URL when document.open() happens and the
test was depending on that to terminate.
browser_wyciwyg_urlbarCopying.js is being removed because it's trying to test
wyciwyg URIs, which no longer exist.
The changes in docshell/test/navigation are because document.open() no longer
affects session history. One of the tests was testing the interactions there
and is being removed; another is being repurposed to just test that
document.open() does not affect history.length.
The change to test_x-frame-options.html is because document.open() now removes
event listeners on the window, which it didn't use to do (and in the specific
case in this test reused the existing inner too, so the listener was still
around in practice). The new behavior matches other browsers.
The removal of test_bug172261.html is because document.open() no longer affects
session history, so you can't go back across it or forward to the "opened"
state, so the situation that test is trying to test no longer exists.
The changes to test_bug255820.html are because reloading a document after
document.open() will now just load the URL of the document that was the entry
document for the open() call, not reload the written content. So there's not
much point testing reload behavior, and in this test it was just reloading the
toplevel test file inside the frames.
The change to test_bug346659.html is because now we no longer create a new
Window on document.open().
The change to test_bug1232829.html is because document.open() (implicit in this
test) no longer adds history entries, so the back() was just leaving the test
page instead of going back across the document.open(). The test is a
crashtest in practice, so might still be testing something useful about how
document.open() interacts with animations.
The change to test_bug715739.html is because the URL of the document after
document.open() is now the URL of the entry document, not a wyciwyg URL, so
reload() has different behavior than it used to.
The change to test_bug329869.html is because now when we go back we're
reloading the original document we had, not doing a wyciwyg load, and the
security info now doesn't include the untrusted script.
The changes to the wpt expectations are removing a bunch of expected failures
now that we pass those tests and disabling some tests that are fundamentally
racy and hence fail randomly. The latter all have github issues filed for the
test problem.
The change to testing/web-platform/tests/common/object-association.js is fixing
tests that were not matching the spec (and were failing in other browsers).
The change to parser-uses-registry-of-owner-document.html is fixing tests that
were not matching the spec (and were failing in other browsers).
The change to document-write.tentative.html is because the test was buggy: it
was using the same iframe element for all its tests and racing loads from some
tests against API calls from other tests, etc. It's a wonder it ever managed
to pass, independent of these patches (and in fact it doesn't pass according to
wpt.fyi data, even in Firefox).
The changes in html/browsers/history/the-history-interface are because
document.open() no longer adds history entries. The test was failing in all
other browsers for the same reason.
The changes in html/browsers/history/the-location-interface are because
reloading a document.open()-created thing now loads the URL of the page that
was the entry document for the open() call. The test was failing in all other
browsers.
The change to reload_document_open_write.html is because we now reload the url
of the document that entered the script that called open() when we reload, not
the written content. Other browsers were failing this test too; Gecko with
the old document.open implementation was the only one that passed.
The change to http-refresh.py is to fix a test bug: it was not returning a
Content-Type header, so we were putting up helper app dialogs, etc.
The change to test_ext_contentscript.js is because we no create a new global
for document.open() calls. Kris Maglione OKed this part.
Differential Revision: https://phabricator.services.mozilla.com/D17323
--HG--
extra : moz-landing-system : lando
2019-02-28 02:24:48 +03:00
|
|
|
const nsAString& /* unused */, mozilla::ErrorResult& aError);
|
2019-01-02 16:26:56 +03:00
|
|
|
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> Open(
|
2019-02-27 08:12:13 +03:00
|
|
|
const nsAString& aURL, const nsAString& aName, const nsAString& aFeatures,
|
|
|
|
bool aReplace, mozilla::ErrorResult& rv);
|
2012-12-26 06:00:47 +04:00
|
|
|
void Close(mozilla::ErrorResult& rv);
|
2019-02-27 08:12:13 +03:00
|
|
|
void Write(const mozilla::dom::Sequence<nsString>& aText,
|
2012-12-26 06:00:47 +04:00
|
|
|
mozilla::ErrorResult& rv);
|
2019-02-27 08:12:13 +03:00
|
|
|
void Writeln(const mozilla::dom::Sequence<nsString>& aText,
|
2012-12-26 06:00:47 +04:00
|
|
|
mozilla::ErrorResult& rv);
|
2018-01-26 09:00:49 +03:00
|
|
|
void GetDesignMode(nsAString& aDesignMode);
|
2016-10-11 04:07:48 +03:00
|
|
|
void SetDesignMode(const nsAString& aDesignMode,
|
|
|
|
nsIPrincipal& aSubjectPrincipal, mozilla::ErrorResult& rv);
|
2016-10-03 11:34:14 +03:00
|
|
|
void SetDesignMode(const nsAString& aDesignMode,
|
|
|
|
const mozilla::Maybe<nsIPrincipal*>& aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& rv);
|
2019-03-27 00:57:12 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2012-12-26 06:00:47 +04:00
|
|
|
bool ExecCommand(const nsAString& aCommandID, bool aDoShowUI,
|
2017-02-01 23:43:36 +03:00
|
|
|
const nsAString& aValue, nsIPrincipal& aSubjectPrincipal,
|
2016-11-15 08:18:33 +03:00
|
|
|
mozilla::ErrorResult& rv);
|
2012-12-26 06:00:47 +04:00
|
|
|
bool QueryCommandEnabled(const nsAString& aCommandID,
|
2017-02-01 23:43:36 +03:00
|
|
|
nsIPrincipal& aSubjectPrincipal,
|
2012-12-26 06:00:47 +04:00
|
|
|
mozilla::ErrorResult& rv);
|
|
|
|
bool QueryCommandIndeterm(const nsAString& aCommandID,
|
|
|
|
mozilla::ErrorResult& rv);
|
|
|
|
bool QueryCommandState(const nsAString& aCommandID, mozilla::ErrorResult& rv);
|
2016-11-15 08:18:33 +03:00
|
|
|
bool QueryCommandSupported(const nsAString& aCommandID,
|
|
|
|
mozilla::dom::CallerType aCallerType);
|
2019-03-13 03:43:48 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2012-12-26 06:00:47 +04:00
|
|
|
void QueryCommandValue(const nsAString& aCommandID, nsAString& aValue,
|
|
|
|
mozilla::ErrorResult& rv);
|
2018-01-26 09:01:08 +03:00
|
|
|
void GetFgColor(nsAString& aFgColor);
|
|
|
|
void SetFgColor(const nsAString& aFgColor);
|
|
|
|
void GetLinkColor(nsAString& aLinkColor);
|
|
|
|
void SetLinkColor(const nsAString& aLinkColor);
|
|
|
|
void GetVlinkColor(nsAString& aAvlinkColor);
|
|
|
|
void SetVlinkColor(const nsAString& aVlinkColor);
|
|
|
|
void GetAlinkColor(nsAString& aAlinkColor);
|
|
|
|
void SetAlinkColor(const nsAString& aAlinkColor);
|
|
|
|
void GetBgColor(nsAString& aBgColor);
|
|
|
|
void SetBgColor(const nsAString& aBgColor);
|
2012-12-26 06:00:47 +04:00
|
|
|
void Clear() const {
|
|
|
|
// Deprecated
|
|
|
|
}
|
2018-01-26 09:01:16 +03:00
|
|
|
void CaptureEvents();
|
|
|
|
void ReleaseEvents();
|
2012-12-26 06:00:47 +04:00
|
|
|
// We're picking up GetLocation from Document
|
2016-09-16 10:18:18 +03:00
|
|
|
already_AddRefed<mozilla::dom::Location> GetLocation() const {
|
2019-01-02 16:05:23 +03:00
|
|
|
return Document::GetLocation();
|
2012-12-26 06:00:47 +04:00
|
|
|
}
|
|
|
|
|
2017-08-27 06:28:15 +03:00
|
|
|
static bool MatchFormControls(Element* aElement, int32_t aNamespaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAtom, void* aData);
|
2017-08-27 06:28:15 +03:00
|
|
|
|
2017-09-14 21:56:58 +03:00
|
|
|
void GetFormsAndFormControls(nsContentList** aFormList,
|
|
|
|
nsContentList** aFormControlList);
|
2018-07-10 11:09:59 +03:00
|
|
|
|
|
|
|
void UserInteractionForTesting();
|
|
|
|
|
Bug 1514940 - part 1: Forcibly disable new keyCode/charCode value of keypress events if the document is Confluence r=smaug,Ehsan,kmag
Old Confluence does not aware of conflated model keypress event (see UI Events
spec, https://w3c.github.io/uievents/#determine-keypress-keyCode).
Additionally, Confluence can be hosted with any domains. Therefore, we cannot
use blacklist to disable the conflated model keypress event only on it.
This patch checks whether current or parent document is Confluence with JS
module, called KeyPressEventModelCheckerChild. For kicking this module,
nsHTMLDocument dispatches an custom event, CheckKeyPressEventModel, when it
becomes editable only first time. Finally, if it's a Confluence instance, the
module let PresShell know that we need to use split model keypress event in it.
Differential Revision: https://phabricator.services.mozilla.com/D17907
--HG--
extra : moz-landing-system : lando
2019-02-05 14:35:43 +03:00
|
|
|
void SetKeyPressEventModel(uint16_t aKeyPressEventModel);
|
|
|
|
|
1998-08-28 19:55:31 +04:00
|
|
|
protected:
|
2014-07-09 01:23:16 +04:00
|
|
|
~nsHTMLDocument();
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult GetBodySize(int32_t* aWidth, int32_t* aHeight);
|
2000-08-16 05:04:52 +04:00
|
|
|
|
2002-03-24 02:13:20 +03:00
|
|
|
nsIContent* MatchId(nsIContent* aContent, const nsAString& aId);
|
1998-08-08 03:08:00 +04:00
|
|
|
|
2002-04-19 10:05:03 +04:00
|
|
|
static void DocumentWriteTerminationFunc(nsISupports* aRef);
|
2002-04-19 03:25:35 +04:00
|
|
|
|
2013-03-17 12:51:39 +04:00
|
|
|
already_AddRefed<nsIURI> GetDomainURI();
|
2017-03-07 19:37:34 +03:00
|
|
|
already_AddRefed<nsIURI> CreateInheritingURIForHost(
|
|
|
|
const nsACString& aHostString);
|
|
|
|
already_AddRefed<nsIURI> RegistrableDomainSuffixOfInternal(
|
|
|
|
const nsAString& aHostSuffixString, nsIURI* aOrigHost);
|
|
|
|
|
2019-02-27 08:12:13 +03:00
|
|
|
void WriteCommon(const nsAString& aText, bool aNewlineTerminate,
|
|
|
|
mozilla::ErrorResult& aRv);
|
2012-12-26 06:00:47 +04:00
|
|
|
// A version of WriteCommon used by WebIDL bindings
|
2019-02-27 08:12:13 +03:00
|
|
|
void WriteCommon(const mozilla::dom::Sequence<nsString>& aText,
|
2012-12-26 06:00:47 +04:00
|
|
|
bool aNewlineTerminate, mozilla::ErrorResult& rv);
|
1999-01-06 03:32:41 +03:00
|
|
|
|
2015-01-22 04:57:29 +03:00
|
|
|
// This should *ONLY* be used in GetCookie/SetCookie.
|
|
|
|
already_AddRefed<nsIChannel> CreateDummyChannelForCookies(
|
|
|
|
nsIURI* aCodebaseURI);
|
|
|
|
|
2008-10-29 23:12:24 +03:00
|
|
|
/**
|
|
|
|
* Like IsEditingOn(), but will flush as needed first.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsEditingOnAfterFlush();
|
2008-10-29 23:12:24 +03:00
|
|
|
|
2005-06-07 23:21:05 +04:00
|
|
|
void* GenerateParserKey(void);
|
|
|
|
|
2017-09-14 21:56:58 +03:00
|
|
|
// A helper class to keep nsContentList objects alive for a short period of
|
|
|
|
// time. Note, when the final Release is called on an nsContentList object, it
|
|
|
|
// removes itself from MutationObserver list.
|
|
|
|
class ContentListHolder : public mozilla::Runnable {
|
|
|
|
public:
|
|
|
|
ContentListHolder(nsHTMLDocument* aDocument, nsContentList* aFormList,
|
|
|
|
nsContentList* aFormControlList)
|
|
|
|
: mozilla::Runnable("ContentListHolder"),
|
|
|
|
mDocument(aDocument),
|
|
|
|
mFormList(aFormList),
|
|
|
|
mFormControlList(aFormControlList) {}
|
|
|
|
|
|
|
|
~ContentListHolder() {
|
|
|
|
MOZ_ASSERT(!mDocument->mContentListHolder ||
|
|
|
|
mDocument->mContentListHolder == this);
|
|
|
|
mDocument->mContentListHolder = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<nsHTMLDocument> mDocument;
|
|
|
|
RefPtr<nsContentList> mFormList;
|
|
|
|
RefPtr<nsContentList> mFormControlList;
|
|
|
|
};
|
|
|
|
|
|
|
|
friend class ContentListHolder;
|
|
|
|
ContentListHolder* mContentListHolder;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<mozilla::dom::HTMLAllCollection> mAll;
|
2013-06-12 10:55:00 +04:00
|
|
|
|
2002-07-17 02:38:51 +04:00
|
|
|
/** # of forms in the document, synchronously set */
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mNumForms;
|
2002-07-17 02:38:51 +04:00
|
|
|
|
2014-07-10 01:27:49 +04:00
|
|
|
static void TryHintCharset(nsIContentViewer* aContentViewer,
|
2013-01-18 18:27:03 +04:00
|
|
|
int32_t& aCharsetSource,
|
2017-06-18 14:37:50 +03:00
|
|
|
NotNull<const Encoding*>& aEncoding);
|
2014-07-10 01:27:49 +04:00
|
|
|
void TryUserForcedCharset(nsIContentViewer* aCv, nsIDocShell* aDocShell,
|
2013-01-18 18:27:03 +04:00
|
|
|
int32_t& aCharsetSource,
|
2017-06-18 14:37:50 +03:00
|
|
|
NotNull<const Encoding*>& aEncoding);
|
2013-01-18 18:27:03 +04:00
|
|
|
static void TryCacheCharset(nsICachingChannel* aCachingChannel,
|
2017-06-18 14:37:50 +03:00
|
|
|
int32_t& aCharsetSource,
|
|
|
|
NotNull<const Encoding*>& aEncoding);
|
2012-10-16 11:42:54 +04:00
|
|
|
void TryParentCharset(nsIDocShell* aDocShell, int32_t& charsetSource,
|
2017-06-18 14:37:50 +03:00
|
|
|
NotNull<const Encoding*>& aEncoding);
|
|
|
|
void TryTLD(int32_t& aCharsetSource, NotNull<const Encoding*>& aCharset);
|
2018-12-04 11:02:04 +03:00
|
|
|
static void TryFallback(int32_t& aCharsetSource,
|
|
|
|
NotNull<const Encoding*>& aEncoding);
|
2001-12-26 06:17:59 +03:00
|
|
|
|
Bug 1514940 - part 1: Forcibly disable new keyCode/charCode value of keypress events if the document is Confluence r=smaug,Ehsan,kmag
Old Confluence does not aware of conflated model keypress event (see UI Events
spec, https://w3c.github.io/uievents/#determine-keypress-keyCode).
Additionally, Confluence can be hosted with any domains. Therefore, we cannot
use blacklist to disable the conflated model keypress event only on it.
This patch checks whether current or parent document is Confluence with JS
module, called KeyPressEventModelCheckerChild. For kicking this module,
nsHTMLDocument dispatches an custom event, CheckKeyPressEventModel, when it
becomes editable only first time. Finally, if it's a Confluence instance, the
module let PresShell know that we need to use split model keypress event in it.
Differential Revision: https://phabricator.services.mozilla.com/D17907
--HG--
extra : moz-landing-system : lando
2019-02-05 14:35:43 +03:00
|
|
|
/**
|
|
|
|
* MaybeDispatchCheckKeyPressEventModelEvent() dispatches
|
|
|
|
* "CheckKeyPressEventModel" event to check whether we should dispatch
|
|
|
|
* keypress events in confluent model or split model. This should be
|
|
|
|
* called only when mEditingState is changed to eDesignMode or
|
|
|
|
* eConentEditable at first time.
|
|
|
|
*/
|
|
|
|
void MaybeDispatchCheckKeyPressEventModelEvent();
|
|
|
|
|
2006-01-24 04:25:14 +03:00
|
|
|
// Tracks if we are currently processing any document.write calls (either
|
|
|
|
// implicit or explicit). Note that if a write call writes out something which
|
|
|
|
// would block the parser, then mWriteLevel will be incorrect until the parser
|
|
|
|
// finishes processing that script.
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mWriteLevel;
|
2006-01-24 04:25:14 +03:00
|
|
|
|
2003-03-26 10:41:30 +03:00
|
|
|
// Load flags of the document's channel
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mLoadFlags;
|
2003-03-26 10:41:30 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mTooDeepWriteRecursion;
|
2007-02-11 03:30:20 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mDisableDocWrite;
|
2009-11-06 07:27:30 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mWarnedWidthHeight;
|
2010-08-27 15:44:28 +04:00
|
|
|
|
2002-11-07 18:36:25 +03:00
|
|
|
/* Midas implementation */
|
2019-04-03 15:51:38 +03:00
|
|
|
nsCommandManager* GetMidasCommandManager();
|
2008-01-14 12:26:22 +03:00
|
|
|
|
2019-04-03 15:51:38 +03:00
|
|
|
RefPtr<nsCommandManager> mMidasCommandManager;
|
2007-06-28 06:48:16 +04:00
|
|
|
|
|
|
|
nsresult TurnEditingOff();
|
2019-03-27 00:57:12 +03:00
|
|
|
// MOZ_CAN_RUN_SCRIPT_BOUNDARY because this is called from all sorts
|
|
|
|
// of places, and I'm pretty sure the exact ExecCommand call it
|
|
|
|
// makes cannot actually run script.
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult EditingStateChanged();
|
2009-01-31 15:53:01 +03:00
|
|
|
void MaybeEditingStateChanged();
|
2007-06-28 06:48:16 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mContentEditableCount;
|
2007-06-28 06:48:16 +04:00
|
|
|
EditingState mEditingState;
|
2002-11-07 18:36:25 +03:00
|
|
|
|
2008-10-01 04:49:30 +04:00
|
|
|
// When false, the .cookies property is completely disabled
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mDisableCookieAccess;
|
2013-03-23 03:08:59 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Temporary flag that is set in EndUpdate() to ignore
|
|
|
|
* MaybeEditingStateChanged() script runners from a nested scope.
|
|
|
|
*/
|
|
|
|
bool mPendingMaybeEditingStateChanged;
|
Bug 1514940 - part 1: Forcibly disable new keyCode/charCode value of keypress events if the document is Confluence r=smaug,Ehsan,kmag
Old Confluence does not aware of conflated model keypress event (see UI Events
spec, https://w3c.github.io/uievents/#determine-keypress-keyCode).
Additionally, Confluence can be hosted with any domains. Therefore, we cannot
use blacklist to disable the conflated model keypress event only on it.
This patch checks whether current or parent document is Confluence with JS
module, called KeyPressEventModelCheckerChild. For kicking this module,
nsHTMLDocument dispatches an custom event, CheckKeyPressEventModel, when it
becomes editable only first time. Finally, if it's a Confluence instance, the
module let PresShell know that we need to use split model keypress event in it.
Differential Revision: https://phabricator.services.mozilla.com/D17907
--HG--
extra : moz-landing-system : lando
2019-02-05 14:35:43 +03:00
|
|
|
|
|
|
|
// mHasBeenEditable is set to true when mEditingState is firstly set to
|
|
|
|
// eDesignMode or eContentEditable.
|
|
|
|
bool mHasBeenEditable;
|
2019-02-23 19:06:52 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set to true once we know that we are loading plain text content.
|
|
|
|
*/
|
|
|
|
bool mIsPlainText;
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
inline nsHTMLDocument* Document::AsHTMLDocument() {
|
2018-04-21 19:42:31 +03:00
|
|
|
MOZ_ASSERT(IsHTMLOrXHTML());
|
|
|
|
return static_cast<nsHTMLDocument*>(this);
|
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2008-11-03 13:31:47 +03:00
|
|
|
#define NS_HTML_DOCUMENT_INTERFACE_TABLE_BEGIN(_class) \
|
|
|
|
NS_DOCUMENT_INTERFACE_TABLE_BEGIN(_class) \
|
2018-01-26 09:03:25 +03:00
|
|
|
NS_INTERFACE_TABLE_ENTRY(_class, nsIHTMLDocument)
|
2008-11-03 13:31:47 +03:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
#endif /* nsHTMLDocument_h___ */
|