Bug 1343886. Handle input or textarea elements having a non-textcontrol frame better. r=ehsan

MozReview-Commit-ID: FRzdvTLMAID
This commit is contained in:
Boris Zbarsky 2017-03-06 10:29:38 -05:00
Родитель 88119fbb90
Коммит fdab22f79c
7 изменённых файлов: 27 добавлений и 18 удалений

Просмотреть файл

@ -6615,14 +6615,6 @@ HTMLInputElement::GetSelectionRange(int32_t* aSelectionStart,
if (IsInComposedDoc()) {
GetComposedDoc()->FlushPendingNotifications(FlushType::Frames);
}
if (!GetPrimaryFrame()) {
// Can we return a selection range anyway here, now that it lives on our
// state? In fact, could we make this behave more like
// GetSelectionDirection, in the sense of working even when we have no
// frame, by just delegating entirely to mState? And then, do we really
// need the flush?
return NS_ERROR_FAILURE;
}
nsTextEditorState* state = GetEditorState();
if (!state) {

Просмотреть файл

@ -848,14 +848,6 @@ HTMLTextAreaElement::GetSelectionRange(int32_t* aSelectionStart,
if (IsInComposedDoc()) {
GetComposedDoc()->FlushPendingNotifications(FlushType::Frames);
}
if (!GetPrimaryFrame()) {
// Can we return a selection range anyway here, now that it lives on our
// state? In fact, could we make this behave more like
// GetSelectionDirection, in the sense of working even when we have no
// frame, by just delegating entirely to mState? And then, do we really
// need the flush?
return NS_ERROR_FAILURE;
}
return mState.GetSelectionRange(aSelectionStart, aSelectionEnd);
}

Просмотреть файл

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<script>
document.documentElement.scrollTop = "500";
o1 = document.createRange();
o2 = document.createElement('input');
o1.selectNode(document.documentElement);
o1.surroundContents(o2);
o2.selectionStart;
</script>
</head>
<body></body>
</html>

Просмотреть файл

@ -0,0 +1,3 @@
<input xmlns="http://www.w3.org/1999/xhtml">
<script>document.documentElement.selectionStart</script>
</input>

Просмотреть файл

@ -0,0 +1,3 @@
<textarea xmlns="http://www.w3.org/1999/xhtml">
<script>document.documentElement.selectionStart</script>
</textarea>

Просмотреть файл

@ -78,3 +78,6 @@ load 1237633.html
load 1281972-1.html
load 1282894.html
load 1290904.html
load 1343886-1.html
load 1343886-2.xml
load 1343886-3.xml

Просмотреть файл

@ -1553,11 +1553,13 @@ nsresult
nsTextEditorState::GetSelectionRange(int32_t* aSelectionStart,
int32_t* aSelectionEnd)
{
MOZ_ASSERT(mBoundFrame,
"Caller didn't flush out frames and check for a frame?");
MOZ_ASSERT(aSelectionStart);
MOZ_ASSERT(aSelectionEnd);
if (!mBoundFrame) {
return NS_ERROR_FAILURE;
}
// It's not clear that all the checks here are needed, but the previous
// version of this code in nsTextControlFrame was doing them, so we keep them
// for now.