mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 751496 - get rid nsAccessible::GetBoundsFrame, r=rbsaunde
This commit is contained in:
parent
b9eb3aab00
commit
09b9b0422e
@ -914,7 +914,7 @@ void nsAccessible::GetBoundsRect(nsRect& aTotalBounds, nsIFrame** aBoundingFrame
|
||||
|
||||
// Initialization area
|
||||
*aBoundingFrame = nsnull;
|
||||
nsIFrame *firstFrame = GetBoundsFrame();
|
||||
nsIFrame* firstFrame = GetFrame();
|
||||
if (!firstFrame)
|
||||
return;
|
||||
|
||||
@ -1029,13 +1029,6 @@ nsAccessible::GetBounds(PRInt32* aX, PRInt32* aY,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// helpers
|
||||
|
||||
nsIFrame* nsAccessible::GetBoundsFrame()
|
||||
{
|
||||
return GetFrame();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessible::SetSelected(bool aSelect)
|
||||
{
|
||||
if (IsDefunct())
|
||||
|
@ -445,6 +445,11 @@ public:
|
||||
*/
|
||||
void TestChildCache(nsAccessible* aCachedChild) const;
|
||||
|
||||
/**
|
||||
* Return boundaries rect relative the bounding frame.
|
||||
*/
|
||||
virtual void GetBoundsRect(nsRect& aRect, nsIFrame** aRelativeFrame);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Downcasting and types
|
||||
|
||||
@ -745,9 +750,6 @@ protected:
|
||||
*/
|
||||
mozilla::a11y::role ARIATransformRole(mozilla::a11y::role aRole);
|
||||
|
||||
virtual nsIFrame* GetBoundsFrame();
|
||||
virtual void GetBoundsRect(nsRect& aRect, nsIFrame** aRelativeFrame);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Name helpers
|
||||
|
||||
|
@ -123,6 +123,8 @@ public:
|
||||
virtual nsresult HandleAccEvent(AccEvent* aAccEvent);
|
||||
#endif
|
||||
|
||||
virtual void GetBoundsRect(nsRect& aRect, nsIFrame** aRelativeFrame);
|
||||
|
||||
// nsHyperTextAccessible
|
||||
virtual already_AddRefed<nsIEditor> GetEditor() const;
|
||||
|
||||
@ -384,7 +386,6 @@ protected:
|
||||
virtual void CacheChildren();
|
||||
|
||||
// nsDocAccessible
|
||||
virtual void GetBoundsRect(nsRect& aRect, nsIFrame** aRelativeFrame);
|
||||
virtual nsresult AddEventListeners();
|
||||
virtual nsresult RemoveEventListeners();
|
||||
|
||||
|
@ -105,6 +105,7 @@ public:
|
||||
virtual PRUint64 NativeState();
|
||||
virtual nsAccessible* ChildAtPoint(PRInt32 aX, PRInt32 aY,
|
||||
EWhichChildAtPoint aWhichChild);
|
||||
virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame);
|
||||
|
||||
// HyperLinkAccessible
|
||||
virtual PRUint32 StartOffset();
|
||||
@ -114,7 +115,6 @@ protected:
|
||||
|
||||
// nsAccessible
|
||||
virtual void CacheChildren();
|
||||
virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -256,22 +256,6 @@ nsHTMLSelectOptionAccessible::GetNameInternal(nsAString& aName)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsAccessible protected
|
||||
nsIFrame* nsHTMLSelectOptionAccessible::GetBoundsFrame()
|
||||
{
|
||||
PRUint64 state = 0;
|
||||
nsIContent* content = GetSelectState(&state);
|
||||
if (state & states::COLLAPSED) {
|
||||
if (content) {
|
||||
return content->GetPrimaryFrame();
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return nsAccessible::GetBoundsFrame();
|
||||
}
|
||||
|
||||
PRUint64
|
||||
nsHTMLSelectOptionAccessible::NativeState()
|
||||
{
|
||||
@ -348,8 +332,16 @@ nsHTMLSelectOptionAccessible::GetLevelInternal()
|
||||
return level;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsHTMLSelectOptionAccessible: nsIAccessible
|
||||
void
|
||||
nsHTMLSelectOptionAccessible::GetBoundsRect(nsRect& aTotalBounds,
|
||||
nsIFrame** aBoundingFrame)
|
||||
{
|
||||
nsAccessible* combobox = GetCombobox();
|
||||
if (combobox && (combobox->State() & states::COLLAPSED))
|
||||
combobox->GetBoundsRect(aTotalBounds, aBoundingFrame);
|
||||
else
|
||||
nsHyperTextAccessibleWrap::GetBoundsRect(aTotalBounds, aBoundingFrame);
|
||||
}
|
||||
|
||||
/** select us! close combo box if necessary*/
|
||||
NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
||||
|
@ -122,6 +122,7 @@ public:
|
||||
virtual PRUint64 NativeState();
|
||||
|
||||
virtual PRInt32 GetLevelInternal();
|
||||
virtual void GetBoundsRect(nsRect& aTotalBounds, nsIFrame** aBoundingFrame);
|
||||
|
||||
// ActionAccessible
|
||||
virtual PRUint8 ActionCount();
|
||||
@ -129,10 +130,6 @@ public:
|
||||
// Widgets
|
||||
virtual nsAccessible* ContainerWidget() const;
|
||||
|
||||
protected:
|
||||
// nsAccessible
|
||||
virtual nsIFrame* GetBoundsFrame();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@ -141,6 +138,19 @@ private:
|
||||
* @return Select element content, returns null if not avaliable
|
||||
*/
|
||||
nsIContent* GetSelectState(PRUint64* aState);
|
||||
|
||||
/**
|
||||
* Return a combobox accessible the option belongs to if any.
|
||||
*/
|
||||
nsAccessible* GetCombobox() const
|
||||
{
|
||||
if (mParent && mParent->IsListControl()) {
|
||||
nsAccessible* combobox = mParent->Parent();
|
||||
return combobox->IsCombobox() ? combobox : nsnull;
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -46,6 +46,7 @@ include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_TEST_FILES =\
|
||||
test_select.html \
|
||||
test_zoom.html \
|
||||
$(NULL)
|
||||
|
||||
|
85
accessible/tests/mochitest/bounds/test_select.html
Normal file
85
accessible/tests/mochitest/bounds/test_select.html
Normal file
@ -0,0 +1,85 @@
|
||||
<!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"
|
||||
src="../events.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
function openComboboxNCheckBounds(aID)
|
||||
{
|
||||
this.combobox = getAccessible(aID);
|
||||
this.comboboxList = this.combobox.firstChild;
|
||||
this.comboboxOption = this.comboboxList.firstChild;
|
||||
|
||||
this.eventSeq = [
|
||||
new invokerChecker(EVENT_FOCUS, this.comboboxOption)
|
||||
];
|
||||
|
||||
this.invoke = function openComboboxNCheckBounds_invoke()
|
||||
{
|
||||
getNode(aID).focus();
|
||||
synthesizeKey("VK_DOWN", { altKey: true });
|
||||
}
|
||||
|
||||
this.finalCheck = function openComboboxNCheckBounds_invoke()
|
||||
{
|
||||
testBounds(this.comboboxOption);
|
||||
}
|
||||
|
||||
this.getID = function openComboboxNCheckBounds_getID()
|
||||
{
|
||||
return "open combobox and test boundaries";
|
||||
}
|
||||
}
|
||||
|
||||
//gA11yEventDumpToConsole = true;
|
||||
|
||||
var gQueue = null;
|
||||
|
||||
function doTest()
|
||||
{
|
||||
// Combobox
|
||||
testBounds("combobox");
|
||||
|
||||
// Option boundaries matches to combobox boundaries when collapsed.
|
||||
var selectBounds = getBoundsForDOMElm("combobox");
|
||||
testBounds("option1", selectBounds);
|
||||
|
||||
// Open combobox and test option boundaries.
|
||||
gQueue = new eventQueue();
|
||||
gQueue.push(new openComboboxNCheckBounds("combobox"));
|
||||
gQueue.invoke(); // Will call SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addA11yLoadEvent(doTest);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<select id="combobox">
|
||||
<option id="option1">item1</option>
|
||||
<option>item2</option>
|
||||
</select>
|
||||
</body>
|
||||
</html>
|
@ -94,10 +94,10 @@ function getChildAtPoint(aIdentifier, aX, aY, aFindDeepestChild)
|
||||
/**
|
||||
* Test the accessible boundaries.
|
||||
*/
|
||||
function testBounds(aID)
|
||||
function testBounds(aID, aRect)
|
||||
{
|
||||
var [expectedX, expectedY, expectedWidth, expectedHeight] =
|
||||
getBoundsForDOMElm(aID);
|
||||
(aRect != undefined) ? aRect : getBoundsForDOMElm(aID);
|
||||
|
||||
var [x, y, width, height] = getBounds(aID);
|
||||
is(x, expectedX, "Wrong x coordinate of " + prettyName(aID));
|
||||
@ -166,6 +166,9 @@ function CSSToDevicePixels(aWindow, aX, aY, aWidth, aHeight)
|
||||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
|
||||
var ratio = winUtil.screenPixelsPerCSSPixel;
|
||||
return [aX * ratio, aY * ratio, aWidth * ratio, aHeight * ratio];
|
||||
}
|
||||
|
||||
// CSS pixels and ratio can be not integer. Device pixels are always integer.
|
||||
// Do our best and hope it works.
|
||||
return [ Math.round(aX * ratio), Math.round(aY * ratio),
|
||||
Math.round(aWidth * ratio), Math.round(aHeight * ratio) ];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user