Pref accessibility.browsewithcaret implemented, bug=49508, r=sfraser, sr=waterson

This commit is contained in:
aaronl%chorus.net 2001-02-15 05:07:46 +00:00
Родитель 50e7e91688
Коммит ab4d0dcaee
19 изменённых файлов: 799 добавлений и 215 удалений

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

@ -72,11 +72,19 @@
#include "nsIMarkupDocumentViewer.h" #include "nsIMarkupDocumentViewer.h"
#include "nsITreeFrame.h" #include "nsITreeFrame.h"
#include "nsIScrollableViewProvider.h" #include "nsIScrollableViewProvider.h"
#include "nsIDOMNSDocument.h"
#include "nsIDOMRange.h"
#include "nsICaret.h"
#include "nsILookAndFeel.h"
#include "nsWidgetsCID.h"
#include "nsIFormControl.h"
//we will use key binding by default now. this wil lbreak viewer for now //we will use key binding by default now. this wil lbreak viewer for now
#define NON_KEYBINDING 0 #define NON_KEYBINDING 0
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
nsIContent * gLastFocusedContent = 0; // Strong reference nsIContent * gLastFocusedContent = 0; // Strong reference
nsIDocument * gLastFocusedDocument = 0; // Strong reference nsIDocument * gLastFocusedDocument = 0; // Strong reference
@ -125,6 +133,7 @@ nsEventStateManager::nsEventStateManager()
mFirstBlurEvent = nsnull; mFirstBlurEvent = nsnull;
mFirstFocusEvent = nsnull; mFirstFocusEvent = nsnull;
mAccessKeys = nsnull; mAccessKeys = nsnull;
mBrowseWithCaret = PR_FALSE;
hHover = PR_FALSE; hHover = PR_FALSE;
NS_INIT_REFCNT(); NS_INIT_REFCNT();
@ -375,7 +384,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
currentFocus->HandleDOMEvent(aPresContext, &focusevent, nsnull, NS_EVENT_FLAG_INIT, &status); currentFocus->HandleDOMEvent(aPresContext, &focusevent, nsnull, NS_EVENT_FLAG_INIT, &status);
} }
globalObject->HandleDOMEvent(aPresContext, &focusevent, nsnull, NS_EVENT_FLAG_INIT, &status); globalObject->HandleDOMEvent(aPresContext, &focusevent, nsnull, NS_EVENT_FLAG_INIT, &status);
NS_IF_RELEASE(mCurrentFocus); NS_IF_RELEASE(mCurrentFocus);
mCurrentFocus = currentFocus; // we kept this reference above mCurrentFocus = currentFocus; // we kept this reference above
NS_IF_RELEASE(gLastFocusedContent); NS_IF_RELEASE(gLastFocusedContent);
@ -390,8 +399,17 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
NS_IF_ADDREF(gLastFocusedDocument); NS_IF_ADDREF(gLastFocusedDocument);
} }
} }
// Set mBrowseWithCaret to value of preference if we're in HTML (don't use caret in XUL)
if (mDocument) {
mBrowseWithCaret = PR_FALSE;
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(mDocument));
if (htmlDoc)
mPrefService->GetBoolPref("accessibility.browsewithcaret", &mBrowseWithCaret);
}
break; break;
case NS_LOSTFOCUS: case NS_LOSTFOCUS:
{ {
// Hold the blur, wait for the focus so we can query the style of the focus // Hold the blur, wait for the focus so we can query the style of the focus
@ -399,7 +417,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
// at that time. // at that time.
} }
break; break;
case NS_ACTIVATE: case NS_ACTIVATE:
{ {
// If we have a command dispatcher, and if it has a focused window and a // If we have a command dispatcher, and if it has a focused window and a
@ -421,7 +439,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
// Obtain focus info from the command dispatcher. // Obtain focus info from the command dispatcher.
focusController->GetFocusedWindow(getter_AddRefs(focusedWindow)); focusController->GetFocusedWindow(getter_AddRefs(focusedWindow));
focusController->GetFocusedElement(getter_AddRefs(focusedElement)); focusController->GetFocusedElement(getter_AddRefs(focusedElement));
focusController->SetSuppressFocusScroll(PR_TRUE); focusController->SetSuppressFocusScroll(PR_TRUE);
} }
@ -961,7 +979,7 @@ nsEventStateManager::GetParentScrollingView(nsMouseScrollEvent *aEvent,
if (!rootFrame) return NS_ERROR_FAILURE; if (!rootFrame) return NS_ERROR_FAILURE;
presShell->GetPresContext(&presCtxOuter); //addrefs presShell->GetPresContext(&presCtxOuter); //addrefs
nsPoint eventPoint; nsPoint eventPoint;
rootFrame->GetOrigin(eventPoint); rootFrame->GetOrigin(eventPoint);
eventPoint += aEvent->point; eventPoint += aEvent->point;
@ -981,12 +999,12 @@ nsEventStateManager::GetParentScrollingView(nsMouseScrollEvent *aEvent,
if (rv != NS_OK) return NS_ERROR_FAILURE; if (rv != NS_OK) return NS_ERROR_FAILURE;
} }
} }
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext, nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
nsEvent *aEvent, nsEvent *aEvent,
nsIFrame* aTargetFrame, nsIFrame* aTargetFrame,
nsEventStatus* aStatus, nsEventStatus* aStatus,
@ -995,7 +1013,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
NS_ENSURE_ARG(aPresContext); NS_ENSURE_ARG(aPresContext);
NS_ENSURE_ARG_POINTER(aStatus); NS_ENSURE_ARG_POINTER(aStatus);
mCurrentTarget = aTargetFrame; mCurrentTarget = aTargetFrame;
NS_IF_RELEASE(mCurrentTargetContent); NS_IF_RELEASE(mCurrentTargetContent);
nsresult ret = NS_OK; nsresult ret = NS_OK;
NS_ASSERTION(mCurrentTarget, "mCurrentTarget is null"); NS_ASSERTION(mCurrentTarget, "mCurrentTarget is null");
@ -1189,13 +1207,19 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
} }
break; break;
case NS_DRAGDROP_DROP: case NS_DRAGDROP_DROP:
case NS_DRAGDROP_EXIT: case NS_DRAGDROP_EXIT:
// clean up after ourselves. make sure we do this _after_ the event, else we'll // clean up after ourselves. make sure we do this _after_ the event, else we'll
// clean up too early! // clean up too early!
GenerateDragDropEnterExit(aPresContext, (nsGUIEvent*)aEvent); GenerateDragDropEnterExit(aPresContext, (nsGUIEvent*)aEvent);
break; break;
case NS_KEY_UP:
if (mBrowseWithCaret)
MoveFocusToCaret();
break;
case NS_KEY_PRESS: case NS_KEY_PRESS:
if (nsEventStatus_eConsumeNoDefault != *aStatus) { if (nsEventStatus_eConsumeNoDefault != *aStatus) {
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent; nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
@ -1212,9 +1236,9 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
*aStatus = nsEventStatus_eConsumeNoDefault; *aStatus = nsEventStatus_eConsumeNoDefault;
break; break;
//the problem is that viewer does not have xul so we cannot completely eliminate these //the problem is that viewer does not have xul so we cannot completely eliminate these
#if NON_KEYBINDING #if NON_KEYBINDING
case NS_VK_PAGE_DOWN: case NS_VK_PAGE_DOWN:
case NS_VK_PAGE_UP: case NS_VK_PAGE_UP:
if (!mCurrentFocus) { if (!mCurrentFocus) {
nsIScrollableView* sv = GetNearestScrollingView(aView); nsIScrollableView* sv = GetNearestScrollingView(aView);
@ -2005,8 +2029,10 @@ PRBool
nsEventStateManager::ChangeFocus(nsIContent* aFocusContent, nsIFrame* aTargetFrame, PRBool aSetFocus) nsEventStateManager::ChangeFocus(nsIContent* aFocusContent, nsIFrame* aTargetFrame, PRBool aSetFocus)
{ {
aFocusContent->SetFocus(mPresContext); aFocusContent->SetFocus(mPresContext);
MoveCaretToFocus();
return PR_FALSE; return PR_FALSE;
} }
void void
nsEventStateManager::ShiftFocus(PRBool forward) nsEventStateManager::ShiftFocus(PRBool forward)
@ -2024,20 +2050,25 @@ nsEventStateManager::ShiftFocus(PRBool forward)
if (nsnull == mCurrentFocus) { if (nsnull == mCurrentFocus) {
mCurrentFocus = mDocument->GetRootContent(); mCurrentFocus = mDocument->GetRootContent();
if (nsnull == mCurrentFocus) { if (nsnull == mCurrentFocus) {
return; return;
} }
mCurrentTabIndex = forward ? 1 : 0; mCurrentTabIndex = forward ? 1 : 0;
topOfDoc = PR_TRUE; topOfDoc = PR_TRUE;
} }
nsIFrame* primaryFrame; nsIFrame* primaryFrame = nsnull;
nsCOMPtr<nsIPresShell> shell; nsCOMPtr<nsIPresShell> shell;
if (mPresContext) { if (mPresContext) {
nsresult rv = mPresContext->GetShell(getter_AddRefs(shell)); nsresult rv = mPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell){ if (NS_SUCCEEDED(rv) && shell){
if (topOfDoc) { if (mBrowseWithCaret) {
primaryFrame = nsnull; nsCOMPtr<nsIContent> caretFocus;
PRUint32 caretOffset;
GetCaretLocation(getter_AddRefs(caretFocus), &primaryFrame, &caretOffset);
}
else if (topOfDoc) {
primaryFrame = nsnull;
} }
else { else {
shell->GetPrimaryFrameFor(mCurrentFocus, &primaryFrame); shell->GetPrimaryFrameFor(mCurrentFocus, &primaryFrame);
@ -2943,7 +2974,11 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo
} }
} }
} }
// For accessibility.browsewithcaret option, we must make the caret visible in text nodes
if (presShell && mBrowseWithCaret)
EnsureCaretVisible(presShell, aContent);
return NS_OK; return NS_OK;
} }
@ -3124,3 +3159,209 @@ nsresult NS_NewEventStateManager(nsIEventStateManager** aInstancePtrResult)
return manager->Init(); return manager->Init();
} }
nsresult nsEventStateManager::GetCaretLocation(nsIContent **aCaretContent,
nsIFrame **aCaretFrame, PRUint32* aCaretOffset)
{
// In order to return the nsIContent and nsIFrame of the caret's position,
// we need to get a pres shell, and then get the selection from it
*aCaretFrame = nsnull;
*aCaretContent = nsnull;
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIPresShell> shell;
if (mPresContext)
rv = mPresContext->GetShell(getter_AddRefs(shell));
nsCOMPtr<nsIFrameSelection> selectionFrame;
if (shell)
rv = shell->GetFrameSelection(getter_AddRefs(selectionFrame));
nsCOMPtr<nsISelection> domSelection;
if (selectionFrame)
rv = selectionFrame->GetSelection(nsISelectionController::SELECTION_NORMAL,
getter_AddRefs(domSelection));
nsCOMPtr<nsIDOMNode> focusDomNode;
if (domSelection) {
rv = domSelection->GetAnchorNode(getter_AddRefs(focusDomNode));
typedef PRInt32* PRInt32_ptr;
domSelection->GetAnchorOffset(PRInt32_ptr(aCaretOffset));
}
nsCOMPtr<nsIContent> selectionContent(do_QueryInterface(focusDomNode));
nsIFrame *primaryFrame = nsnull;
if (selectionContent)
rv = shell->GetPrimaryFrameFor(selectionContent, &primaryFrame);
*aCaretFrame = primaryFrame;
*aCaretContent = selectionContent;
NS_ADDREF(*aCaretContent);
return rv;
}
nsresult nsEventStateManager::MoveFocusToCaret()
{
// mBrowseWithCaret equals the pref accessibility.browsewithcaret
// When it's true, the user can arrow around the browser as if it's a
// read only text editor.
// If they cursor over a focusable element, then send focus to it
nsCOMPtr<nsIContent> caretContent;
nsIFrame *caretFrame;
PRUint32 caretOffset;
nsresult rv = GetCaretLocation(getter_AddRefs(caretContent),
&caretFrame, &caretOffset);
if (caretContent) {
// First check to see if our caret is at the very end of a node
// If so, the caret is actually sitting in front of the next
// logical frame's primary node - so for this case we need to
// change caretContent to that node.
nsCOMPtr<nsIContent> origCaretContent(caretContent);
nsAutoString nodeValue;
nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(caretContent));
domNode->GetNodeValue(nodeValue);
if (nodeValue.Length() == caretOffset) {
// Yes, indeed we were at the end of the last node
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
rv = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),
EXTENSIVE, mPresContext, caretFrame);
do {
// Get the next logical frame, and set the start of
// focusable elements. Search for focusable elements from there.
// Continue getting next frame until the primary node for the frame
// we are on changes - we don't want to be stuck in the same place
frameTraversal->Next();
nsISupports* currentItem;
frameTraversal->CurrentItem(&currentItem);
caretFrame = NS_STATIC_CAST(nsIFrame*, currentItem);
if (caretFrame)
caretFrame->GetContent(getter_AddRefs(caretContent));
else break;
}
while (caretContent && caretContent == origCaretContent);
}
// We now have the correct start node in caretContent!
// Search for focusable elements, starting with caretContent
// Keep going up while we look - an ancestory might be focusable
// jst: We could end the loop earlier, such as when we're no longer
// in the same frame, by comparing getPrimaryFrameFor(caretContent)
// with a variable holding the starting caretContent
nsCOMPtr<nsIAtom> tag;
while (caretContent && NS_SUCCEEDED(rv)) {
// Keep testing while caretContent is equal to something,
// eventually we'll run out of ancestors
domNode = do_QueryInterface(caretContent);
if (!domNode)
break;
domNode->GetNodeValue(nodeValue);
caretContent->GetTag(*getter_AddRefs(tag));
if (caretContent.get() == mCurrentFocus)
break; // already focused on this node, this whole thing's moot
// For now, all we're going to focus on during this move by
// cursor is ordinary links
// Add more focusable tags here later if necessary ...
if (nsHTMLAtoms::a == tag.get()) {
// We are on a link, so change focus to it.
ChangeFocus(caretContent, caretFrame, PR_TRUE);
break;
}
// Get the parent
nsIContent* parent;
caretContent->GetParent(parent);
caretContent = dont_AddRef(parent);
}
}
return NS_OK;
}
nsresult nsEventStateManager::MoveCaretToFocus()
{
// If in HTML content and the pref accessibility.browsewithcaret is TRUE,
// then always move the caret to beginning of a new focus
if (mBrowseWithCaret && mPresContext) {
nsCOMPtr<nsIPresShell> shell;
mPresContext->GetShell(getter_AddRefs(shell));
if (shell) {
// rangeDoc is a document interface we can create a range with
nsCOMPtr<nsIDOMNSDocument> rangeDoc(do_QueryInterface(mDocument));
nsCOMPtr<nsIDOMNode> currentFocusNode(do_QueryInterface(mCurrentFocus));
nsCOMPtr<nsIFrameSelection> frameSelection;
shell->GetFrameSelection(getter_AddRefs(frameSelection));
nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(currentFocusNode));
if (frameSelection && currentFocusNode && rangeDoc && !formControl) {
nsCOMPtr<nsISelection> domSelection;
frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL,
getter_AddRefs(domSelection));
if (domSelection) {
// First clear the selection
domSelection ->RemoveAllRanges();
nsCOMPtr<nsIDOMRange> newRange;
nsresult rv = rangeDoc->CreateRange(getter_AddRefs(newRange));
if (NS_SUCCEEDED(rv)) {
// If we could create a new range, then set it to the current focus node
// And then collapse the selection
newRange->SelectNodeContents(currentFocusNode);
domSelection->AddRange(newRange);
domSelection->CollapseToStart();
}
}
}
}
}
return NS_OK;
}
nsresult nsEventStateManager::EnsureCaretVisible(nsIPresShell* aPresShell, nsIContent *aContent)
{
// When browsing with caret, make sure caret is visible after new focus
nsCOMPtr<nsIFrameSelection> frameSelection;
aPresShell->GetFrameSelection(getter_AddRefs(frameSelection));
nsCOMPtr<nsICaret> caret;
aPresShell->GetCaret(getter_AddRefs(caret));
if (frameSelection && caret) {
nsCOMPtr<nsISelection> domSelection;
frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL,
getter_AddRefs(domSelection));
if (domSelection) {
nsCOMPtr<nsIDOMNode> focusDomNode;
domSelection->GetAnchorNode(getter_AddRefs(focusDomNode));
// first, tell the caret which selection to use
if (!aContent) {
caret->SetCaretDOMSelection(domSelection);
// otherwise, aContent == nsnull, so item is focusable
// in that case, let focus handlers take care of setting the caret's dom selection
}
nsCOMPtr<nsISelectionController> selCon(do_QueryInterface(aPresShell));
if (!selCon)
return NS_ERROR_NO_INTERFACE;
selCon->SetCaretEnabled(PR_TRUE);
caret->SetCaretVisible(PR_TRUE);
PRInt32 pixelWidth = 1;
nsCOMPtr<nsILookAndFeel> lookNFeel(do_GetService(kLookAndFeelCID));
if (lookNFeel)
lookNFeel->GetMetric(nsILookAndFeel::eMetric_MultiLineCaretWidth, pixelWidth);
caret->SetCaretWidth(pixelWidth);
}
}
return NS_OK;
}

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

