From 631b7c6baa484ee1836bd3c4a6e1737d734caee8 Mon Sep 17 00:00:00 2001 From: Alexander Surkov Date: Mon, 14 May 2012 13:51:45 +0900 Subject: [PATCH] Bug 754627 - GetBounds on bullet return wrong values, r=tbsaunde, roc --- accessible/src/html/HTMLListAccessible.cpp | 22 ++++- accessible/src/html/HTMLListAccessible.h | 8 ++ accessible/tests/mochitest/bounds/Makefile.in | 1 + .../tests/mochitest/bounds/test_list.html | 81 +++++++++++++++++++ layout/generic/nsBlockFrame.h | 44 +++++----- 5 files changed, 132 insertions(+), 24 deletions(-) create mode 100644 accessible/tests/mochitest/bounds/test_list.html diff --git a/accessible/src/html/HTMLListAccessible.cpp b/accessible/src/html/HTMLListAccessible.cpp index 1ca1a2af70e..623978d6117 100644 --- a/accessible/src/html/HTMLListAccessible.cpp +++ b/accessible/src/html/HTMLListAccessible.cpp @@ -11,6 +11,7 @@ #include "States.h" #include "nsBlockFrame.h" +#include "nsBulletFrame.h" using namespace mozilla; using namespace mozilla::a11y; @@ -85,15 +86,15 @@ HTMLLIAccessible::GetBounds(PRInt32* aX, PRInt32* aY, PRInt32* aWidth, PRInt32* aHeight) { nsresult rv = nsAccessibleWrap::GetBounds(aX, aY, aWidth, aHeight); - if (NS_FAILED(rv) || !mBullet) + if (NS_FAILED(rv) || !mBullet || mBullet->IsInside()) return rv; PRInt32 bulletX = 0, bulletY = 0, bulletWidth = 0, bulletHeight = 0; rv = mBullet->GetBounds(&bulletX, &bulletY, &bulletWidth, &bulletHeight); NS_ENSURE_SUCCESS(rv, rv); + *aWidth += *aX - bulletX; *aX = bulletX; // Move x coordinate of list item over to cover bullet as well - *aWidth += bulletWidth; return NS_OK; } @@ -144,6 +145,13 @@ HTMLLIAccessible::CacheChildren() //////////////////////////////////////////////////////////////////////////////// // HTMLListBulletAccessible: nsAccessNode +nsIFrame* +HTMLListBulletAccessible::GetFrame() const +{ + nsBlockFrame* blockFrame = do_QueryFrame(mContent->GetPrimaryFrame()); + return blockFrame ? blockFrame->GetBullet() : nsnull; +} + bool HTMLListBulletAccessible::IsPrimaryForNode() const { @@ -199,3 +207,13 @@ HTMLListBulletAccessible::AppendTextTo(nsAString& aText, PRUint32 aStartOffset, aText.Append(Substring(bulletText, aStartOffset, aLength)); } + +//////////////////////////////////////////////////////////////////////////////// +// HTMLListBulletAccessible: public + +bool +HTMLListBulletAccessible::IsInside() const +{ + nsBlockFrame* blockFrame = do_QueryFrame(mContent->GetPrimaryFrame()); + return blockFrame ? blockFrame->HasInsideBullet() : false; +} diff --git a/accessible/src/html/HTMLListAccessible.h b/accessible/src/html/HTMLListAccessible.h index 9feacec9a35..4d7c068373a 100644 --- a/accessible/src/html/HTMLListAccessible.h +++ b/accessible/src/html/HTMLListAccessible.h @@ -80,6 +80,7 @@ public: virtual ~HTMLListBulletAccessible() { } // nsAccessNode + virtual nsIFrame* GetFrame() const; virtual bool IsPrimaryForNode() const; // nsAccessible @@ -88,6 +89,13 @@ public: virtual PRUint64 NativeState(); virtual void AppendTextTo(nsAString& aText, PRUint32 aStartOffset = 0, PRUint32 aLength = PR_UINT32_MAX); + + // HTMLListBulletAccessible + + /** + * Return true if the bullet is inside of list item element boundaries. + */ + bool IsInside() const; }; } // namespace a11y diff --git a/accessible/tests/mochitest/bounds/Makefile.in b/accessible/tests/mochitest/bounds/Makefile.in index d993d84d3ee..c11a613a43b 100644 --- a/accessible/tests/mochitest/bounds/Makefile.in +++ b/accessible/tests/mochitest/bounds/Makefile.in @@ -46,6 +46,7 @@ include $(DEPTH)/config/autoconf.mk include $(topsrcdir)/config/rules.mk _TEST_FILES =\ + test_list.html \ test_select.html \ test_zoom.html \ $(NULL) diff --git a/accessible/tests/mochitest/bounds/test_list.html b/accessible/tests/mochitest/bounds/test_list.html new file mode 100644 index 00000000000..38a79689b6c --- /dev/null +++ b/accessible/tests/mochitest/bounds/test_list.html @@ -0,0 +1,81 @@ + + + + Accessible boundaries when page is zoomed + + + + + + + + + + + + + + + Mozilla Bug 754627 + +

+ +
+  
+ + + + + + + diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index 6b97e308c70..d26a1e86e9c 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -250,6 +250,28 @@ public: return HasOutsideBullet() || HasInsideBullet(); } + /** + * @return true if this frame has an inside bullet frame. + */ + bool HasInsideBullet() const { + return 0 != (mState & NS_BLOCK_FRAME_HAS_INSIDE_BULLET); + } + + /** + * @return true if this frame has an outside bullet frame. + */ + bool HasOutsideBullet() const { + return 0 != (mState & NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET); + } + + /** + * @return the bullet frame or nsnull if we don't have one. + */ + nsBulletFrame* GetBullet() const { + nsBulletFrame* outside = GetOutsideBullet(); + return outside ? outside : GetInsideBullet(); + } + virtual void MarkIntrinsicWidthsDirty(); virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext); virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext); @@ -748,25 +770,11 @@ protected: nsFrameList* GetOverflowOutOfFlows() const; void SetOverflowOutOfFlows(const nsFrameList& aList, nsFrameList* aPropValue); - /** - * @return true if this frame has an inside bullet frame. - */ - bool HasInsideBullet() const { - return 0 != (mState & NS_BLOCK_FRAME_HAS_INSIDE_BULLET); - } - /** * @return the inside bullet frame or nsnull if we don't have one. */ nsBulletFrame* GetInsideBullet() const; - /** - * @return true if this frame has an outside bullet frame. - */ - bool HasOutsideBullet() const { - return 0 != (mState & NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET); - } - /** * @return the outside bullet frame or nsnull if we don't have one. */ @@ -777,14 +785,6 @@ protected: */ nsFrameList* GetOutsideBulletList() const; - /** - * @return the bullet frame or nsnull if we don't have one. - */ - nsBulletFrame* GetBullet() const { - nsBulletFrame* outside = GetOutsideBullet(); - return outside ? outside : GetInsideBullet(); - } - /** * @return true if this frame has pushed floats. */