mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 637671 - Don't display the selection for a non-focused text element when restoring the selection state after a reframe; r=bzbarsky
This commit is contained in:
parent
373b34bd69
commit
21594f846d
@ -82,11 +82,13 @@ struct SelectionState {
|
||||
|
||||
class RestoreSelectionState : public nsRunnable {
|
||||
public:
|
||||
RestoreSelectionState(nsTextControlFrame *aFrame, PRInt32 aStart, PRInt32 aEnd)
|
||||
RestoreSelectionState(nsTextEditorState *aState, nsTextControlFrame *aFrame,
|
||||
PRInt32 aStart, PRInt32 aEnd)
|
||||
: mFrame(aFrame),
|
||||
mWeakFrame(aFrame),
|
||||
mStart(aStart),
|
||||
mEnd(aEnd)
|
||||
mEnd(aEnd),
|
||||
mTextEditorState(aState)
|
||||
{
|
||||
}
|
||||
|
||||
@ -96,6 +98,7 @@ public:
|
||||
// need to block script to avoid nested PrepareEditor calls (bug 642800).
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
mFrame->SetSelectionRange(mStart, mEnd);
|
||||
mTextEditorState->HideSelectionIfBlurred();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -105,6 +108,7 @@ private:
|
||||
nsWeakFrame mWeakFrame;
|
||||
PRInt32 mStart;
|
||||
PRInt32 mEnd;
|
||||
nsTextEditorState* mTextEditorState;
|
||||
};
|
||||
|
||||
/*static*/
|
||||
@ -1385,7 +1389,7 @@ nsTextEditorState::PrepareEditor(const nsAString *aValue)
|
||||
|
||||
// Restore our selection after being bound to a new frame
|
||||
if (mSelState) {
|
||||
nsContentUtils::AddScriptRunner(new RestoreSelectionState(mBoundFrame, mSelState->mStart, mSelState->mEnd));
|
||||
nsContentUtils::AddScriptRunner(new RestoreSelectionState(this, mBoundFrame, mSelState->mStart, mSelState->mEnd));
|
||||
mSelState = nsnull;
|
||||
}
|
||||
|
||||
@ -2011,6 +2015,16 @@ nsTextEditorState::SetPlaceholderClass(PRBool aVisible,
|
||||
classValue, aNotify);
|
||||
}
|
||||
|
||||
void
|
||||
nsTextEditorState::HideSelectionIfBlurred()
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mSelCon, "Should have a selection controller if we have a frame!");
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
|
||||
if (!nsContentUtils::IsFocusedContent(content)) {
|
||||
mSelCon->SetDisplaySelection(nsISelectionController::SELECTION_HIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsAnonDivObserver, nsIMutationObserver)
|
||||
|
||||
void
|
||||
|
@ -210,6 +210,8 @@ public:
|
||||
|
||||
void ClearValueCache() { mCachedValue.Truncate(); }
|
||||
|
||||
void HideSelectionIfBlurred();
|
||||
|
||||
private:
|
||||
// not copy constructible
|
||||
nsTextEditorState(const nsTextEditorState&);
|
||||
|
@ -60,3 +60,5 @@ fails-if(Android) != spellcheck-hyphen-multiple-invalid.html spellcheck-hyphen-m
|
||||
== caret_on_presshell_reinit.html caret_on_presshell_reinit-ref.html
|
||||
== caret_on_presshell_reinit-2.html caret_on_presshell_reinit-ref.html
|
||||
== 642800.html 642800-ref.html
|
||||
== selection_visibility_after_reframe.html selection_visibility_after_reframe-ref.html
|
||||
!= selection_visibility_after_reframe-2.html selection_visibility_after_reframe-ref.html
|
||||
|
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<input value="foo">
|
||||
<script>
|
||||
var i = document.querySelector("input");
|
||||
i.selectionStart = 1;
|
||||
i.selectionEnd = 2;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<input value="foo">
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<input value="foo">
|
||||
<script>
|
||||
var i = document.querySelector("input");
|
||||
i.selectionStart = 1;
|
||||
i.selectionEnd = 2;
|
||||
i.style.display = "none";
|
||||
document.body.clientHeight;
|
||||
i.style.display = "";
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user