mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1346623 - Part 2: Add an API to get computed style values through an AnonymousContent object. r=bholley
MozReview-Commit-ID: Dbvuk16CjFT --HG-- extra : rebase_source : 2c40e4cd9ce08d6f2a5feb13293cc151de6deb80
This commit is contained in:
parent
2a59bf895d
commit
0c4867b06c
@ -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,29 @@ 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(""), shell,
|
||||
nsComputedDOMStyle::eAll);
|
||||
aRv = cs->GetPropertyValue(aPropertyName, aResult);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user