mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1169514 - Part 1: Move noscript rule from the preference style sheet to a cached UA style sheet. r=jwatt
This commit is contained in:
parent
21c7de4127
commit
d4b22a556a
@ -167,6 +167,9 @@ SVGDocument::EnsureNonSVGUserAgentStyleSheetsLoaded()
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::FormsSheet());
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::CounterStylesSheet());
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::HTMLSheet());
|
||||
if (nsLayoutUtils::ShouldUseNoScriptSheet(this)) {
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::NoScriptSheet());
|
||||
}
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::UASheet());
|
||||
|
||||
EndUpdate(UPDATE_STYLE);
|
||||
|
@ -2334,6 +2334,13 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
||||
}
|
||||
|
||||
if (nsLayoutUtils::ShouldUseNoScriptSheet(aDocument)) {
|
||||
sheet = nsLayoutStylesheetCache::NoScriptSheet();
|
||||
if (sheet) {
|
||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
||||
}
|
||||
}
|
||||
|
||||
sheet = nsLayoutStylesheetCache::HTMLSheet();
|
||||
if (sheet) {
|
||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
||||
|
@ -8449,3 +8449,14 @@ nsLayoutUtils::TransformToAncestorAndCombineRegions(
|
||||
nsRegion* dest = isPrecise ? aPreciseTargetDest : aImpreciseTargetDest;
|
||||
dest->OrWith(transformed);
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
nsLayoutUtils::ShouldUseNoScriptSheet(nsIDocument* aDocument)
|
||||
{
|
||||
// also handle the case where print is done from print preview
|
||||
// see bug #342439 for more details
|
||||
if (aDocument->IsStaticDocument()) {
|
||||
aDocument = aDocument->GetOriginalDocument();
|
||||
}
|
||||
return aDocument->IsScriptEnabled();
|
||||
}
|
||||
|
@ -2672,6 +2672,8 @@ public:
|
||||
*/
|
||||
static bool ContainsMetricsWithId(const Layer* aLayer, const ViewID& aScrollId);
|
||||
|
||||
static bool ShouldUseNoScriptSheet(nsIDocument* aDocument);
|
||||
|
||||
private:
|
||||
static uint32_t sFontSizeInflationEmPerLine;
|
||||
static uint32_t sFontSizeInflationMinTwips;
|
||||
|
@ -1367,9 +1367,6 @@ PresShell::SetPreferenceStyleRules(bool aForceReflow)
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = SetPrefFocusRules();
|
||||
}
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = SetPrefNoScriptRule();
|
||||
}
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = SetPrefNoFramesRule();
|
||||
}
|
||||
@ -1451,34 +1448,6 @@ PresShell::CreatePreferenceStyleSheet()
|
||||
// and just "append"?
|
||||
static uint32_t sInsertPrefSheetRulesAt = 2;
|
||||
|
||||
nsresult
|
||||
PresShell::SetPrefNoScriptRule()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// also handle the case where print is done from print preview
|
||||
// see bug #342439 for more details
|
||||
nsIDocument* doc = mDocument;
|
||||
if (doc->IsStaticDocument()) {
|
||||
doc = doc->GetOriginalDocument();
|
||||
}
|
||||
|
||||
bool scriptEnabled = doc->IsScriptEnabled();
|
||||
if (scriptEnabled) {
|
||||
if (!mPrefStyleSheet) {
|
||||
rv = CreatePreferenceStyleSheet();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
uint32_t index = 0;
|
||||
mPrefStyleSheet->
|
||||
InsertRuleInternal(NS_LITERAL_STRING("noscript{display:none!important}"),
|
||||
sInsertPrefSheetRulesAt, &index);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult PresShell::SetPrefNoFramesRule(void)
|
||||
{
|
||||
NS_ASSERTION(mPresContext,"null prescontext not allowed");
|
||||
|
@ -522,7 +522,6 @@ protected:
|
||||
nsresult CreatePreferenceStyleSheet(void);
|
||||
nsresult SetPrefLinkRules(void);
|
||||
nsresult SetPrefFocusRules(void);
|
||||
nsresult SetPrefNoScriptRule();
|
||||
nsresult SetPrefNoFramesRule(void);
|
||||
|
||||
// methods for painting a range to an offscreen buffer
|
||||
|
@ -10,6 +10,7 @@ toolkit.jar:
|
||||
res/plaintext.css (plaintext.css)
|
||||
res/viewsource.css (viewsource.css)
|
||||
res/counterstyles.css (counterstyles.css)
|
||||
res/noscript.css (noscript.css)
|
||||
* res/forms.css (forms.css)
|
||||
res/number-control.css (number-control.css)
|
||||
res/arrow.gif (arrow.gif)
|
||||
|
9
layout/style/noscript.css
Normal file
9
layout/style/noscript.css
Normal file
@ -0,0 +1,9 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* This sheet is added to the style set for documents with script disabled */
|
||||
|
||||
noscript {
|
||||
display: none !important;
|
||||
}
|
@ -192,6 +192,19 @@ nsLayoutStylesheetCache::CounterStylesSheet()
|
||||
return gStyleCache->mCounterStylesSheet;
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
nsLayoutStylesheetCache::NoScriptSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
|
||||
if (!gStyleCache->mNoScriptSheet) {
|
||||
LoadSheetURL("resource://gre-resources/noscript.css",
|
||||
gStyleCache->mNoScriptSheet, true);
|
||||
}
|
||||
|
||||
return gStyleCache->mNoScriptSheet;
|
||||
}
|
||||
|
||||
void
|
||||
nsLayoutStylesheetCache::Shutdown()
|
||||
{
|
||||
@ -225,6 +238,7 @@ nsLayoutStylesheetCache::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf
|
||||
MEASURE(mHTMLSheet);
|
||||
MEASURE(mMathMLSheet);
|
||||
MEASURE(mMinimalXULSheet);
|
||||
MEASURE(mNoScriptSheet);
|
||||
MEASURE(mNumberControlSheet);
|
||||
MEASURE(mQuirkSheet);
|
||||
MEASURE(mSVGSheet);
|
||||
|
@ -48,6 +48,7 @@ class nsLayoutStylesheetCache final
|
||||
static mozilla::CSSStyleSheet* SVGSheet();
|
||||
static mozilla::CSSStyleSheet* MathMLSheet();
|
||||
static mozilla::CSSStyleSheet* CounterStylesSheet();
|
||||
static mozilla::CSSStyleSheet* NoScriptSheet();
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
@ -78,6 +79,7 @@ private:
|
||||
nsRefPtr<mozilla::CSSStyleSheet> mHTMLSheet;
|
||||
nsRefPtr<mozilla::CSSStyleSheet> mMathMLSheet;
|
||||
nsRefPtr<mozilla::CSSStyleSheet> mMinimalXULSheet;
|
||||
nsRefPtr<mozilla::CSSStyleSheet> mNoScriptSheet;
|
||||
nsRefPtr<mozilla::CSSStyleSheet> mNumberControlSheet;
|
||||
nsRefPtr<mozilla::CSSStyleSheet> mQuirkSheet;
|
||||
nsRefPtr<mozilla::CSSStyleSheet> mSVGSheet;
|
||||
|
Loading…
Reference in New Issue
Block a user