mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 11:57:32 +09:00
Bug 1422931 - Fix crash with slot element and make webcomponents preference per-doc
Tag #1375
This commit is contained in:
parent
6d8e6e8955
commit
3b90312fac
11 changed files with 45 additions and 5 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#include "nsIAnonymousContentCreator.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsCSSAnonBoxes.h"
|
||||
#include "nsDocument.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
|
@ -66,7 +67,8 @@ ExplicitChildIterator::ExplicitChildIterator(const nsIContent* aParent,
|
|||
mIsFirst(aStartAtBeginning),
|
||||
mIndexInInserted(0)
|
||||
{
|
||||
mParentAsSlot = HTMLSlotElement::FromContent(mParent);
|
||||
mParentAsSlot = nsDocument::IsWebComponentsEnabled(mParent) ?
|
||||
HTMLSlotElement::FromContent(mParent) : nullptr;
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
|
|
|
|||
6
dom/base/crashtests/1422931.html
Normal file
6
dom/base/crashtests/1422931.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<!-- Testing slot element with "dom.webcomponents.enabled" set to false -->
|
||||
<slot><div></div></slot>
|
||||
</html>
|
||||
|
|
@ -211,3 +211,4 @@ load 1304437.html
|
|||
pref(clipboard.autocopy,true) load 1385272-1.html
|
||||
pref(dom.webcomponents.customelements.enabled,true) load 1341693.html
|
||||
pref(dom.webcomponents.enabled,true) load 1419799.html
|
||||
pref(dom.webcomponents.enabled,false) load 1422931.html
|
||||
|
|
|
|||
|
|
@ -7034,7 +7034,7 @@ nsContentUtils::IsContentInsertionPoint(nsIContent* aContent)
|
|||
bool
|
||||
nsContentUtils::HasDistributedChildren(nsIContent* aContent)
|
||||
{
|
||||
if (!aContent) {
|
||||
if (!aContent || !nsDocument::IsWebComponentsEnabled(aContent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1332,6 +1332,10 @@ nsIDocument::nsIDocument()
|
|||
{
|
||||
SetIsInDocument();
|
||||
|
||||
// Set this when document is created and value stays the same for the lifetime
|
||||
// of the document.
|
||||
mIsWebComponentsEnabled = nsContentUtils::IsWebComponentsEnabled();
|
||||
|
||||
PR_INIT_CLIST(&mDOMMediaQueryLists);
|
||||
}
|
||||
|
||||
|
|
@ -5685,6 +5689,12 @@ nsDocument::IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject)
|
|||
return IsWebComponentsEnabled(window);
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocument::IsWebComponentsEnabled(const nsINode* aNode)
|
||||
{
|
||||
return aNode->OwnerDoc()->IsWebComponentsEnabled();
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocument::IsWebComponentsEnabled(dom::NodeInfo* aNodeInfo)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -793,7 +793,6 @@ public:
|
|||
|
||||
virtual void NotifyLayerManagerRecreated() override;
|
||||
|
||||
|
||||
private:
|
||||
void AddOnDemandBuiltInUASheet(mozilla::StyleSheet* aSheet);
|
||||
nsRadioGroupStruct* GetRadioGroupInternal(const nsAString& aName) const;
|
||||
|
|
@ -1383,6 +1382,9 @@ protected:
|
|||
public:
|
||||
// Check whether web components are enabled for the global of aObject.
|
||||
static bool IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject);
|
||||
// Check whether web components are enabled for the document this node belongs
|
||||
// to.
|
||||
static bool IsWebComponentsEnabled(const nsINode* aNode);
|
||||
// Check whether web components are enabled for the global of the document
|
||||
// this nodeinfo comes from.
|
||||
static bool IsWebComponentsEnabled(mozilla::dom::NodeInfo* aNodeInfo);
|
||||
|
|
|
|||
|
|
@ -2885,6 +2885,11 @@ public:
|
|||
--mThrowOnDynamicMarkupInsertionCounter;
|
||||
}
|
||||
|
||||
bool IsWebComponentsEnabled() const
|
||||
{
|
||||
return mIsWebComponentsEnabled;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool GetUseCounter(mozilla::UseCounter aUseCounter)
|
||||
{
|
||||
|
|
@ -3028,6 +3033,9 @@ protected:
|
|||
// container for per-context fonts (downloadable, SVG, etc.)
|
||||
RefPtr<mozilla::dom::FontFaceSet> mFontFaceSet;
|
||||
|
||||
// True if dom.webcomponents.enabled pref is set when document is created.
|
||||
bool mIsWebComponentsEnabled : 1;
|
||||
|
||||
// Compatibility mode
|
||||
nsCompatibility mCompatMode;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#ifdef DEBUG
|
||||
#include "nsRange.h"
|
||||
#endif
|
||||
#include "nsDocument.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
|
@ -155,6 +156,12 @@ void nsTextNode::UnbindFromTree(bool aDeep, bool aNullParent)
|
|||
nsGenericDOMDataNode::UnbindFromTree(aDeep, aNullParent);
|
||||
}
|
||||
|
||||
bool
|
||||
nsTextNode::IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject)
|
||||
{
|
||||
return nsDocument::IsWebComponentsEnabled(aCx, aObject);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
nsTextNode::List(FILE* out, int32_t aIndent) const
|
||||
|
|
|
|||
|
|
@ -75,6 +75,10 @@ public:
|
|||
|
||||
virtual nsIDOMNode* AsDOMNode() override { return this; }
|
||||
|
||||
// Need to have a copy here because including nsDocument.h in this file will
|
||||
// fail to build on Windows.
|
||||
static bool IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject);
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual void List(FILE* out, int32_t aIndent) const override;
|
||||
virtual void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const override;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ NS_NewHTMLSlotElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
|||
mozilla::dom::FromParser aFromParser)
|
||||
{
|
||||
RefPtr<mozilla::dom::NodeInfo> nodeInfo(aNodeInfo);
|
||||
if (nsDocument::IsWebComponentsEnabled(nodeInfo)) {
|
||||
if (nsDocument::IsWebComponentsEnabled(nodeInfo->GetDocument())) {
|
||||
already_AddRefed<mozilla::dom::NodeInfo> nodeInfoArg(nodeInfo.forget());
|
||||
return new mozilla::dom::HTMLSlotElement(nodeInfoArg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ interface Text : CharacterData {
|
|||
};
|
||||
|
||||
partial interface Text {
|
||||
[BinaryName="assignedSlotByMode", Pref="dom.webcomponents.enabled"]
|
||||
[BinaryName="assignedSlotByMode", Func="nsTextNode::IsWebComponentsEnabled"]
|
||||
readonly attribute HTMLSlotElement? assignedSlot;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue