mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-05 05:30:29 +00:00
Bug 1343886. Handle input or textarea elements having a non-textcontrol frame better. r=ehsan
MozReview-Commit-ID: FRzdvTLMAID
This commit is contained in:
parent
88119fbb90
commit
fdab22f79c
@ -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);
|
||||
}
|
||||
|
14
dom/html/crashtests/1343886-1.html
Normal file
14
dom/html/crashtests/1343886-1.html
Normal file
@ -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>
|
3
dom/html/crashtests/1343886-2.xml
Normal file
3
dom/html/crashtests/1343886-2.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<input xmlns="http://www.w3.org/1999/xhtml">
|
||||
<script>document.documentElement.selectionStart</script>
|
||||
</input>
|
3
dom/html/crashtests/1343886-3.xml
Normal file
3
dom/html/crashtests/1343886-3.xml
Normal file
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user