зеркало из https://github.com/mozilla/pjs.git
Bug 754627 - GetBounds on bullet return wrong values, r=tbsaunde, roc
This commit is contained in:
Родитель
9110389eb8
Коммит
631b7c6baa
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Accessible boundaries when page is zoomed</title>
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="../common.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../role.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../layout.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
function doTest()
|
||||
{
|
||||
// Inside list
|
||||
var li = getAccessible("insidelist_item");
|
||||
testBounds(li);
|
||||
|
||||
var [xLI, yLI, widthLI, heightLI] = getBounds(li);
|
||||
var bullet = li.firstChild;
|
||||
var [x, y, width, height] = getBounds(bullet);
|
||||
is(x, xLI,
|
||||
"Bullet x should match to list item x");
|
||||
ok(y >= yLI,
|
||||
"Bullet y= " + y + " should be not less than list item y=" + yLI);
|
||||
ok(width < widthLI,
|
||||
"Bullet width should be lesser list item width");
|
||||
ok(height <= heightLI,
|
||||
"Bullet height= " + height + " should be not greater than list item height=" + heightLI);
|
||||
|
||||
// Outside list
|
||||
li = getAccessible("outsidelist_item");
|
||||
var [xLIElm, yLIElm, widthLIElm, heightLIElm] = getBoundsForDOMElm(li);
|
||||
[xLI, yLI, widthLI, heightLI] = getBounds(li);
|
||||
|
||||
ok(xLI < xLIElm,
|
||||
"Outside list item x=" + xLI + " should be lesser than list item element x=" + xLIElm);
|
||||
is(yLI, yLIElm,
|
||||
"Outside list item y should match to list item element y");
|
||||
ok(widthLI > widthLIElm,
|
||||
"Outside list item width=" + widthLI + " should be greater than list item element width=" + widthLIElm);
|
||||
is(heightLI, heightLIElm,
|
||||
"Outside list item height should match to list item element height");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addA11yLoadEvent(doTest);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=754627"
|
||||
title="GetBounds on bullet return wrong values">
|
||||
Mozilla Bug 754627
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<ul style="list-style-position: inside;">
|
||||
<li id="insidelist_item">item</li>
|
||||
</ul>
|
||||
|
||||
<ul style="list-style-position: outside;">
|
||||
<li id="outsidelist_item">item</li>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -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.
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче