mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-11-18 11:08:26 +00:00
#405: fix regression when date/time not enabled; improve input element enable checking performance
This commit is contained in:
parent
1c5fbc3107
commit
4fefd4a540
@ -112,8 +112,6 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include "nsIColorPicker.h"
|
#include "nsIColorPicker.h"
|
||||||
#include "nsIDatePicker.h" // TenFourFox issue 405
|
|
||||||
#include "nsITimePicker.h" // TenFourFox issue 405
|
|
||||||
#include "nsIStringEnumerator.h"
|
#include "nsIStringEnumerator.h"
|
||||||
#include "HTMLSplitOnSpacesTokenizer.h"
|
#include "HTMLSplitOnSpacesTokenizer.h"
|
||||||
#include "nsIController.h"
|
#include "nsIController.h"
|
||||||
@ -122,6 +120,10 @@
|
|||||||
|
|
||||||
// input type=date
|
// input type=date
|
||||||
#include "js/Date.h"
|
#include "js/Date.h"
|
||||||
|
#include "nsIDatePicker.h" // TenFourFox issue 405
|
||||||
|
|
||||||
|
// input type=time
|
||||||
|
#include "nsITimePicker.h" // TenFourFox issue 405
|
||||||
|
|
||||||
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Input)
|
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Input)
|
||||||
|
|
||||||
@ -221,6 +223,32 @@ const Decimal HTMLInputElement::kStepAny = Decimal(0);
|
|||||||
#define PROGRESS_STR "progress"
|
#define PROGRESS_STR "progress"
|
||||||
static const uint32_t kProgressEventInterval = 50; // ms
|
static const uint32_t kProgressEventInterval = 50; // ms
|
||||||
|
|
||||||
|
// Increase performance of checking for enabled types of input elements.
|
||||||
|
// TenFourFox issue 405
|
||||||
|
static bool sDOMInputPrefsCacheInitialized = false;
|
||||||
|
static bool sDOMInputEnableDate = false;
|
||||||
|
static bool sDOMInputEnableTime = false;
|
||||||
|
static bool sDOMInputEnableColor = false;
|
||||||
|
static bool sDOMInputEnableNumber = false;
|
||||||
|
static void InitializeDOMInputPrefCache() {
|
||||||
|
if (MOZ_UNLIKELY(sDOMInputPrefsCacheInitialized)) return;
|
||||||
|
Preferences::AddBoolVarCache(&sDOMInputEnableDate, "tenfourfox.dom.forms.date");
|
||||||
|
Preferences::AddBoolVarCache(&sDOMInputEnableTime, "tenfourfox.dom.forms.time");
|
||||||
|
// Mozilla implementations that existed prior
|
||||||
|
Preferences::AddBoolVarCache(&sDOMInputEnableColor, "dom.forms.color");
|
||||||
|
Preferences::AddBoolVarCache(&sDOMInputEnableNumber, "dom.forms.number");
|
||||||
|
sDOMInputPrefsCacheInitialized = true;
|
||||||
|
}
|
||||||
|
#define ENABLED(x) static inline bool Input ## x ## Enabled() { \
|
||||||
|
if (MOZ_UNLIKELY(!sDOMInputPrefsCacheInitialized)) InitializeDOMInputPrefCache(); \
|
||||||
|
return sDOMInputEnable ## x ; \
|
||||||
|
}
|
||||||
|
ENABLED(Date)
|
||||||
|
ENABLED(Time)
|
||||||
|
ENABLED(Color)
|
||||||
|
ENABLED(Number)
|
||||||
|
#undef ENABLED
|
||||||
|
|
||||||
class HTMLInputElementState final : public nsISupports
|
class HTMLInputElementState final : public nsISupports
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -3218,7 +3246,8 @@ HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
|
|||||||
// "hopped up" text field with special handling, we need to preempt
|
// "hopped up" text field with special handling, we need to preempt
|
||||||
// the line editor here before it has a chance to handle the key.
|
// the line editor here before it has a chance to handle the key.
|
||||||
// TenFourFox issue 405
|
// TenFourFox issue 405
|
||||||
if (mType == NS_FORM_INPUT_DATE || mType == NS_FORM_INPUT_TIME) {
|
if ((mType == NS_FORM_INPUT_DATE && InputDateEnabled()) ||
|
||||||
|
(mType == NS_FORM_INPUT_TIME && InputTimeEnabled())) {
|
||||||
if (aVisitor.mEvent->mMessage == eKeyPress && aVisitor.mEvent->mFlags.mIsTrusted) {
|
if (aVisitor.mEvent->mMessage == eKeyPress && aVisitor.mEvent->mFlags.mIsTrusted) {
|
||||||
WidgetKeyboardEvent* keyEvent = aVisitor.mEvent->AsKeyboardEvent();
|
WidgetKeyboardEvent* keyEvent = aVisitor.mEvent->AsKeyboardEvent();
|
||||||
if (!(keyEvent->IsMeta() ||
|
if (!(keyEvent->IsMeta() ||
|
||||||
@ -3913,7 +3942,8 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
|
|||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
WidgetKeyboardEvent* keyEvent = aVisitor.mEvent->AsKeyboardEvent();
|
WidgetKeyboardEvent* keyEvent = aVisitor.mEvent->AsKeyboardEvent();
|
||||||
|
|
||||||
if ((mType == NS_FORM_INPUT_DATE || mType == NS_FORM_INPUT_TIME) &&
|
if (((mType == NS_FORM_INPUT_DATE && InputDateEnabled()) ||
|
||||||
|
(mType == NS_FORM_INPUT_TIME && InputTimeEnabled())) &&
|
||||||
keyEvent && keyEvent->mMessage == eKeyPress &&
|
keyEvent && keyEvent->mMessage == eKeyPress &&
|
||||||
aVisitor.mEvent->mFlags.mIsTrusted &&
|
aVisitor.mEvent->mFlags.mIsTrusted &&
|
||||||
(keyEvent->keyCode == NS_VK_BACK || keyEvent->keyCode == NS_VK_DELETE) &&
|
(keyEvent->keyCode == NS_VK_BACK || keyEvent->keyCode == NS_VK_DELETE) &&
|
||||||
@ -4909,14 +4939,10 @@ HTMLInputElement::ParseAttribute(int32_t aNamespaceID,
|
|||||||
newType = aResult.GetEnumValue();
|
newType = aResult.GetEnumValue();
|
||||||
if (/* (IsExperimentalMobileType(newType) &&
|
if (/* (IsExperimentalMobileType(newType) &&
|
||||||
!Preferences::GetBool("dom.experimental_forms", false)) || */
|
!Preferences::GetBool("dom.experimental_forms", false)) || */
|
||||||
(newType == NS_FORM_INPUT_DATE &&
|
(newType == NS_FORM_INPUT_DATE && !InputDateEnabled()) ||
|
||||||
!Preferences::GetBool("tenfourfox.dom.forms.date", false)) ||
|
(newType == NS_FORM_INPUT_TIME && !InputTimeEnabled()) ||
|
||||||
(newType == NS_FORM_INPUT_TIME &&
|
(newType == NS_FORM_INPUT_NUMBER && !InputNumberEnabled()) ||
|
||||||
!Preferences::GetBool("tenfourfox.dom.forms.time", false)) ||
|
(newType == NS_FORM_INPUT_COLOR && !InputColorEnabled())) {
|
||||||
(newType == NS_FORM_INPUT_NUMBER &&
|
|
||||||
!Preferences::GetBool("dom.forms.number", false)) ||
|
|
||||||
(newType == NS_FORM_INPUT_COLOR &&
|
|
||||||
!Preferences::GetBool("dom.forms.color", false))) {
|
|
||||||
newType = kInputDefaultType->value;
|
newType = kInputDefaultType->value;
|
||||||
aResult.SetTo(newType, &aValue);
|
aResult.SetTo(newType, &aValue);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user