Bug 572649 - Attempting to scroll a textarea with a horizontal scrollbar using the mouse jumps to its bottom right (focusing a textarea with the mouse scrolls the selection into view); r=roc a=blocking-betaN+

This commit is contained in:
Ehsan Akhgari
2010-09-20 19:30:07 -04:00
parent 9e86c9d9cb
commit 2f0543d19f
3 changed files with 76 additions and 4 deletions

View File

@@ -703,10 +703,21 @@ void nsTextControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
nsISelection *caretSelection = caret->GetCaretDOMSelection();
const PRBool isFocusedRightNow = ourSel == caretSelection;
if (!isFocusedRightNow) {
nsRefPtr<ScrollOnFocusEvent> event = new ScrollOnFocusEvent(this);
nsresult rv = NS_DispatchToCurrentThread(event);
if (NS_SUCCEEDED(rv)) {
mScrollEvent = event;
// Don't scroll the current selection if we've been focused using the mouse.
PRUint32 lastFocusMethod = 0;
nsIDocument* doc = GetContent()->GetCurrentDoc();
if (doc) {
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm) {
fm->GetLastFocusMethod(doc->GetWindow(), &lastFocusMethod);
}
}
if (!(lastFocusMethod & nsIFocusManager::FLAG_BYMOUSE)) {
nsRefPtr<ScrollOnFocusEvent> event = new ScrollOnFocusEvent(this);
nsresult rv = NS_DispatchToCurrentThread(event);
if (NS_SUCCEEDED(rv)) {
mScrollEvent = event;
}
}
}