@ -106,8 +106,8 @@ protected:
void UpdateCursor(nsIPresContext* aPresContext, nsEvent* aEvent, nsIFrame* aTargetFrame, nsEventStatus* aStatus); void UpdateCursor(nsIPresContext* aPresContext, nsEvent* aEvent, nsIFrame* aTargetFrame, nsEventStatus* aStatus);
void GenerateMouseEnterExit(nsIPresContext* aPresContext, nsGUIEvent* aEvent); void GenerateMouseEnterExit(nsIPresContext* aPresContext, nsGUIEvent* aEvent);
void GenerateDragDropEnterExit(nsIPresContext* aPresContext, nsGUIEvent* aEvent); void GenerateDragDropEnterExit(nsIPresContext* aPresContext, nsGUIEvent* aEvent);
NS_IMETHOD SetClickCount(nsIPresContext* aPresContext, nsMouseEvent *aEvent, nsEventStatus* aStatus); NS_IMETHOD SetClickCount(nsIPresContext* aPresContext, nsMouseEvent *aEvent, nsEventStatus* aStatus);
NS_IMETHOD CheckForAndDispatchClick(nsIPresContext* aPresContext, nsMouseEvent *aEvent, nsEventStatus* aStatus); NS_IMETHOD CheckForAndDispatchClick(nsIPresContext* aPresContext, nsMouseEvent *aEvent, nsEventStatus* aStatus);
PRBool ChangeFocus(nsIContent* aFocus, nsIFrame* aFocusFrame, PRBool aSetFocus); PRBool ChangeFocus(nsIContent* aFocus, nsIFrame* aFocusFrame, PRBool aSetFocus);
void ShiftFocus(PRBool foward); void ShiftFocus(PRBool foward);
NS_IMETHOD GetNextTabbableContent(nsIContent* aRootContent, nsIFrame* aFrame, PRBool foward, nsIContent** aResult); NS_IMETHOD GetNextTabbableContent(nsIContent* aRootContent, nsIFrame* aFrame, PRBool foward, nsIContent** aResult);
@ -141,6 +141,12 @@ protected:
PRBool mSuppressFocusChange; // Used only for Ender text fields to suppress a focus firing on mouse down PRBool mSuppressFocusChange; // Used only for Ender text fields to suppress a focus firing on mouse down
// Return the location of the caret
nsresult GetCaretLocation(nsIContent **caretContent, nsIFrame **caretFrame, PRUint32 *caretOffset);
nsresult MoveFocusToCaret();
nsresult MoveCaretToFocus();
nsresult EnsureCaretVisible(nsIPresShell* aPresShell, nsIContent *aContent);
//Any frames here must be checked for validity in ClearFrameRefs //Any frames here must be checked for validity in ClearFrameRefs
nsIFrame* mCurrentTarget; nsIFrame* mCurrentTarget;
nsIContent* mCurrentTargetContent; nsIContent* mCurrentTargetContent;
@ -148,7 +154,7 @@ protected:
nsIFrame* mLastMouseOverFrame; nsIFrame* mLastMouseOverFrame;
nsCOMPtr<nsIContent> mLastMouseOverContent; nsCOMPtr<nsIContent> mLastMouseOverContent;
nsIFrame* mLastDragOverFrame; nsIFrame* mLastDragOverFrame;
// member variables for the d&d gesture state machine // member variables for the d&d gesture state machine
PRBool mIsTrackingDragGesture; PRBool mIsTrackingDragGesture;
nsPoint mGestureDownPoint; nsPoint mGestureDownPoint;
@ -191,6 +197,9 @@ protected:
//Pref for using hierarchical hover (possibly expensive) or not //Pref for using hierarchical hover (possibly expensive) or not
PRBool hHover; PRBool hHover;
// So we don't have to keep checking accessibility.browsewithcaret pref
PRBool mBrowseWithCaret;
}; };
extern nsresult NS_NewEventStateManager(nsIEventStateManager** aInstancePtrResult); extern nsresult NS_NewEventStateManager(nsIEventStateManager** aInstancePtrResult);

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

