mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-21 07:47:32 +09:00
Issue #3053 - Implement CSSStyleSheet constructor
This commit is contained in:
parent
c02dd71673
commit
536619ee89
5 changed files with 79 additions and 0 deletions
|
|
@ -12,8 +12,10 @@
|
|||
#include "mozilla/CSSStyleSheet.h"
|
||||
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIMediaList.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
|
|
@ -222,6 +224,40 @@ StyleSheet::DeleteRule(uint32_t aIndex)
|
|||
|
||||
// WebIDL CSSStyleSheet API
|
||||
|
||||
/* static */ already_AddRefed<StyleSheet>
|
||||
StyleSheet::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindowInner> window =
|
||||
do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!window) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> document = window->GetDoc();
|
||||
if (!document) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> documentURI = document->GetDocumentURI();
|
||||
nsCOMPtr<nsIURI> baseURI = document->GetBaseURI();
|
||||
nsIPrincipal* principal = nsContentUtils::ObjectPrincipal(aGlobal.Get());
|
||||
if (!documentURI || !baseURI || !principal) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<StyleSheet> sheet =
|
||||
new CSSStyleSheet(css::eAuthorSheetFeatures, CORS_NONE,
|
||||
document->GetReferrerPolicy());
|
||||
sheet->SetURIs(documentURI, nullptr, baseURI);
|
||||
sheet->SetPrincipal(principal);
|
||||
sheet->SetComplete();
|
||||
|
||||
return sheet.forget();
|
||||
}
|
||||
|
||||
dom::CSSRuleList*
|
||||
StyleSheet::GetCssRules(nsIPrincipal& aSubjectPrincipal,
|
||||
ErrorResult& aRv)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue