From e2020fa7f2dfda58eba1118482a271ec82a596f5 Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Thu, 13 Nov 2014 00:17:29 -0800 Subject: [PATCH] Add CPAltEnterTextAreaFeature checking. FF doesn't add a cariage return on textarea when doing alt+enter --- AppKit/CPCompatibility.j | 4 ++++ AppKit/CPTextField.j | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/AppKit/CPCompatibility.j b/AppKit/CPCompatibility.j index c471c1408..623249cd2 100644 --- a/AppKit/CPCompatibility.j +++ b/AppKit/CPCompatibility.j @@ -78,6 +78,8 @@ CPInputOnInputEventFeature = 30; CPFileAPIFeature = 31; +CPAltEnterTextAreaFeature = 32; + /* @@ -100,6 +102,7 @@ var USER_AGENT = "", // default these features to true PLATFORM_FEATURES[CPInputTypeCanBeChangedFeature] = YES; PLATFORM_FEATURES[CPInputSetFontOutsideOfDOM] = YES; +PLATFORM_FEATURES[CPAltEnterTextAreaFeature] = YES; if (typeof window !== "undefined" && typeof window.navigator !== "undefined") USER_AGENT = window.navigator.userAgent; @@ -208,6 +211,7 @@ else if (USER_AGENT.indexOf("Gecko") !== -1) // Must follow KHTML check. // Some day this might be fixed and should be version prefixed. No known fixed version yet. PLATFORM_FEATURES[CPInput1PxLeftPadding] = YES; + PLATFORM_FEATURES[CPAltEnterTextAreaFeature] = NO; // This was supposed to be added in Firefox 22, but when testing with the latest beta as of 2013-06-14 // it does not seem to work. It seems to exhibit the CPJavaScriptPasteRequiresEditableTarget problem, // and in addition doesn't seem to work with our native copy code either. diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 63ea80fe2..4b5f1dff6 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -1079,9 +1079,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); [self _didEdit]; } - console.error("newValue : >" + newValue + "<") - console.error("_stringValue : >" + _stringValue + "<") - if ([self _valueIsValid:_stringValue]) { // If _isEditing == YES then the target action can also be called via @@ -1129,7 +1126,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); // we don't need to do this in case of textarea // or we will end up with 2 carriage returns - if (aCharacter != CPNewlineCharacter || element.nodeName.toUpperCase() != "TEXTAREA") + if (aCharacter != CPNewlineCharacter || element.nodeName.toUpperCase() != "TEXTAREA" || !CPFeatureIsCompatible(CPAltEnterTextAreaFeature)) element.value = [element.value stringByReplacingCharactersInRange:[self selectedRange] withString:aCharacter]; [self _setStringValue:element.value];