@ -10,10 +10,10 @@ Can't yet put script tags in XBL (hyatt has the bug)
<bindings id="htmlBindings" <bindings id="htmlBindings"
xmlns="http://www.mozilla.org/xbl" xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="browserBase"> <binding id="browserBase">
<handlers> <handlers>
<handler event="draggesture"> <handler event="draggesture">
<!-- <!--
nsDragAndDrop.startDrag(event, contentAreaDNDObserver); nsDragAndDrop.startDrag(event, contentAreaDNDObserver);
@ -29,7 +29,7 @@ Can't yet put script tags in XBL (hyatt has the bug)
nsDragAndDrop.drop(event, contentAreaDNDObserver); nsDragAndDrop.drop(event, contentAreaDNDObserver);
--> -->
</handler> </handler>
<handler event="keypress" key=" "> <handler event="keypress" key=" ">
<![CDATA[ <![CDATA[
var v = document.commandDispatcher.focusedElement; var v = document.commandDispatcher.focusedElement;
@ -67,13 +67,13 @@ Can't yet put script tags in XBL (hyatt has the bug)
return true; return true;
]]> ]]>
</handler> </handler>
<handler event="keypress" keycode="VK_PAGE_UP" command="cmd_scrollPageUp"/> <handler event="keypress" keycode="VK_PAGE_UP" command="cmd_scrollPageUp" />
<handler event="keypress" keycode="VK_PAGE_DOWN" command="cmd_scrollPageDown"/> <handler event="keypress" keycode="VK_PAGE_DOWN" command="cmd_scrollPageDown" />
<handler event="keypress" keycode="VK_UP" command="cmd_scrollLineUp"/> <handler event="keypress" keycode="VK_UP" command="cmd_scrollLineUp" />
<handler event="keypress" keycode="VK_DOWN" command="cmd_scrollLineDown"/> <handler event="keypress" keycode="VK_DOWN" command="cmd_scrollLineDown" />
<handler event="keypress" keycode="VK_LEFT" command="cmd_scrollLeft"/> <handler event="keypress" keycode="VK_LEFT" command="cmd_scrollLeft" />
<handler event="keypress" keycode="VK_RIGHT" command="cmd_scrollRight"/> <handler event="keypress" keycode="VK_RIGHT" command="cmd_scrollRight" />
<handler event="keypress" keycode="VK_HOME" command="cmd_scrollTop"/> <handler event="keypress" keycode="VK_HOME" command="cmd_scrollTop"/>
<handler event="keypress" keycode="VK_END" command="cmd_scrollBottom"/> <handler event="keypress" keycode="VK_END" command="cmd_scrollBottom"/>
@ -119,7 +119,7 @@ Can't yet put script tags in XBL (hyatt has the bug)
<binding id="inputFieldsBase"> <binding id="inputFieldsBase">
<handlers> <handlers>
<handler event="keypress" id="key_home" keycode="VK_HOME" <handler event="keypress" id="key_home" keycode="VK_HOME"
command="cmd_beginLine"/> command="cmd_beginLine"/>
<handler event="keypress" id="key_end" keycode="VK_END" <handler event="keypress" id="key_end" keycode="VK_END"
@ -151,7 +151,7 @@ Can't yet put script tags in XBL (hyatt has the bug)
command="cmd_cut"/> command="cmd_cut"/>
<handler event="keypress" id="key_paste" key="v" modifiers="accel" <handler event="keypress" id="key_paste" key="v" modifiers="accel"
command="cmd_paste"/> command="cmd_paste"/>
<handler event="keypress" id="key_undo" key="z" modifiers="accel" <handler event="keypress" id="key_undo" key="z" modifiers="accel"
command="cmd_undo"/> command="cmd_undo"/>
</handlers> </handlers>
@ -190,7 +190,7 @@ Can't yet put script tags in XBL (hyatt has the bug)
command="cmd_cut"/> command="cmd_cut"/>
<handler event="keypress" id="key_paste" key="v" modifiers="accel" <handler event="keypress" id="key_paste" key="v" modifiers="accel"
command="cmd_paste"/> command="cmd_paste"/>
<handler event="keypress" id="key_undo" key="z" modifiers="accel" <handler event="keypress" id="key_undo" key="z" modifiers="accel"
command="cmd_undo"/> command="cmd_undo"/>
</handlers> </handlers>

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

@ -54,7 +54,6 @@
command="cmd_deleteCharBackward"/> command="cmd_deleteCharBackward"/>
<handler event="keypress" id="key_delforw" key="d" modifiers="control" <handler event="keypress" id="key_delforw" key="d" modifiers="control"
command="cmd_deleteCharForward"/> command="cmd_deleteCharForward"/>
</handlers> </handlers>
</binding> </binding>
@ -105,7 +104,20 @@
</handlers> </handlers>
</binding> </binding>
<binding id="browser"/> <binding id="browser">
<handlers>
<handler event="keypress" keycode="VK_LEFT" modifiers="alt" command="cmd_wordPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="alt" command="cmd_wordNext" />
<handler event="keypress" keycode="VK_LEFT" modifiers="alt,shift" command="cmd_selectWordPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="alt,shift" command="cmd_selectWordNext" />
<handler event="keypress" keycode="VK_LEFT" modifiers="shift" command="cmd_selectCharPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="shift" command="cmd_selectCharNext" />
<handler event="keypress" keycode="VK_HOME" modifiers="shift" command="cmd_selectBeginLine" />
<handler event="keypress" keycode="VK_END" modifiers="shift" command="cmd_selectEndLine" />
<handler event="keypress" keycode="VK_UP" modifiers="shift" command="cmd_selectLinePrevious" />
<handler event="keypress" keycode="VK_DOWN" modifiers="shift" command="cmd_selectLineNext" />
</handlers>
</binding>
<binding id="editor"> <binding id="editor">
<handlers> <handlers>

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

@ -79,6 +79,16 @@
<handler event="keypress" keycode="VK_INSERT" modifiers="shift" command="cmd_paste"/> <handler event="keypress" keycode="VK_INSERT" modifiers="shift" command="cmd_paste"/>
<handler event="keypress" keycode="VK_HOME" modifiers="control" command="cmd_scrollTop"/> <handler event="keypress" keycode="VK_HOME" modifiers="control" command="cmd_scrollTop"/>
<handler event="keypress" keycode="VK_END" modifiers="control" command="cmd_scrollBottom"/> <handler event="keypress" keycode="VK_END" modifiers="control" command="cmd_scrollBottom"/>
<handler event="keypress" keycode="VK_LEFT" modifiers="control" command="cmd_wordPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="control" command="cmd_wordNext" />
<handler event="keypress" keycode="VK_LEFT" modifiers="control,shift" command="cmd_selectWordPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="control,shift" command="cmd_selectWordNext" />
<handler event="keypress" keycode="VK_LEFT" modifiers="shift" command="cmd_selectCharPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="shift" command="cmd_selectCharNext" />
<handler event="keypress" keycode="VK_HOME" modifiers="shift" command="cmd_selectBeginLine" />
<handler event="keypress" keycode="VK_END" modifiers="shift" command="cmd_selectEndLine" />
<handler event="keypress" keycode="VK_UP" modifiers="shift" command="cmd_selectLinePrevious" />
<handler event="keypress" keycode="VK_DOWN" modifiers="shift" command="cmd_selectLineNext" />
</handlers> </handlers>
</binding> </binding>

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

@ -127,6 +127,16 @@
<handler event="keypress" keycode="VK_F20" command="cmd_cut" /> <handler event="keypress" keycode="VK_F20" command="cmd_cut" />
<handler event="keypress" keycode="VK_F16" command="cmd_copy" /> <handler event="keypress" keycode="VK_F16" command="cmd_copy" />
<handler event="keypress" keycode="VK_F18" command="cmd_paste" /> <handler event="keypress" keycode="VK_F18" command="cmd_paste" />
<handler event="keypress" keycode="VK_LEFT" modifiers="control" command="cmd_wordPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="control" command="cmd_wordNext" />
<handler event="keypress" keycode="VK_LEFT" modifiers="control,shift" command="cmd_selectWordPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="control,shift" command="cmd_selectWordNext" />
<handler event="keypress" keycode="VK_LEFT" modifiers="shift" command="cmd_selectCharPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="shift" command="cmd_selectCharNext" />
<handler event="keypress" keycode="VK_HOME" modifiers="shift" command="cmd_selectBeginLine" />
<handler event="keypress" keycode="VK_END" modifiers="shift" command="cmd_selectEndLine" />
<handler event="keypress" keycode="VK_UP" modifiers="shift" command="cmd_selectLinePrevious" />
<handler event="keypress" keycode="VK_DOWN" modifiers="shift" command="cmd_selectLineNext" />
</handlers> </handlers>
</binding> </binding>

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

@ -84,6 +84,16 @@
<handler event="keypress" keycode="VK_INSERT" modifiers="shift" command="cmd_paste"/> <handler event="keypress" keycode="VK_INSERT" modifiers="shift" command="cmd_paste"/>
<handler event="keypress" keycode="VK_HOME" modifiers="control" command="cmd_scrollTop"/> <handler event="keypress" keycode="VK_HOME" modifiers="control" command="cmd_scrollTop"/>
<handler event="keypress" keycode="VK_END" modifiers="control" command="cmd_scrollBottom"/> <handler event="keypress" keycode="VK_END" modifiers="control" command="cmd_scrollBottom"/>
<handler event="keypress" keycode="VK_LEFT" modifiers="control" command="cmd_wordPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="control" command="cmd_wordNext" />
<handler event="keypress" keycode="VK_LEFT" modifiers="control,shift" command="cmd_selectWordPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="control,shift" command="cmd_selectWordNext" />
<handler event="keypress" keycode="VK_LEFT" modifiers="shift" command="cmd_selectCharPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="shift" command="cmd_selectCharNext" />
<handler event="keypress" keycode="VK_HOME" modifiers="shift" command="cmd_selectBeginLine" />
<handler event="keypress" keycode="VK_END" modifiers="shift" command="cmd_selectEndLine" />
<handler event="keypress" keycode="VK_UP" modifiers="shift" command="cmd_selectLinePrevious" />
<handler event="keypress" keycode="VK_DOWN" modifiers="shift" command="cmd_selectLineNext" />
</handlers> </handlers>
</binding> </binding>

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

