Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2023-04-08 07:34:30 +08:00
commit d27b63fc1c
10 changed files with 36 additions and 47 deletions

View file

@ -6695,6 +6695,25 @@ nsIDocument::SetDir(const nsAString& aDirection)
} }
} }
bool
nsIDocument::MatchNameAttribute(Element* aElement, int32_t aNamespaceID,
nsIAtom* aAtom, void* aData)
{
NS_PRECONDITION(aElement, "Must have element to work with!");
nsString* elementName = static_cast<nsString*>(aData);
return
aElement->GetNameSpaceID() == kNameSpaceID_XHTML &&
aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
*elementName, eCaseMatters);
}
/* static */
void*
nsIDocument::UseExistingNameString(nsINode* aRootNode, const nsString* aName)
{
return const_cast<nsString*>(aName);
}
NS_IMETHODIMP NS_IMETHODIMP
nsDocument::GetInputEncoding(nsAString& aInputEncoding) nsDocument::GetInputEncoding(nsAString& aInputEncoding)
{ {

View file

@ -2599,6 +2599,11 @@ public:
virtual void SetTitle(const nsAString& aTitle, mozilla::ErrorResult& rv) = 0; virtual void SetTitle(const nsAString& aTitle, mozilla::ErrorResult& rv) = 0;
void GetDir(nsAString& aDirection) const; void GetDir(nsAString& aDirection) const;
void SetDir(const nsAString& aDirection); void SetDir(const nsAString& aDirection);
already_AddRefed<nsContentList> GetElementsByName(const nsAString & aName)
{
return NS_GetFuncStringNodeList(this, MatchNameAttribute, nullptr,
UseExistingNameString, aName);
}
nsPIDOMWindowOuter* GetDefaultView() const nsPIDOMWindowOuter* GetDefaultView() const
{ {
return GetWindow(); return GetWindow();
@ -2883,6 +2888,12 @@ protected:
// the relevant refresh driver. // the relevant refresh driver.
void UpdateFrameRequestCallbackSchedulingState(nsIPresShell* aOldShell = nullptr); void UpdateFrameRequestCallbackSchedulingState(nsIPresShell* aOldShell = nullptr);
// Helpers for GetElementsByName.
static bool MatchNameAttribute(mozilla::dom::Element* aElement,
int32_t aNamespaceID,
nsIAtom* aAtom, void* aData);
static void* UseExistingNameString(nsINode* aRootNode, const nsString* aName);
nsCString mReferrer; nsCString mReferrer;
nsString mLastModified; nsString mLastModified;

View file

@ -1810,33 +1810,6 @@ nsHTMLDocument::Writeln(JSContext* cx, const Sequence<nsString>& aText,
WriteCommon(cx, aText, true, rv); WriteCommon(cx, aText, true, rv);
} }
bool
nsHTMLDocument::MatchNameAttribute(Element* aElement, int32_t aNamespaceID,
nsIAtom* aAtom, void* aData)
{
NS_PRECONDITION(aElement, "Must have element to work with!");
nsString* elementName = static_cast<nsString*>(aData);
return
aElement->GetNameSpaceID() == kNameSpaceID_XHTML &&
aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
*elementName, eCaseMatters);
}
/* static */
void*
nsHTMLDocument::UseExistingNameString(nsINode* aRootNode, const nsString* aName)
{
return const_cast<nsString*>(aName);
}
NS_IMETHODIMP
nsHTMLDocument::GetElementsByName(const nsAString& aElementName,
nsIDOMNodeList** aReturn)
{
*aReturn = GetElementsByName(aElementName).take();
return NS_OK;
}
void void
nsHTMLDocument::AddedForm() nsHTMLDocument::AddedForm()
{ {

View file

@ -185,11 +185,6 @@ public:
return nsHTMLDocument::GetForms(); return nsHTMLDocument::GetForms();
} }
nsIHTMLCollection* Scripts(); nsIHTMLCollection* Scripts();
already_AddRefed<nsContentList> GetElementsByName(const nsAString & aName)
{
return NS_GetFuncStringNodeList(this, MatchNameAttribute, nullptr,
UseExistingNameString, aName);
}
already_AddRefed<nsIDocument> Open(JSContext* cx, already_AddRefed<nsIDocument> Open(JSContext* cx,
const nsAString& aType, const nsAString& aType,
const nsAString& aReplace, const nsAString& aReplace,
@ -260,10 +255,6 @@ protected:
nsIAtom* aAtom, void* aData); nsIAtom* aAtom, void* aData);
static bool MatchAnchors(mozilla::dom::Element* aElement, int32_t aNamespaceID, static bool MatchAnchors(mozilla::dom::Element* aElement, int32_t aNamespaceID,
nsIAtom* aAtom, void* aData); nsIAtom* aAtom, void* aData);
static bool MatchNameAttribute(mozilla::dom::Element* aElement,
int32_t aNamespaceID,
nsIAtom* aAtom, void* aData);
static void* UseExistingNameString(nsINode* aRootNode, const nsString* aName);
static void DocumentWriteTerminationFunc(nsISupports *aRef); static void DocumentWriteTerminationFunc(nsISupports *aRef);

View file

@ -29,7 +29,6 @@ interface nsIDOMHTMLDocument : nsIDOMDocument
readonly attribute nsIDOMHTMLCollection links; readonly attribute nsIDOMHTMLCollection links;
readonly attribute nsIDOMHTMLCollection forms; readonly attribute nsIDOMHTMLCollection forms;
readonly attribute nsIDOMHTMLCollection scripts; readonly attribute nsIDOMHTMLCollection scripts;
nsIDOMNodeList getElementsByName(in DOMString elementName);
// If aContentType is not something supported by nsHTMLDocument and // If aContentType is not something supported by nsHTMLDocument and
// the HTML content sink, trying to write to the document will // the HTML content sink, trying to write to the document will

View file

@ -123,7 +123,8 @@ partial interface Document {
//(HTML only)readonly attribute HTMLCollection links; //(HTML only)readonly attribute HTMLCollection links;
//(HTML only)readonly attribute HTMLCollection forms; //(HTML only)readonly attribute HTMLCollection forms;
//(HTML only)readonly attribute HTMLCollection scripts; //(HTML only)readonly attribute HTMLCollection scripts;
//(HTML only)NodeList getElementsByName(DOMString elementName); [Pure]
NodeList getElementsByName(DOMString elementName);
//(Not implemented)readonly attribute DOMElementMap cssElementMap; //(Not implemented)readonly attribute DOMElementMap cssElementMap;
// dynamic markup insertion // dynamic markup insertion

View file

@ -29,7 +29,6 @@ interface HTMLDocument : Document {
readonly attribute HTMLCollection forms; readonly attribute HTMLCollection forms;
[Pure] [Pure]
readonly attribute HTMLCollection scripts; readonly attribute HTMLCollection scripts;
NodeList getElementsByName(DOMString elementName);
// dynamic markup insertion // dynamic markup insertion
[CEReactions, Throws] [CEReactions, Throws]

View file

@ -38,7 +38,7 @@ interface Node : EventTarget {
readonly attribute boolean isConnected; readonly attribute boolean isConnected;
[Pure] [Pure]
readonly attribute Document? ownerDocument; readonly attribute Document? ownerDocument;
[Pure, Pref="dom.getRootNode.enabled"] [Pure, Pref="dom.webcomponents.enabled"]
Node getRootNode(optional GetRootNodeOptions options); Node getRootNode(optional GetRootNodeOptions options);
[Pure] [Pure]
readonly attribute Node? parentNode; readonly attribute Node? parentNode;

View file

@ -2986,11 +2986,10 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll,
} }
// Search for an anchor element with a matching "name" attribute // Search for an anchor element with a matching "name" attribute
if (!content && htmlDoc) { if (!content && htmlDoc && mDocument) {
nsCOMPtr<nsIDOMNodeList> list;
// Find a matching list of named nodes // Find a matching list of named nodes
rv = htmlDoc->GetElementsByName(aAnchorName, getter_AddRefs(list)); nsCOMPtr<nsIDOMNodeList> list = mDocument->GetElementsByName(aAnchorName);
if (NS_SUCCEEDED(rv) && list) { if (list) {
uint32_t i; uint32_t i;
// Loop through the named nodes looking for the first anchor // Loop through the named nodes looking for the first anchor
for (i = 0; true; i++) { for (i = 0; true; i++) {

View file

@ -1239,11 +1239,8 @@ pref("privacy.trackingprotection.pbmode.enabled", false);
pref("dom.event.contextmenu.enabled", true); pref("dom.event.contextmenu.enabled", true);
pref("dom.event.clipboardevents.enabled", true); pref("dom.event.clipboardevents.enabled", true);
// TODO: merge these two prefs!
// Enable Google WebComponents? // Enable Google WebComponents?
pref("dom.webcomponents.enabled", true); pref("dom.webcomponents.enabled", true);
// Whether WC getRootNode is available
pref("dom.getRootNode.enabled", true);
pref("javascript.enabled", true); pref("javascript.enabled", true);
// Enable Array.prototype.values // Enable Array.prototype.values