summaryrefslogtreecommitdiffstats
path: root/layout/style/StyleSheet.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
commit086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch)
treea4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /layout/style/StyleSheet.cpp
parentAdding debian version 124.0.1-1. (diff)
downloadfirefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz
firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'layout/style/StyleSheet.cpp')
-rw-r--r--layout/style/StyleSheet.cpp47
1 files changed, 21 insertions, 26 deletions
diff --git a/layout/style/StyleSheet.cpp b/layout/style/StyleSheet.cpp
index 494618d879..b1ce1d66e2 100644
--- a/layout/style/StyleSheet.cpp
+++ b/layout/style/StyleSheet.cpp
@@ -28,7 +28,6 @@
#include "mozilla/css/SheetLoadData.h"
#include "mozAutoDocUpdate.h"
-#include "SheetLoadData.h"
namespace mozilla {
@@ -136,8 +135,12 @@ already_AddRefed<StyleSheet> StyleSheet::Constructor(
// 3. Set the sheet's disabled flag according to aOptions.
sheet->SetDisabled(aOptions.mDisabled);
+ sheet->SetURLExtraData();
sheet->SetComplete();
+ sheet->ReplaceSync(""_ns, aRv);
+ MOZ_ASSERT(!aRv.Failed());
+
// 4. Return sheet.
return sheet.forget();
}
@@ -740,7 +743,9 @@ already_AddRefed<dom::Promise> StyleSheet::Replace(const nsACString& aText,
loadData->mIsBeingParsed = true;
MOZ_ASSERT(!mReplacePromise);
mReplacePromise = promise;
- ParseSheet(*loader, aText, *loadData)
+ RefPtr<css::SheetLoadDataHolder> holder(
+ new css::SheetLoadDataHolder(__func__, loadData, false));
+ ParseSheet(*loader, aText, holder)
->Then(
target, __func__,
[loadData] { loadData->SheetFinishedParsingAsync(); },
@@ -769,7 +774,6 @@ void StyleSheet::ReplaceSync(const nsACString& aText, ErrorResult& aRv) {
// 3. Parse aText into rules.
// 4. If rules contain @imports, skip them and continue parsing.
auto* loader = mConstructorDocument->CSSLoader();
- SetURLExtraData();
RefPtr<const StyleStylesheetContents> rawContent =
Servo_StyleSheet_FromUTF8Bytes(
loader, this,
@@ -1159,28 +1163,19 @@ already_AddRefed<StyleSheet> StyleSheet::CreateEmptyChildSheet(
return child.forget();
}
-// We disable parallel stylesheet parsing if the browser is recording CSS errors
-// (which parallel parsing can't handle).
-static bool AllowParallelParse(css::Loader& aLoader, URLExtraData* aUrlData) {
- Document* doc = aLoader.GetDocument();
- if (doc && css::ErrorReporter::ShouldReportErrors(*doc)) {
- return false;
- }
- // Otherwise we can parse in parallel.
- return true;
-}
-
RefPtr<StyleSheetParsePromise> StyleSheet::ParseSheet(
css::Loader& aLoader, const nsACString& aBytes,
- css::SheetLoadData& aLoadData) {
+ const RefPtr<css::SheetLoadDataHolder>& aLoadData) {
MOZ_ASSERT(mParsePromise.IsEmpty());
+ MOZ_ASSERT_IF(NS_IsMainThread(), mAsyncParseBlockers == 0);
+
RefPtr<StyleSheetParsePromise> p = mParsePromise.Ensure(__func__);
- if (!aLoadData.ShouldDefer()) {
+ if (!aLoadData->get()->ShouldDefer()) {
mParsePromise.SetTaskPriority(nsIRunnablePriority::PRIORITY_RENDER_BLOCKING,
__func__);
}
+ BlockParsePromise();
SetURLExtraData();
-
// @import rules are disallowed due to this decision:
// https://github.com/WICG/construct-stylesheets/issues/119#issuecomment-588352418
// We may allow @import rules again in the future.
@@ -1191,26 +1186,26 @@ RefPtr<StyleSheetParsePromise> StyleSheet::ParseSheet(
const bool shouldRecordCounters =
aLoader.GetDocument() && aLoader.GetDocument()->GetStyleUseCounters() &&
!urlData->ChromeRulesEnabled();
- if (!AllowParallelParse(aLoader, urlData)) {
+
+ if (aLoadData->get()->mRecordErrors) {
+ MOZ_ASSERT(NS_IsMainThread());
UniquePtr<StyleUseCounters> counters;
if (shouldRecordCounters) {
counters.reset(Servo_UseCounters_Create());
}
-
RefPtr<StyleStylesheetContents> contents =
Servo_StyleSheet_FromUTF8Bytes(
- &aLoader, this, &aLoadData, &aBytes, mParsingMode, urlData,
- aLoadData.mCompatMode,
+ &aLoader, this, aLoadData->get(), &aBytes, mParsingMode, urlData,
+ aLoadData->get()->mCompatMode,
/* reusable_sheets = */ nullptr, counters.get(), allowImportRules,
StyleSanitizationKind::None,
/* sanitized_output = */ nullptr)
.Consume();
FinishAsyncParse(contents.forget(), std::move(counters));
} else {
- auto holder = MakeRefPtr<css::SheetLoadDataHolder>(__func__, &aLoadData);
- Servo_StyleSheet_FromUTF8BytesAsync(holder, urlData, &aBytes, mParsingMode,
- aLoadData.mCompatMode,
- shouldRecordCounters, allowImportRules);
+ Servo_StyleSheet_FromUTF8BytesAsync(
+ aLoadData, urlData, &aBytes, mParsingMode,
+ aLoadData->get()->mCompatMode, shouldRecordCounters, allowImportRules);
}
return p;
@@ -1224,7 +1219,7 @@ void StyleSheet::FinishAsyncParse(
Inner().mContents = aSheetContents;
Inner().mUseCounters = std::move(aUseCounters);
FixUpRuleListAfterContentsChangeIfNeeded();
- mParsePromise.Resolve(true, __func__);
+ UnblockParsePromise();
}
void StyleSheet::ParseSheetSync(