@ -4247,7 +4247,7 @@ GlobalWindowImpl::RegisterEventListener(const char* aEventName,
nsCOMPtr<nsIScriptContext> scriptCX; nsCOMPtr<nsIScriptContext> scriptCX;
nsJSUtils::nsGetDynamicScriptContext(cx, getter_AddRefs(scriptCX)); nsJSUtils::nsGetDynamicScriptContext(cx, getter_AddRefs(scriptCX));
if (!scriptCX || if (!scriptCX ||
NS_FAILED(manager->RegisterScriptEventListener(scriptCX, this, NS_FAILED(manager->RegisterScriptEventListener(scriptCX, this,
eventName, eventName,
aIID))) { aIID))) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -4406,7 +4406,7 @@ GlobalWindowImpl::GetOnchange(jsval* aOnchange)
{ {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
GlobalWindowImpl::SetOnchange(jsval aOnchange) GlobalWindowImpl::SetOnchange(jsval aOnchange)
{ {
return RegisterEventListener("onchange", NS_GET_IID(nsIDOMFormListener)); return RegisterEventListener("onchange", NS_GET_IID(nsIDOMFormListener));
@ -4974,48 +4974,39 @@ const char *sCutString = "cmd_cut";
const char *sPasteString = "cmd_paste"; const char *sPasteString = "cmd_paste";
const char *sSelectAllString = "cmd_selectAll"; const char *sSelectAllString = "cmd_selectAll";
const char *sScrollTopString = "cmd_scrollTop";
const char *sScrollBottomString = "cmd_scrollBottom";
const char *sScrollPageUpString = "cmd_scrollPageUp";
const char *sScrollPageDownString = "cmd_scrollPageDown";
const char *sScrollLineUpString = "cmd_scrollLineUp";
const char *sScrollLineDownString = "cmd_scrollLineDown";
const char *sScrollLeftString = "cmd_scrollLeft";
const char *sScrollRightString = "cmd_scrollRight";
// These are so the browser can use editor navigation key bindings
// helps with accessibility (boolean pref accessibility.browsewithcaret)
const char *sSelectCharPreviousString = "cmd_selectCharPrevious";
const char *sSelectCharNextString = "cmd_selectCharNext";
const char *sWordPreviousString = "cmd_wordPrevious";
const char *sWordNextString = "cmd_wordNext";
const char *sSelectWordPreviousString = "cmd_selectWordPrevious";
const char *sSelectWordNextString = "cmd_selectWordNext";
const char *sBeginLineString = "cmd_beginLine"; const char *sBeginLineString = "cmd_beginLine";
const char *sEndLineString = "cmd_endLine"; const char *sEndLineString = "cmd_endLine";
const char *sSelectBeginLineString = "cmd_selectBeginLine"; const char *sSelectBeginLineString = "cmd_selectBeginLine";
const char *sSelectEndLineString = "cmd_selectEndLine"; const char *sSelectEndLineString = "cmd_selectEndLine";
const char *sScrollTopString = "cmd_scrollTop"; const char *sSelectLinePreviousString = "cmd_selectLinePrevious";
const char *sScrollBottomString = "cmd_scrollBottom"; const char *sSelectLineNextString = "cmd_selectLineNext";
const char *sMoveTopString = "cmd_moveTop"; const char *sSelectPagePreviousString = "cmd_selectPagePrevious";
const char *sMoveBottomString = "cmd_moveBottom"; const char *sSelectPageNextString = "cmd_selectPageNext";
const char *sSelectMoveTopString = "cmd_selectTop";
const char *sSelectMoveBottomString = "cmd_selectBottom";
const char *sDownString = "cmd_linedown"; const char *sSelectMoveTopString = "cmd_selectMoveTop";
const char *sUpString = "cmd_lineup"; const char *sSelectMoveBottomString = "cmd_selectMoveBottom";
const char *sSelectDownString = "cmd_selectLineDown";
const char *sSelectUpString = "cmd_selectLineUp";
const char *sLeftString = "cmd_charPrevious";
const char *sRightString = "cmd_charNext";
const char *sSelectLeftString = "cmd_selectCharPrevious";
const char *sSelectRightString = "cmd_selectCharNext";
const char *sWordLeftString = "cmd_wordPrevious";
const char *sWordRightString = "cmd_wordNext";
const char *sSelectWordLeftString = "cmd_selectWordPrevious";
const char *sSelectWordRightString = "cmd_selectWordNext";
const char *sScrollPageUp = "cmd_scrollPageUp";
const char *sScrollPageDown = "cmd_scrollPageDown";
const char *sScrollLineUp = "cmd_scrollLineUp";
const char *sScrollLineDown = "cmd_scrollLineDown";
const char *sMovePageUp = "cmd_scrollPageUp";
const char *sMovePageDown = "cmd_scrollPageDown";
const char *sSelectMovePageUp = "cmd_selectPageUp";
const char *sSelectMovePageDown = "cmd_selectPageDown";
const char *sScrollLeft = "cmd_scrollLeft";
const char *sScrollRight = "cmd_scrollRight";
NS_IMPL_ADDREF(nsDOMWindowController) NS_IMPL_ADDREF(nsDOMWindowController)
NS_IMPL_RELEASE(nsDOMWindowController) NS_IMPL_RELEASE(nsDOMWindowController)
@ -5030,6 +5021,12 @@ nsDOMWindowController::nsDOMWindowController(nsIDOMWindowInternal *aWindow)
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();
mWindow = aWindow; mWindow = aWindow;
// Set browse with caret flag so we don't need to every time
mBrowseWithCaret = PR_FALSE;
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID));
if (prefs)
prefs->GetBoolPref("accessibility.browsewithcaret", &mBrowseWithCaret);
} }
nsresult nsresult
@ -5123,44 +5120,38 @@ NS_IMETHODIMP nsDOMWindowController::SupportsCommand(const PRUnichar *aCommand,
NS_ENSURE_ARG_POINTER(aResult); NS_ENSURE_ARG_POINTER(aResult);
*aResult = PR_FALSE; *aResult = PR_FALSE;
if (nsCAutoString(sCopyString).EqualsWithConversion(aCommand) || if (nsCAutoString(sCopyString).EqualsWithConversion(aCommand) ||
nsCAutoString(sSelectAllString).EqualsWithConversion(aCommand) || nsCAutoString(sSelectAllString).EqualsWithConversion(aCommand) ||
nsCAutoString(sCutString).EqualsWithConversion(aCommand) || nsCAutoString(sCutString).EqualsWithConversion(aCommand) ||
nsCAutoString(sPasteString).EqualsWithConversion(aCommand) || nsCAutoString(sPasteString).EqualsWithConversion(aCommand) ||
nsCAutoString(sScrollTopString).EqualsWithConversion(aCommand) ||
nsCAutoString(sScrollBottomString).EqualsWithConversion(aCommand) ||
nsCAutoString(sScrollPageUpString).EqualsWithConversion(aCommand) ||
nsCAutoString(sScrollPageDownString).EqualsWithConversion(aCommand) ||
nsCAutoString(sScrollLineUpString).EqualsWithConversion(aCommand) ||
nsCAutoString(sScrollLineDownString).EqualsWithConversion(aCommand) ||
nsCAutoString(sScrollLeftString).EqualsWithConversion(aCommand) ||
nsCAutoString(sScrollRightString).EqualsWithConversion(aCommand) ||
nsCAutoString(sSelectCharPreviousString).EqualsWithConversion(aCommand) ||
nsCAutoString(sSelectCharNextString).EqualsWithConversion(aCommand) ||
nsCAutoString(sWordPreviousString).EqualsWithConversion(aCommand) ||
nsCAutoString(sWordNextString).EqualsWithConversion(aCommand) ||
nsCAutoString(sSelectWordPreviousString).EqualsWithConversion(aCommand) ||
nsCAutoString(sSelectWordNextString).EqualsWithConversion(aCommand) ||
nsCAutoString(sBeginLineString).EqualsWithConversion(aCommand) || nsCAutoString(sBeginLineString).EqualsWithConversion(aCommand) ||
nsCAutoString(sEndLineString).EqualsWithConversion(aCommand) || nsCAutoString(sEndLineString).EqualsWithConversion(aCommand) ||
nsCAutoString(sSelectBeginLineString).EqualsWithConversion(aCommand) || nsCAutoString(sSelectBeginLineString).EqualsWithConversion(aCommand) ||
nsCAutoString(sSelectEndLineString).EqualsWithConversion(aCommand) || nsCAutoString(sSelectEndLineString).EqualsWithConversion(aCommand) ||
nsCAutoString(sScrollTopString).EqualsWithConversion(aCommand) || nsCAutoString(sSelectLinePreviousString).EqualsWithConversion(aCommand) ||
nsCAutoString(sScrollBottomString).EqualsWithConversion(aCommand) || nsCAutoString(sSelectLineNextString).EqualsWithConversion(aCommand) ||
nsCAutoString(sMoveTopString).EqualsWithConversion(aCommand) || nsCAutoString(sSelectPagePreviousString).EqualsWithConversion(aCommand) ||
nsCAutoString(sMoveBottomString).EqualsWithConversion(aCommand) || nsCAutoString(sSelectPageNextString).EqualsWithConversion(aCommand) ||
nsCAutoString(sSelectMoveTopString).EqualsWithConversion(aCommand) || nsCAutoString(sSelectMoveTopString).EqualsWithConversion(aCommand) ||
nsCAutoString(sSelectMoveBottomString).EqualsWithConversion(aCommand) || nsCAutoString(sSelectMoveBottomString).EqualsWithConversion(aCommand)
nsCAutoString(sDownString).EqualsWithConversion(aCommand) || ) {
nsCAutoString(sUpString).EqualsWithConversion(aCommand) || *aResult=PR_TRUE;
nsCAutoString(sLeftString).EqualsWithConversion(aCommand) || }
nsCAutoString(sRightString).EqualsWithConversion(aCommand) ||
nsCAutoString(sSelectDownString).EqualsWithConversion(aCommand) ||
nsCAutoString(sSelectUpString).EqualsWithConversion(aCommand) ||
nsCAutoString(sSelectLeftString).EqualsWithConversion(aCommand) ||
nsCAutoString(sSelectRightString).EqualsWithConversion(aCommand) ||
nsCAutoString(sWordLeftString).EqualsWithConversion(aCommand) ||
nsCAutoString(sWordRightString).EqualsWithConversion(aCommand) ||
nsCAutoString(sSelectWordLeftString).EqualsWithConversion(aCommand) ||
nsCAutoString(sSelectWordRightString).EqualsWithConversion(aCommand) ||
nsCAutoString(sScrollPageUp).EqualsWithConversion(aCommand) ||
nsCAutoString(sScrollPageDown).EqualsWithConversion(aCommand) ||
nsCAutoString(sScrollLineUp).EqualsWithConversion(aCommand) ||
nsCAutoString(sScrollLineDown).EqualsWithConversion(aCommand) ||
nsCAutoString(sMovePageUp).EqualsWithConversion(aCommand) ||
nsCAutoString(sMovePageDown).EqualsWithConversion(aCommand) ||
nsCAutoString(sSelectMovePageUp).EqualsWithConversion(aCommand) ||
nsCAutoString(sSelectMovePageDown).EqualsWithConversion(aCommand) ||
nsCAutoString(sScrollLeft).EqualsWithConversion(aCommand) ||
nsCAutoString(sScrollRight).EqualsWithConversion(aCommand)) {
*aResult = PR_TRUE;
}
return NS_OK; return NS_OK;
} }
@ -5170,68 +5161,74 @@ NS_IMETHODIMP nsDOMWindowController::DoCommand(const PRUnichar *aCommand)
NS_ENSURE_ARG_POINTER(aCommand); NS_ENSURE_ARG_POINTER(aCommand);
nsresult rv = NS_ERROR_FAILURE; nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIContentViewerEdit> editInterface; nsCOMPtr<nsIContentViewerEdit> editInterface;
nsCOMPtr<nsISelectionController> selCont;
rv = GetEditInterface(getter_AddRefs(editInterface)); rv = GetEditInterface(getter_AddRefs(editInterface));
nsCOMPtr<nsIPresShell> presShell; if (!editInterface)
if (NS_FAILED(rv))
return rv; return rv;
if (nsCAutoString(sCopyString).EqualsWithConversion(aCommand)) { if (nsCAutoString(sCopyString).EqualsWithConversion(aCommand))
rv = editInterface->CopySelection(); return editInterface->CopySelection();
} if (nsCAutoString(sSelectAllString).EqualsWithConversion(aCommand))
else if (nsCAutoString(sCutString).EqualsWithConversion(aCommand)) { return editInterface->SelectAll();
rv = editInterface->CutSelection(); if (nsCAutoString(sCutString).EqualsWithConversion(aCommand))
} return editInterface->CutSelection();
else if (nsCAutoString(sPasteString).EqualsWithConversion(aCommand)) {
rv = editInterface->Paste();
}
else if (nsCAutoString(sSelectAllString).EqualsWithConversion(aCommand)) {
rv = editInterface->SelectAll();
}
else if (nsCAutoString(sScrollPageUp).EqualsWithConversion(aCommand)) {
NS_ENSURE_SUCCESS(GetSelectionController(getter_AddRefs(selCont)),
NS_ERROR_FAILURE);
return selCont->ScrollPage(PR_FALSE);
}
else if (nsCAutoString(sScrollPageDown).EqualsWithConversion(aCommand)) {
NS_ENSURE_SUCCESS(GetSelectionController(getter_AddRefs(selCont)),
NS_ERROR_FAILURE);
return selCont->ScrollPage(PR_TRUE);
}
else if (nsCAutoString(sScrollLineUp).EqualsWithConversion(aCommand)) {
NS_ENSURE_SUCCESS(GetSelectionController(getter_AddRefs(selCont)),
NS_ERROR_FAILURE);
return selCont->ScrollLine(PR_FALSE);
}
else if (nsCAutoString(sScrollLineDown).EqualsWithConversion(aCommand)) {
NS_ENSURE_SUCCESS(GetSelectionController(getter_AddRefs(selCont)),
NS_ERROR_FAILURE);
return selCont->ScrollLine(PR_TRUE);
}
else if (nsCAutoString(sScrollLeft).EqualsWithConversion(aCommand)) {
NS_ENSURE_SUCCESS(GetSelectionController(getter_AddRefs(selCont)),
NS_ERROR_FAILURE);
return selCont->ScrollHorizontal(PR_TRUE);
}
else if (nsCAutoString(sScrollRight).EqualsWithConversion(aCommand)) {
NS_ENSURE_SUCCESS(GetSelectionController(getter_AddRefs(selCont)),
NS_ERROR_FAILURE);
return selCont->ScrollHorizontal(PR_FALSE);
}
else if (nsCAutoString(sScrollTopString).EqualsWithConversion(aCommand)) {
NS_ENSURE_SUCCESS(GetSelectionController(getter_AddRefs(selCont)),
NS_ERROR_FAILURE);
return selCont->CompleteScroll(PR_FALSE);
}
else if (nsCAutoString(sScrollBottomString).EqualsWithConversion(aCommand)) {
NS_ENSURE_SUCCESS(GetSelectionController(getter_AddRefs(selCont)),
NS_ERROR_FAILURE);
return selCont->CompleteScroll(PR_TRUE);
}
return NS_OK; nsCOMPtr<nsISelectionController> selCont;
rv = GetSelectionController(getter_AddRefs(selCont));
if (!selCont)
return rv;
if (nsCAutoString(sPasteString).EqualsWithConversion(aCommand))
rv = editInterface->Paste();
else if (nsCAutoString(sScrollTopString).EqualsWithConversion(aCommand))
rv = (mBrowseWithCaret? selCont->CompleteMove(PR_FALSE, PR_FALSE): selCont->CompleteScroll(PR_FALSE));
else if (nsCAutoString(sScrollBottomString).EqualsWithConversion(aCommand))
rv = (mBrowseWithCaret? selCont->CompleteMove(PR_TRUE, PR_FALSE): selCont->CompleteScroll(PR_TRUE));
else if (nsCAutoString(sScrollPageUpString).EqualsWithConversion(aCommand))
rv = (mBrowseWithCaret? selCont->PageMove(PR_FALSE, PR_FALSE): selCont->ScrollPage(PR_FALSE));
else if (nsCAutoString(sScrollPageDownString).EqualsWithConversion(aCommand))
rv = (mBrowseWithCaret? selCont->PageMove(PR_TRUE, PR_FALSE): selCont->ScrollPage(PR_TRUE));
else if (nsCAutoString(sScrollLineUpString).EqualsWithConversion(aCommand))
rv = (mBrowseWithCaret? selCont->LineMove(PR_FALSE, PR_FALSE): selCont->ScrollLine(PR_FALSE));
else if (nsCAutoString(sScrollLineDownString).EqualsWithConversion(aCommand))
rv = (mBrowseWithCaret? selCont->LineMove(PR_TRUE, PR_FALSE): selCont->ScrollLine(PR_TRUE));
else if (nsCAutoString(sScrollLeftString).EqualsWithConversion(aCommand))
rv = (mBrowseWithCaret? selCont->CharacterMove(PR_FALSE, PR_FALSE): selCont->ScrollHorizontal(PR_TRUE));
else if (nsCAutoString(sScrollRightString).EqualsWithConversion(aCommand))
rv = (mBrowseWithCaret? selCont->CharacterMove(PR_TRUE, PR_FALSE): selCont->ScrollHorizontal(PR_FALSE));
// These commands are so the browser can use editor navigation key bindings -
// Helps with accessibility - aaronl@chorus.net
else if (nsCAutoString(sSelectCharPreviousString).EqualsWithConversion(aCommand))
rv = selCont->CharacterMove(PR_FALSE, PR_TRUE);
else if (nsCAutoString(sSelectCharNextString).EqualsWithConversion(aCommand))
rv = selCont->CharacterMove(PR_TRUE, PR_TRUE);
else if (nsCAutoString(sWordPreviousString).EqualsWithConversion(aCommand))
rv = selCont->WordMove(PR_FALSE, PR_FALSE);
else if (nsCAutoString(sWordNextString).EqualsWithConversion(aCommand))
rv = selCont->WordMove(PR_TRUE, PR_FALSE);
else if (nsCAutoString(sSelectWordPreviousString).EqualsWithConversion(aCommand))
rv = selCont->WordMove(PR_FALSE, PR_TRUE);
else if (nsCAutoString(sSelectWordNextString).EqualsWithConversion(aCommand))
rv = selCont->WordMove(PR_TRUE, PR_TRUE);
else if (nsCAutoString(sBeginLineString).EqualsWithConversion(aCommand))
rv = selCont->IntraLineMove(PR_FALSE, PR_FALSE);
else if (nsCAutoString(sEndLineString).EqualsWithConversion(aCommand))
rv = selCont->IntraLineMove(PR_TRUE, PR_FALSE);
else if (nsCAutoString(sSelectBeginLineString).EqualsWithConversion(aCommand))
rv = selCont->IntraLineMove(PR_FALSE, PR_TRUE);
else if (nsCAutoString(sSelectEndLineString).EqualsWithConversion(aCommand))
rv = selCont->IntraLineMove(PR_TRUE, PR_TRUE);
else if (nsCAutoString(sSelectLinePreviousString).EqualsWithConversion(aCommand))
rv = selCont->LineMove(PR_FALSE, PR_TRUE);
else if (nsCAutoString(sSelectLineNextString).EqualsWithConversion(aCommand))
rv = selCont->LineMove(PR_TRUE, PR_TRUE);
else if (nsCAutoString(sSelectMoveTopString).EqualsWithConversion(aCommand))
rv = selCont->CompleteMove(PR_FALSE, PR_TRUE);
else if (nsCAutoString(sSelectMoveBottomString).EqualsWithConversion(aCommand))
rv = selCont->CompleteMove(PR_TRUE, PR_TRUE);
return rv;
} }
NS_IMETHODIMP nsDOMWindowController::OnEvent(const PRUnichar *aEventName) NS_IMETHODIMP nsDOMWindowController::OnEvent(const PRUnichar *aEventName)
{ {
return NS_OK; return NS_OK;

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

@ -104,7 +104,7 @@ public:
NS_IMETHOD SetOpenerWindow(nsIDOMWindowInternal *aOpener); NS_IMETHOD SetOpenerWindow(nsIDOMWindowInternal *aOpener);
NS_IMETHOD SetGlobalObjectOwner(nsIScriptGlobalObjectOwner* aOwner); NS_IMETHOD SetGlobalObjectOwner(nsIScriptGlobalObjectOwner* aOwner);
NS_IMETHOD GetGlobalObjectOwner(nsIScriptGlobalObjectOwner** aOwner); NS_IMETHOD GetGlobalObjectOwner(nsIScriptGlobalObjectOwner** aOwner);
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent,
nsIDOMEvent** aDOMEvent, PRUint32 aFlags, nsIDOMEvent** aDOMEvent, PRUint32 aFlags,
nsEventStatus* aEventStatus); nsEventStatus* aEventStatus);
@ -272,7 +272,7 @@ protected:
nsCOMPtr<nsIPrincipal> mDocumentPrincipal; nsCOMPtr<nsIPrincipal> mDocumentPrincipal;
}; };
/* /*
* Timeout struct that holds information about each JavaScript * Timeout struct that holds information about each JavaScript
* timeout. * timeout.
*/ */
@ -412,13 +412,14 @@ public:
nsDOMWindowController( nsIDOMWindowInternal* aWindow ); nsDOMWindowController( nsIDOMWindowInternal* aWindow );
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSICONTROLLER NS_DECL_NSICONTROLLER
private: private:
nsresult GetPresShell(nsIPresShell **aPresShell); nsresult GetPresShell(nsIPresShell **aPresShell);
nsresult GetEditInterface( nsIContentViewerEdit** aEditInterface); nsresult GetEditInterface( nsIContentViewerEdit** aEditInterface);
nsresult GetSelectionController(nsISelectionController ** aSelCon); nsresult GetSelectionController(nsISelectionController ** aSelCon);
nsIDOMWindowInternal *mWindow; nsIDOMWindowInternal *mWindow;
PRBool mBrowseWithCaret;
}; };
#endif // DOM_CONTROLLER #endif // DOM_CONTROLLER

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

