author | Cameron McCormack <cam@mcc.id.au> |
Tue, 16 Jun 2015 11:34:47 +1000 | |
changeset 267107 | 44e4a6479eb15ea2e28dc81c7a63d61ca4720f59 |
parent 267106 | 0f16ee136b51d8b294e82cb4812f7cb05ff45ffd |
child 267108 | fca18f7bf521de38df05680ea36663836dc3413d |
push id | unknown |
push user | unknown |
push date | unknown |
reviewers | jwatt |
bugs | 1169514 |
milestone | 41.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/svg/SVGDocument.cpp +++ b/dom/svg/SVGDocument.cpp @@ -162,16 +162,19 @@ SVGDocument::EnsureNonSVGUserAgentStyleS CSSStyleSheet* sheet = nsLayoutStylesheetCache::NumberControlSheet(); if (sheet) { // number-control.css can be behind a pref EnsureOnDemandBuiltInUASheet(sheet); } EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::FormsSheet()); EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::CounterStylesSheet()); EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::HTMLSheet()); + if (nsLayoutUtils::ShouldUseNoScriptSheet(this)) { + EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::NoScriptSheet()); + } EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::UASheet()); EndUpdate(UPDATE_STYLE); } JSObject* SVGDocument::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) {
--- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -2329,16 +2329,23 @@ nsDocumentViewer::CreateStyleSet(nsIDocu styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet); } sheet = nsLayoutStylesheetCache::CounterStylesSheet(); if (sheet) { 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); } styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, nsLayoutStylesheetCache::UASheet()); } else {
--- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -8444,8 +8444,19 @@ nsLayoutUtils::TransformToAncestorAndCom Matrix matrix2D; bool isPrecise = (matrix.Is2D(&matrix2D) && !matrix2D.HasNonAxisAlignedTransform()); nsRect transformed = TransformFrameRectToAncestor( aFrame, aBounds, aAncestorFrame); 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(); +}
--- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -2667,16 +2667,18 @@ public: static nsMargin ScrollbarAreaToExcludeFromCompositionBoundsFor(nsIFrame* aScrollFrame); /** * Looks in the layer subtree rooted at aLayer for a metrics with scroll id * aScrollId. Returns true if such is found. */ static bool ContainsMetricsWithId(const Layer* aLayer, const ViewID& aScrollId); + static bool ShouldUseNoScriptSheet(nsIDocument* aDocument); + private: static uint32_t sFontSizeInflationEmPerLine; static uint32_t sFontSizeInflationMinTwips; static uint32_t sFontSizeInflationLineThreshold; static int32_t sFontSizeInflationMappingIntercept; static uint32_t sFontSizeInflationMaxRatio; static bool sFontSizeInflationForceEnabled; static bool sFontSizeInflationDisabledInMasterProcess;
--- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -1363,19 +1363,16 @@ PresShell::SetPreferenceStyleRules(bool // as the color rules will be overrides and the links rules will be agent if (NS_SUCCEEDED(result)) { result = SetPrefLinkRules(); } if (NS_SUCCEEDED(result)) { result = SetPrefFocusRules(); } if (NS_SUCCEEDED(result)) { - result = SetPrefNoScriptRule(); - } - if (NS_SUCCEEDED(result)) { result = SetPrefNoFramesRule(); } #ifdef DEBUG_attinasi printf( "Preference Style Rules set: error=%ld\n", (long)result); #endif // Note that this method never needs to force any calculation; the caller // will recalculate style if needed @@ -1446,44 +1443,16 @@ PresShell::CreatePreferenceStyleSheet() return NS_OK; } // XXX We want these after the @namespace rules. Does order matter // for these rules, or can we call StyleRule::StyleRuleCount() // 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"); if (!mPresContext) { return NS_ERROR_FAILURE; } nsresult rv = NS_OK;
--- a/layout/base/nsPresShell.h +++ b/layout/base/nsPresShell.h @@ -517,17 +517,16 @@ protected: /** * methods that manage rules that are used to implement the associated preferences * - initially created for bugs 31816, 20760, 22963 */ nsresult ClearPreferenceStyleRules(void); nsresult CreatePreferenceStyleSheet(void); nsresult SetPrefLinkRules(void); nsresult SetPrefFocusRules(void); - nsresult SetPrefNoScriptRule(); nsresult SetPrefNoFramesRule(void); // methods for painting a range to an offscreen buffer // given a display list, clip the items within the list to // the range nsRect ClipListToRange(nsDisplayListBuilder *aBuilder, nsDisplayList* aList,
--- a/layout/style/jar.mn +++ b/layout/style/jar.mn @@ -5,14 +5,15 @@ toolkit.jar: * res/ua.css (ua.css) res/html.css (html.css) res/quirk.css (quirk.css) res/full-screen-override.css (full-screen-override.css) 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) res/arrowd.gif (arrowd.gif) % resource gre-resources %res/
new file mode 100644 --- /dev/null +++ b/layout/style/noscript.css @@ -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; +}
--- a/layout/style/nsLayoutStylesheetCache.cpp +++ b/layout/style/nsLayoutStylesheetCache.cpp @@ -187,16 +187,29 @@ nsLayoutStylesheetCache::MathMLSheet() CSSStyleSheet* nsLayoutStylesheetCache::CounterStylesSheet() { EnsureGlobal(); 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() { NS_IF_RELEASE(gCSSLoader); gStyleCache = nullptr; } MOZ_DEFINE_MALLOC_SIZE_OF(LayoutStylesheetCacheMallocSizeOf) @@ -220,16 +233,17 @@ nsLayoutStylesheetCache::SizeOfIncluding #define MEASURE(s) n += s ? s->SizeOfIncludingThis(aMallocSizeOf) : 0; MEASURE(mCounterStylesSheet); MEASURE(mFormsSheet); MEASURE(mFullScreenOverrideSheet); MEASURE(mHTMLSheet); MEASURE(mMathMLSheet); MEASURE(mMinimalXULSheet); + MEASURE(mNoScriptSheet); MEASURE(mNumberControlSheet); MEASURE(mQuirkSheet); MEASURE(mSVGSheet); MEASURE(mScrollbarsSheet); MEASURE(mUASheet); MEASURE(mUserChromeSheet); MEASURE(mUserContentSheet); MEASURE(mXULSheet);
--- a/layout/style/nsLayoutStylesheetCache.h +++ b/layout/style/nsLayoutStylesheetCache.h @@ -43,16 +43,17 @@ class nsLayoutStylesheetCache final static mozilla::CSSStyleSheet* HTMLSheet(); static mozilla::CSSStyleSheet* MinimalXULSheet(); static mozilla::CSSStyleSheet* XULSheet(); static mozilla::CSSStyleSheet* QuirkSheet(); static mozilla::CSSStyleSheet* FullScreenOverrideSheet(); static mozilla::CSSStyleSheet* SVGSheet(); static mozilla::CSSStyleSheet* MathMLSheet(); static mozilla::CSSStyleSheet* CounterStylesSheet(); + static mozilla::CSSStyleSheet* NoScriptSheet(); static void Shutdown(); size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; private: nsLayoutStylesheetCache(); ~nsLayoutStylesheetCache(); @@ -73,16 +74,17 @@ private: static mozilla::StaticRefPtr<nsLayoutStylesheetCache> gStyleCache; static mozilla::css::Loader* gCSSLoader; nsRefPtr<mozilla::CSSStyleSheet> mCounterStylesSheet; nsRefPtr<mozilla::CSSStyleSheet> mFormsSheet; nsRefPtr<mozilla::CSSStyleSheet> mFullScreenOverrideSheet; 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; nsRefPtr<mozilla::CSSStyleSheet> mScrollbarsSheet; nsRefPtr<mozilla::CSSStyleSheet> mUASheet; nsRefPtr<mozilla::CSSStyleSheet> mUserChromeSheet; nsRefPtr<mozilla::CSSStyleSheet> mUserContentSheet; nsRefPtr<mozilla::CSSStyleSheet> mXULSheet;