summaryrefslogtreecommitdiffstats
path: root/dom
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-04-16 20:19:06 -0400
committerMatt A. Tobin <email@mattatobin.com>2020-04-16 20:19:06 -0400
commitde45820b64ab03768336c7242622ef9f499347cf (patch)
tree718a67a64a29f2440850e693f8ba707f3b91c179 /dom
parentab05e6f9ad185a1f7c405fd29876edca9e0567ba (diff)
downloadUXP-de45820b64ab03768336c7242622ef9f499347cf.tar
UXP-de45820b64ab03768336c7242622ef9f499347cf.tar.gz
UXP-de45820b64ab03768336c7242622ef9f499347cf.tar.lz
UXP-de45820b64ab03768336c7242622ef9f499347cf.tar.xz
UXP-de45820b64ab03768336c7242622ef9f499347cf.zip
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
Diffstat (limited to 'dom')
-rw-r--r--dom/base/AnonymousContent.cpp27
-rw-r--r--dom/base/AnonymousContent.h5
-rw-r--r--dom/webidl/AnonymousContent.webidl8
3 files changed, 40 insertions, 0 deletions
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<nsComputedDOMStyle> cs =
+ new nsComputedDOMStyle(element,
+ NS_LITERAL_STRING(""),
+ element->OwnerDoc(),
+ nsComputedDOMStyle::eAll);
+ aRv = cs->GetPropertyValue(aPropertyName, aResult);
+}
+
} // namespace dom
} // namespace mozilla
diff --git a/dom/base/AnonymousContent.h b/dom/base/AnonymousContent.h
index fd3b59c44..b56c14595 100644
--- a/dom/base/AnonymousContent.h
+++ b/dom/base/AnonymousContent.h
@@ -68,6 +68,11 @@ public:
const Sequence<OwningNonNull<DOMRect>>& aRects,
ErrorResult& aError);
+ void GetComputedStylePropertyValue(const nsAString& aElementId,
+ const nsAString& aPropertyName,
+ DOMString& aResult,
+ ErrorResult& aRv);
+
private:
~AnonymousContent();
nsCOMPtr<Element> mContentNode;
diff --git a/dom/webidl/AnonymousContent.webidl b/dom/webidl/AnonymousContent.webidl
index 6755fe598..8be69cd26 100644
--- a/dom/webidl/AnonymousContent.webidl
+++ b/dom/webidl/AnonymousContent.webidl
@@ -77,4 +77,12 @@ interface AnonymousContent {
[Throws]
void setCutoutRectsForElement(DOMString elementId,
sequence<DOMRect> rects);
+
+ /**
+ * Get the computed value of a property on an element inside this custom
+ * anonymous content.
+ */
+ [Throws]
+ DOMString? getComputedStylePropertyValue(DOMString elementId,
+ DOMString propertyName);
};