@ -67,7 +67,7 @@ nsCaret::nsCaret()
, mCaretTwipsWidth(-1) , mCaretTwipsWidth(-1)
, mCaretPixelsWidth(1) , mCaretPixelsWidth(1)
, mVisible(PR_FALSE) , mVisible(PR_FALSE)
, mReadOnly(PR_TRUE) , mReadOnly(PR_FALSE)
, mDrawn(PR_FALSE) , mDrawn(PR_FALSE)
, mShowWhenSelection(PR_FALSE) , mShowWhenSelection(PR_FALSE)
, mLastCaretFrame(nsnull) , mLastCaretFrame(nsnull)
@ -780,12 +780,11 @@ void nsCaret::DrawCaret()
mCaretRect.IntersectRect(clipRect, caretRect); mCaretRect.IntersectRect(clipRect, caretRect);
} }
/*
if (mReadOnly) if (mReadOnly)
inRendContext.SetColor(NS_RGB(85, 85, 85)); // we are drawing it; gray mRendContext->SetColor(NS_RGB(85, 85, 85)); // we are drawing it; gray
*/ else
mRendContext->SetColor(NS_RGB(255,255,255));
mRendContext->SetColor(NS_RGB(255,255,255));
mRendContext->InvertRect(mCaretRect); mRendContext->InvertRect(mCaretRect);
PRBool emptyClip; // I know what you're thinking. "Did he fire six shots or only five?" PRBool emptyClip; // I know what you're thinking. "Did he fire six shots or only five?"

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

@ -67,7 +67,7 @@ nsCaret::nsCaret()
, mCaretTwipsWidth(-1) , mCaretTwipsWidth(-1)
, mCaretPixelsWidth(1) , mCaretPixelsWidth(1)
, mVisible(PR_FALSE) , mVisible(PR_FALSE)
, mReadOnly(PR_TRUE) , mReadOnly(PR_FALSE)
, mDrawn(PR_FALSE) , mDrawn(PR_FALSE)
, mShowWhenSelection(PR_FALSE) , mShowWhenSelection(PR_FALSE)
, mLastCaretFrame(nsnull) , mLastCaretFrame(nsnull)
@ -780,12 +780,11 @@ void nsCaret::DrawCaret()
mCaretRect.IntersectRect(clipRect, caretRect); mCaretRect.IntersectRect(clipRect, caretRect);
} }
/*
if (mReadOnly) if (mReadOnly)
inRendContext.SetColor(NS_RGB(85, 85, 85)); // we are drawing it; gray mRendContext->SetColor(NS_RGB(85, 85, 85)); // we are drawing it; gray
*/ else
mRendContext->SetColor(NS_RGB(255,255,255));
mRendContext->SetColor(NS_RGB(255,255,255));
mRendContext->InvertRect(mCaretRect); mRendContext->InvertRect(mCaretRect);
PRBool emptyClip; // I know what you're thinking. "Did he fire six shots or only five?" PRBool emptyClip; // I know what you're thinking. "Did he fire six shots or only five?"

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

