mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 185236 part 3. Add a way to differentiate SheetComplete calls for actual loads and for the fake SheetLoadData we use to trigger observer notifications for already-complete sheets. r=peterv
This commit is contained in:
parent
b63dea03b7
commit
dbbc87145e
@ -240,6 +240,10 @@ public:
|
|||||||
// loads.
|
// loads.
|
||||||
PRPackedBool mUseSystemPrincipal : 1;
|
PRPackedBool mUseSystemPrincipal : 1;
|
||||||
|
|
||||||
|
// If true, this SheetLoadData is being used as a way to handle
|
||||||
|
// async observer notification for an already-complete sheet.
|
||||||
|
PRPackedBool mSheetAlreadyComplete : 1;
|
||||||
|
|
||||||
// This is the element that imported the sheet. Needed to get the
|
// This is the element that imported the sheet. Needed to get the
|
||||||
// charset set on it.
|
// charset set on it.
|
||||||
nsCOMPtr<nsIStyleSheetLinkingElement> mOwningElement;
|
nsCOMPtr<nsIStyleSheetLinkingElement> mOwningElement;
|
||||||
@ -330,6 +334,7 @@ SheetLoadData::SheetLoadData(Loader* aLoader,
|
|||||||
mWasAlternate(aIsAlternate),
|
mWasAlternate(aIsAlternate),
|
||||||
mAllowUnsafeRules(PR_FALSE),
|
mAllowUnsafeRules(PR_FALSE),
|
||||||
mUseSystemPrincipal(PR_FALSE),
|
mUseSystemPrincipal(PR_FALSE),
|
||||||
|
mSheetAlreadyComplete(PR_FALSE),
|
||||||
mOwningElement(aOwningElement),
|
mOwningElement(aOwningElement),
|
||||||
mObserver(aObserver),
|
mObserver(aObserver),
|
||||||
mLoaderPrincipal(aLoaderPrincipal)
|
mLoaderPrincipal(aLoaderPrincipal)
|
||||||
@ -359,6 +364,7 @@ SheetLoadData::SheetLoadData(Loader* aLoader,
|
|||||||
mWasAlternate(PR_FALSE),
|
mWasAlternate(PR_FALSE),
|
||||||
mAllowUnsafeRules(PR_FALSE),
|
mAllowUnsafeRules(PR_FALSE),
|
||||||
mUseSystemPrincipal(PR_FALSE),
|
mUseSystemPrincipal(PR_FALSE),
|
||||||
|
mSheetAlreadyComplete(PR_FALSE),
|
||||||
mOwningElement(nsnull),
|
mOwningElement(nsnull),
|
||||||
mObserver(aObserver),
|
mObserver(aObserver),
|
||||||
mLoaderPrincipal(aLoaderPrincipal)
|
mLoaderPrincipal(aLoaderPrincipal)
|
||||||
@ -402,6 +408,7 @@ SheetLoadData::SheetLoadData(Loader* aLoader,
|
|||||||
mWasAlternate(PR_FALSE),
|
mWasAlternate(PR_FALSE),
|
||||||
mAllowUnsafeRules(aAllowUnsafeRules),
|
mAllowUnsafeRules(aAllowUnsafeRules),
|
||||||
mUseSystemPrincipal(aUseSystemPrincipal),
|
mUseSystemPrincipal(aUseSystemPrincipal),
|
||||||
|
mSheetAlreadyComplete(PR_FALSE),
|
||||||
mOwningElement(nsnull),
|
mOwningElement(nsnull),
|
||||||
mObserver(aObserver),
|
mObserver(aObserver),
|
||||||
mLoaderPrincipal(aLoaderPrincipal),
|
mLoaderPrincipal(aLoaderPrincipal),
|
||||||
@ -1650,7 +1657,9 @@ Loader::DoSheetComplete(SheetLoadData* aLoadData, nsresult aStatus,
|
|||||||
while (data) {
|
while (data) {
|
||||||
NS_ABORT_IF_FALSE(!data->mSheet->IsModified(),
|
NS_ABORT_IF_FALSE(!data->mSheet->IsModified(),
|
||||||
"should not get marked modified during parsing");
|
"should not get marked modified during parsing");
|
||||||
|
if (!data->mSheetAlreadyComplete) {
|
||||||
data->mSheet->SetComplete();
|
data->mSheet->SetComplete();
|
||||||
|
}
|
||||||
if (data->mMustNotify && (data->mObserver || !mObservers.IsEmpty())) {
|
if (data->mMustNotify && (data->mObserver || !mObservers.IsEmpty())) {
|
||||||
// Don't notify here so we don't trigger script. Remember the
|
// Don't notify here so we don't trigger script. Remember the
|
||||||
// info we need to notify, then do it later when it's safe.
|
// info we need to notify, then do it later when it's safe.
|
||||||
@ -1751,11 +1760,6 @@ Loader::LoadInlineStyle(nsIContent* aElement,
|
|||||||
owningElement, *aIsAlternate,
|
owningElement, *aIsAlternate,
|
||||||
aObserver, nsnull);
|
aObserver, nsnull);
|
||||||
|
|
||||||
if (!data) {
|
|
||||||
sheet->SetComplete();
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We never actually load this, so just set its principal directly
|
// We never actually load this, so just set its principal directly
|
||||||
sheet->SetPrincipal(aElement->NodePrincipal());
|
sheet->SetPrincipal(aElement->NodePrincipal());
|
||||||
|
|
||||||
@ -1827,7 +1831,7 @@ Loader::LoadStyleLink(nsIContent* aElement,
|
|||||||
if (state == eSheetComplete) {
|
if (state == eSheetComplete) {
|
||||||
LOG((" Sheet already complete: 0x%p",
|
LOG((" Sheet already complete: 0x%p",
|
||||||
static_cast<void*>(sheet.get())));
|
static_cast<void*>(sheet.get())));
|
||||||
if (aObserver) {
|
if (aObserver || !mObservers.IsEmpty()) {
|
||||||
rv = PostLoadEvent(aURL, sheet, aObserver, *aIsAlternate);
|
rv = PostLoadEvent(aURL, sheet, aObserver, *aIsAlternate);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@ -1841,11 +1845,6 @@ Loader::LoadStyleLink(nsIContent* aElement,
|
|||||||
SheetLoadData* data = new SheetLoadData(this, aTitle, aURL, sheet,
|
SheetLoadData* data = new SheetLoadData(this, aTitle, aURL, sheet,
|
||||||
owningElement, *aIsAlternate,
|
owningElement, *aIsAlternate,
|
||||||
aObserver, principal);
|
aObserver, principal);
|
||||||
if (!data) {
|
|
||||||
sheet->SetComplete();
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_ADDREF(data);
|
NS_ADDREF(data);
|
||||||
|
|
||||||
// If we have to parse and it's an alternate non-inline, defer it
|
// If we have to parse and it's an alternate non-inline, defer it
|
||||||
@ -1996,11 +1995,6 @@ Loader::LoadChildSheet(nsCSSStyleSheet* aParentSheet,
|
|||||||
SheetLoadData* data = new SheetLoadData(this, aURL, sheet, parentData,
|
SheetLoadData* data = new SheetLoadData(this, aURL, sheet, parentData,
|
||||||
observer, principal);
|
observer, principal);
|
||||||
|
|
||||||
if (!data) {
|
|
||||||
sheet->SetComplete();
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_ADDREF(data);
|
NS_ADDREF(data);
|
||||||
PRBool syncLoad = data->mSyncLoad;
|
PRBool syncLoad = data->mSyncLoad;
|
||||||
|
|
||||||
@ -2097,7 +2091,7 @@ Loader::InternalLoadNonDocumentSheet(nsIURI* aURL,
|
|||||||
|
|
||||||
if (state == eSheetComplete) {
|
if (state == eSheetComplete) {
|
||||||
LOG((" Sheet already complete"));
|
LOG((" Sheet already complete"));
|
||||||
if (aObserver) {
|
if (aObserver || !mObservers.IsEmpty()) {
|
||||||
rv = PostLoadEvent(aURL, sheet, aObserver, PR_FALSE);
|
rv = PostLoadEvent(aURL, sheet, aObserver, PR_FALSE);
|
||||||
}
|
}
|
||||||
if (aSheet) {
|
if (aSheet) {
|
||||||
@ -2111,11 +2105,6 @@ Loader::InternalLoadNonDocumentSheet(nsIURI* aURL,
|
|||||||
aUseSystemPrincipal, aCharset, aObserver,
|
aUseSystemPrincipal, aCharset, aObserver,
|
||||||
aOriginPrincipal);
|
aOriginPrincipal);
|
||||||
|
|
||||||
if (!data) {
|
|
||||||
sheet->SetComplete();
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_ADDREF(data);
|
NS_ADDREF(data);
|
||||||
rv = LoadSheet(data, state);
|
rv = LoadSheet(data, state);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
@ -2138,7 +2127,7 @@ Loader::PostLoadEvent(nsIURI* aURI,
|
|||||||
{
|
{
|
||||||
LOG(("css::Loader::PostLoadEvent"));
|
LOG(("css::Loader::PostLoadEvent"));
|
||||||
NS_PRECONDITION(aSheet, "Must have sheet");
|
NS_PRECONDITION(aSheet, "Must have sheet");
|
||||||
NS_PRECONDITION(aObserver, "Must have observer");
|
NS_PRECONDITION(aObserver || !mObservers.IsEmpty(), "Must have observer");
|
||||||
|
|
||||||
nsRefPtr<SheetLoadData> evt =
|
nsRefPtr<SheetLoadData> evt =
|
||||||
new SheetLoadData(this, EmptyString(), // title doesn't matter here
|
new SheetLoadData(this, EmptyString(), // title doesn't matter here
|
||||||
@ -2166,6 +2155,7 @@ Loader::PostLoadEvent(nsIURI* aURI,
|
|||||||
|
|
||||||
// We want to notify the observer for this data.
|
// We want to notify the observer for this data.
|
||||||
evt->mMustNotify = PR_TRUE;
|
evt->mMustNotify = PR_TRUE;
|
||||||
|
evt->mSheetAlreadyComplete = PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
Loading…
Reference in New Issue
Block a user