Bug 1293570 - Revert parts of bug 1003741 which were added to make selection APIs work on <input type=number>; r=baku
In particular we keep the frame a form control frame so that it gets the correct CSS box sizing by the layout code.
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsILoadContext.h"
|
||||
#include "nsITextControlFrame.h"
|
||||
#include "nsNumberControlFrame.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsContentList.h"
|
||||
#include "nsCSSPseudoElements.h"
|
||||
@@ -10880,7 +10881,8 @@ nsIDocument::CaretPositionFromPoint(float aX, float aY)
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> input = do_QueryInterface(nonanon);
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea = do_QueryInterface(nonanon);
|
||||
nsITextControlFrame* textFrame = do_QueryFrame(nonanon->GetPrimaryFrame());
|
||||
if (!!textFrame) {
|
||||
nsNumberControlFrame* numberFrame = do_QueryFrame(nonanon->GetPrimaryFrame());
|
||||
if (textFrame || numberFrame) {
|
||||
// If the anonymous content node has a child, then we need to make sure
|
||||
// that we get the appropriate child, as otherwise the offset may not be
|
||||
// correct when we construct a range for it.
|
||||
|
||||
@@ -1513,7 +1513,7 @@ private:
|
||||
bool SupportsTextSelection() const {
|
||||
return mType == NS_FORM_INPUT_TEXT || mType == NS_FORM_INPUT_SEARCH ||
|
||||
mType == NS_FORM_INPUT_URL || mType == NS_FORM_INPUT_TEL ||
|
||||
mType == NS_FORM_INPUT_PASSWORD || mType == NS_FORM_INPUT_NUMBER;
|
||||
mType == NS_FORM_INPUT_PASSWORD;
|
||||
}
|
||||
|
||||
static bool MayFireChangeOnBlur(uint8_t aType) {
|
||||
|
||||
@@ -42,16 +42,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1283915
|
||||
|
||||
synthesizeKey("1", {});
|
||||
is(nField.value, "1");
|
||||
isCursorAtEnd(nField);
|
||||
document.body.offsetWidth;
|
||||
|
||||
synthesizeKey("2", {});
|
||||
is(nField.value, "12");
|
||||
isCursorAtEnd(nField);
|
||||
|
||||
synthesizeKey("3", {});
|
||||
is(nField.value, "123");
|
||||
isCursorAtEnd(nField);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=850364
|
||||
<input type="url" id="input_url"></input>
|
||||
<input type="tel" id="input_tel"></input>
|
||||
<input type="password" id="input_password"></input>
|
||||
<input type="number" id="input_number"></input>
|
||||
<textarea id="input_textarea"></textarea>
|
||||
|
||||
<!-- "SetRangeText() non-supported types" -->
|
||||
@@ -40,7 +39,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=850364
|
||||
|
||||
/** Tests for Bug 850364 && Bug 918940**/
|
||||
|
||||
var SupportedTypes = ["text", "search", "url", "tel", "password", "textarea", "number"];
|
||||
var SupportedTypes = ["text", "search", "url", "tel", "password", "textarea"];
|
||||
var NonSupportedTypes = ["button", "submit", "image", "reset", "radio",
|
||||
"checkbox", "range", "file", "email"];
|
||||
|
||||
@@ -93,58 +92,58 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=850364
|
||||
}, false);
|
||||
|
||||
var test = " setRange(replacement), shrink";
|
||||
elem.value = "0123456789123456";
|
||||
elem.value = "0123456789ABCDEF";
|
||||
elem.setSelectionRange(1, 6);
|
||||
elem.setRangeText("999");
|
||||
is(elem.value, "09996789123456", msg + test);
|
||||
elem.setRangeText("xyz");
|
||||
is(elem.value, "0xyz6789ABCDEF", msg + test);
|
||||
is(elem.selectionStart, 1, msg + test);
|
||||
is(elem.selectionEnd, 4, msg + test);
|
||||
elem.setRangeText("222");
|
||||
is(elem.value, "02226789123456", msg + test);
|
||||
elem.setRangeText("mnk");
|
||||
is(elem.value, "0mnk6789ABCDEF", msg + test);
|
||||
expectedNumOfSelectCalls += 3;
|
||||
|
||||
test = " setRange(replacement), expand";
|
||||
elem.value = "0123456789123456";
|
||||
elem.value = "0123456789ABCDEF";
|
||||
elem.setSelectionRange(1, 2);
|
||||
elem.setRangeText("999");
|
||||
is(elem.value, "099923456789123456", msg + test);
|
||||
elem.setRangeText("xyz");
|
||||
is(elem.value, "0xyz23456789ABCDEF", msg + test);
|
||||
is(elem.selectionStart, 1, msg + test);
|
||||
is(elem.selectionEnd, 4, msg + test);
|
||||
elem.setRangeText("222");
|
||||
is(elem.value, "022223456789123456", msg + test);
|
||||
elem.setRangeText("mnk");
|
||||
is(elem.value, "0mnk23456789ABCDEF", msg + test);
|
||||
expectedNumOfSelectCalls += 3;
|
||||
|
||||
test = " setRange(replacement) pure insertion at start";
|
||||
elem.value = "0123456789123456";
|
||||
elem.value = "0123456789ABCDEF";
|
||||
elem.setSelectionRange(0, 0);
|
||||
elem.setRangeText("999");
|
||||
is(elem.value, "9990123456789123456", msg + test);
|
||||
elem.setRangeText("xyz");
|
||||
is(elem.value, "xyz0123456789ABCDEF", msg + test);
|
||||
is(elem.selectionStart, 0, msg + test);
|
||||
is(elem.selectionEnd, 0, msg + test);
|
||||
elem.setRangeText("222");
|
||||
is(elem.value, "2229990123456789123456", msg + test);
|
||||
elem.setRangeText("mnk");
|
||||
is(elem.value, "mnkxyz0123456789ABCDEF", msg + test);
|
||||
expectedNumOfSelectCalls += 3;
|
||||
|
||||
test = " setRange(replacement) pure insertion in the middle";
|
||||
elem.value = "0123456789123456";
|
||||
elem.value = "0123456789ABCDEF";
|
||||
elem.setSelectionRange(4, 4);
|
||||
elem.setRangeText("999");
|
||||
is(elem.value, "0123999456789123456", msg + test);
|
||||
elem.setRangeText("xyz");
|
||||
is(elem.value, "0123xyz456789ABCDEF", msg + test);
|
||||
is(elem.selectionStart, 4, msg + test);
|
||||
is(elem.selectionEnd, 4, msg + test);
|
||||
elem.setRangeText("222");
|
||||
is(elem.value, "0123222999456789123456", msg + test);
|
||||
elem.setRangeText("mnk");
|
||||
is(elem.value, "0123mnkxyz456789ABCDEF", msg + test);
|
||||
expectedNumOfSelectCalls += 3;
|
||||
|
||||
test = " setRange(replacement) pure insertion at the end";
|
||||
elem.value = "1123456789123456";
|
||||
elem.value = "0123456789ABCDEF";
|
||||
elem.setSelectionRange(16, 16);
|
||||
elem.setRangeText("999");
|
||||
is(elem.value, "1123456789123456999", msg + test);
|
||||
elem.setRangeText("xyz");
|
||||
is(elem.value, "0123456789ABCDEFxyz", msg + test);
|
||||
is(elem.selectionStart, 16, msg + test);
|
||||
is(elem.selectionEnd, 16, msg + test);
|
||||
elem.setRangeText("222");
|
||||
is(elem.value, "1123456789123456222999", msg + test);
|
||||
elem.setRangeText("mnk");
|
||||
is(elem.value, "0123456789ABCDEFmnkxyz", msg + test);
|
||||
expectedNumOfSelectCalls += 3;
|
||||
|
||||
//test SetRange(replacement, start, end, mode) with start > end
|
||||
@@ -156,43 +155,43 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=850364
|
||||
is(opThrows, true, msg + " should throw IndexSizeError");
|
||||
|
||||
//test SelectionMode 'select'
|
||||
elem.value = "1023456789123456";
|
||||
elem.setRangeText("999", 4, 9, "select");
|
||||
is(elem.value, "10239999123456", msg + ".value == \"10239999123456\"");
|
||||
elem.value = "0123456789ABCDEF";
|
||||
elem.setRangeText("xyz", 4, 9, "select");
|
||||
is(elem.value, "0123xyz9ABCDEF", msg + ".value == \"0123xyz9ABCDEF\"");
|
||||
is(elem.selectionStart, 4, msg + ".selectionStart == 4, with \"select\"");
|
||||
is(elem.selectionEnd, 7, msg + ".selectionEnd == 7, with \"select\"");
|
||||
expectedNumOfSelectCalls += 1;
|
||||
|
||||
elem.setRangeText("888", 6, 25, "select");
|
||||
is(elem.value, "102399888", msg + ".value == \"102399888\"");
|
||||
elem.setRangeText("pqm", 6, 25, "select");
|
||||
is(elem.value, "0123xypqm", msg + ".value == \"0123xypqm\"");
|
||||
is(elem.selectionStart, 6, msg + ".selectionStart == 6, with \"select\"");
|
||||
is(elem.selectionEnd, 9, msg + ".selectionEnd == 9, with \"select\"");
|
||||
expectedNumOfSelectCalls += 1;
|
||||
|
||||
//test SelectionMode 'start'
|
||||
elem.value = "0123456789123456";
|
||||
elem.setRangeText("999", 4, 9, "start");
|
||||
is(elem.value, "01239999123456", msg + ".value == \"01239999123456\"");
|
||||
elem.value = "0123456789ABCDEF";
|
||||
elem.setRangeText("xyz", 4, 9, "start");
|
||||
is(elem.value, "0123xyz9ABCDEF", msg + ".value == \"0123xyz9ABCDEF\"");
|
||||
is(elem.selectionStart, 4, msg + ".selectionStart == 4, with \"start\"");
|
||||
is(elem.selectionEnd, 4, msg + ".selectionEnd == 4, with \"start\"");
|
||||
expectedNumOfSelectCalls += 1;
|
||||
|
||||
elem.setRangeText("888", 6, 25, "start");
|
||||
is(elem.value, "012399888", msg + ".value == \"012399888\"");
|
||||
elem.setRangeText("pqm", 6, 25, "start");
|
||||
is(elem.value, "0123xypqm", msg + ".value == \"0123xypqm\"");
|
||||
is(elem.selectionStart, 6, msg + ".selectionStart == 6, with \"start\"");
|
||||
is(elem.selectionEnd, 6, msg + ".selectionEnd == 6, with \"start\"");
|
||||
expectedNumOfSelectCalls += 1;
|
||||
|
||||
//test SelectionMode 'end'
|
||||
elem.value = "1023456789123456";
|
||||
elem.setRangeText("999", 4, 9, "end");
|
||||
is(elem.value, "10239999123456", msg + ".value == \"10239999123456\"");
|
||||
elem.value = "0123456789ABCDEF";
|
||||
elem.setRangeText("xyz", 4, 9, "end");
|
||||
is(elem.value, "0123xyz9ABCDEF", msg + ".value == \"0123xyz9ABCDEF\"");
|
||||
is(elem.selectionStart, 7, msg + ".selectionStart == 7, with \"end\"");
|
||||
is(elem.selectionEnd, 7, msg + ".selectionEnd == 7, with \"end\"");
|
||||
expectedNumOfSelectCalls += 1;
|
||||
|
||||
elem.setRangeText("888", 6, 25, "end");
|
||||
is(elem.value, "102399888", msg + ".value == \"102399888\"");
|
||||
elem.setRangeText("pqm", 6, 25, "end");
|
||||
is(elem.value, "0123xypqm", msg + ".value == \"0123xypqm\"");
|
||||
is(elem.selectionStart, 9, msg + ".selectionStart == 9, with \"end\"");
|
||||
is(elem.selectionEnd, 9, msg + ".selectionEnd == 9, with \"end\"");
|
||||
expectedNumOfSelectCalls += 1;
|
||||
@@ -202,8 +201,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=850364
|
||||
//subcase: selection{Start|End} > end
|
||||
elem.value = "0123456789";
|
||||
elem.setSelectionRange(6, 9);
|
||||
elem.setRangeText("7", 1, 2, "preserve");
|
||||
is(elem.value, "0723456789", msg + ".value == \"0723456789\"");
|
||||
elem.setRangeText("Z", 1, 2, "preserve");
|
||||
is(elem.value, "0Z23456789", msg + ".value == \"0Z23456789\"");
|
||||
is(elem.selectionStart, 6, msg + ".selectionStart == 6, with \"preserve\"");
|
||||
is(elem.selectionEnd, 9, msg + ".selectionEnd == 9, with \"preserve\"");
|
||||
expectedNumOfSelectCalls += 2;
|
||||
@@ -211,8 +210,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=850364
|
||||
//subcase: selection{Start|End} < end
|
||||
elem.value = "0123456789";
|
||||
elem.setSelectionRange(4, 5);
|
||||
elem.setRangeText("3456", 2, 9, "preserve");
|
||||
is(elem.value, "0134569", msg + ".value == \"0134569\"");
|
||||
elem.setRangeText("QRST", 2, 9, "preserve");
|
||||
is(elem.value, "01QRST9", msg + ".value == \"01QRST9\"");
|
||||
is(elem.selectionStart, 2, msg + ".selectionStart == 2, with \"preserve\"");
|
||||
is(elem.selectionEnd, 6, msg + ".selectionEnd == 6, with \"preserve\"");
|
||||
expectedNumOfSelectCalls += 2;
|
||||
@@ -220,8 +219,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=850364
|
||||
//subcase: selectionStart > end, selectionEnd < end
|
||||
elem.value = "0123456789";
|
||||
elem.setSelectionRange(8, 4);
|
||||
elem.setRangeText("3456", 1, 5);
|
||||
is(elem.value, "0345656789", msg + ".value == \"0345656789\"");
|
||||
elem.setRangeText("QRST", 1, 5);
|
||||
is(elem.value, "0QRST56789", msg + ".value == \"0QRST56789\"");
|
||||
is(elem.selectionStart, 1, msg + ".selectionStart == 1, with \"default\"");
|
||||
is(elem.selectionEnd, 5, msg + ".selectionEnd == 5, with \"default\"");
|
||||
expectedNumOfSelectCalls += 2;
|
||||
@@ -229,8 +228,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=850364
|
||||
//subcase: selectionStart < end, selectionEnd > end
|
||||
elem.value = "0123456789";
|
||||
elem.setSelectionRange(4, 9);
|
||||
elem.setRangeText("3456", 2, 6);
|
||||
is(elem.value, "0134566789", msg + ".value == \"0134566789\"");
|
||||
elem.setRangeText("QRST", 2, 6);
|
||||
is(elem.value, "01QRST6789", msg + ".value == \"01QRST6789\"");
|
||||
is(elem.selectionStart, 2, msg + ".selectionStart == 2, with \"default\"");
|
||||
is(elem.selectionEnd, 9, msg + ".selectionEnd == 9, with \"default\"");
|
||||
expectedNumOfSelectCalls += 2;
|
||||
|
||||
@@ -46,7 +46,6 @@ NS_IMPL_FRAMEARENA_HELPERS(nsNumberControlFrame)
|
||||
NS_QUERYFRAME_HEAD(nsNumberControlFrame)
|
||||
NS_QUERYFRAME_ENTRY(nsNumberControlFrame)
|
||||
NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
|
||||
NS_QUERYFRAME_ENTRY(nsITextControlFrame)
|
||||
NS_QUERYFRAME_ENTRY(nsIFormControlFrame)
|
||||
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
||||
|
||||
@@ -473,72 +472,6 @@ nsNumberControlFrame::GetType() const
|
||||
return nsGkAtoms::numberControlFrame;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNumberControlFrame::GetEditor(nsIEditor **aEditor)
|
||||
{
|
||||
return GetTextFieldFrame()->GetEditor(aEditor);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNumberControlFrame::SetSelectionStart(int32_t aSelectionStart)
|
||||
{
|
||||
return GetTextFieldFrame()->SetSelectionStart(aSelectionStart);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNumberControlFrame::SetSelectionEnd(int32_t aSelectionEnd)
|
||||
{
|
||||
return GetTextFieldFrame()->SetSelectionEnd(aSelectionEnd);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNumberControlFrame::SetSelectionRange(int32_t aSelectionStart,
|
||||
int32_t aSelectionEnd,
|
||||
SelectionDirection aDirection)
|
||||
{
|
||||
return GetTextFieldFrame()->SetSelectionRange(aSelectionStart, aSelectionEnd,
|
||||
aDirection);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNumberControlFrame::GetSelectionRange(int32_t* aSelectionStart,
|
||||
int32_t* aSelectionEnd,
|
||||
SelectionDirection* aDirection)
|
||||
{
|
||||
return GetTextFieldFrame()->GetSelectionRange(aSelectionStart, aSelectionEnd,
|
||||
aDirection);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNumberControlFrame::GetOwnedSelectionController(nsISelectionController** aSelCon)
|
||||
{
|
||||
return GetTextFieldFrame()->GetOwnedSelectionController(aSelCon);
|
||||
}
|
||||
|
||||
nsFrameSelection*
|
||||
nsNumberControlFrame::GetOwnedFrameSelection()
|
||||
{
|
||||
return GetTextFieldFrame()->GetOwnedFrameSelection();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNumberControlFrame::GetPhonetic(nsAString& aPhonetic)
|
||||
{
|
||||
return GetTextFieldFrame()->GetPhonetic(aPhonetic);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNumberControlFrame::EnsureEditorInitialized()
|
||||
{
|
||||
return GetTextFieldFrame()->EnsureEditorInitialized();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNumberControlFrame::ScrollSelectionIntoView()
|
||||
{
|
||||
return GetTextFieldFrame()->ScrollSelectionIntoView();
|
||||
}
|
||||
|
||||
void
|
||||
nsNumberControlFrame::SetFocus(bool aOn, bool aRepaint)
|
||||
{
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsContainerFrame.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
#include "nsITextControlFrame.h"
|
||||
#include "nsIAnonymousContentCreator.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsITextControlFrame;
|
||||
class nsPresContext;
|
||||
|
||||
namespace mozilla {
|
||||
@@ -29,7 +29,7 @@ class HTMLInputElement;
|
||||
*/
|
||||
class nsNumberControlFrame final : public nsContainerFrame
|
||||
, public nsIAnonymousContentCreator
|
||||
, public nsITextControlFrame
|
||||
, public nsIFormControlFrame
|
||||
{
|
||||
friend nsIFrame*
|
||||
NS_NewNumberControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
||||
@@ -87,34 +87,6 @@ public:
|
||||
~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
|
||||
}
|
||||
|
||||
// nsITextControlFrame
|
||||
NS_IMETHOD GetEditor(nsIEditor **aEditor) override;
|
||||
|
||||
NS_IMETHOD SetSelectionStart(int32_t aSelectionStart) override;
|
||||
NS_IMETHOD SetSelectionEnd(int32_t aSelectionEnd) override;
|
||||
|
||||
NS_IMETHOD SetSelectionRange(int32_t aSelectionStart,
|
||||
int32_t aSelectionEnd,
|
||||
SelectionDirection aDirection = eNone) override;
|
||||
|
||||
NS_IMETHOD GetSelectionRange(int32_t* aSelectionStart,
|
||||
int32_t* aSelectionEnd,
|
||||
SelectionDirection* aDirection = nullptr) override;
|
||||
|
||||
NS_IMETHOD GetOwnedSelectionController(nsISelectionController** aSelCon) override;
|
||||
virtual nsFrameSelection* GetOwnedFrameSelection() override;
|
||||
|
||||
virtual nsresult GetPhonetic(nsAString& aPhonetic) override;
|
||||
|
||||
/**
|
||||
* Ensure mEditor is initialized with the proper flags and the default value.
|
||||
* @throws NS_ERROR_NOT_INITIALIZED if mEditor has not been created
|
||||
* @throws various and sundry other things
|
||||
*/
|
||||
virtual nsresult EnsureEditorInitialized() override;
|
||||
|
||||
virtual nsresult ScrollSelectionIntoView() override;
|
||||
|
||||
// nsIFormControlFrame
|
||||
virtual void SetFocus(bool aOn, bool aRepaint) override;
|
||||
virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) override;
|
||||
|
||||
@@ -29,6 +29,3 @@
|
||||
|
||||
[input type datetime-local should not support variable-length selections]
|
||||
expected: FAIL
|
||||
|
||||
[input type number should not support variable-length selections]
|
||||
expected: FAIL
|
||||
|
||||
Reference in New Issue
Block a user