@ -72,11 +72,19 @@
#include "nsIMarkupDocumentViewer.h" #include "nsIMarkupDocumentViewer.h"
#include "nsITreeFrame.h" #include "nsITreeFrame.h"
#include "nsIScrollableViewProvider.h" #include "nsIScrollableViewProvider.h"
#include "nsIDOMNSDocument.h"
#include "nsIDOMRange.h"
#include "nsICaret.h"
#include "nsILookAndFeel.h"
#include "nsWidgetsCID.h"
#include "nsIFormControl.h"
//we will use key binding by default now. this wil lbreak viewer for now //we will use key binding by default now. this wil lbreak viewer for now
#define NON_KEYBINDING 0 #define NON_KEYBINDING 0
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
nsIContent * gLastFocusedContent = 0; // Strong reference nsIContent * gLastFocusedContent = 0; // Strong reference
nsIDocument * gLastFocusedDocument = 0; // Strong reference nsIDocument * gLastFocusedDocument = 0; // Strong reference
@ -125,6 +133,7 @@ nsEventStateManager::nsEventStateManager()
mFirstBlurEvent = nsnull; mFirstBlurEvent = nsnull;
mFirstFocusEvent = nsnull; mFirstFocusEvent = nsnull;
mAccessKeys = nsnull; mAccessKeys = nsnull;
mBrowseWithCaret = PR_FALSE;
hHover = PR_FALSE; hHover = PR_FALSE;
NS_INIT_REFCNT(); NS_INIT_REFCNT();
@ -375,7 +384,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
currentFocus->HandleDOMEvent(aPresContext, &focusevent, nsnull, NS_EVENT_FLAG_INIT, &status); currentFocus->HandleDOMEvent(aPresContext, &focusevent, nsnull, NS_EVENT_FLAG_INIT, &status);
} }
globalObject->HandleDOMEvent(aPresContext, &focusevent, nsnull, NS_EVENT_FLAG_INIT, &status); globalObject->HandleDOMEvent(aPresContext, &focusevent, nsnull, NS_EVENT_FLAG_INIT, &status);
NS_IF_RELEASE(mCurrentFocus); NS_IF_RELEASE(mCurrentFocus);
mCurrentFocus = currentFocus; // we kept this reference above mCurrentFocus = currentFocus; // we kept this reference above
NS_IF_RELEASE(gLastFocusedContent); NS_IF_RELEASE(gLastFocusedContent);
@ -390,8 +399,17 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
NS_IF_ADDREF(gLastFocusedDocument); NS_IF_ADDREF(gLastFocusedDocument);
} }
} }
// Set mBrowseWithCaret to value of preference if we're in HTML (don't use caret in XUL)
if (mDocument) {
mBrowseWithCaret = PR_FALSE;
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(mDocument));
if (htmlDoc)
mPrefService->GetBoolPref("accessibility.browsewithcaret", &mBrowseWithCaret);
}
break; break;
case NS_LOSTFOCUS: case NS_LOSTFOCUS:
{ {
// Hold the blur, wait for the focus so we can query the style of the focus // Hold the blur, wait for the focus so we can query the style of the focus
@ -399,7 +417,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
// at that time. // at that time.
} }
break; break;
case NS_ACTIVATE: case NS_ACTIVATE:
{ {
// If we have a command dispatcher, and if it has a focused window and a // If we have a command dispatcher, and if it has a focused window and a
@ -421,7 +439,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
// Obtain focus info from the command dispatcher. // Obtain focus info from the command dispatcher.
focusController->GetFocusedWindow(getter_AddRefs(focusedWindow)); focusController->GetFocusedWindow(getter_AddRefs(focusedWindow));
focusController->GetFocusedElement(getter_AddRefs(focusedElement)); focusController->GetFocusedElement(getter_AddRefs(focusedElement));
focusController->SetSuppressFocusScroll(PR_TRUE); focusController->SetSuppressFocusScroll(PR_TRUE);
} }
@ -961,7 +979,7 @@ nsEventStateManager::GetParentScrollingView(nsMouseScrollEvent *aEvent,
if (!rootFrame) return NS_ERROR_FAILURE; if (!rootFrame) return NS_ERROR_FAILURE;
presShell->GetPresContext(&presCtxOuter); //addrefs presShell->GetPresContext(&presCtxOuter); //addrefs
nsPoint eventPoint; nsPoint eventPoint;
rootFrame->GetOrigin(eventPoint); rootFrame->GetOrigin(eventPoint);
eventPoint += aEvent->point; eventPoint += aEvent->point;
@ -981,12 +999,12 @@ nsEventStateManager::GetParentScrollingView(nsMouseScrollEvent *aEvent,
if (rv != NS_OK) return NS_ERROR_FAILURE; if (rv != NS_OK) return NS_ERROR_FAILURE;
} }
} }
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext, nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
nsEvent *aEvent, nsEvent *aEvent,
nsIFrame* aTargetFrame, nsIFrame* aTargetFrame,
nsEventStatus* aStatus, nsEventStatus* aStatus,
@ -995,7 +1013,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
NS_ENSURE_ARG(aPresContext); NS_ENSURE_ARG(aPresContext);
NS_ENSURE_ARG_POINTER(aStatus); NS_ENSURE_ARG_POINTER(aStatus);
mCurrentTarget = aTargetFrame; mCurrentTarget = aTargetFrame;
NS_IF_RELEASE(mCurrentTargetContent); NS_IF_RELEASE(mCurrentTargetContent);
nsresult ret = NS_OK; nsresult ret = NS_OK;
NS_ASSERTION(mCurrentTarget, "mCurrentTarget is null"); NS_ASSERTION(mCurrentTarget, "mCurrentTarget is null");
@ -1189,13 +1207,19 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
} }
break; break;
case NS_DRAGDROP_DROP: case NS_DRAGDROP_DROP:
case NS_DRAGDROP_EXIT: case NS_DRAGDROP_EXIT:
// clean up after ourselves. make sure we do this _after_ the event, else we'll // clean up after ourselves. make sure we do this _after_ the event, else we'll
// clean up too early! // clean up too early!
GenerateDragDropEnterExit(aPresContext, (nsGUIEvent*)aEvent); GenerateDragDropEnterExit(aPresContext, (nsGUIEvent*)aEvent);
break; break;
case NS_KEY_UP:
if (mBrowseWithCaret)
MoveFocusToCaret();
break;
case NS_KEY_PRESS: case NS_KEY_PRESS:
if (nsEventStatus_eConsumeNoDefault != *aStatus) { if (nsEventStatus_eConsumeNoDefault != *aStatus) {
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent; nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
@ -1212,9 +1236,9 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
*aStatus = nsEventStatus_eConsumeNoDefault; *aStatus = nsEventStatus_eConsumeNoDefault;
break; break;
//the problem is that viewer does not have xul so we cannot completely eliminate these //the problem is that viewer does not have xul so we cannot completely eliminate these
#if NON_KEYBINDING #if NON_KEYBINDING
case NS_VK_PAGE_DOWN: case NS_VK_PAGE_DOWN:
case NS_VK_PAGE_UP: case NS_VK_PAGE_UP:
if (!mCurrentFocus) { if (!mCurrentFocus) {
nsIScrollableView* sv = GetNearestScrollingView(aView); nsIScrollableView* sv = GetNearestScrollingView(aView);
@ -2005,8 +2029,10 @@ PRBool
nsEventStateManager::ChangeFocus(nsIContent* aFocusContent, nsIFrame* aTargetFrame, PRBool aSetFocus) nsEventStateManager::ChangeFocus(nsIContent* aFocusContent, nsIFrame* aTargetFrame, PRBool aSetFocus)
{ {
aFocusContent->SetFocus(mPresContext); aFocusContent->SetFocus(mPresContext);
MoveCaretToFocus();
return PR_FALSE; return PR_FALSE;
} }
void void
nsEventStateManager::ShiftFocus(PRBool forward) nsEventStateManager::ShiftFocus(PRBool forward)
@ -2024,20 +2050,25 @@ nsEventStateManager::ShiftFocus(PRBool forward)
if (nsnull == mCurrentFocus) { if (nsnull == mCurrentFocus) {
mCurrentFocus = mDocument->GetRootContent(); mCurrentFocus = mDocument->GetRootContent();
if (nsnull == mCurrentFocus) { if (nsnull == mCurrentFocus) {
return; return;
} }
mCurrentTabIndex = forward ? 1 : 0; mCurrentTabIndex = forward ? 1 : 0;
topOfDoc = PR_TRUE; topOfDoc = PR_TRUE;
} }
nsIFrame* primaryFrame; nsIFrame* primaryFrame = nsnull;
nsCOMPtr<nsIPresShell> shell; nsCOMPtr<nsIPresShell> shell;
if (mPresContext) { if (mPresContext) {
nsresult rv = mPresContext->GetShell(getter_AddRefs(shell)); nsresult rv = mPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell){ if (NS_SUCCEEDED(rv) && shell){
if (topOfDoc) { if (mBrowseWithCaret) {
primaryFrame = nsnull; nsCOMPtr<nsIContent> caretFocus;
PRUint32 caretOffset;
GetCaretLocation(getter_AddRefs(caretFocus), &primaryFrame, &caretOffset);
}
else if (topOfDoc) {
primaryFrame = nsnull;
} }
else { else {
shell->GetPrimaryFrameFor(mCurrentFocus, &primaryFrame); shell->GetPrimaryFrameFor(mCurrentFocus, &primaryFrame);
@ -2943,7 +2974,11 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo
} }
} }
} }
// For accessibility.browsewithcaret option, we must make the caret visible in text nodes
if (presShell && mBrowseWithCaret)
EnsureCaretVisible(presShell, aContent);
return NS_OK; return NS_OK;
} }
@ -3124,3 +3159,209 @@ nsresult NS_NewEventStateManager(nsIEventStateManager** aInstancePtrResult)
return manager->Init(); return manager->Init();
} }
nsresult nsEventStateManager::GetCaretLocation(nsIContent **aCaretContent,
nsIFrame **aCaretFrame, PRUint32* aCaretOffset)
{
// In order to return the nsIContent and nsIFrame of the caret's position,
// we need to get a pres shell, and then get the selection from it
*aCaretFrame = nsnull;
*aCaretContent = nsnull;
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIPresShell> shell;
if (mPresContext)
rv = mPresContext->GetShell(getter_AddRefs(shell));
nsCOMPtr<nsIFrameSelection> selectionFrame;
if (shell)
rv = shell->GetFrameSelection(getter_AddRefs(selectionFrame));
nsCOMPtr<nsISelection> domSelection;
if (selectionFrame)
rv = selectionFrame->GetSelection(nsISelectionController::SELECTION_NORMAL,
getter_AddRefs(domSelection));
nsCOMPtr<nsIDOMNode> focusDomNode;
if (domSelection) {
rv = domSelection->GetAnchorNode(getter_AddRefs(focusDomNode));
typedef PRInt32* PRInt32_ptr;
domSelection->GetAnchorOffset(PRInt32_ptr(aCaretOffset));
}
nsCOMPtr<nsIContent> selectionContent(do_QueryInterface(focusDomNode));
nsIFrame *primaryFrame = nsnull;
if (selectionContent)
rv = shell->GetPrimaryFrameFor(selectionContent, &primaryFrame);
*aCaretFrame = primaryFrame;
*aCaretContent = selectionContent;
NS_ADDREF(*aCaretContent);
return rv;
}
nsresult nsEventStateManager::MoveFocusToCaret()
{
// mBrowseWithCaret equals the pref accessibility.browsewithcaret
// When it's true, the user can arrow around the browser as if it's a
// read only text editor.
// If they cursor over a focusable element, then send focus to it
nsCOMPtr<nsIContent> caretContent;
nsIFrame *caretFrame;
PRUint32 caretOffset;
nsresult rv = GetCaretLocation(getter_AddRefs(caretContent),
&caretFrame, &caretOffset);
if (caretContent) {
// First check to see if our caret is at the very end of a node
// If so, the caret is actually sitting in front of the next
// logical frame's primary node - so for this case we need to
// change caretContent to that node.
nsCOMPtr<nsIContent> origCaretContent(caretContent);
nsAutoString nodeValue;
nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(caretContent));
domNode->GetNodeValue(nodeValue);
if (nodeValue.Length() == caretOffset) {
// Yes, indeed we were at the end of the last node
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
rv = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),
EXTENSIVE, mPresContext, caretFrame);
do {
// Get the next logical frame, and set the start of
// focusable elements. Search for focusable elements from there.
// Continue getting next frame until the primary node for the frame
// we are on changes - we don't want to be stuck in the same place
frameTraversal->Next();
nsISupports* currentItem;
frameTraversal->CurrentItem(&currentItem);
caretFrame = NS_STATIC_CAST(nsIFrame*, currentItem);
if (caretFrame)
caretFrame->GetContent(getter_AddRefs(caretContent));
else break;
}
while (caretContent && caretContent == origCaretContent);
}
// We now have the correct start node in caretContent!
// Search for focusable elements, starting with caretContent
// Keep going up while we look - an ancestory might be focusable
// jst: We could end the loop earlier, such as when we're no longer
// in the same frame, by comparing getPrimaryFrameFor(caretContent)
// with a variable holding the starting caretContent
nsCOMPtr<nsIAtom> tag;
while (caretContent && NS_SUCCEEDED(rv)) {
// Keep testing while caretContent is equal to something,
// eventually we'll run out of ancestors
domNode = do_QueryInterface(caretContent);
if (!domNode)
break;
domNode->GetNodeValue(nodeValue);
caretContent->GetTag(*getter_AddRefs(tag));
if (caretContent.get() == mCurrentFocus)
break; // already focused on this node, this whole thing's moot
// For now, all we're going to focus on during this move by
// cursor is ordinary links
// Add more focusable tags here later if necessary ...
if (nsHTMLAtoms::a == tag.get()) {
// We are on a link, so change focus to it.
ChangeFocus(caretContent, caretFrame, PR_TRUE);
break;
}
// Get the parent
nsIContent* parent;
caretContent->GetParent(parent);
caretContent = dont_AddRef(parent);
}
}
return NS_OK;
}
nsresult nsEventStateManager::MoveCaretToFocus()
{
// If in HTML content and the pref accessibility.browsewithcaret is TRUE,
// then always move the caret to beginning of a new focus
if (mBrowseWithCaret && mPresContext) {
nsCOMPtr<nsIPresShell> shell;
mPresContext->GetShell(getter_AddRefs(shell));
if (shell) {
// rangeDoc is a document interface we can create a range with
nsCOMPtr<nsIDOMNSDocument> rangeDoc(do_QueryInterface(mDocument));
nsCOMPtr<nsIDOMNode> currentFocusNode(do_QueryInterface(mCurrentFocus));
nsCOMPtr<nsIFrameSelection> frameSelection;
shell->GetFrameSelection(getter_AddRefs(frameSelection));
nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(currentFocusNode));
if (frameSelection && currentFocusNode && rangeDoc && !formControl) {
nsCOMPtr<nsISelection> domSelection;
frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL,
getter_AddRefs(domSelection));
if (domSelection) {
// First clear the selection
domSelection ->RemoveAllRanges();
nsCOMPtr<nsIDOMRange> newRange;
nsresult rv = rangeDoc->CreateRange(getter_AddRefs(newRange));
if (NS_SUCCEEDED(rv)) {
// If we could create a new range, then set it to the current focus node
// And then collapse the selection
newRange->SelectNodeContents(currentFocusNode);
domSelection->AddRange(newRange);
domSelection->CollapseToStart();
}
}
}
}
}
return NS_OK;
}
nsresult nsEventStateManager::EnsureCaretVisible(nsIPresShell* aPresShell, nsIContent *aContent)
{
// When browsing with caret, make sure caret is visible after new focus
nsCOMPtr<nsIFrameSelection> frameSelection;
aPresShell->GetFrameSelection(getter_AddRefs(frameSelection));
nsCOMPtr<nsICaret> caret;
aPresShell->GetCaret(getter_AddRefs(caret));
if (frameSelection && caret) {
nsCOMPtr<nsISelection> domSelection;
frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL,
getter_AddRefs(domSelection));
if (domSelection) {
nsCOMPtr<nsIDOMNode> focusDomNode;
domSelection->GetAnchorNode(getter_AddRefs(focusDomNode));
// first, tell the caret which selection to use
if (!aContent) {
caret->SetCaretDOMSelection(domSelection);
// otherwise, aContent == nsnull, so item is focusable
// in that case, let focus handlers take care of setting the caret's dom selection
}
nsCOMPtr<nsISelectionController> selCon(do_QueryInterface(aPresShell));
if (!selCon)
return NS_ERROR_NO_INTERFACE;
selCon->SetCaretEnabled(PR_TRUE);
caret->SetCaretVisible(PR_TRUE);
PRInt32 pixelWidth = 1;
nsCOMPtr<nsILookAndFeel> lookNFeel(do_GetService(kLookAndFeelCID));
if (lookNFeel)
lookNFeel->GetMetric(nsILookAndFeel::eMetric_MultiLineCaretWidth, pixelWidth);
caret->SetCaretWidth(pixelWidth);
}
}
return NS_OK;
}

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

