From de45820b64ab03768336c7242622ef9f499347cf Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Thu, 16 Apr 2020 20:19:06 -0400 Subject: Bug 1346623 - Allow anonymous content created with nsIDocument::InsertAnonymousContent can change from non-native to native AC * Prevent canvas custom content from becoming NAC when reframing the root element * Add an API to get computed style values through an AnonymousContent object Tag #1375 --- dom/base/AnonymousContent.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'dom/base/AnonymousContent.cpp') diff --git a/dom/base/AnonymousContent.cpp b/dom/base/AnonymousContent.cpp index 1df36b048..aea923f2b 100644 --- a/dom/base/AnonymousContent.cpp +++ b/dom/base/AnonymousContent.cpp @@ -7,6 +7,7 @@ #include "AnonymousContent.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/AnonymousContentBinding.h" +#include "nsComputedDOMStyle.h" #include "nsCycleCollectionParticipant.h" #include "nsIDocument.h" #include "nsIDOMHTMLCollection.h" @@ -208,5 +209,31 @@ AnonymousContent::WrapObject(JSContext* aCx, return AnonymousContentBinding::Wrap(aCx, this, aGivenProto, aReflector); } +void +AnonymousContent::GetComputedStylePropertyValue(const nsAString& aElementId, + const nsAString& aPropertyName, + DOMString& aResult, + ErrorResult& aRv) +{ + Element* element = GetElementById(aElementId); + if (!element) { + aRv.Throw(NS_ERROR_NOT_AVAILABLE); + return; + } + + nsIPresShell* shell = element->OwnerDoc()->GetShell(); + if (!shell) { + aRv.Throw(NS_ERROR_NOT_AVAILABLE); + return; + } + + RefPtr cs = + new nsComputedDOMStyle(element, + NS_LITERAL_STRING(""), + element->OwnerDoc(), + nsComputedDOMStyle::eAll); + aRv = cs->GetPropertyValue(aPropertyName, aResult); +} + } // namespace dom } // namespace mozilla -- cgit v1.2.3