mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1169514 - Part 2: Move noframes rules from the preferences style sheet to a cached UA style sheet. r=jwatt
This commit is contained in:
parent
734cedb81b
commit
1d5151d479
@ -167,6 +167,9 @@ SVGDocument::EnsureNonSVGUserAgentStyleSheetsLoaded()
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::FormsSheet());
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::CounterStylesSheet());
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::HTMLSheet());
|
||||
if (nsLayoutUtils::ShouldUseNoFramesSheet(this)) {
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::NoFramesSheet());
|
||||
}
|
||||
if (nsLayoutUtils::ShouldUseNoScriptSheet(this)) {
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::NoScriptSheet());
|
||||
}
|
||||
|
@ -2341,6 +2341,13 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
||||
}
|
||||
}
|
||||
|
||||
if (nsLayoutUtils::ShouldUseNoFramesSheet(aDocument)) {
|
||||
sheet = nsLayoutStylesheetCache::NoFramesSheet();
|
||||
if (sheet) {
|
||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
||||
}
|
||||
}
|
||||
|
||||
sheet = nsLayoutStylesheetCache::HTMLSheet();
|
||||
if (sheet) {
|
||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
||||
|
@ -8460,3 +8460,14 @@ nsLayoutUtils::ShouldUseNoScriptSheet(nsIDocument* aDocument)
|
||||
}
|
||||
return aDocument->IsScriptEnabled();
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
nsLayoutUtils::ShouldUseNoFramesSheet(nsIDocument* aDocument)
|
||||
{
|
||||
bool allowSubframes = true;
|
||||
nsIDocShell* docShell = aDocument->GetDocShell();
|
||||
if (docShell) {
|
||||
docShell->GetAllowSubframes(&allowSubframes);
|
||||
}
|
||||
return !allowSubframes;
|
||||
}
|
||||
|
@ -2673,6 +2673,7 @@ public:
|
||||
static bool ContainsMetricsWithId(const Layer* aLayer, const ViewID& aScrollId);
|
||||
|
||||
static bool ShouldUseNoScriptSheet(nsIDocument* aDocument);
|
||||
static bool ShouldUseNoFramesSheet(nsIDocument* aDocument);
|
||||
|
||||
private:
|
||||
static uint32_t sFontSizeInflationEmPerLine;
|
||||
|
@ -1367,9 +1367,6 @@ PresShell::SetPreferenceStyleRules(bool aForceReflow)
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = SetPrefFocusRules();
|
||||
}
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = SetPrefNoFramesRule();
|
||||
}
|
||||
#ifdef DEBUG_attinasi
|
||||
printf( "Preference Style Rules set: error=%ld\n", (long)result);
|
||||
#endif
|
||||
@ -1448,40 +1445,6 @@ PresShell::CreatePreferenceStyleSheet()
|
||||
// and just "append"?
|
||||
static uint32_t sInsertPrefSheetRulesAt = 2;
|
||||
|
||||
nsresult PresShell::SetPrefNoFramesRule(void)
|
||||
{
|
||||
NS_ASSERTION(mPresContext,"null prescontext not allowed");
|
||||
if (!mPresContext) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!mPrefStyleSheet) {
|
||||
rv = CreatePreferenceStyleSheet();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
NS_ASSERTION(mPrefStyleSheet, "prefstylesheet should not be null");
|
||||
|
||||
bool allowSubframes = true;
|
||||
nsCOMPtr<nsIDocShell> docShell(mPresContext->GetDocShell());
|
||||
if (docShell) {
|
||||
docShell->GetAllowSubframes(&allowSubframes);
|
||||
}
|
||||
if (!allowSubframes) {
|
||||
uint32_t index = 0;
|
||||
rv = mPrefStyleSheet->
|
||||
InsertRuleInternal(NS_LITERAL_STRING("noframes{display:block}"),
|
||||
sInsertPrefSheetRulesAt, &index);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = mPrefStyleSheet->
|
||||
InsertRuleInternal(NS_LITERAL_STRING("frame, frameset, iframe {display:none!important}"),
|
||||
sInsertPrefSheetRulesAt, &index);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult PresShell::SetPrefLinkRules(void)
|
||||
{
|
||||
NS_ASSERTION(mPresContext,"null prescontext not allowed");
|
||||
|
@ -522,7 +522,6 @@ protected:
|
||||
nsresult CreatePreferenceStyleSheet(void);
|
||||
nsresult SetPrefLinkRules(void);
|
||||
nsresult SetPrefFocusRules(void);
|
||||
nsresult SetPrefNoFramesRule(void);
|
||||
|
||||
// methods for painting a range to an offscreen buffer
|
||||
|
||||
|
@ -11,6 +11,7 @@ toolkit.jar:
|
||||
res/viewsource.css (viewsource.css)
|
||||
res/counterstyles.css (counterstyles.css)
|
||||
res/noscript.css (noscript.css)
|
||||
res/noframes.css (noframes.css)
|
||||
* res/forms.css (forms.css)
|
||||
res/number-control.css (number-control.css)
|
||||
res/arrow.gif (arrow.gif)
|
||||
|
13
layout/style/noframes.css
Normal file
13
layout/style/noframes.css
Normal file
@ -0,0 +1,13 @@
|
||||
/* 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 frames disabled */
|
||||
|
||||
noframes {
|
||||
display: block;
|
||||
}
|
||||
|
||||
frame, frameset, iframe {
|
||||
display: none !important;
|
||||
}
|
@ -205,6 +205,19 @@ nsLayoutStylesheetCache::NoScriptSheet()
|
||||
return gStyleCache->mNoScriptSheet;
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
nsLayoutStylesheetCache::NoFramesSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
|
||||
if (!gStyleCache->mNoFramesSheet) {
|
||||
LoadSheetURL("resource://gre-resources/noframes.css",
|
||||
gStyleCache->mNoFramesSheet, true);
|
||||
}
|
||||
|
||||
return gStyleCache->mNoFramesSheet;
|
||||
}
|
||||
|
||||
void
|
||||
nsLayoutStylesheetCache::Shutdown()
|
||||
{
|
||||
@ -238,6 +251,7 @@ nsLayoutStylesheetCache::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf
|
||||
MEASURE(mHTMLSheet);
|
||||
MEASURE(mMathMLSheet);
|
||||
MEASURE(mMinimalXULSheet);
|
||||
MEASURE(mNoFramesSheet);
|
||||
MEASURE(mNoScriptSheet);
|
||||
MEASURE(mNumberControlSheet);
|
||||
MEASURE(mQuirkSheet);
|
||||
|
@ -49,6 +49,7 @@ class nsLayoutStylesheetCache final
|
||||
static mozilla::CSSStyleSheet* MathMLSheet();
|
||||
static mozilla::CSSStyleSheet* CounterStylesSheet();
|
||||
static mozilla::CSSStyleSheet* NoScriptSheet();
|
||||
static mozilla::CSSStyleSheet* NoFramesSheet();
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
@ -79,6 +80,7 @@ private:
|
||||
nsRefPtr<mozilla::CSSStyleSheet> mHTMLSheet;
|
||||
nsRefPtr<mozilla::CSSStyleSheet> mMathMLSheet;
|
||||
nsRefPtr<mozilla::CSSStyleSheet> mMinimalXULSheet;
|
||||
nsRefPtr<mozilla::CSSStyleSheet> mNoFramesSheet;
|
||||
nsRefPtr<mozilla::CSSStyleSheet> mNoScriptSheet;
|
||||
nsRefPtr<mozilla::CSSStyleSheet> mNumberControlSheet;
|
||||
nsRefPtr<mozilla::CSSStyleSheet> mQuirkSheet;
|
||||
|
Loading…
Reference in New Issue
Block a user