Permalink
Browse files

merge mozilla-central with devtools

  • Loading branch information...
Rob Campbell
Rob Campbell committed Mar 30, 2011
2 parents 7541653 + 440eb14 commit 68fcb7b9f2444fb78ce8d99ab346f28a6186f0af
Showing 796 changed files with 50,392 additions and 31,106 deletions.
@@ -374,16 +374,6 @@ class nsAccUtils
role != nsIAccessibleRole::ROLE_STATICTEXT;
}
- /**
- * Return true if the given accessible hasn't children.
- */
- static inline PRBool IsLeaf(nsIAccessible *aAcc)
- {
- PRInt32 numChildren = 0;
- aAcc->GetChildCount(&numChildren);
- return numChildren == 0;
- }
-
/**
* Return true if the given accessible can't have children. Used when exposing
* to platform accessibility APIs, should the children be pruned off?
@@ -100,6 +100,7 @@
#endif
#include "mozilla/FunctionTimer.h"
+#include "mozilla/dom/Element.h"
////////////////////////////////////////////////////////////////////////////////
// nsAccessibilityService
@@ -275,7 +276,7 @@ nsAccessibilityService::CreateHTMLImageAccessible(nsIContent* aContent,
if (!mapElmName.IsEmpty()) {
if (mapElmName.CharAt(0) == '#')
mapElmName.Cut(0,1);
- mapElm = htmlDoc->GetImageMap(mapElmName);
+ mapElm = do_QueryInterface(htmlDoc->GetImageMap(mapElmName));
}
}
@@ -765,24 +765,22 @@ nsAccessible::GetFocusedChild(nsIAccessible **aFocusedChild)
}
// nsAccessible::GetChildAtPoint()
-nsresult
-nsAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY, PRBool aDeepestChild,
- nsIAccessible **aChild)
+nsAccessible*
+nsAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
+ EWhichChildAtPoint aWhichChild)
{
// If we can't find the point in a child, we will return the fallback answer:
// we return |this| if the point is within it, otherwise nsnull.
PRInt32 x = 0, y = 0, width = 0, height = 0;
nsresult rv = GetBounds(&x, &y, &width, &height);
- NS_ENSURE_SUCCESS(rv, rv);
+ NS_ENSURE_SUCCESS(rv, nsnull);
- nsCOMPtr<nsIAccessible> fallbackAnswer;
+ nsAccessible* fallbackAnswer = nsnull;
if (aX >= x && aX < x + width && aY >= y && aY < y + height)
fallbackAnswer = this;
- if (nsAccUtils::MustPrune(this)) { // Do not dig any further
- NS_IF_ADDREF(*aChild = fallbackAnswer);
- return NS_OK;
- }
+ if (nsAccUtils::MustPrune(this)) // Do not dig any further
+ return fallbackAnswer;
// Search an accessible at the given point starting from accessible document
// because containing block (see CSS2) for out of flow element (for example,
@@ -791,10 +789,10 @@ nsAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY, PRBool aDeepestChild,
// for DOM parent but GetFrameForPoint() should be called for containing block
// to get an out of flow element.
nsDocAccessible *accDocument = GetDocAccessible();
- NS_ENSURE_TRUE(accDocument, NS_ERROR_FAILURE);
+ NS_ENSURE_TRUE(accDocument, nsnull);
nsIFrame *frame = accDocument->GetFrame();
- NS_ENSURE_STATE(frame);
+ NS_ENSURE_TRUE(frame, nsnull);
nsPresContext *presContext = frame->PresContext();
@@ -806,19 +804,15 @@ nsAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY, PRBool aDeepestChild,
nsIFrame *foundFrame = presShell->GetFrameForPoint(frame, offset);
nsIContent* content = nsnull;
- if (!foundFrame || !(content = foundFrame->GetContent())) {
- NS_IF_ADDREF(*aChild = fallbackAnswer);
- return NS_OK;
- }
+ if (!foundFrame || !(content = foundFrame->GetContent()))
+ return fallbackAnswer;
// Get accessible for the node with the point or the first accessible in
// the DOM parent chain.
nsAccessible* accessible =
GetAccService()->GetAccessibleOrContainer(content, mWeakShell);
- if (!accessible) {
- NS_IF_ADDREF(*aChild = fallbackAnswer);
- return NS_OK;
- }
+ if (!accessible)
+ return fallbackAnswer;
if (accessible == this) {
// Manually walk through accessible children and see if the are within this
@@ -836,40 +830,36 @@ nsAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY, PRBool aDeepestChild,
aY >= childY && aY < childY + childHeight &&
(nsAccUtils::State(child) & nsIAccessibleStates::STATE_INVISIBLE) == 0) {
- if (aDeepestChild)
- return child->GetDeepestChildAtPoint(aX, aY, aChild);
+ if (aWhichChild == eDeepestChild)
+ return child->GetChildAtPoint(aX, aY, eDeepestChild);
- NS_IF_ADDREF(*aChild = child);
- return NS_OK;
+ return child;
}
}
// The point is in this accessible but not in a child. We are allowed to
// return |this| as the answer.
- NS_IF_ADDREF(*aChild = accessible);
- return NS_OK;
+ return accessible;
}
// Since DOM node of obtained accessible may be out of flow then we should
// ensure obtained accessible is a child of this accessible.
- nsCOMPtr<nsIAccessible> parent, child(accessible);
- while (PR_TRUE) {
- child->GetParent(getter_AddRefs(parent));
+ nsAccessible* child = accessible;
+ while (true) {
+ nsAccessible* parent = child->GetParent();
if (!parent) {
// Reached the top of the hierarchy. These bounds were inside an
// accessible that is not a descendant of this one.
- NS_IF_ADDREF(*aChild = fallbackAnswer);
- return NS_OK;
+ return fallbackAnswer;
}
- if (parent == this) {
- NS_ADDREF(*aChild = (aDeepestChild ? accessible : child));
- return NS_OK;
- }
- child.swap(parent);
+ if (parent == this)
+ return aWhichChild == eDeepestChild ? accessible : child;
+
+ child = parent;
}
- return NS_OK;
+ return nsnull;
}
// nsIAccessible getChildAtPoint(in long x, in long y)
@@ -883,7 +873,8 @@ nsAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
if (IsDefunct())
return NS_ERROR_FAILURE;
- return GetChildAtPoint(aX, aY, PR_FALSE, aAccessible);
+ NS_IF_ADDREF(*aAccessible = GetChildAtPoint(aX, aY, eDirectChild));
+ return NS_OK;
}
// nsIAccessible getDeepestChildAtPoint(in long x, in long y)
@@ -897,7 +888,8 @@ nsAccessible::GetDeepestChildAtPoint(PRInt32 aX, PRInt32 aY,
if (IsDefunct())
return NS_ERROR_FAILURE;
- return GetChildAtPoint(aX, aY, PR_TRUE, aAccessible);
+ NS_IF_ADDREF(*aAccessible = GetChildAtPoint(aX, aY, eDeepestChild));
+ return NS_OK;
}
void nsAccessible::GetBoundsRect(nsRect& aTotalBounds, nsIFrame** aBoundingFrame)
@@ -2716,7 +2708,7 @@ nsAccessible::BindToParent(nsAccessible* aParent, PRUint32 aIndexInParent)
if (mParent) {
if (mParent != aParent) {
NS_ERROR("Adopting child!");
- mParent->InvalidateChildren();
+ mParent->RemoveChild(this);
} else {
NS_ERROR("Binding to the same parent!");
return;
@@ -189,17 +189,24 @@ class nsAccessible : public nsAccessNodeWrap,
*/
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
+ /**
+ * Used by GetChildAtPoint() method to get direct or deepest child at point.
+ */
+ enum EWhichChildAtPoint {
+ eDirectChild,
+ eDeepestChild
+ };
+
/**
* Return direct or deepest child at the given point.
*
- * @param aX [in] x coordinate relative screen
- * @param aY [in] y coordinate relative screen
- * @param aDeepestChild [in] flag points if deep child should be returned
- * @param aChild [out] found child
- */
- virtual nsresult GetChildAtPoint(PRInt32 aX, PRInt32 aY,
- PRBool aDeepestChild,
- nsIAccessible **aChild);
+ * @param aX [in] x coordinate relative screen
+ * @param aY [in] y coordinate relative screen
+ * @param aWhichChild [in] flag points if deepest or direct child
+ * should be returned
+ */
+ virtual nsAccessible* GetChildAtPoint(PRInt32 aX, PRInt32 aY,
+ EWhichChildAtPoint aWhichChild);
/**
* Return calculated group level based on accessible hierarchy.
@@ -170,22 +170,11 @@ nsApplicationAccessible::GroupPosition(PRInt32 *aGroupLevel,
return NS_OK;
}
-NS_IMETHODIMP
+nsAccessible*
nsApplicationAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
- nsIAccessible **aChild)
+ EWhichChildAtPoint aWhichChild)
{
- NS_ENSURE_ARG_POINTER(aChild);
- *aChild = nsnull;
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-nsApplicationAccessible::GetDeepestChildAtPoint(PRInt32 aX, PRInt32 aY,
- nsIAccessible **aChild)
-{
- NS_ENSURE_ARG_POINTER(aChild);
- *aChild = nsnull;
- return NS_ERROR_NOT_IMPLEMENTED;
+ return nsnull;
}
NS_IMETHODIMP
@@ -98,8 +98,6 @@ class nsApplicationAccessible: public nsAccessibleWrap,
NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes);
NS_IMETHOD GroupPosition(PRInt32 *aGroupLevel, PRInt32 *aSimilarItemsInGroup,
PRInt32 *aPositionInGroup);
- NS_IMETHOD GetChildAtPoint(PRInt32 aX, PRInt32 aY, nsIAccessible **aChild);
- NS_IMETHOD GetDeepestChildAtPoint(PRInt32 aX, PRInt32 aY, nsIAccessible **aChild);
NS_IMETHOD GetRelationByType(PRUint32 aRelationType,
nsIAccessibleRelation **aRelation);
NS_IMETHOD GetRelationsCount(PRUint32 *aRelationsCount);
@@ -128,6 +126,8 @@ class nsApplicationAccessible: public nsAccessibleWrap,
virtual nsresult GetARIAState(PRUint32 *aState, PRUint32 *aExtraState);
virtual PRUint32 NativeRole();
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
+ virtual nsAccessible* GetChildAtPoint(PRInt32 aX, PRInt32 aY,
+ EWhichChildAtPoint aWhichChild);
virtual void InvalidateChildren();
@@ -67,14 +67,12 @@ NS_IMPL_ISUPPORTS_INHERITED0(nsLeafAccessible, nsAccessible)
////////////////////////////////////////////////////////////////////////////////
// nsLeafAccessible: nsAccessible public
-nsresult
+nsAccessible*
nsLeafAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
- PRBool aDeepestChild,
- nsIAccessible **aChild)
+ EWhichChildAtPoint aWhichChild)
{
// Don't walk into leaf accessibles.
- NS_ADDREF(*aChild = this);
- return NS_OK;
+ return this;
}
////////////////////////////////////////////////////////////////////////////////
@@ -63,9 +63,8 @@ class nsLeafAccessible : public nsAccessibleWrap
NS_DECL_ISUPPORTS_INHERITED
// nsAccessible
- virtual nsresult GetChildAtPoint(PRInt32 aX, PRInt32 aY,
- PRBool aDeepestChild,
- nsIAccessible **aChild);
+ virtual nsAccessible* GetChildAtPoint(PRInt32 aX, PRInt32 aY,
+ EWhichChildAtPoint aWhichChild);
protected:
@@ -1231,19 +1231,17 @@ void nsDocAccessible::ContentAppended(nsIDocument *aDocument,
{
}
-void nsDocAccessible::ContentStatesChanged(nsIDocument* aDocument,
- nsIContent* aContent1,
- nsIContent* aContent2,
- nsEventStates aStateMask)
+void nsDocAccessible::ContentStateChanged(nsIDocument* aDocument,
+ nsIContent* aContent,
+ nsEventStates aStateMask)
{
if (aStateMask.HasState(NS_EVENT_STATE_CHECKED)) {
- nsHTMLSelectOptionAccessible::SelectionChangedIfOption(aContent1);
- nsHTMLSelectOptionAccessible::SelectionChangedIfOption(aContent2);
+ nsHTMLSelectOptionAccessible::SelectionChangedIfOption(aContent);
}
if (aStateMask.HasState(NS_EVENT_STATE_INVALID)) {
nsRefPtr<AccEvent> event =
- new AccStateChangeEvent(aContent1, nsIAccessibleStates::STATE_INVALID,
+ new AccStateChangeEvent(aContent, nsIAccessibleStates::STATE_INVALID,
PR_FALSE, PR_TRUE);
FireDelayedAccessibleEvent(event);
}
@@ -76,32 +76,25 @@ nsOuterDocAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState)
return NS_OK;
}
-nsresult
+nsAccessible*
nsOuterDocAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
- PRBool aDeepestChild,
- nsIAccessible **aChild)
+ EWhichChildAtPoint aWhichChild)
{
PRInt32 docX = 0, docY = 0, docWidth = 0, docHeight = 0;
nsresult rv = GetBounds(&docX, &docY, &docWidth, &docHeight);
- NS_ENSURE_SUCCESS(rv, rv);
+ NS_ENSURE_SUCCESS(rv, nsnull);
if (aX < docX || aX >= docX + docWidth || aY < docY || aY >= docY + docHeight)
- return NS_OK;
+ return nsnull;
// Always return the inner doc as direct child accessible unless bounds
// outside of it.
- nsCOMPtr<nsIAccessible> childAcc;
- rv = GetFirstChild(getter_AddRefs(childAcc));
- NS_ENSURE_SUCCESS(rv, rv);
-
- if (!childAcc)
- return NS_OK;
-
- if (aDeepestChild)
- return childAcc->GetDeepestChildAtPoint(aX, aY, aChild);
+ nsAccessible* child = GetChildAt(0);
+ NS_ENSURE_TRUE(child, nsnull);
- NS_ADDREF(*aChild = childAcc);
- return NS_OK;
+ if (aWhichChild = eDeepestChild)
+ return child->GetChildAtPoint(aX, aY, eDeepestChild);
+ return child;
}
nsresult
@@ -70,9 +70,8 @@ class nsOuterDocAccessible : public nsAccessibleWrap
virtual PRUint32 NativeRole();
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
- virtual nsresult GetChildAtPoint(PRInt32 aX, PRInt32 aY,
- PRBool aDeepestChild,
- nsIAccessible **aChild);
+ virtual nsAccessible* GetChildAtPoint(PRInt32 aX, PRInt32 aY,
+ EWhichChildAtPoint aWhichChild);
virtual void InvalidateChildren();
virtual PRBool AppendChild(nsAccessible *aAccessible);
@@ -246,14 +246,12 @@ nsHTMLAreaAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState)
return nsHTMLLinkAccessible::GetStateInternal(aState, aExtraState);
}
-nsresult
+nsAccessible*
nsHTMLAreaAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
- PRBool aDeepestChild,
- nsIAccessible **aChild)
+ EWhichChildAtPoint aWhichChild)
{
// Don't walk into area accessibles.
- NS_ADDREF(*aChild = this);
- return NS_OK;
+ return this;
}
////////////////////////////////////////////////////////////////////////////////
Oops, something went wrong.

0 comments on commit 68fcb7b

Please sign in to comment.