diff --git a/accessible/public/Makefile.in b/accessible/public/Makefile.in index 3a03a40a3f2d..614f00f6ed07 100644 --- a/accessible/public/Makefile.in +++ b/accessible/public/Makefile.in @@ -36,6 +36,7 @@ XPIDLSRCS = \ nsIAccessibleEventReceiver.idl \ nsIAccessibleEventListener.idl \ nsIAccessibleSelectable.idl \ + nsIAccessibleProvider.idl \ $(NULL) EXPORTS = \ diff --git a/accessible/public/makefile.win b/accessible/public/makefile.win index 0ee73dd6f71c..5f939366785f 100644 --- a/accessible/public/makefile.win +++ b/accessible/public/makefile.win @@ -30,6 +30,7 @@ XPIDLSRCS = \ .\nsIAccessibleEventReceiver.idl \ .\nsIAccessibleEventListener.idl \ .\nsIAccessibleSelectable.idl \ + .\nsIAccessibleProvider.idl \ $(NULL) EXPORTS = \ diff --git a/accessible/public/nsIAccessibilityService.idl b/accessible/public/nsIAccessibilityService.idl index 31b2ddc6c2d1..45d7e0306289 100644 --- a/accessible/public/nsIAccessibilityService.idl +++ b/accessible/public/nsIAccessibilityService.idl @@ -38,6 +38,7 @@ interface nsIAccessibilityService : nsISupports nsIAccessible createHTMLListboxAccessible(in nsIDOMNode aNode, in nsISupports aPresShell); nsIAccessible createHTMLSelectOptionAccessible(in nsIDOMNode aNode, in nsIAccessible aAccParent, in nsISupports aPresShell); nsIAccessible createHTMLCheckboxAccessible(in nsISupports aFrame); + nsIAccessible createXULCheckboxAccessible(in nsIDOMNode aNode); nsIAccessible createHTMLRadioButtonAccessible(in nsISupports aFrame); nsIAccessible createHTMLButtonAccessible(in nsISupports aFrame); nsIAccessible createHTML4ButtonAccessible(in nsISupports aFrame); diff --git a/accessible/public/nsIAccessibleProvider.idl b/accessible/public/nsIAccessibleProvider.idl new file mode 100644 index 000000000000..e77325048945 --- /dev/null +++ b/accessible/public/nsIAccessibleProvider.idl @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1999 Netscape Communications Corporation. All + * Rights Reserved. + * + * Original Author: John Gaunt (jgaunt@netscape.com) + * + * Contributor(s): + * John Gaunt + */ + +#include "nsISupports.idl" +#include "nsIAccessible.idl" + +[scriptable, uuid(3f0e3eb0-1dd2-11b2-9605-be5b8e76cf4b)] +interface nsIAccessibleProvider : nsISupports +{ + readonly attribute nsIAccessible accessible; +}; diff --git a/accessible/src/base/nsAccessibilityService.cpp b/accessible/src/base/nsAccessibilityService.cpp index e3d1c034ad37..c8c77c81b5f2 100644 --- a/accessible/src/base/nsAccessibilityService.cpp +++ b/accessible/src/base/nsAccessibilityService.cpp @@ -45,10 +45,12 @@ #include "nsHTMLListboxAccessible.h" #include "nsIDOMHTMLAreaElement.h" #include "nsHTMLFormControlAccessible.h" +#include "nsIAccessibleProvider.h" #include "nsILink.h" #include "nsIDocShellTreeItem.h" #include "nsIDOMDocument.h" #include "nsIDOMHTMLOptionElement.h" +#include "nsIDOMXULCheckboxElement.h" // IFrame #include "nsIDocShell.h" @@ -175,6 +177,19 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLCheckboxAccessible(nsISupports * return NS_OK; } +NS_IMETHODIMP nsAccessibilityService::CreateXULCheckboxAccessible(nsIDOMNode *aNode, nsIAccessible **_retval) +{ + nsCOMPtr weakShell; + GetShellFromNode(aNode, getter_AddRefs(weakShell)); + + *_retval = new nsHTMLCheckboxAccessible(aNode, weakShell); + if (! *_retval) + return NS_ERROR_OUT_OF_MEMORY; + + NS_ADDREF(*_retval); + return NS_OK; +} + /* nsIAccessible createHTMRadioButtonAccessible (in nsISupports aPresShell, in nsISupports aFrame); */ NS_IMETHODIMP nsAccessibilityService::CreateHTMLRadioButtonAccessible(nsISupports *aFrame, nsIAccessible **_retval) { @@ -340,6 +355,28 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextFieldAccessible(nsISupports return NS_OK; } +NS_IMETHODIMP nsAccessibilityService::GetShellFromNode(nsIDOMNode *aNode, nsIWeakReference **aWeakShell) +{ + nsCOMPtr domDoc; + aNode->GetOwnerDocument(getter_AddRefs(domDoc)); + nsCOMPtr doc(do_QueryInterface(domDoc)); + if (!doc) + return NS_ERROR_INVALID_ARG; + + // ---- Get the pres shell ---- + nsCOMPtr shell; + doc->GetShellAt(0, getter_AddRefs(shell)); + if (!shell) + return NS_ERROR_FAILURE; + + nsCOMPtr weakRef(do_GetWeakReference(shell)); + + *aWeakShell = weakRef; + NS_IF_ADDREF(*aWeakShell); + + return NS_OK; +} + NS_IMETHODIMP nsAccessibilityService::GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIWeakReference** aShell, nsIDOMNode** aNode) { NS_ASSERTION(aFrame,"Error -- 1st argument (aFrame) is null!!"); @@ -624,9 +661,12 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode, nsCOMPtr newAcc; frame->GetAccessible(getter_AddRefs(newAcc)); - // ---- Try QI'ing node to get nsIAccessible ---- - if (!newAcc) - newAcc = do_QueryInterface(aNode); + // ---- Is it a XUL element? -- they impl nsIAccessibleProvider via XBL + if (!newAcc) { + nsCOMPtr accProv(do_QueryInterface(aNode)); + if (accProv) + accProv->GetAccessible(getter_AddRefs(newAcc)); + } // ---- If link, create link accessible ---- if (!newAcc) { diff --git a/accessible/src/base/nsAccessibilityService.h b/accessible/src/base/nsAccessibilityService.h index 5450fe88de2b..47efd8451536 100644 --- a/accessible/src/base/nsAccessibilityService.h +++ b/accessible/src/base/nsAccessibilityService.h @@ -51,6 +51,7 @@ public: private: NS_IMETHOD GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIWeakReference** aShell, nsIDOMNode** aContent); + NS_IMETHOD GetShellFromNode(nsIDOMNode *aNode, nsIWeakReference **weakShell); void GetOwnerFor(nsIPresShell *aPresShell, nsIPresShell **aOwnerShell, nsIContent **aOwnerContent); nsIContent* FindContentForDocShell(nsIPresShell* aPresShell, nsIContent* aContent, nsIDocShell* aDocShell); diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index 1958599ce2d1..6a159804e09d 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -623,6 +623,49 @@ NS_IMETHODIMP nsAccessible::GetAccState(PRUint32 *aAccState) } } + nsCOMPtr content(do_QueryInterface(mDOMNode)); + if (content) { + nsCOMPtr shell(do_QueryReferent(mPresShell)); + if (shell) { + nsIFrame *frame = nsnull; + shell->GetPrimaryFrameFor(content, &frame); + if (frame) { + /* + PRBool isVisible = PR_FALSE, isFinishedLooking = PR_FALSE; + nsCOMPtr presContext; + shell->GetPresContext(getter_AddRefs(presContext)); + nsRect twipsRect, pixelsRect; + GetAbsoluteFramePosition(presContext, frame, twipsRect, pixelsRect); + + + //frame->IsVisibleForPainting(presContext, presContext, PR_TRUE, &isVisible); // 3rd param = bool to check css visibility + //frame->CheckVisibility(presContext, 0,1, PR_TRUE, &isFinishedLooking, &isVisible); + if (twipsRect.y < 0) + *aAccState |= STATE_OFFSCREEN; + */ + nsSize frameSize; + frame->GetSize(frameSize); + if (frameSize.width == 0) + *aAccState |= STATE_INVISIBLE; + + } + } + } + + + /** + * called to see if the children of the frame are visible from indexstart to index end. + * this does not change any state. returns PR_TRUE only if the indexes are valid and any of + * the children are visible. for textframes this index is the character index. + * if aStart = aEnd result will be PR_FALSE + * @param aStart start index of first child from 0-N (number of children) + * @param aEnd end index of last child from 0-N + * @param aRecurse should this frame talk to siblings to get to the contents other children? + * @param aFinished did this frame have the aEndIndex? or is there more work to do + * @param _retval return value true or false. false = range is not rendered. + */ + //NS_IMETHOD CheckVisibility(nsIPresContext* aContext, PRInt32 aStartIndex, PRInt32 aEndIndex, PRBool aRecurse, PRBool *aFinished, PRBool *_retval)=0; + return rv; } diff --git a/accessible/src/base/nsGenericAccessible.cpp b/accessible/src/base/nsGenericAccessible.cpp index 9a815144d5aa..2ae05b790b77 100644 --- a/accessible/src/base/nsGenericAccessible.cpp +++ b/accessible/src/base/nsGenericAccessible.cpp @@ -25,7 +25,6 @@ #include "nsIFrame.h" #include "nsCOMPtr.h" #include "nsIWeakReference.h" -#include "nsISelectionController.h" #include "nsReadableUtils.h" #include "nsIContent.h" diff --git a/accessible/src/html/nsHTMLAreaAccessible.cpp b/accessible/src/html/nsHTMLAreaAccessible.cpp index b87d133fad44..7df379d54494 100644 --- a/accessible/src/html/nsHTMLAreaAccessible.cpp +++ b/accessible/src/html/nsHTMLAreaAccessible.cpp @@ -30,7 +30,6 @@ #include "nsIServiceManager.h" #include "nsIDOMElement.h" #include "nsIDOMHTMLAreaElement.h" -#include "nsGUIEvent.h" // --- area ----- diff --git a/accessible/src/html/nsHTMLFormControlAccessible.cpp b/accessible/src/html/nsHTMLFormControlAccessible.cpp index 4ecc9554195d..36c39d2d15fc 100644 --- a/accessible/src/html/nsHTMLFormControlAccessible.cpp +++ b/accessible/src/html/nsHTMLFormControlAccessible.cpp @@ -29,12 +29,12 @@ #include "nsHTMLAtoms.h" #include "nsIDOMHTMLButtonElement.h" #include "nsReadableUtils.h" -#include "nsString.h" #include "nsAccessible.h" #include "nsIFrame.h" #include "nsIDOMHTMLLabelElement.h" #include "nsIDOMHTMLFormElement.h" #include "nsISelectionController.h" +#include "nsIDOMXULCheckboxElement.h" nsHTMLFormControlAccessible::nsHTMLFormControlAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell): nsLeafAccessible(aNode, aShell) @@ -117,25 +117,29 @@ NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccName(nsAWritableString& _retval NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccState(PRUint32 *_retval) { // can be - // focusable, focused, checked, protected, unavailable - nsCOMPtr element(do_QueryInterface(mDOMNode)); + // focusable, focused, protected, unavailable + nsCOMPtr htmlFormElement(do_QueryInterface(mDOMNode)); nsAccessible::GetAccState(_retval); - *_retval |= STATE_FOCUSABLE; - - PRBool checked = PR_FALSE; - element->GetChecked(&checked); - if (checked) *_retval |= STATE_CHECKED; PRBool disabled = PR_FALSE; - element->GetDisabled(&disabled); + if (htmlFormElement) { + htmlFormElement->GetDisabled(&disabled); + nsAutoString typeString; + htmlFormElement->GetType(typeString); + if (typeString.EqualsIgnoreCase("password")) + *_retval |= STATE_PROTECTED; + } + else { + nsCOMPtr xulFormElement(do_QueryInterface(mDOMNode)); + if (xulFormElement) + xulFormElement->GetDisabled(&disabled); + } + if (disabled) *_retval |= STATE_UNAVAILABLE; - - nsAutoString typeString; - element->GetType(typeString); - if (typeString.EqualsIgnoreCase("password")) - *_retval |= STATE_PROTECTED; + else + *_retval |= STATE_FOCUSABLE; return NS_OK; } @@ -164,15 +168,12 @@ NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccNumActions(PRUint8 *_retval) /* wstring getAccActionName (in PRUint8 index); */ NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval) { - if (index == 0) { + if (index == 0) { // 0 is the magic value for default action // check or uncheck - nsCOMPtr element(do_QueryInterface(mDOMNode)); + PRUint32 state; + GetAccState(&state); - PRBool checked = PR_FALSE; - if (element) - element->GetChecked(&checked); - - if (checked) + if (state & STATE_CHECKED) _retval = NS_LITERAL_STRING("uncheck"); else _retval = NS_LITERAL_STRING("check"); @@ -186,15 +187,43 @@ NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccActionName(PRUint8 index, nsAWrita NS_IMETHODIMP nsHTMLCheckboxAccessible::AccDoAction(PRUint8 index) { if (index == 0) { // 0 is the magic value for default action - nsCOMPtr element(do_QueryInterface(mDOMNode)); + nsCOMPtr htmlCheckboxElement(do_QueryInterface(mDOMNode)); PRBool checked = PR_FALSE; - element->GetChecked(&checked); - element->SetChecked(checked ? PR_FALSE : PR_TRUE); + if (htmlCheckboxElement) { + htmlCheckboxElement->GetChecked(&checked); + htmlCheckboxElement->SetChecked(!checked); + } + else { + nsCOMPtr xulCheckboxElement(do_QueryInterface(mDOMNode)); + if (xulCheckboxElement) { + xulCheckboxElement->GetChecked(&checked); + xulCheckboxElement->SetChecked(!checked); + } + } return NS_OK; } return NS_ERROR_INVALID_ARG; } +NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccState(PRUint32 *_retval) +{ + nsHTMLFormControlAccessible::GetAccState(_retval); + PRBool checked = PR_FALSE; // Radio buttons and check boxes can be checked + + nsCOMPtr htmlCheckboxElement(do_QueryInterface(mDOMNode)); + if (htmlCheckboxElement) + htmlCheckboxElement->GetChecked(&checked); + else { + nsCOMPtr xulCheckboxElement(do_QueryInterface(mDOMNode)); + if (xulCheckboxElement) + xulCheckboxElement->GetChecked(&checked); + } + + if (checked) + *_retval |= STATE_CHECKED; + + return NS_OK; +} //------ Radio button ------- @@ -240,6 +269,28 @@ NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccRole(PRUint32 *_retval) return NS_OK; } +NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccState(PRUint32 *_retval) +{ + nsHTMLFormControlAccessible::GetAccState(_retval); + PRBool checked = PR_FALSE; // Radio buttons and check boxes can be checked + + nsCOMPtr htmlRadioElement(do_QueryInterface(mDOMNode)); + if (htmlRadioElement) + htmlRadioElement->GetChecked(&checked); + + /* ----- Need to add this code soon + + nsCOMPtr xulRadioElement(do_QueryInteface(mDOMNode)); + if (xulRadioElement) + xulRadioElement->GetChecked(&checked); + */ + + if (checked) + *_retval |= STATE_CHECKED; + + return NS_OK; +} + // ----- Button ----- nsHTMLButtonAccessible::nsHTMLButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell): @@ -387,6 +438,11 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccRole(PRUint32 *_retval) /* wstring getAccValue (); */ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccValue(nsAWritableString& _retval) { + PRUint32 state; + GetAccState(&state); + if (state & STATE_PROTECTED) // Don't return password text! + return NS_ERROR_FAILURE; + nsCOMPtr textArea(do_QueryInterface(mDOMNode)); if (textArea) { textArea->GetValue(_retval); diff --git a/accessible/src/html/nsHTMLFormControlAccessible.h b/accessible/src/html/nsHTMLFormControlAccessible.h index c83ed2981e0b..2b5bc7df41ac 100644 --- a/accessible/src/html/nsHTMLFormControlAccessible.h +++ b/accessible/src/html/nsHTMLFormControlAccessible.h @@ -54,6 +54,7 @@ public: NS_IMETHOD GetAccNumActions(PRUint8 *_retval); NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval); NS_IMETHOD AccDoAction(PRUint8 index); + NS_IMETHOD GetAccState(PRUint32 *_retval); }; class nsHTMLRadioButtonAccessible : public nsHTMLFormControlAccessible @@ -65,6 +66,7 @@ public: NS_IMETHOD GetAccNumActions(PRUint8 *_retval); NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval); NS_IMETHOD AccDoAction(PRUint8 index); + NS_IMETHOD GetAccState(PRUint32 *_retval); }; class nsHTMLButtonAccessible : public nsHTMLFormControlAccessible diff --git a/accessible/src/html/nsHTMLTextAccessible.cpp b/accessible/src/html/nsHTMLTextAccessible.cpp index 3490eaa3a5e3..04055b05269a 100644 --- a/accessible/src/html/nsHTMLTextAccessible.cpp +++ b/accessible/src/html/nsHTMLTextAccessible.cpp @@ -24,7 +24,6 @@ #include "nsHTMLTextAccessible.h" #include "nsWeakReference.h" #include "nsIFrame.h" -#include "nsString.h" #include "nsILink.h" #include "nsILinkHandler.h" #include "nsISelection.h" diff --git a/accessible/src/nsAccessibilityService.cpp b/accessible/src/nsAccessibilityService.cpp index e3d1c034ad37..c8c77c81b5f2 100644 --- a/accessible/src/nsAccessibilityService.cpp +++ b/accessible/src/nsAccessibilityService.cpp @@ -45,10 +45,12 @@ #include "nsHTMLListboxAccessible.h" #include "nsIDOMHTMLAreaElement.h" #include "nsHTMLFormControlAccessible.h" +#include "nsIAccessibleProvider.h" #include "nsILink.h" #include "nsIDocShellTreeItem.h" #include "nsIDOMDocument.h" #include "nsIDOMHTMLOptionElement.h" +#include "nsIDOMXULCheckboxElement.h" // IFrame #include "nsIDocShell.h" @@ -175,6 +177,19 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLCheckboxAccessible(nsISupports * return NS_OK; } +NS_IMETHODIMP nsAccessibilityService::CreateXULCheckboxAccessible(nsIDOMNode *aNode, nsIAccessible **_retval) +{ + nsCOMPtr weakShell; + GetShellFromNode(aNode, getter_AddRefs(weakShell)); + + *_retval = new nsHTMLCheckboxAccessible(aNode, weakShell); + if (! *_retval) + return NS_ERROR_OUT_OF_MEMORY; + + NS_ADDREF(*_retval); + return NS_OK; +} + /* nsIAccessible createHTMRadioButtonAccessible (in nsISupports aPresShell, in nsISupports aFrame); */ NS_IMETHODIMP nsAccessibilityService::CreateHTMLRadioButtonAccessible(nsISupports *aFrame, nsIAccessible **_retval) { @@ -340,6 +355,28 @@ NS_IMETHODIMP nsAccessibilityService::CreateHTMLTextFieldAccessible(nsISupports return NS_OK; } +NS_IMETHODIMP nsAccessibilityService::GetShellFromNode(nsIDOMNode *aNode, nsIWeakReference **aWeakShell) +{ + nsCOMPtr domDoc; + aNode->GetOwnerDocument(getter_AddRefs(domDoc)); + nsCOMPtr doc(do_QueryInterface(domDoc)); + if (!doc) + return NS_ERROR_INVALID_ARG; + + // ---- Get the pres shell ---- + nsCOMPtr shell; + doc->GetShellAt(0, getter_AddRefs(shell)); + if (!shell) + return NS_ERROR_FAILURE; + + nsCOMPtr weakRef(do_GetWeakReference(shell)); + + *aWeakShell = weakRef; + NS_IF_ADDREF(*aWeakShell); + + return NS_OK; +} + NS_IMETHODIMP nsAccessibilityService::GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIWeakReference** aShell, nsIDOMNode** aNode) { NS_ASSERTION(aFrame,"Error -- 1st argument (aFrame) is null!!"); @@ -624,9 +661,12 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode, nsCOMPtr newAcc; frame->GetAccessible(getter_AddRefs(newAcc)); - // ---- Try QI'ing node to get nsIAccessible ---- - if (!newAcc) - newAcc = do_QueryInterface(aNode); + // ---- Is it a XUL element? -- they impl nsIAccessibleProvider via XBL + if (!newAcc) { + nsCOMPtr accProv(do_QueryInterface(aNode)); + if (accProv) + accProv->GetAccessible(getter_AddRefs(newAcc)); + } // ---- If link, create link accessible ---- if (!newAcc) { diff --git a/accessible/src/nsAccessibilityService.h b/accessible/src/nsAccessibilityService.h index 5450fe88de2b..47efd8451536 100644 --- a/accessible/src/nsAccessibilityService.h +++ b/accessible/src/nsAccessibilityService.h @@ -51,6 +51,7 @@ public: private: NS_IMETHOD GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIWeakReference** aShell, nsIDOMNode** aContent); + NS_IMETHOD GetShellFromNode(nsIDOMNode *aNode, nsIWeakReference **weakShell); void GetOwnerFor(nsIPresShell *aPresShell, nsIPresShell **aOwnerShell, nsIContent **aOwnerContent); nsIContent* FindContentForDocShell(nsIPresShell* aPresShell, nsIContent* aContent, nsIDocShell* aDocShell); diff --git a/accessible/src/nsAccessible.cpp b/accessible/src/nsAccessible.cpp index 1958599ce2d1..6a159804e09d 100644 --- a/accessible/src/nsAccessible.cpp +++ b/accessible/src/nsAccessible.cpp @@ -623,6 +623,49 @@ NS_IMETHODIMP nsAccessible::GetAccState(PRUint32 *aAccState) } } + nsCOMPtr content(do_QueryInterface(mDOMNode)); + if (content) { + nsCOMPtr shell(do_QueryReferent(mPresShell)); + if (shell) { + nsIFrame *frame = nsnull; + shell->GetPrimaryFrameFor(content, &frame); + if (frame) { + /* + PRBool isVisible = PR_FALSE, isFinishedLooking = PR_FALSE; + nsCOMPtr presContext; + shell->GetPresContext(getter_AddRefs(presContext)); + nsRect twipsRect, pixelsRect; + GetAbsoluteFramePosition(presContext, frame, twipsRect, pixelsRect); + + + //frame->IsVisibleForPainting(presContext, presContext, PR_TRUE, &isVisible); // 3rd param = bool to check css visibility + //frame->CheckVisibility(presContext, 0,1, PR_TRUE, &isFinishedLooking, &isVisible); + if (twipsRect.y < 0) + *aAccState |= STATE_OFFSCREEN; + */ + nsSize frameSize; + frame->GetSize(frameSize); + if (frameSize.width == 0) + *aAccState |= STATE_INVISIBLE; + + } + } + } + + + /** + * called to see if the children of the frame are visible from indexstart to index end. + * this does not change any state. returns PR_TRUE only if the indexes are valid and any of + * the children are visible. for textframes this index is the character index. + * if aStart = aEnd result will be PR_FALSE + * @param aStart start index of first child from 0-N (number of children) + * @param aEnd end index of last child from 0-N + * @param aRecurse should this frame talk to siblings to get to the contents other children? + * @param aFinished did this frame have the aEndIndex? or is there more work to do + * @param _retval return value true or false. false = range is not rendered. + */ + //NS_IMETHOD CheckVisibility(nsIPresContext* aContext, PRInt32 aStartIndex, PRInt32 aEndIndex, PRBool aRecurse, PRBool *aFinished, PRBool *_retval)=0; + return rv; } diff --git a/accessible/src/nsGenericAccessible.cpp b/accessible/src/nsGenericAccessible.cpp index 9a815144d5aa..2ae05b790b77 100644 --- a/accessible/src/nsGenericAccessible.cpp +++ b/accessible/src/nsGenericAccessible.cpp @@ -25,7 +25,6 @@ #include "nsIFrame.h" #include "nsCOMPtr.h" #include "nsIWeakReference.h" -#include "nsISelectionController.h" #include "nsReadableUtils.h" #include "nsIContent.h" diff --git a/accessible/src/nsHTMLAreaAccessible.cpp b/accessible/src/nsHTMLAreaAccessible.cpp index b87d133fad44..7df379d54494 100644 --- a/accessible/src/nsHTMLAreaAccessible.cpp +++ b/accessible/src/nsHTMLAreaAccessible.cpp @@ -30,7 +30,6 @@ #include "nsIServiceManager.h" #include "nsIDOMElement.h" #include "nsIDOMHTMLAreaElement.h" -#include "nsGUIEvent.h" // --- area ----- diff --git a/accessible/src/nsHTMLFormControlAccessible.cpp b/accessible/src/nsHTMLFormControlAccessible.cpp index 4ecc9554195d..36c39d2d15fc 100644 --- a/accessible/src/nsHTMLFormControlAccessible.cpp +++ b/accessible/src/nsHTMLFormControlAccessible.cpp @@ -29,12 +29,12 @@ #include "nsHTMLAtoms.h" #include "nsIDOMHTMLButtonElement.h" #include "nsReadableUtils.h" -#include "nsString.h" #include "nsAccessible.h" #include "nsIFrame.h" #include "nsIDOMHTMLLabelElement.h" #include "nsIDOMHTMLFormElement.h" #include "nsISelectionController.h" +#include "nsIDOMXULCheckboxElement.h" nsHTMLFormControlAccessible::nsHTMLFormControlAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell): nsLeafAccessible(aNode, aShell) @@ -117,25 +117,29 @@ NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccName(nsAWritableString& _retval NS_IMETHODIMP nsHTMLFormControlAccessible::GetAccState(PRUint32 *_retval) { // can be - // focusable, focused, checked, protected, unavailable - nsCOMPtr element(do_QueryInterface(mDOMNode)); + // focusable, focused, protected, unavailable + nsCOMPtr htmlFormElement(do_QueryInterface(mDOMNode)); nsAccessible::GetAccState(_retval); - *_retval |= STATE_FOCUSABLE; - - PRBool checked = PR_FALSE; - element->GetChecked(&checked); - if (checked) *_retval |= STATE_CHECKED; PRBool disabled = PR_FALSE; - element->GetDisabled(&disabled); + if (htmlFormElement) { + htmlFormElement->GetDisabled(&disabled); + nsAutoString typeString; + htmlFormElement->GetType(typeString); + if (typeString.EqualsIgnoreCase("password")) + *_retval |= STATE_PROTECTED; + } + else { + nsCOMPtr xulFormElement(do_QueryInterface(mDOMNode)); + if (xulFormElement) + xulFormElement->GetDisabled(&disabled); + } + if (disabled) *_retval |= STATE_UNAVAILABLE; - - nsAutoString typeString; - element->GetType(typeString); - if (typeString.EqualsIgnoreCase("password")) - *_retval |= STATE_PROTECTED; + else + *_retval |= STATE_FOCUSABLE; return NS_OK; } @@ -164,15 +168,12 @@ NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccNumActions(PRUint8 *_retval) /* wstring getAccActionName (in PRUint8 index); */ NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccActionName(PRUint8 index, nsAWritableString& _retval) { - if (index == 0) { + if (index == 0) { // 0 is the magic value for default action // check or uncheck - nsCOMPtr element(do_QueryInterface(mDOMNode)); + PRUint32 state; + GetAccState(&state); - PRBool checked = PR_FALSE; - if (element) - element->GetChecked(&checked); - - if (checked) + if (state & STATE_CHECKED) _retval = NS_LITERAL_STRING("uncheck"); else _retval = NS_LITERAL_STRING("check"); @@ -186,15 +187,43 @@ NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccActionName(PRUint8 index, nsAWrita NS_IMETHODIMP nsHTMLCheckboxAccessible::AccDoAction(PRUint8 index) { if (index == 0) { // 0 is the magic value for default action - nsCOMPtr element(do_QueryInterface(mDOMNode)); + nsCOMPtr htmlCheckboxElement(do_QueryInterface(mDOMNode)); PRBool checked = PR_FALSE; - element->GetChecked(&checked); - element->SetChecked(checked ? PR_FALSE : PR_TRUE); + if (htmlCheckboxElement) { + htmlCheckboxElement->GetChecked(&checked); + htmlCheckboxElement->SetChecked(!checked); + } + else { + nsCOMPtr xulCheckboxElement(do_QueryInterface(mDOMNode)); + if (xulCheckboxElement) { + xulCheckboxElement->GetChecked(&checked); + xulCheckboxElement->SetChecked(!checked); + } + } return NS_OK; } return NS_ERROR_INVALID_ARG; } +NS_IMETHODIMP nsHTMLCheckboxAccessible::GetAccState(PRUint32 *_retval) +{ + nsHTMLFormControlAccessible::GetAccState(_retval); + PRBool checked = PR_FALSE; // Radio buttons and check boxes can be checked + + nsCOMPtr htmlCheckboxElement(do_QueryInterface(mDOMNode)); + if (htmlCheckboxElement) + htmlCheckboxElement->GetChecked(&checked); + else { + nsCOMPtr xulCheckboxElement(do_QueryInterface(mDOMNode)); + if (xulCheckboxElement) + xulCheckboxElement->GetChecked(&checked); + } + + if (checked) + *_retval |= STATE_CHECKED; + + return NS_OK; +} //------ Radio button ------- @@ -240,6 +269,28 @@ NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccRole(PRUint32 *_retval) return NS_OK; } +NS_IMETHODIMP nsHTMLRadioButtonAccessible::GetAccState(PRUint32 *_retval) +{ + nsHTMLFormControlAccessible::GetAccState(_retval); + PRBool checked = PR_FALSE; // Radio buttons and check boxes can be checked + + nsCOMPtr htmlRadioElement(do_QueryInterface(mDOMNode)); + if (htmlRadioElement) + htmlRadioElement->GetChecked(&checked); + + /* ----- Need to add this code soon + + nsCOMPtr xulRadioElement(do_QueryInteface(mDOMNode)); + if (xulRadioElement) + xulRadioElement->GetChecked(&checked); + */ + + if (checked) + *_retval |= STATE_CHECKED; + + return NS_OK; +} + // ----- Button ----- nsHTMLButtonAccessible::nsHTMLButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell): @@ -387,6 +438,11 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccRole(PRUint32 *_retval) /* wstring getAccValue (); */ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccValue(nsAWritableString& _retval) { + PRUint32 state; + GetAccState(&state); + if (state & STATE_PROTECTED) // Don't return password text! + return NS_ERROR_FAILURE; + nsCOMPtr textArea(do_QueryInterface(mDOMNode)); if (textArea) { textArea->GetValue(_retval); diff --git a/accessible/src/nsHTMLFormControlAccessible.h b/accessible/src/nsHTMLFormControlAccessible.h index c83ed2981e0b..2b5bc7df41ac 100644 --- a/accessible/src/nsHTMLFormControlAccessible.h +++ b/accessible/src/nsHTMLFormControlAccessible.h @@ -54,6 +54,7 @@ public: NS_IMETHOD GetAccNumActions(PRUint8 *_retval); NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval); NS_IMETHOD AccDoAction(PRUint8 index); + NS_IMETHOD GetAccState(PRUint32 *_retval); }; class nsHTMLRadioButtonAccessible : public nsHTMLFormControlAccessible @@ -65,6 +66,7 @@ public: NS_IMETHOD GetAccNumActions(PRUint8 *_retval); NS_IMETHOD GetAccActionName(PRUint8 index, nsAWritableString& _retval); NS_IMETHOD AccDoAction(PRUint8 index); + NS_IMETHOD GetAccState(PRUint32 *_retval); }; class nsHTMLButtonAccessible : public nsHTMLFormControlAccessible diff --git a/accessible/src/nsHTMLTextAccessible.cpp b/accessible/src/nsHTMLTextAccessible.cpp index 3490eaa3a5e3..04055b05269a 100644 --- a/accessible/src/nsHTMLTextAccessible.cpp +++ b/accessible/src/nsHTMLTextAccessible.cpp @@ -24,7 +24,6 @@ #include "nsHTMLTextAccessible.h" #include "nsWeakReference.h" #include "nsIFrame.h" -#include "nsString.h" #include "nsILink.h" #include "nsILinkHandler.h" #include "nsISelection.h" diff --git a/dom/public/idl/xul/MANIFEST_IDL b/dom/public/idl/xul/MANIFEST_IDL index 5f8d104c2293..e1e8f1c719a2 100644 --- a/dom/public/idl/xul/MANIFEST_IDL +++ b/dom/public/idl/xul/MANIFEST_IDL @@ -2,3 +2,6 @@ nsIDOMXULCommandDispatcher.idl nsIDOMXULDocument.idl nsIDOMXULElement.idl nsIDOMXULTreeElement.idl +nsIDOMXULCheckboxElement.idl +nsIDOMXULControlElement.idl +nsIDOMXULLabeledControlElement.idl diff --git a/dom/public/idl/xul/Makefile.in b/dom/public/idl/xul/Makefile.in index 2ac3af0c1e55..792fe2422ab0 100644 --- a/dom/public/idl/xul/Makefile.in +++ b/dom/public/idl/xul/Makefile.in @@ -34,6 +34,9 @@ XPIDLSRCS = \ nsIDOMXULDocument.idl \ nsIDOMXULElement.idl \ nsIDOMXULTreeElement.idl \ + nsIDOMXULCheckboxElement.idl \ + nsIDOMXULControlElement.idl \ + nsIDOMXULLabeledControlElement.idl \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/dom/public/idl/xul/makefile.win b/dom/public/idl/xul/makefile.win index cf8811cc9af9..62cd22369a67 100644 --- a/dom/public/idl/xul/makefile.win +++ b/dom/public/idl/xul/makefile.win @@ -30,6 +30,9 @@ XPIDLSRCS = \ .\nsIDOMXULDocument.idl \ .\nsIDOMXULElement.idl \ .\nsIDOMXULTreeElement.idl \ + .\nsIDOMXULCheckboxElement.idl \ + .\nsIDOMXULControlElement.idl \ + .\nsIDOMXULLabeledControlElement.idl \ $(NULL) include <$(DEPTH)\config\rules.mak> diff --git a/dom/public/idl/xul/nsIDOMXULCheckboxElement.idl b/dom/public/idl/xul/nsIDOMXULCheckboxElement.idl new file mode 100644 index 000000000000..c48da845a6fc --- /dev/null +++ b/dom/public/idl/xul/nsIDOMXULCheckboxElement.idl @@ -0,0 +1,37 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * David Hyatt (original author) + * Johnny Stenback + */ + +#include "nsIDOMElement.idl" +#include "nsIDOMXULLabeledControlElement.idl" + +[scriptable, uuid(5afaba88-1dd2-11b2-9249-dd65a129d0e4)] +interface nsIDOMXULCheckboxElement : nsIDOMXULLabeledControlElement { + attribute boolean checked; + attribute long checkState; + attribute boolean autoCheck; +}; + + + + diff --git a/dom/public/idl/xul/nsIDOMXULControlElement.idl b/dom/public/idl/xul/nsIDOMXULControlElement.idl new file mode 100644 index 000000000000..2f9f30e4cc76 --- /dev/null +++ b/dom/public/idl/xul/nsIDOMXULControlElement.idl @@ -0,0 +1,41 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * David Hyatt (original author) + * Johnny Stenback + */ + +#include "nsIDOMElement.idl" +#include "nsIDOMXULElement.idl" + +interface nsIControllers; + +[scriptable, uuid(007b8358-1dd2-11b2-8924-d209efc3f124)] +interface nsIDOMXULControlElement : nsIDOMXULElement { + attribute boolean disabled; + attribute long tabIndex; + +// readonly attribute nsIControllers controllers; + +// void focus(); +// void blur(); +}; + + diff --git a/dom/public/idl/xul/nsIDOMXULLabeledControlElement.idl b/dom/public/idl/xul/nsIDOMXULLabeledControlElement.idl new file mode 100644 index 000000000000..485d27d8017c --- /dev/null +++ b/dom/public/idl/xul/nsIDOMXULLabeledControlElement.idl @@ -0,0 +1,38 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * David Hyatt (original author) + * Johnny Stenback + */ + +#include "nsIDOMElement.idl" +#include "nsIDOMXULControlElement.idl" + +[scriptable, uuid(a457ea70-1dd1-11b2-9089-8fd894122084)] +interface nsIDOMXULLabeledControlElement : nsIDOMXULControlElement { + attribute DOMString crop; + attribute DOMString image; + attribute DOMString label; + attribute DOMString accessKey; + attribute DOMString command; + +// void doCommand(); +}; + diff --git a/xpfe/global/resources/content/bindings/checkbox.xml b/xpfe/global/resources/content/bindings/checkbox.xml index 588325362c25..458dafe288ba 100644 --- a/xpfe/global/resources/content/bindings/checkbox.xml +++ b/xpfe/global/resources/content/bindings/checkbox.xml @@ -21,7 +21,15 @@ - + + + + + +