mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-18 06:45:33 +00:00
Bug 974430 - Put the |input[type=number]| rule in forms.css into a separate sheet so we can make it respect the dom.forms.number pref. r=dbaron
--HG-- extra : rebase_source : 450ffd1ca743868d75dda6ce0f89078216934e79
This commit is contained in:
parent
c4df4bacb1
commit
724f52955d
@ -2225,6 +2225,11 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
||||
}
|
||||
}
|
||||
|
||||
sheet = nsLayoutStylesheetCache::NumberControlSheet();
|
||||
if (sheet) {
|
||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
||||
}
|
||||
|
||||
sheet = nsLayoutStylesheetCache::FormsSheet();
|
||||
if (sheet) {
|
||||
styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, sheet);
|
||||
|
@ -901,13 +901,9 @@ input[type=range]::-moz-range-thumb {
|
||||
-moz-user-select: none ! important;
|
||||
}
|
||||
|
||||
input[type="number"] {
|
||||
-moz-appearance: number-input;
|
||||
/* Has to revert some properties applied by the generic input rule. */
|
||||
-moz-binding: none;
|
||||
width: 149px; /* to match type=text */
|
||||
overflow-clip-box: content-box;
|
||||
}
|
||||
/* As a temporary workaround until bug 677302 the rule for input[type=number]
|
||||
* has moved to number-control.css
|
||||
*/
|
||||
|
||||
input[type=number]::-moz-number-wrapper {
|
||||
/* Prevent styling that would change the type of frame we construct. */
|
||||
|
@ -10,6 +10,7 @@ toolkit.jar:
|
||||
res/plaintext.css (plaintext.css)
|
||||
res/viewsource.css (viewsource.css)
|
||||
* res/forms.css (forms.css)
|
||||
res/number-control.css (number-control.css)
|
||||
res/arrow.gif (arrow.gif)
|
||||
res/arrowd.gif (arrowd.gif)
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/css/Loader.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsNetUtil.h"
|
||||
@ -16,6 +17,12 @@
|
||||
#include "nsIXULRuntime.h"
|
||||
#include "nsCSSStyleSheet.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
static bool sNumberControlEnabled;
|
||||
|
||||
#define NUMBER_CONTROL_PREF "dom.forms.number"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(
|
||||
nsLayoutStylesheetCache, nsIObserver, nsIMemoryReporter)
|
||||
|
||||
@ -35,6 +42,7 @@ nsLayoutStylesheetCache::Observe(nsISupports* aSubject,
|
||||
strcmp(aTopic, "chrome-flush-caches") == 0) {
|
||||
mScrollbarsSheet = nullptr;
|
||||
mFormsSheet = nullptr;
|
||||
mNumberControlSheet = nullptr;
|
||||
}
|
||||
else {
|
||||
NS_NOTREACHED("Unexpected observer topic.");
|
||||
@ -85,6 +93,31 @@ nsLayoutStylesheetCache::FormsSheet()
|
||||
return gStyleCache->mFormsSheet;
|
||||
}
|
||||
|
||||
nsCSSStyleSheet*
|
||||
nsLayoutStylesheetCache::NumberControlSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
if (!gStyleCache)
|
||||
return nullptr;
|
||||
|
||||
if (!sNumberControlEnabled) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!gStyleCache->mNumberControlSheet) {
|
||||
nsCOMPtr<nsIURI> sheetURI;
|
||||
NS_NewURI(getter_AddRefs(sheetURI),
|
||||
NS_LITERAL_CSTRING("resource://gre-resources/number-control.css"));
|
||||
|
||||
if (sheetURI)
|
||||
LoadSheet(sheetURI, gStyleCache->mNumberControlSheet, false);
|
||||
|
||||
NS_ASSERTION(gStyleCache->mNumberControlSheet, "Could not load number-control.css");
|
||||
}
|
||||
|
||||
return gStyleCache->mNumberControlSheet;
|
||||
}
|
||||
|
||||
nsCSSStyleSheet*
|
||||
nsLayoutStylesheetCache::UserContentSheet()
|
||||
{
|
||||
@ -164,6 +197,7 @@ nsLayoutStylesheetCache::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf
|
||||
|
||||
MEASURE(mScrollbarsSheet);
|
||||
MEASURE(mFormsSheet);
|
||||
MEASURE(mNumberControlSheet);
|
||||
MEASURE(mUserContentSheet);
|
||||
MEASURE(mUserChromeSheet);
|
||||
MEASURE(mUASheet);
|
||||
@ -237,6 +271,9 @@ nsLayoutStylesheetCache::EnsureGlobal()
|
||||
NS_ADDREF(gStyleCache);
|
||||
|
||||
gStyleCache->InitMemoryReporter();
|
||||
|
||||
Preferences::AddBoolVarCache(&sNumberControlEnabled, NUMBER_CONTROL_PREF,
|
||||
true);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -33,6 +33,9 @@ class nsLayoutStylesheetCache MOZ_FINAL
|
||||
|
||||
static nsCSSStyleSheet* ScrollbarsSheet();
|
||||
static nsCSSStyleSheet* FormsSheet();
|
||||
// This function is expected to return nullptr when the dom.forms.number
|
||||
// pref is disabled.
|
||||
static nsCSSStyleSheet* NumberControlSheet();
|
||||
static nsCSSStyleSheet* UserContentSheet();
|
||||
static nsCSSStyleSheet* UserChromeSheet();
|
||||
static nsCSSStyleSheet* UASheet();
|
||||
@ -58,6 +61,7 @@ private:
|
||||
static mozilla::css::Loader* gCSSLoader;
|
||||
nsRefPtr<nsCSSStyleSheet> mScrollbarsSheet;
|
||||
nsRefPtr<nsCSSStyleSheet> mFormsSheet;
|
||||
nsRefPtr<nsCSSStyleSheet> mNumberControlSheet;
|
||||
nsRefPtr<nsCSSStyleSheet> mUserContentSheet;
|
||||
nsRefPtr<nsCSSStyleSheet> mUserChromeSheet;
|
||||
nsRefPtr<nsCSSStyleSheet> mUASheet;
|
||||
|
17
layout/style/number-control.css
Normal file
17
layout/style/number-control.css
Normal file
@ -0,0 +1,17 @@
|
||||
/* 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 file exists purely because we need the styling for input[type=number]
|
||||
* to apply only if the pref dom.forms.number is true. Once bug 677302 is
|
||||
* fixed this rule can move back to forms.css.
|
||||
*/
|
||||
|
||||
input[type="number"] {
|
||||
-moz-appearance: number-input;
|
||||
/* Has to revert some properties applied by the generic input rule. */
|
||||
-moz-binding: none;
|
||||
width: 149px; /* to match type=text */
|
||||
overflow-clip-box: content-box;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user