@ -106,8 +106,8 @@ protected:
void UpdateCursor(nsIPresContext* aPresContext, nsEvent* aEvent, nsIFrame* aTargetFrame, nsEventStatus* aStatus); void UpdateCursor(nsIPresContext* aPresContext, nsEvent* aEvent, nsIFrame* aTargetFrame, nsEventStatus* aStatus);
void GenerateMouseEnterExit(nsIPresContext* aPresContext, nsGUIEvent* aEvent); void GenerateMouseEnterExit(nsIPresContext* aPresContext, nsGUIEvent* aEvent);
void GenerateDragDropEnterExit(nsIPresContext* aPresContext, nsGUIEvent* aEvent); void GenerateDragDropEnterExit(nsIPresContext* aPresContext, nsGUIEvent* aEvent);
NS_IMETHOD SetClickCount(nsIPresContext* aPresContext, nsMouseEvent *aEvent, nsEventStatus* aStatus); NS_IMETHOD SetClickCount(nsIPresContext* aPresContext, nsMouseEvent *aEvent, nsEventStatus* aStatus);
NS_IMETHOD CheckForAndDispatchClick(nsIPresContext* aPresContext, nsMouseEvent *aEvent, nsEventStatus* aStatus); NS_IMETHOD CheckForAndDispatchClick(nsIPresContext* aPresContext, nsMouseEvent *aEvent, nsEventStatus* aStatus);
PRBool ChangeFocus(nsIContent* aFocus, nsIFrame* aFocusFrame, PRBool aSetFocus); PRBool ChangeFocus(nsIContent* aFocus, nsIFrame* aFocusFrame, PRBool aSetFocus);
void ShiftFocus(PRBool foward); void ShiftFocus(PRBool foward);
NS_IMETHOD GetNextTabbableContent(nsIContent* aRootContent, nsIFrame* aFrame, PRBool foward, nsIContent** aResult); NS_IMETHOD GetNextTabbableContent(nsIContent* aRootContent, nsIFrame* aFrame, PRBool foward, nsIContent** aResult);
@ -141,6 +141,12 @@ protected:
PRBool mSuppressFocusChange; // Used only for Ender text fields to suppress a focus firing on mouse down PRBool mSuppressFocusChange; // Used only for Ender text fields to suppress a focus firing on mouse down
// Return the location of the caret
nsresult GetCaretLocation(nsIContent **caretContent, nsIFrame **caretFrame, PRUint32 *caretOffset);
nsresult MoveFocusToCaret();
nsresult MoveCaretToFocus();
nsresult EnsureCaretVisible(nsIPresShell* aPresShell, nsIContent *aContent);
//Any frames here must be checked for validity in ClearFrameRefs //Any frames here must be checked for validity in ClearFrameRefs
nsIFrame* mCurrentTarget; nsIFrame* mCurrentTarget;
nsIContent* mCurrentTargetContent; nsIContent* mCurrentTargetContent;
@ -148,7 +154,7 @@ protected:
nsIFrame* mLastMouseOverFrame; nsIFrame* mLastMouseOverFrame;
nsCOMPtr<nsIContent> mLastMouseOverContent; nsCOMPtr<nsIContent> mLastMouseOverContent;
nsIFrame* mLastDragOverFrame; nsIFrame* mLastDragOverFrame;
// member variables for the d&d gesture state machine // member variables for the d&d gesture state machine
PRBool mIsTrackingDragGesture; PRBool mIsTrackingDragGesture;
nsPoint mGestureDownPoint; nsPoint mGestureDownPoint;
@ -191,6 +197,9 @@ protected:
//Pref for using hierarchical hover (possibly expensive) or not //Pref for using hierarchical hover (possibly expensive) or not
PRBool hHover; PRBool hHover;
// So we don't have to keep checking accessibility.browsewithcaret pref
PRBool mBrowseWithCaret;
}; };
extern nsresult NS_NewEventStateManager(nsIEventStateManager** aInstancePtrResult); extern nsresult NS_NewEventStateManager(nsIEventStateManager** aInstancePtrResult);

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

