зеркало из https://github.com/mozilla/pjs.git
Patch that gets tabbing back into text fields. r=waterson
This commit is contained in:
Родитель
b34e26f745
Коммит
563b3b509d
|
@ -700,6 +700,10 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
|
||||||
if (!keyEvent->isAlt) {
|
if (!keyEvent->isAlt) {
|
||||||
switch(keyEvent->keyCode) {
|
switch(keyEvent->keyCode) {
|
||||||
case NS_VK_TAB:
|
case NS_VK_TAB:
|
||||||
|
if (mConsumeFocusEvents) {
|
||||||
|
mConsumeFocusEvents = PR_FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
//Shift focus forward or back depending on shift key
|
//Shift focus forward or back depending on shift key
|
||||||
ShiftFocus(!((nsInputEvent*)aEvent)->isShift);
|
ShiftFocus(!((nsInputEvent*)aEvent)->isShift);
|
||||||
*aStatus = nsEventStatus_eConsumeNoDefault;
|
*aStatus = nsEventStatus_eConsumeNoDefault;
|
||||||
|
@ -1490,6 +1494,17 @@ nsEventStateManager::ShiftFocus(PRBool forward)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now we need to get the content node's frame and reset
|
||||||
|
// the mCurrentTarget target. Otherwise the focus
|
||||||
|
// code will be slightly out of sync (with regards to
|
||||||
|
// focusing widgets within the current target).
|
||||||
|
nsCOMPtr<nsIPresShell> shell;
|
||||||
|
if (mPresContext) {
|
||||||
|
nsresult rv = mPresContext->GetShell(getter_AddRefs(shell));
|
||||||
|
if (NS_SUCCEEDED(rv) && shell){
|
||||||
|
shell->GetPrimaryFrameFor(next, &mCurrentTarget);
|
||||||
|
}
|
||||||
|
}
|
||||||
ChangeFocus(next, mCurrentTarget, PR_TRUE);
|
ChangeFocus(next, mCurrentTarget, PR_TRUE);
|
||||||
|
|
||||||
NS_IF_RELEASE(mCurrentFocus);
|
NS_IF_RELEASE(mCurrentFocus);
|
||||||
|
@ -1917,6 +1932,9 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIPresShell> presShell;
|
||||||
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
||||||
|
|
||||||
if (nsnull != gLastFocusedPresContext) {
|
if (nsnull != gLastFocusedPresContext) {
|
||||||
|
|
||||||
if (gLastFocusedContent) {
|
if (gLastFocusedContent) {
|
||||||
|
@ -1925,7 +1943,7 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo
|
||||||
// the Ender widget case.
|
// the Ender widget case.
|
||||||
nsCOMPtr<nsIDocument> doc;
|
nsCOMPtr<nsIDocument> doc;
|
||||||
gLastFocusedContent->GetDocument(*getter_AddRefs(doc));
|
gLastFocusedContent->GetDocument(*getter_AddRefs(doc));
|
||||||
if(doc) {
|
if (doc) {
|
||||||
nsCOMPtr<nsIPresShell> shell = getter_AddRefs(doc->GetShellAt(0));
|
nsCOMPtr<nsIPresShell> shell = getter_AddRefs(doc->GetShellAt(0));
|
||||||
nsCOMPtr<nsIPresContext> oldPresContext;
|
nsCOMPtr<nsIPresContext> oldPresContext;
|
||||||
shell->GetPresContext(getter_AddRefs(oldPresContext));
|
shell->GetPresContext(getter_AddRefs(oldPresContext));
|
||||||
|
@ -1947,10 +1965,7 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo
|
||||||
// Go ahead and fire a blur on the window.
|
// Go ahead and fire a blur on the window.
|
||||||
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
||||||
gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
|
gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
|
||||||
|
|
||||||
nsCOMPtr<nsIPresShell> presShell;
|
|
||||||
aPresContext->GetShell(getter_AddRefs(presShell));
|
|
||||||
|
|
||||||
if (!mDocument) {
|
if (!mDocument) {
|
||||||
if (presShell) {
|
if (presShell) {
|
||||||
presShell->GetDocument(&mDocument);
|
presShell->GetDocument(&mDocument);
|
||||||
|
@ -2001,32 +2016,19 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXx The following line could be bad in the case where a
|
||||||
|
// parent element is really the one with the focus.
|
||||||
nsIFrame * currentFocusFrame = mCurrentTarget;
|
nsIFrame * currentFocusFrame = mCurrentTarget;
|
||||||
|
|
||||||
// Check to see if the newly focused content's frame has a view with a widget
|
|
||||||
// i.e TextField or TextArea, if so, don't set the focus on their window
|
|
||||||
PRBool shouldSetFocusOnWindow = PR_TRUE;
|
|
||||||
if (nsnull != currentFocusFrame) {
|
|
||||||
nsIView * view = nsnull;
|
|
||||||
currentFocusFrame->GetView(aPresContext, &view);
|
|
||||||
if (view != nsnull) {
|
|
||||||
nsIWidget *window = nsnull;
|
|
||||||
view->GetWidget(window);
|
|
||||||
if (window != nsnull) { // addrefs
|
|
||||||
shouldSetFocusOnWindow = PR_FALSE;
|
|
||||||
NS_RELEASE(window);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the window that this frame is in and
|
// Find the window that this frame is in and
|
||||||
// make sure it has focus
|
// make sure it has focus
|
||||||
// XXX Note: mLastWindowToHaveFocus this does not track when ANY focus
|
// GFX Text Control frames handle their own focus
|
||||||
// event comes through, the only place this gets set is here
|
// and must be special-cased.
|
||||||
// so some windows may get multiple focus events
|
nsCOMPtr<nsIGfxTextControlFrame> gfxFrame = do_QueryInterface(currentFocusFrame);
|
||||||
// For example, if you clicked in the window (generates focus event)
|
if (gfxFrame) {
|
||||||
// then click on a gfx control (generates another focus event)
|
gfxFrame->SetInnerFocus();
|
||||||
if (shouldSetFocusOnWindow && nsnull != currentFocusFrame) {
|
}
|
||||||
|
else if (currentFocusFrame) {
|
||||||
nsIFrame * parentFrame;
|
nsIFrame * parentFrame;
|
||||||
currentFocusFrame->GetParentWithView(aPresContext, &parentFrame);
|
currentFocusFrame->GetParentWithView(aPresContext, &parentFrame);
|
||||||
if (nsnull != parentFrame) {
|
if (nsnull != parentFrame) {
|
||||||
|
|
|
@ -700,6 +700,10 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
|
||||||
if (!keyEvent->isAlt) {
|
if (!keyEvent->isAlt) {
|
||||||
switch(keyEvent->keyCode) {
|
switch(keyEvent->keyCode) {
|
||||||
case NS_VK_TAB:
|
case NS_VK_TAB:
|
||||||
|
if (mConsumeFocusEvents) {
|
||||||
|
mConsumeFocusEvents = PR_FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
//Shift focus forward or back depending on shift key
|
//Shift focus forward or back depending on shift key
|
||||||
ShiftFocus(!((nsInputEvent*)aEvent)->isShift);
|
ShiftFocus(!((nsInputEvent*)aEvent)->isShift);
|
||||||
*aStatus = nsEventStatus_eConsumeNoDefault;
|
*aStatus = nsEventStatus_eConsumeNoDefault;
|
||||||
|
@ -1490,6 +1494,17 @@ nsEventStateManager::ShiftFocus(PRBool forward)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now we need to get the content node's frame and reset
|
||||||
|
// the mCurrentTarget target. Otherwise the focus
|
||||||
|
// code will be slightly out of sync (with regards to
|
||||||
|
// focusing widgets within the current target).
|
||||||
|
nsCOMPtr<nsIPresShell> shell;
|
||||||
|
if (mPresContext) {
|
||||||
|
nsresult rv = mPresContext->GetShell(getter_AddRefs(shell));
|
||||||
|
if (NS_SUCCEEDED(rv) && shell){
|
||||||
|
shell->GetPrimaryFrameFor(next, &mCurrentTarget);
|
||||||
|
}
|
||||||
|
}
|
||||||
ChangeFocus(next, mCurrentTarget, PR_TRUE);
|
ChangeFocus(next, mCurrentTarget, PR_TRUE);
|
||||||
|
|
||||||
NS_IF_RELEASE(mCurrentFocus);
|
NS_IF_RELEASE(mCurrentFocus);
|
||||||
|
@ -1917,6 +1932,9 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIPresShell> presShell;
|
||||||
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
||||||
|
|
||||||
if (nsnull != gLastFocusedPresContext) {
|
if (nsnull != gLastFocusedPresContext) {
|
||||||
|
|
||||||
if (gLastFocusedContent) {
|
if (gLastFocusedContent) {
|
||||||
|
@ -1925,7 +1943,7 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo
|
||||||
// the Ender widget case.
|
// the Ender widget case.
|
||||||
nsCOMPtr<nsIDocument> doc;
|
nsCOMPtr<nsIDocument> doc;
|
||||||
gLastFocusedContent->GetDocument(*getter_AddRefs(doc));
|
gLastFocusedContent->GetDocument(*getter_AddRefs(doc));
|
||||||
if(doc) {
|
if (doc) {
|
||||||
nsCOMPtr<nsIPresShell> shell = getter_AddRefs(doc->GetShellAt(0));
|
nsCOMPtr<nsIPresShell> shell = getter_AddRefs(doc->GetShellAt(0));
|
||||||
nsCOMPtr<nsIPresContext> oldPresContext;
|
nsCOMPtr<nsIPresContext> oldPresContext;
|
||||||
shell->GetPresContext(getter_AddRefs(oldPresContext));
|
shell->GetPresContext(getter_AddRefs(oldPresContext));
|
||||||
|
@ -1947,10 +1965,7 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo
|
||||||
// Go ahead and fire a blur on the window.
|
// Go ahead and fire a blur on the window.
|
||||||
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
||||||
gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
|
gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
|
||||||
|
|
||||||
nsCOMPtr<nsIPresShell> presShell;
|
|
||||||
aPresContext->GetShell(getter_AddRefs(presShell));
|
|
||||||
|
|
||||||
if (!mDocument) {
|
if (!mDocument) {
|
||||||
if (presShell) {
|
if (presShell) {
|
||||||
presShell->GetDocument(&mDocument);
|
presShell->GetDocument(&mDocument);
|
||||||
|
@ -2001,32 +2016,19 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXx The following line could be bad in the case where a
|
||||||
|
// parent element is really the one with the focus.
|
||||||
nsIFrame * currentFocusFrame = mCurrentTarget;
|
nsIFrame * currentFocusFrame = mCurrentTarget;
|
||||||
|
|
||||||
// Check to see if the newly focused content's frame has a view with a widget
|
|
||||||
// i.e TextField or TextArea, if so, don't set the focus on their window
|
|
||||||
PRBool shouldSetFocusOnWindow = PR_TRUE;
|
|
||||||
if (nsnull != currentFocusFrame) {
|
|
||||||
nsIView * view = nsnull;
|
|
||||||
currentFocusFrame->GetView(aPresContext, &view);
|
|
||||||
if (view != nsnull) {
|
|
||||||
nsIWidget *window = nsnull;
|
|
||||||
view->GetWidget(window);
|
|
||||||
if (window != nsnull) { // addrefs
|
|
||||||
shouldSetFocusOnWindow = PR_FALSE;
|
|
||||||
NS_RELEASE(window);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the window that this frame is in and
|
// Find the window that this frame is in and
|
||||||
// make sure it has focus
|
// make sure it has focus
|
||||||
// XXX Note: mLastWindowToHaveFocus this does not track when ANY focus
|
// GFX Text Control frames handle their own focus
|
||||||
// event comes through, the only place this gets set is here
|
// and must be special-cased.
|
||||||
// so some windows may get multiple focus events
|
nsCOMPtr<nsIGfxTextControlFrame> gfxFrame = do_QueryInterface(currentFocusFrame);
|
||||||
// For example, if you clicked in the window (generates focus event)
|
if (gfxFrame) {
|
||||||
// then click on a gfx control (generates another focus event)
|
gfxFrame->SetInnerFocus();
|
||||||
if (shouldSetFocusOnWindow && nsnull != currentFocusFrame) {
|
}
|
||||||
|
else if (currentFocusFrame) {
|
||||||
nsIFrame * parentFrame;
|
nsIFrame * parentFrame;
|
||||||
currentFocusFrame->GetParentWithView(aPresContext, &parentFrame);
|
currentFocusFrame->GetParentWithView(aPresContext, &parentFrame);
|
||||||
if (nsnull != parentFrame) {
|
if (nsnull != parentFrame) {
|
||||||
|
|
|
@ -37,4 +37,5 @@ public:
|
||||||
|
|
||||||
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
|
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
|
||||||
NS_IMETHOD GetWebShell(nsIWebShell** aWebShell) = 0;
|
NS_IMETHOD GetWebShell(nsIWebShell** aWebShell) = 0;
|
||||||
|
NS_IMETHOD SetInnerFocus() = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,4 +37,5 @@ public:
|
||||||
|
|
||||||
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
|
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
|
||||||
NS_IMETHOD GetWebShell(nsIWebShell** aWebShell) = 0;
|
NS_IMETHOD GetWebShell(nsIWebShell** aWebShell) = 0;
|
||||||
|
NS_IMETHOD SetInnerFocus() = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,4 +37,5 @@ public:
|
||||||
|
|
||||||
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
|
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
|
||||||
NS_IMETHOD GetWebShell(nsIWebShell** aWebShell) = 0;
|
NS_IMETHOD GetWebShell(nsIWebShell** aWebShell) = 0;
|
||||||
|
NS_IMETHOD SetInnerFocus() = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -238,6 +238,13 @@ nsGfxTextControlFrame::GetWebShell(nsIWebShell **aWebShell)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsGfxTextControlFrame::SetInnerFocus()
|
||||||
|
{
|
||||||
|
SetFocus();
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsGfxTextControlFrame::CreateEditor()
|
nsGfxTextControlFrame::CreateEditor()
|
||||||
{
|
{
|
||||||
|
@ -3355,8 +3362,16 @@ nsEnderEventListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||||
}
|
}
|
||||||
NS_RELEASE(manager);
|
NS_RELEASE(manager);
|
||||||
|
|
||||||
if(event.flags & NS_EVENT_FLAG_STOP_DISPATCH)
|
// Call consume focus events on the inner event state manager to prevent its
|
||||||
{
|
// PostHandleEvent from immediately blurring us.
|
||||||
|
nsCOMPtr<nsIPresContext> pc;
|
||||||
|
mInnerShell->GetPresContext(getter_AddRefs(pc));
|
||||||
|
|
||||||
|
nsCOMPtr<nsIEventStateManager> esm;
|
||||||
|
pc->GetEventStateManager(getter_AddRefs(esm));
|
||||||
|
esm->ConsumeFocusEvents(PR_TRUE);
|
||||||
|
|
||||||
|
if(event.flags & NS_EVENT_FLAG_STOP_DISPATCH) {
|
||||||
aKeyEvent->PreventCapture();
|
aKeyEvent->PreventCapture();
|
||||||
aKeyEvent->PreventBubble();
|
aKeyEvent->PreventBubble();
|
||||||
}
|
}
|
||||||
|
@ -3437,7 +3452,6 @@ nsEnderEventListener::DispatchMouseEvent(nsIDOMMouseEvent *aEvent, PRInt32 aEven
|
||||||
nsCOMPtr<nsIEventStateManager> esm;
|
nsCOMPtr<nsIEventStateManager> esm;
|
||||||
pc->GetEventStateManager(getter_AddRefs(esm));
|
pc->GetEventStateManager(getter_AddRefs(esm));
|
||||||
esm->ConsumeFocusEvents(PR_TRUE);
|
esm->ConsumeFocusEvents(PR_TRUE);
|
||||||
// Now set the focus in to the widget.
|
|
||||||
mFrame->SetFocus();
|
mFrame->SetFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -510,6 +510,7 @@ public:
|
||||||
/* ============= nsIGfxTextControlFrame ================= */
|
/* ============= nsIGfxTextControlFrame ================= */
|
||||||
NS_IMETHOD GetEditor(nsIEditor **aEditor);
|
NS_IMETHOD GetEditor(nsIEditor **aEditor);
|
||||||
NS_IMETHOD GetWebShell(nsIWebShell **aWebShell);
|
NS_IMETHOD GetWebShell(nsIWebShell **aWebShell);
|
||||||
|
NS_IMETHOD SetInnerFocus();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче