diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-03-30 09:44:21 +0200 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-03-30 09:44:21 +0200 |
commit | a1a007a4856fa50d6d811c2268f881e3666f4c67 (patch) | |
tree | 24b082c1bfb5777f1770c82a534bf765160bc1b8 /dom/base | |
parent | eddd0de2ae80e176011f41a5400e81522d53f4f3 (diff) | |
parent | 59bf4204a84f7638d3f89a29bc7c04e5dc401369 (diff) | |
download | UXP-a1a007a4856fa50d6d811c2268f881e3666f4c67.tar UXP-a1a007a4856fa50d6d811c2268f881e3666f4c67.tar.gz UXP-a1a007a4856fa50d6d811c2268f881e3666f4c67.tar.lz UXP-a1a007a4856fa50d6d811c2268f881e3666f4c67.tar.xz UXP-a1a007a4856fa50d6d811c2268f881e3666f4c67.zip |
Merge branch 'master' of https://github.com/MoonchildProductions/UXP into html_input_datetime_1
Diffstat (limited to 'dom/base')
29 files changed, 377 insertions, 86 deletions
diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 886acc670..9ced64c0d 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -165,10 +165,9 @@ nsIContent::DoGetID() const } const nsAttrValue* -nsIContent::DoGetClasses() const +Element::DoGetClasses() const { MOZ_ASSERT(HasFlag(NODE_MAY_HAVE_CLASS), "Unexpected call"); - MOZ_ASSERT(IsElement(), "Only elements can have classes"); if (IsSVGElement()) { const nsAttrValue* animClass = @@ -178,7 +177,7 @@ nsIContent::DoGetClasses() const } } - return AsElement()->GetParsedAttr(nsGkAtoms::_class); + return GetParsedAttr(nsGkAtoms::_class); } NS_IMETHODIMP diff --git a/dom/base/Element.h b/dom/base/Element.h index 5d878df60..cf1d197e2 100644 --- a/dom/base/Element.h +++ b/dom/base/Element.h @@ -544,6 +544,18 @@ public: virtual uint32_t GetAttrCount() const override; virtual bool IsNodeOfType(uint32_t aFlags) const override; + /** + * Get the class list of this element (this corresponds to the value of the + * class attribute). This may be null if there are no classes, but that's not + * guaranteed (e.g. we could have class=""). + */ + const nsAttrValue* GetClasses() const { + if (HasFlag(NODE_MAY_HAVE_CLASS)) { + return DoGetClasses(); + } + return nullptr; + } + #ifdef DEBUG virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override { @@ -1372,6 +1384,12 @@ protected: private: /** + * Hook for implementing GetClasses. This is guaranteed to only be + * called if the NODE_MAY_HAVE_CLASS flag is set. + */ + const nsAttrValue* DoGetClasses() const; + + /** * Get this element's client area rect in app units. * @return the frame's client area */ diff --git a/dom/base/File.cpp b/dom/base/File.cpp index 46b37b976..8602a3064 100644..100755 --- a/dom/base/File.cpp +++ b/dom/base/File.cpp @@ -29,6 +29,7 @@ #include "nsStringStream.h" #include "nsJSUtils.h" #include "nsPrintfCString.h" +#include "mozilla/TimerClamping.h" #include "mozilla/SHA1.h" #include "mozilla/CheckedInt.h" #include "mozilla/Preferences.h" @@ -727,7 +728,7 @@ BlobImplBase::GetLastModified(ErrorResult& aRv) mLastModificationDate = PR_Now(); } - return mLastModificationDate / PR_USEC_PER_MSEC; + return TimerClamping::ReduceUsTimeValue(mLastModificationDate) / PR_USEC_PER_MSEC; } void diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index 293177ce7..79f6cff51 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -574,6 +574,9 @@ FragmentOrElement::nsDOMSlots::Traverse(nsCycleCollectionTraversalCallback &cb, NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mChildrenList"); cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIDOMNodeList*, mChildrenList)); + NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mLabelsList"); + cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIDOMNodeList*, mLabelsList)); + NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mClassList"); cb.NoteXPCOMChild(mClassList.get()); @@ -602,6 +605,7 @@ FragmentOrElement::nsDOMSlots::Unlink(bool aIsXUL) mShadowRoot = nullptr; mContainingShadow = nullptr; mChildrenList = nullptr; + mLabelsList = nullptr; mCustomElementData = nullptr; mClassList = nullptr; } @@ -1827,7 +1831,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(FragmentOrElement) } nsAutoString classes; - const nsAttrValue* classAttrValue = tmp->GetClasses(); + const nsAttrValue* classAttrValue = tmp->IsElement() ? + tmp->AsElement()->GetClasses() : nullptr; if (classAttrValue) { classes.AppendLiteral(" class='"); nsAutoString classString; diff --git a/dom/base/FragmentOrElement.h b/dom/base/FragmentOrElement.h index 3cb5575fe..1cd8033bb 100644 --- a/dom/base/FragmentOrElement.h +++ b/dom/base/FragmentOrElement.h @@ -24,6 +24,7 @@ class ContentUnbinder; class nsContentList; +class nsLabelsNodeList; class nsDOMAttributeMap; class nsDOMTokenList; class nsIControllers; @@ -313,6 +314,11 @@ public: */ RefPtr<nsDOMTokenList> mClassList; + /* + * An object implementing the .labels property for this element. + */ + RefPtr<nsLabelsNodeList> mLabelsList; + /** * ShadowRoot bound to the element. */ diff --git a/dom/base/MultipartBlobImpl.cpp b/dom/base/MultipartBlobImpl.cpp index ba26d07f9..03bb62add 100644..100755 --- a/dom/base/MultipartBlobImpl.cpp +++ b/dom/base/MultipartBlobImpl.cpp @@ -17,6 +17,7 @@ #include "nsContentUtils.h" #include "nsIScriptError.h" #include "nsIXPConnect.h" +#include "mozilla/TimerClamping.h" #include <algorithm> using namespace mozilla; @@ -270,8 +271,7 @@ MultipartBlobImpl::SetLengthAndModifiedDate(ErrorResult& aRv) // var x = new Date(); var f = new File(...); // x.getTime() < f.dateModified.getTime() // could fail. - mLastModificationDate = - lastModifiedSet ? lastModified * PR_USEC_PER_MSEC : JS_Now(); + mLastModificationDate = TimerClamping::ReduceUsTimeValue(lastModifiedSet ? lastModified * PR_USEC_PER_MSEC : JS_Now()); } } diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 290af152b..5c315517c 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -97,8 +97,10 @@ #endif #include "mozilla/dom/ContentChild.h" +#ifdef MOZ_EME #include "mozilla/EMEUtils.h" #include "mozilla/DetailedPromise.h" +#endif namespace mozilla { namespace dom { @@ -214,7 +216,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Navigator) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mServiceWorkerContainer) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow) +#ifdef MOZ_EME NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaKeySystemAccessManager) +#endif NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPresentation) #ifdef MOZ_GAMEPAD NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGamepadServiceTest) @@ -288,10 +292,12 @@ Navigator::Invalidate() mServiceWorkerContainer = nullptr; +#ifdef MOZ_EME if (mMediaKeySystemAccessManager) { mMediaKeySystemAccessManager->Shutdown(); mMediaKeySystemAccessManager = nullptr; } +#endif #ifdef MOZ_GAMEPAD if (mGamepadServiceTest) { @@ -1854,16 +1860,6 @@ Navigator::GetUserAgent(nsPIDOMWindowInner* aWindow, nsIURI* aURI, { MOZ_ASSERT(NS_IsMainThread()); - if (!aIsCallerChrome) { - const nsAdoptingString& override = - mozilla::Preferences::GetString("general.useragent.override"); - - if (override) { - aUserAgent = override; - return NS_OK; - } - } - nsresult rv; nsCOMPtr<nsIHttpProtocolHandler> service(do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http", &rv)); @@ -1894,6 +1890,7 @@ Navigator::GetUserAgent(nsPIDOMWindowInner* aWindow, nsIURI* aURI, return siteSpecificUA->GetUserAgentForURIAndWindow(aURI, aWindow, aUserAgent); } +#ifdef MOZ_EME static nsCString ToCString(const nsString& aString) { @@ -2019,6 +2016,7 @@ Navigator::RequestMediaKeySystemAccess(const nsAString& aKeySystem, mMediaKeySystemAccessManager->Request(promise, aKeySystem, aConfigs); return promise.forget(); } +#endif Presentation* Navigator::GetPresentation(ErrorResult& aRv) diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index 4b4ae6759..d47a80bc1 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -18,7 +18,9 @@ #include "nsString.h" #include "nsTArray.h" #include "nsWeakPtr.h" +#ifdef MOZ_EME #include "mozilla/dom/MediaKeySystemAccessManager.h" +#endif class nsPluginArray; class nsMimeTypeArray; @@ -258,12 +260,14 @@ public: // any, else null. static already_AddRefed<nsPIDOMWindowInner> GetWindowFromGlobal(JSObject* aGlobal); +#ifdef MOZ_EME already_AddRefed<Promise> RequestMediaKeySystemAccess(const nsAString& aKeySystem, const Sequence<MediaKeySystemConfiguration>& aConfig, ErrorResult& aRv); private: RefPtr<MediaKeySystemAccessManager> mMediaKeySystemAccessManager; +#endif public: void NotifyVRDisplaysUpdated(); diff --git a/dom/base/TimerClamping.cpp b/dom/base/TimerClamping.cpp new file mode 100755 index 000000000..70639686b --- /dev/null +++ b/dom/base/TimerClamping.cpp @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* 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/. */ + +#include "TimerClamping.h" + +namespace mozilla { + +/* static */ +double +TimerClamping::ReduceSTimeValue(double aTime) +{ + static const double maxResolutionS = .002; + return floor(aTime / maxResolutionS) * maxResolutionS; +} + +/* static */ +double +TimerClamping::ReduceMsTimeValue(double aTime) +{ + static const double maxResolutionMs = 2; + return floor(aTime / maxResolutionMs) * maxResolutionMs; +} + +/* static */ +double +TimerClamping::ReduceUsTimeValue(double aTime) +{ + static const double maxResolutionUs = 2000; + return floor(aTime / maxResolutionUs) * maxResolutionUs; +} + +}
\ No newline at end of file diff --git a/dom/base/TimerClamping.h b/dom/base/TimerClamping.h new file mode 100755 index 000000000..2ffd6add5 --- /dev/null +++ b/dom/base/TimerClamping.h @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* 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 TimerClamping_h___ +#define TimerClamping_h___ + +namespace mozilla { + +class TimerClamping +{ +public: + static double ReduceSTimeValue(double aTime); + static double ReduceMsTimeValue(double aTime); + static double ReduceUsTimeValue(double aTime); +}; + +} + +#endif /* TimerClamping_h___ */
\ No newline at end of file diff --git a/dom/base/moz.build b/dom/base/moz.build index 0bc9902e4..0fb345d22 100644..100755 --- a/dom/base/moz.build +++ b/dom/base/moz.build @@ -143,6 +143,7 @@ EXPORTS.mozilla += [ 'CORSMode.h', 'FeedWriterEnabled.h', 'TextInputProcessor.h', + 'TimerClamping.h', 'UseCounter.h', ] @@ -363,6 +364,7 @@ UNIFIED_SOURCES += [ 'TextInputProcessor.cpp', 'ThirdPartyUtil.cpp', 'Timeout.cpp', + 'TimerClamping.cpp', 'TreeWalker.cpp', 'WebKitCSSMatrix.cpp', 'WebSocket.cpp', @@ -411,7 +413,7 @@ EXTRA_COMPONENTS += [ ] # Firefox for Android provides an alternate version of this component -if CONFIG['MOZ_BUILD_APP'] != 'mobile/android': +if not CONFIG['MOZ_FENNEC']: EXTRA_COMPONENTS += [ 'SiteSpecificUserAgent.js', 'SiteSpecificUserAgent.manifest', @@ -472,7 +474,7 @@ include('/ipc/chromium/chromium-config.mozbuild') FINAL_LIBRARY = 'xul' -if CONFIG['MOZ_BUILD_APP'] in ['mobile/android', 'xulrunner'] or CONFIG['MOZ_PHOENIX']: +if CONFIG['MOZ_PHOENIX'] or CONFIG['MOZ_FENNEC'] or CONFIG['MOZ_XULRUNNER']: DEFINES['HAVE_SIDEBAR'] = True if CONFIG['MOZ_X11']: diff --git a/dom/base/nsContentList.cpp b/dom/base/nsContentList.cpp index 09e949009..43e65777d 100644 --- a/dom/base/nsContentList.cpp +++ b/dom/base/nsContentList.cpp @@ -254,19 +254,6 @@ const nsCacheableFuncStringContentList::ContentListType nsCacheableFuncStringHTMLCollection::sType = nsCacheableFuncStringContentList::eHTMLCollection; #endif -JSObject* -nsCacheableFuncStringNodeList::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) -{ - return NodeListBinding::Wrap(cx, this, aGivenProto); -} - - -JSObject* -nsCacheableFuncStringHTMLCollection::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) -{ - return HTMLCollectionBinding::Wrap(cx, this, aGivenProto); -} - // Hashtable for storing nsCacheableFuncStringContentList static PLDHashTable* gFuncStringContentListHashTable; @@ -379,6 +366,7 @@ NS_GetFuncStringHTMLCollection(nsINode* aRootNode, aString); } +//----------------------------------------------------- // nsContentList implementation nsContentList::nsContentList(nsINode* aRootNode, @@ -660,7 +648,7 @@ nsContentList::AttributeChanged(nsIDocument *aDocument, Element* aElement, const nsAttrValue* aOldValue) { NS_PRECONDITION(aElement, "Must have a content node to work with"); - + if (!mFunc || !mFuncMayDependOnAttr || mState == LIST_DIRTY || !MayContainRelevantNodes(aElement->GetParentNode()) || !nsContentUtils::IsInSameAnonymousTree(mRootNode, aElement)) { @@ -806,7 +794,7 @@ nsContentList::ContentInserted(nsIDocument *aDocument, ASSERT_IN_SYNC; } - + void nsContentList::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, @@ -1075,3 +1063,128 @@ nsContentList::AssertInSync() NS_ASSERTION(cnt == mElements.Length(), "Too few elements"); } #endif + +//----------------------------------------------------- +// nsCacheableFuncStringNodeList + +JSObject* +nsCacheableFuncStringNodeList::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) +{ + return NodeListBinding::Wrap(cx, this, aGivenProto); +} + +//----------------------------------------------------- +// nsCacheableFuncStringHTMLCollection + +JSObject* +nsCacheableFuncStringHTMLCollection::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) +{ + return HTMLCollectionBinding::Wrap(cx, this, aGivenProto); +} + +//----------------------------------------------------- +// nsLabelsNodeList + +JSObject* +nsLabelsNodeList::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) +{ + return NodeListBinding::Wrap(cx, this, aGivenProto); +} + +void +nsLabelsNodeList::AttributeChanged(nsIDocument* aDocument, Element* aElement, + int32_t aNameSpaceID, nsIAtom* aAttribute, + int32_t aModType, + const nsAttrValue* aOldValue) +{ + MOZ_ASSERT(aElement, "Must have a content node to work with"); + if (mState == LIST_DIRTY || + !nsContentUtils::IsInSameAnonymousTree(mRootNode, aElement)) { + return; + } + + // We need to handle input type changes to or from "hidden". + if (aElement->IsHTMLElement(nsGkAtoms::input) && + aAttribute == nsGkAtoms::type && aNameSpaceID == kNameSpaceID_None) { + SetDirty(); + return; + } +} + +void +nsLabelsNodeList::ContentAppended(nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aFirstNewContent, + int32_t aNewIndexInContainer) +{ + // If a labelable element is moved to outside or inside of + // nested associated labels, we're gonna have to modify + // the content list. + if (mState != LIST_DIRTY || + nsContentUtils::IsInSameAnonymousTree(mRootNode, aContainer)) { + SetDirty(); + return; + } +} + +void +nsLabelsNodeList::ContentInserted(nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aChild, + int32_t aIndexInContainer) +{ + // If a labelable element is moved to outside or inside of + // nested associated labels, we're gonna have to modify + // the content list. + if (mState != LIST_DIRTY || + nsContentUtils::IsInSameAnonymousTree(mRootNode, aChild)) { + SetDirty(); + return; + } +} + +void +nsLabelsNodeList::ContentRemoved(nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aChild, + int32_t aIndexInContainer, + nsIContent* aPreviousSibling) +{ + // If a labelable element is removed, we're gonna have to clean + // the content list. + if (mState != LIST_DIRTY || + nsContentUtils::IsInSameAnonymousTree(mRootNode, aChild)) { + SetDirty(); + return; + } +} + +void +nsLabelsNodeList::MaybeResetRoot(nsINode* aRootNode) +{ + MOZ_ASSERT(aRootNode, "Must have root"); + if (mRootNode == aRootNode) { + return; + } + + if (mRootNode) { + mRootNode->RemoveMutationObserver(this); + } + mRootNode = aRootNode; + mRootNode->AddMutationObserver(this); + SetDirty(); +} + +void +nsLabelsNodeList::PopulateSelf(uint32_t aNeededLength) +{ + MOZ_ASSERT(mRootNode, "Must have root"); + + // Start searching at the root. + nsINode* cur = mRootNode; + if (mElements.IsEmpty() && cur->IsElement() && Match(cur->AsElement())) { + mElements.AppendElement(cur->AsElement()); + } + + nsContentList::PopulateSelf(aNeededLength); +} diff --git a/dom/base/nsContentList.h b/dom/base/nsContentList.h index 3878074b2..83d27da95 100644 --- a/dom/base/nsContentList.h +++ b/dom/base/nsContentList.h @@ -371,9 +371,9 @@ protected: * traversed the whole document (or both). * * @param aNeededLength the length the list should have when we are - * done (unless it exhausts the document) + * done (unless it exhausts the document) */ - void PopulateSelf(uint32_t aNeededLength); + virtual void PopulateSelf(uint32_t aNeededLength); /** * @param aContainer a content node which must be a descendant of @@ -584,4 +584,40 @@ public: #endif }; +class nsLabelsNodeList final : public nsContentList +{ +public: + nsLabelsNodeList(nsINode* aRootNode, + nsContentListMatchFunc aFunc, + nsContentListDestroyFunc aDestroyFunc, + void* aData) + : nsContentList(aRootNode, aFunc, aDestroyFunc, aData) + { + } + + NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED + + virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override; + + /** + * Reset root, mutation observer, and clear content list + * if the root has been changed. + * + * @param aRootNode The node under which to limit our search. + */ + void MaybeResetRoot(nsINode* aRootNode); + +private: + /** + * Start searching at the last one if we already have nodes, otherwise + * start searching at the root. + * + * @param aNeededLength The list of length should have when we are + * done (unless it exhausts the document). + */ + void PopulateSelf(uint32_t aNeededLength) override; +}; #endif // nsContentList_h___ diff --git a/dom/base/nsContentListDeclarations.h b/dom/base/nsContentListDeclarations.h index db3a09036..a5e0e3691 100644 --- a/dom/base/nsContentListDeclarations.h +++ b/dom/base/nsContentListDeclarations.h @@ -18,6 +18,12 @@ class nsINode; class nsString; class nsAString; +namespace mozilla { +namespace dom { +class Element; +} // namespace dom +} // namespace mozilla + // Magic namespace id that means "match all namespaces". This is // negative so it won't collide with actual namespace constants. #define kNameSpaceID_Wildcard INT32_MIN @@ -26,7 +32,7 @@ class nsAString; // arbitrary matching algorithm. aContent is the content that may // match the list, while aNamespaceID, aAtom, and aData are whatever // was passed to the list's constructor. -typedef bool (*nsContentListMatchFunc)(nsIContent* aContent, +typedef bool (*nsContentListMatchFunc)(mozilla::dom::Element* aElement, int32_t aNamespaceID, nsIAtom* aAtom, void* aData); diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 1cc352685..02c6bf1de 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -6287,11 +6287,11 @@ struct ClassMatchingInfo { // static bool -nsContentUtils::MatchClassNames(nsIContent* aContent, int32_t aNamespaceID, +nsContentUtils::MatchClassNames(Element* aElement, int32_t aNamespaceID, nsIAtom* aAtom, void* aData) { // We can't match if there are no class names - const nsAttrValue* classAttr = aContent->GetClasses(); + const nsAttrValue* classAttr = aElement->GetClasses(); if (!classAttr) { return false; } diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index f688eeecf..0a293d73e 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -2753,7 +2753,8 @@ private: static void DropFragmentParsers(); - static bool MatchClassNames(nsIContent* aContent, int32_t aNamespaceID, + static bool MatchClassNames(mozilla::dom::Element* aElement, + int32_t aNamespaceID, nsIAtom* aAtom, void* aData); static void DestroyClassNameArray(void* aData); static void* AllocClassMatchingInfo(nsINode* aRootNode, diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 8e6920a0e..eaea49b02 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -61,6 +61,7 @@ #include "nsGenericHTMLElement.h" #include "mozilla/dom/CDATASection.h" #include "mozilla/dom/ProcessingInstruction.h" +#include "nsDSURIContentListener.h" #include "nsDOMString.h" #include "nsNodeUtils.h" #include "nsLayoutUtils.h" // for GetFrameForPoint @@ -2456,6 +2457,15 @@ nsDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel, NS_ENSURE_SUCCESS(rv, rv); } + // XFO needs to be checked after CSP because it is ignored if + // the CSP defines frame-ancestors. + if (!nsDSURIContentListener::CheckFrameOptions(aChannel, docShell, NodePrincipal())) { + MOZ_LOG(gCspPRLog, LogLevel::Debug, + ("XFO doesn't like frame's ancestry, not loading.")); + // stop! ERROR page! + aChannel->Cancel(NS_ERROR_CSP_FRAME_ANCESTOR_VIOLATION); + } + return NS_OK; } @@ -4330,6 +4340,7 @@ nsDocument::SetScopeObject(nsIGlobalObject* aGlobal) } } +#ifdef MOZ_EME static void CheckIfContainsEMEContent(nsISupports* aSupports, void* aContainsEME) { @@ -4353,6 +4364,7 @@ nsDocument::ContainsEMEContent() static_cast<void*>(&containsEME)); return containsEME; } +#endif // MOZ_EME static void CheckIfContainsMSEContent(nsISupports* aSupports, void* aContainsMSE) @@ -8380,11 +8392,13 @@ nsDocument::CanSavePresentation(nsIRequest *aNewRequest) } #endif // MOZ_WEBRTC +#ifdef MOZ_EME // Don't save presentations for documents containing EME content, so that // CDMs reliably shutdown upon user navigation. if (ContainsEMEContent()) { return false; } +#endif // Don't save presentations for documents containing MSE content, to // reduce memory usage. diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h index 17d936055..3725b3c18 100644 --- a/dom/base/nsDocument.h +++ b/dom/base/nsDocument.h @@ -1267,7 +1267,9 @@ public: js::ExpandoAndGeneration mExpandoAndGeneration; +#ifdef MOZ_EME bool ContainsEMEContent(); +#endif bool ContainsMSEContent(); @@ -1491,7 +1493,6 @@ private: void PostUnblockOnloadEvent(); void DoUnblockOnload(); - nsresult CheckFrameOptions(); nsresult InitCSP(nsIChannel* aChannel); /** diff --git a/dom/base/nsDocumentEncoder.cpp b/dom/base/nsDocumentEncoder.cpp index 0a3570962..84b128b15 100644 --- a/dom/base/nsDocumentEncoder.cpp +++ b/dom/base/nsDocumentEncoder.cpp @@ -481,7 +481,7 @@ nsDocumentEncoder::SerializeToStringRecursive(nsINode* aNode, } if (!aDontSerializeRoot) { - rv = SerializeNodeEnd(node, aStr); + rv = SerializeNodeEnd(maybeFixedNode, aStr); NS_ENSURE_SUCCESS(rv, rv); } diff --git a/dom/base/nsGkAtomList.h b/dom/base/nsGkAtomList.h index 0b76b2bea..e4ae7ede8 100644 --- a/dom/base/nsGkAtomList.h +++ b/dom/base/nsGkAtomList.h @@ -526,6 +526,7 @@ GK_ATOM(keytext, "keytext") GK_ATOM(keyup, "keyup") GK_ATOM(kind, "kind") GK_ATOM(label, "label") +GK_ATOM(labels, "labels") GK_ATOM(lang, "lang") GK_ATOM(language, "language") GK_ATOM(last, "last") @@ -950,6 +951,7 @@ GK_ATOM(onupdateready, "onupdateready") GK_ATOM(onupgradeneeded, "onupgradeneeded") GK_ATOM(onussdreceived, "onussdreceived") GK_ATOM(onversionchange, "onversionchange") +GK_ATOM(onvisibilitychange, "onvisibilitychange") GK_ATOM(onvoicechange, "onvoicechange") GK_ATOM(onvoiceschanged, "onvoiceschanged") GK_ATOM(onvrdisplayconnect, "onvrdisplayconnect") @@ -1449,6 +1451,7 @@ GK_ATOM(font_style, "font-style") GK_ATOM(font_variant, "font-variant") GK_ATOM(foreignObject, "foreignObject") GK_ATOM(fractalNoise, "fractalNoise") +GK_ATOM(fr, "fr") GK_ATOM(fx, "fx") GK_ATOM(fy, "fy") GK_ATOM(G, "G") diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 8ff4b84ce..f784031f6 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -6187,7 +6187,7 @@ nsGlobalWindow::GetScrollMaxY(ErrorResult& aError) FORWARD_TO_OUTER_OR_THROW(GetScrollBoundaryOuter, (eSideBottom), aError, 0); } -CSSIntPoint +CSSPoint nsGlobalWindow::GetScrollXY(bool aDoFlush) { MOZ_ASSERT(IsOuterWindow()); @@ -6211,30 +6211,30 @@ nsGlobalWindow::GetScrollXY(bool aDoFlush) return GetScrollXY(true); } - return sf->GetScrollPositionCSSPixels(); + return CSSPoint::FromAppUnits(scrollPos); } -int32_t +double nsGlobalWindow::GetScrollXOuter() { MOZ_RELEASE_ASSERT(IsOuterWindow()); return GetScrollXY(false).x; } -int32_t +double nsGlobalWindow::GetScrollX(ErrorResult& aError) { FORWARD_TO_OUTER_OR_THROW(GetScrollXOuter, (), aError, 0); } -int32_t +double nsGlobalWindow::GetScrollYOuter() { MOZ_RELEASE_ASSERT(IsOuterWindow()); return GetScrollXY(false).y; } -int32_t +double nsGlobalWindow::GetScrollY(ErrorResult& aError) { FORWARD_TO_OUTER_OR_THROW(GetScrollYOuter, (), aError, 0); diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index eab91c2e4..dbceeab74 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -1050,15 +1050,15 @@ public: void SetInnerHeight(JSContext* aCx, JS::Handle<JS::Value> aValue, mozilla::dom::CallerType aCallerType, mozilla::ErrorResult& aError); - int32_t GetScrollXOuter(); - int32_t GetScrollX(mozilla::ErrorResult& aError); - int32_t GetPageXOffset(mozilla::ErrorResult& aError) + double GetScrollXOuter(); + double GetScrollX(mozilla::ErrorResult& aError); + double GetPageXOffset(mozilla::ErrorResult& aError) { return GetScrollX(aError); } - int32_t GetScrollYOuter(); - int32_t GetScrollY(mozilla::ErrorResult& aError); - int32_t GetPageYOffset(mozilla::ErrorResult& aError) + double GetScrollYOuter(); + double GetScrollY(mozilla::ErrorResult& aError); + double GetPageYOffset(mozilla::ErrorResult& aError) { return GetScrollY(aError); } @@ -1579,7 +1579,7 @@ public: // If aDoFlush is true, we'll flush our own layout; otherwise we'll try to // just flush our parent and only flush ourselves if we think we need to. // Outer windows only. - mozilla::CSSIntPoint GetScrollXY(bool aDoFlush); + mozilla::CSSPoint GetScrollXY(bool aDoFlush); int32_t GetScrollBoundaryOuter(mozilla::Side aSide); diff --git a/dom/base/nsIContent.h b/dom/base/nsIContent.h index f05c47a61..405090865 100644 --- a/dom/base/nsIContent.h +++ b/dom/base/nsIContent.h @@ -862,18 +862,6 @@ public: } /** - * Get the class list of this content node (this corresponds to the - * value of the class attribute). This may be null if there are no - * classes, but that's not guaranteed. - */ - const nsAttrValue* GetClasses() const { - if (HasFlag(NODE_MAY_HAVE_CLASS)) { - return DoGetClasses(); - } - return nullptr; - } - - /** * Walk aRuleWalker over the content style rules (presentational * hint rules) for this content node. */ @@ -990,13 +978,6 @@ protected: */ nsIAtom* DoGetID() const; -private: - /** - * Hook for implementing GetClasses. This is guaranteed to only be - * called if the NODE_MAY_HAVE_CLASS flag is set. - */ - const nsAttrValue* DoGetClasses() const; - public: #ifdef DEBUG /** diff --git a/dom/base/nsPluginArray.cpp b/dom/base/nsPluginArray.cpp index b9c946ca3..5b9378ae0 100644 --- a/dom/base/nsPluginArray.cpp +++ b/dom/base/nsPluginArray.cpp @@ -372,9 +372,21 @@ nsPluginArray::EnsurePlugins() nsCString permString; nsresult rv = pluginHost->GetPermissionStringForTag(pluginTag, 0, permString); if (rv == NS_OK) { - nsIPrincipal* principal = mWindow->GetExtantDoc()->NodePrincipal(); - nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager(); - permMgr->TestPermissionFromPrincipal(principal, permString.get(), &permission); + nsCOMPtr<nsIDocument> currentDoc = mWindow->GetExtantDoc(); + + // The top-level content document gets the final say on whether or not + // a plugin is going to be hidden or not, regardless of the origin + // that a subframe is hosted at. This is to avoid spamming the user + // with the hidden plugin notification bar when third-party iframes + // attempt to access navigator.plugins after the user has already + // expressed that the top-level document has this permission. + nsCOMPtr<nsIDocument> topDoc = currentDoc->GetTopLevelContentDocument(); + + if (topDoc) { + nsIPrincipal* principal = topDoc->NodePrincipal(); + nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager(); + permMgr->TestPermissionFromPrincipal(principal, permString.get(), &permission); + } } } } diff --git a/dom/base/nsXHTMLContentSerializer.cpp b/dom/base/nsXHTMLContentSerializer.cpp index 0dc31d7ae..111ed46c7 100644..100755 --- a/dom/base/nsXHTMLContentSerializer.cpp +++ b/dom/base/nsXHTMLContentSerializer.cpp @@ -306,7 +306,7 @@ nsXHTMLContentSerializer::SerializeAttributes(nsIContent* aContent, continue; } - BorrowedAttrInfo info = aContent->GetAttrInfoAt(index); + mozilla::dom::BorrowedAttrInfo info = aContent->GetAttrInfoAt(index); const nsAttrName* name = info.mName; int32_t namespaceID = name->NamespaceID(); diff --git a/dom/base/test/test_bug1375050.html b/dom/base/test/test_bug1375050.html new file mode 100644 index 000000000..b91b859d0 --- /dev/null +++ b/dom/base/test/test_bug1375050.html @@ -0,0 +1,33 @@ +<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1375050
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 1375050</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+ try { o1 = document.createElement('input'); } catch(e) { console.log(e); };
+ try { o2 = document.createElement('col'); } catch(e) { console.log(e); };
+ try { o4 = document.createRange(); } catch(e) { console.log(e); };
+ try { document.documentElement.appendChild(o1); } catch(e) { console.log(e); };
+ try { for (let p in o1) { let x = o1[p] }; } catch(e) { console.log(e); };
+ try { o4.selectNode(o1); } catch(e) { console.log(e); };
+ try { o6 = document.createComment(" x"); } catch(e) { console.log(e); }
+ try { o4.surroundContents(o6); } catch(e) { console.log(e); }
+ try { o7 = document.implementation.createDocument('', '', null).adoptNode(o1); } catch(e) { console.log(e);};
+ try { o2.appendChild(o1); } catch(e) { console.log(e); };
+ ok(true, "Didn't crash.");
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1375050">Mozilla Bug 1375050</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/base/test/test_bug403852.html b/dom/base/test/test_bug403852.html index 30192cb1b..592711500 100644 --- a/dom/base/test/test_bug403852.html +++ b/dom/base/test/test_bug403852.html @@ -38,7 +38,8 @@ function onOpened(message) { ok("lastModifiedDate" in domFile, "lastModifiedDate must be present"); var d = new Date(message.mtime); - is(d.getTime(), domFile.lastModifiedDate.getTime(), "lastModifiedDate should be the same"); + // Commented out: lastModifiedDate is rounded because it is a DOM API, message is a special-powers Chrome thing + // is(d.getTime(), domFile.lastModifiedDate.getTime(), "lastModifiedDate should be the same"); var x = new Date(); @@ -53,8 +54,8 @@ function onOpened(message) { ok((x.getTime() <= y.getTime()) && (y.getTime() <= z.getTime()), "lastModifiedDate of file which does not have last modified date should be current time"); - var d = new Date(message.fileDate); - is(d.getTime(), message.fileWithDate.lastModifiedDate.getTime(), "lastModifiedDate should be the same when lastModified is set: " + message.fileWithDate.lastModified); + // var d = new Date(message.fileDate); + // is(d.getTime(), message.fileWithDate.lastModifiedDate.getTime(), "lastModifiedDate should be the same when lastModified is set: " + message.fileWithDate.lastModified); script.destroy(); SimpleTest.finish(); diff --git a/dom/base/test/test_file_negative_date.html b/dom/base/test/test_file_negative_date.html index ebfa9bd0d..26cf3b82e 100644 --- a/dom/base/test/test_file_negative_date.html +++ b/dom/base/test/test_file_negative_date.html @@ -22,13 +22,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1158437 var blob = new Blob(['hello world']); var f1 = new File([blob], 'f1.txt', { lastModified: 0 }); -var f2 = new File([blob], 'f2.txt', { lastModified: -1 }); +var f2 = new File([blob], 'f2.txt', { lastModified: -2 }); var f3 = new File([blob], 'f3.txt', { lastModified: -1000 }); is(f1.lastModified, 0, "lastModified == 0 is supported"); ok(f1.lastModifiedDate.toString(), (new Date(0)).toString(), "Correct f1.lastModifiedDate value"); -is(f2.lastModified, -1, "lastModified == -1 is supported"); -ok(f2.lastModifiedDate.toString(), (new Date(-1)).toString(), "Correct f2.lastModifiedDate value"); +is(f2.lastModified, -2, "lastModified == -2 is supported"); +ok(f2.lastModifiedDate.toString(), (new Date(-2)).toString(), "Correct f2.lastModifiedDate value"); is(f3.lastModified, -1000, "lastModified == -1000 is supported"); ok(f3.lastModifiedDate.toString(), (new Date(-1000)).toString(), "Correct f3.lastModifiedDate value"); diff --git a/dom/base/test/test_viewport_scroll.html b/dom/base/test/test_viewport_scroll.html index 9b812360b..7db02b781 100644 --- a/dom/base/test/test_viewport_scroll.html +++ b/dom/base/test/test_viewport_scroll.html @@ -28,10 +28,10 @@ function subtest(winProp, elemProp, win, correctElement, elemToSet, otherElem1, win.scrollTo(50, 50); elemToSet[elemProp] = 100; if (elemToSet == correctElement) { - is(win[winProp], 100, "Setting " + elemToSet.name + "." + elemProp + " should scroll"); + is(Math.round(win[winProp]), 100, "Setting " + elemToSet.name + "." + elemProp + " should scroll"); is(elemToSet[elemProp], 100, "Reading back " + elemToSet.name + "." + elemProp + " after scrolling"); } else { - is(win[winProp], 50, "Setting " + elemToSet.name + "." + elemProp + " should not scroll"); + is(Math.round(win[winProp]), 50, "Setting " + elemToSet.name + "." + elemProp + " should not scroll"); is(elemToSet[elemProp], 0, "Reading back " + elemToSet.name + "." + elemProp + " after not scrolling"); } if (otherElem1 == correctElement) { |