@ -10,10 +10,10 @@ Can't yet put script tags in XBL (hyatt has the bug)
<bindings id="htmlBindings" <bindings id="htmlBindings"
xmlns="http://www.mozilla.org/xbl" xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="browserBase"> <binding id="browserBase">
<handlers> <handlers>
<handler event="draggesture"> <handler event="draggesture">
<!-- <!--
nsDragAndDrop.startDrag(event, contentAreaDNDObserver); nsDragAndDrop.startDrag(event, contentAreaDNDObserver);
@ -29,7 +29,7 @@ Can't yet put script tags in XBL (hyatt has the bug)
nsDragAndDrop.drop(event, contentAreaDNDObserver); nsDragAndDrop.drop(event, contentAreaDNDObserver);
--> -->
</handler> </handler>
<handler event="keypress" key=" "> <handler event="keypress" key=" ">
<![CDATA[ <![CDATA[
var v = document.commandDispatcher.focusedElement; var v = document.commandDispatcher.focusedElement;
@ -67,13 +67,13 @@ Can't yet put script tags in XBL (hyatt has the bug)
return true; return true;
]]> ]]>
</handler> </handler>
<handler event="keypress" keycode="VK_PAGE_UP" command="cmd_scrollPageUp"/> <handler event="keypress" keycode="VK_PAGE_UP" command="cmd_scrollPageUp" />
<handler event="keypress" keycode="VK_PAGE_DOWN" command="cmd_scrollPageDown"/> <handler event="keypress" keycode="VK_PAGE_DOWN" command="cmd_scrollPageDown" />
<handler event="keypress" keycode="VK_UP" command="cmd_scrollLineUp"/> <handler event="keypress" keycode="VK_UP" command="cmd_scrollLineUp" />
<handler event="keypress" keycode="VK_DOWN" command="cmd_scrollLineDown"/> <handler event="keypress" keycode="VK_DOWN" command="cmd_scrollLineDown" />
<handler event="keypress" keycode="VK_LEFT" command="cmd_scrollLeft"/> <handler event="keypress" keycode="VK_LEFT" command="cmd_scrollLeft" />
<handler event="keypress" keycode="VK_RIGHT" command="cmd_scrollRight"/> <handler event="keypress" keycode="VK_RIGHT" command="cmd_scrollRight" />
<handler event="keypress" keycode="VK_HOME" command="cmd_scrollTop"/> <handler event="keypress" keycode="VK_HOME" command="cmd_scrollTop"/>
<handler event="keypress" keycode="VK_END" command="cmd_scrollBottom"/> <handler event="keypress" keycode="VK_END" command="cmd_scrollBottom"/>
@ -119,7 +119,7 @@ Can't yet put script tags in XBL (hyatt has the bug)
<binding id="inputFieldsBase"> <binding id="inputFieldsBase">
<handlers> <handlers>
<handler event="keypress" id="key_home" keycode="VK_HOME" <handler event="keypress" id="key_home" keycode="VK_HOME"
command="cmd_beginLine"/> command="cmd_beginLine"/>
<handler event="keypress" id="key_end" keycode="VK_END" <handler event="keypress" id="key_end" keycode="VK_END"
@ -151,7 +151,7 @@ Can't yet put script tags in XBL (hyatt has the bug)
command="cmd_cut"/> command="cmd_cut"/>
<handler event="keypress" id="key_paste" key="v" modifiers="accel" <handler event="keypress" id="key_paste" key="v" modifiers="accel"
command="cmd_paste"/> command="cmd_paste"/>
<handler event="keypress" id="key_undo" key="z" modifiers="accel" <handler event="keypress" id="key_undo" key="z" modifiers="accel"
command="cmd_undo"/> command="cmd_undo"/>
</handlers> </handlers>
@ -190,7 +190,7 @@ Can't yet put script tags in XBL (hyatt has the bug)
command="cmd_cut"/> command="cmd_cut"/>
<handler event="keypress" id="key_paste" key="v" modifiers="accel" <handler event="keypress" id="key_paste" key="v" modifiers="accel"
command="cmd_paste"/> command="cmd_paste"/>
<handler event="keypress" id="key_undo" key="z" modifiers="accel" <handler event="keypress" id="key_undo" key="z" modifiers="accel"
command="cmd_undo"/> command="cmd_undo"/>
</handlers> </handlers>

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

@ -54,7 +54,6 @@
command="cmd_deleteCharBackward"/> command="cmd_deleteCharBackward"/>
<handler event="keypress" id="key_delforw" key="d" modifiers="control" <handler event="keypress" id="key_delforw" key="d" modifiers="control"
command="cmd_deleteCharForward"/> command="cmd_deleteCharForward"/>
</handlers> </handlers>
</binding> </binding>
@ -105,7 +104,20 @@
</handlers> </handlers>
</binding> </binding>
<binding id="browser"/> <binding id="browser">
<handlers>
<handler event="keypress" keycode="VK_LEFT" modifiers="alt" command="cmd_wordPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="alt" command="cmd_wordNext" />
<handler event="keypress" keycode="VK_LEFT" modifiers="alt,shift" command="cmd_selectWordPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="alt,shift" command="cmd_selectWordNext" />
<handler event="keypress" keycode="VK_LEFT" modifiers="shift" command="cmd_selectCharPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="shift" command="cmd_selectCharNext" />
<handler event="keypress" keycode="VK_HOME" modifiers="shift" command="cmd_selectBeginLine" />
<handler event="keypress" keycode="VK_END" modifiers="shift" command="cmd_selectEndLine" />
<handler event="keypress" keycode="VK_UP" modifiers="shift" command="cmd_selectLinePrevious" />
<handler event="keypress" keycode="VK_DOWN" modifiers="shift" command="cmd_selectLineNext" />
</handlers>
</binding>
<binding id="editor"> <binding id="editor">
<handlers> <handlers>

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

@ -79,6 +79,16 @@
<handler event="keypress" keycode="VK_INSERT" modifiers="shift" command="cmd_paste"/> <handler event="keypress" keycode="VK_INSERT" modifiers="shift" command="cmd_paste"/>
<handler event="keypress" keycode="VK_HOME" modifiers="control" command="cmd_scrollTop"/> <handler event="keypress" keycode="VK_HOME" modifiers="control" command="cmd_scrollTop"/>
<handler event="keypress" keycode="VK_END" modifiers="control" command="cmd_scrollBottom"/> <handler event="keypress" keycode="VK_END" modifiers="control" command="cmd_scrollBottom"/>
<handler event="keypress" keycode="VK_LEFT" modifiers="control" command="cmd_wordPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="control" command="cmd_wordNext" />
<handler event="keypress" keycode="VK_LEFT" modifiers="control,shift" command="cmd_selectWordPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="control,shift" command="cmd_selectWordNext" />
<handler event="keypress" keycode="VK_LEFT" modifiers="shift" command="cmd_selectCharPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="shift" command="cmd_selectCharNext" />
<handler event="keypress" keycode="VK_HOME" modifiers="shift" command="cmd_selectBeginLine" />
<handler event="keypress" keycode="VK_END" modifiers="shift" command="cmd_selectEndLine" />
<handler event="keypress" keycode="VK_UP" modifiers="shift" command="cmd_selectLinePrevious" />
<handler event="keypress" keycode="VK_DOWN" modifiers="shift" command="cmd_selectLineNext" />
</handlers> </handlers>
</binding> </binding>

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

@ -127,6 +127,16 @@
<handler event="keypress" keycode="VK_F20" command="cmd_cut" /> <handler event="keypress" keycode="VK_F20" command="cmd_cut" />
<handler event="keypress" keycode="VK_F16" command="cmd_copy" /> <handler event="keypress" keycode="VK_F16" command="cmd_copy" />
<handler event="keypress" keycode="VK_F18" command="cmd_paste" /> <handler event="keypress" keycode="VK_F18" command="cmd_paste" />
<handler event="keypress" keycode="VK_LEFT" modifiers="control" command="cmd_wordPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="control" command="cmd_wordNext" />
<handler event="keypress" keycode="VK_LEFT" modifiers="control,shift" command="cmd_selectWordPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="control,shift" command="cmd_selectWordNext" />
<handler event="keypress" keycode="VK_LEFT" modifiers="shift" command="cmd_selectCharPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="shift" command="cmd_selectCharNext" />
<handler event="keypress" keycode="VK_HOME" modifiers="shift" command="cmd_selectBeginLine" />
<handler event="keypress" keycode="VK_END" modifiers="shift" command="cmd_selectEndLine" />
<handler event="keypress" keycode="VK_UP" modifiers="shift" command="cmd_selectLinePrevious" />
<handler event="keypress" keycode="VK_DOWN" modifiers="shift" command="cmd_selectLineNext" />
</handlers> </handlers>
</binding> </binding>

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

@ -84,6 +84,16 @@
<handler event="keypress" keycode="VK_INSERT" modifiers="shift" command="cmd_paste"/> <handler event="keypress" keycode="VK_INSERT" modifiers="shift" command="cmd_paste"/>
<handler event="keypress" keycode="VK_HOME" modifiers="control" command="cmd_scrollTop"/> <handler event="keypress" keycode="VK_HOME" modifiers="control" command="cmd_scrollTop"/>
<handler event="keypress" keycode="VK_END" modifiers="control" command="cmd_scrollBottom"/> <handler event="keypress" keycode="VK_END" modifiers="control" command="cmd_scrollBottom"/>
<handler event="keypress" keycode="VK_LEFT" modifiers="control" command="cmd_wordPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="control" command="cmd_wordNext" />
<handler event="keypress" keycode="VK_LEFT" modifiers="control,shift" command="cmd_selectWordPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="control,shift" command="cmd_selectWordNext" />
<handler event="keypress" keycode="VK_LEFT" modifiers="shift" command="cmd_selectCharPrevious" />
<handler event="keypress" keycode="VK_RIGHT" modifiers="shift" command="cmd_selectCharNext" />
<handler event="keypress" keycode="VK_HOME" modifiers="shift" command="cmd_selectBeginLine" />
<handler event="keypress" keycode="VK_END" modifiers="shift" command="cmd_selectEndLine" />
<handler event="keypress" keycode="VK_UP" modifiers="shift" command="cmd_selectLinePrevious" />
<handler event="keypress" keycode="VK_DOWN" modifiers="shift" command="cmd_selectLineNext" />
</handlers> </handlers>
</binding> </binding>

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

@ -17,10 +17,10 @@
* Copyright (C) 1998 Netscape Communications Corporation. All * Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved. * Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
// SYNTAX HINTS: dashes are delimiters. Use underscores instead. // SYNTAX HINTS: dashes are delimiters. Use underscores instead.
// The first character after a period must be alphabetic. // The first character after a period must be alphabetic.
pref("network.search.url","http://cgi.netscape.com/cgi-bin/url_search.cgi?search="); pref("network.search.url","http://cgi.netscape.com/cgi-bin/url_search.cgi?search=");
@ -40,7 +40,7 @@ pref("general.startup.addressbook", false);
pref("general.open_location.last_url", ""); pref("general.open_location.last_url", "");
// 0 = blank, 1 = home (browser.startup.homepage), 2 = last // 0 = blank, 1 = home (browser.startup.homepage), 2 = last
pref("browser.startup.page", 1); pref("browser.startup.page", 1);
pref("browser.startup.homepage", "chrome://navigator/locale/navigator.properties"); pref("browser.startup.homepage", "chrome://navigator/locale/navigator.properties");
// "browser.startup.homepage_override" was for 4.x // "browser.startup.homepage_override" was for 4.x
pref("browser.startup.homepage_override.1", true); pref("browser.startup.homepage_override.1", true);
@ -73,6 +73,10 @@ pref("browser.toolbars.showbutton.net2phone", true);
pref("browser.toolbars.showbutton.print", true); pref("browser.toolbars.showbutton.print", true);
pref("browser.toolbars.showbutton.search", true); pref("browser.toolbars.showbutton.search", true);
pref("accessibility.browsewithcaret", false);
pref("accessibility.usetexttospeech", "");
pref("accessibility.usebrailledisplay", "");
// Dialog modality issues // Dialog modality issues
pref("browser.prefWindowModal", true); pref("browser.prefWindowModal", true);
pref("browser.show_about_as_stupid_modal_window", false); pref("browser.show_about_as_stupid_modal_window", false);