зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1499947 - Part 1 - Remove XULProgressMeterAccessible and its base template class. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D12144 --HG-- extra : rebase_source : 81275b233770a7e9716a2b811a08060fc5006e1b
This commit is contained in:
Родитель
7a412c9948
Коммит
b2a83ffc85
|
@ -430,7 +430,7 @@ MARKUPMAP(p,
|
|||
MARKUPMAP(
|
||||
progress,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLProgressMeterAccessible(aElement, aContext->Document());
|
||||
return new HTMLProgressAccessible(aElement, aContext->Document());
|
||||
},
|
||||
0
|
||||
)
|
||||
|
|
|
@ -319,7 +319,7 @@ enum Role {
|
|||
|
||||
/**
|
||||
* Represents a progress bar, dynamically showing the user the percent
|
||||
* complete of an operation in progress. It is used for xul:progressmeter,
|
||||
* complete of an operation in progress. It is used for html:progress,
|
||||
* role="progressbar".
|
||||
*/
|
||||
PROGRESSBAR = 48,
|
||||
|
|
|
@ -19,7 +19,6 @@ XULMAP_TYPE(menuitem, XULMenuitemAccessibleWrap)
|
|||
XULMAP_TYPE(menulist, XULComboboxAccessible)
|
||||
XULMAP_TYPE(menuseparator, XULMenuSeparatorAccessible)
|
||||
XULMAP_TYPE(notification, XULAlertAccessible)
|
||||
XULMAP_TYPE(progressmeter, XULProgressMeterAccessible)
|
||||
XULMAP_TYPE(radio, XULRadioButtonAccessible)
|
||||
XULMAP_TYPE(radiogroup, XULRadioGroupAccessible)
|
||||
XULMAP_TYPE(richlistbox, XULListboxAccessibleWrap)
|
||||
|
|
|
@ -13,136 +13,6 @@
|
|||
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ProgressMeterAccessible
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template class mozilla::a11y::ProgressMeterAccessible<1>;
|
||||
template class mozilla::a11y::ProgressMeterAccessible<100>;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Accessible
|
||||
|
||||
template<int Max>
|
||||
role
|
||||
ProgressMeterAccessible<Max>::NativeRole() const
|
||||
{
|
||||
return roles::PROGRESSBAR;
|
||||
}
|
||||
|
||||
template<int Max>
|
||||
uint64_t
|
||||
ProgressMeterAccessible<Max>::NativeState() const
|
||||
{
|
||||
uint64_t state = LeafAccessible::NativeState();
|
||||
|
||||
// An undetermined progressbar (i.e. without a value) has a mixed state.
|
||||
nsAutoString attrValue;
|
||||
mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::value, attrValue);
|
||||
|
||||
if (attrValue.IsEmpty())
|
||||
state |= states::MIXED;
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ProgressMeterAccessible<Max>: Widgets
|
||||
|
||||
template<int Max>
|
||||
bool
|
||||
ProgressMeterAccessible<Max>::IsWidget() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ProgressMeterAccessible<Max>: Value
|
||||
|
||||
template<int Max>
|
||||
void
|
||||
ProgressMeterAccessible<Max>::Value(nsString& aValue) const
|
||||
{
|
||||
LeafAccessible::Value(aValue);
|
||||
if (!aValue.IsEmpty())
|
||||
return;
|
||||
|
||||
double maxValue = MaxValue();
|
||||
if (IsNaN(maxValue) || maxValue == 0)
|
||||
return;
|
||||
|
||||
double curValue = CurValue();
|
||||
if (IsNaN(curValue))
|
||||
return;
|
||||
|
||||
// Treat the current value bigger than maximum as 100%.
|
||||
double percentValue = (curValue < maxValue) ?
|
||||
(curValue / maxValue) * 100 : 100;
|
||||
|
||||
aValue.AppendFloat(percentValue);
|
||||
aValue.Append('%');
|
||||
}
|
||||
|
||||
template<int Max>
|
||||
double
|
||||
ProgressMeterAccessible<Max>::MaxValue() const
|
||||
{
|
||||
double value = LeafAccessible::MaxValue();
|
||||
if (!IsNaN(value))
|
||||
return value;
|
||||
|
||||
nsAutoString strValue;
|
||||
if (mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::max, strValue)) {
|
||||
nsresult result = NS_OK;
|
||||
value = strValue.ToDouble(&result);
|
||||
if (NS_SUCCEEDED(result))
|
||||
return value;
|
||||
}
|
||||
|
||||
return Max;
|
||||
}
|
||||
|
||||
template<int Max>
|
||||
double
|
||||
ProgressMeterAccessible<Max>::MinValue() const
|
||||
{
|
||||
double value = LeafAccessible::MinValue();
|
||||
return IsNaN(value) ? 0 : value;
|
||||
}
|
||||
|
||||
template<int Max>
|
||||
double
|
||||
ProgressMeterAccessible<Max>::Step() const
|
||||
{
|
||||
double value = LeafAccessible::Step();
|
||||
return IsNaN(value) ? 0 : value;
|
||||
}
|
||||
|
||||
template<int Max>
|
||||
double
|
||||
ProgressMeterAccessible<Max>::CurValue() const
|
||||
{
|
||||
double value = LeafAccessible::CurValue();
|
||||
if (!IsNaN(value))
|
||||
return value;
|
||||
|
||||
nsAutoString attrValue;
|
||||
if (!mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::value, attrValue))
|
||||
return UnspecifiedNaN<double>();
|
||||
|
||||
nsresult error = NS_OK;
|
||||
value = attrValue.ToDouble(&error);
|
||||
return NS_FAILED(error) ? UnspecifiedNaN<double>() : value;
|
||||
}
|
||||
|
||||
template<int Max>
|
||||
bool
|
||||
ProgressMeterAccessible<Max>::SetCurValue(double aValue)
|
||||
{
|
||||
return false; // progress meters are readonly.
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// CheckboxAccessible
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -11,41 +11,6 @@
|
|||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
/**
|
||||
* Generic class used for progress meters.
|
||||
*/
|
||||
template<int Max>
|
||||
class ProgressMeterAccessible : public LeafAccessible
|
||||
{
|
||||
public:
|
||||
ProgressMeterAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
||||
LeafAccessible(aContent, aDoc)
|
||||
{
|
||||
// Ignore 'ValueChange' DOM event in lieu of @value attribute change
|
||||
// notifications.
|
||||
mStateFlags |= eHasNumericValue | eIgnoreDOMUIEvent;
|
||||
mType = eProgressType;
|
||||
}
|
||||
|
||||
// Accessible
|
||||
virtual void Value(nsString& aValue) const override;
|
||||
virtual mozilla::a11y::role NativeRole() const override;
|
||||
virtual uint64_t NativeState() const override;
|
||||
|
||||
// Value
|
||||
virtual double MaxValue() const override;
|
||||
virtual double MinValue() const override;
|
||||
virtual double CurValue() const override;
|
||||
virtual double Step() const override;
|
||||
virtual bool SetCurValue(double aValue) override;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsWidget() const override;
|
||||
|
||||
protected:
|
||||
virtual ~ProgressMeterAccessible() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Checkbox accessible.
|
||||
*/
|
||||
|
|
|
@ -805,3 +805,121 @@ HTMLFigcaptionAccessible::RelationByType(RelationType aType) const
|
|||
|
||||
return rel;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// HTMLProgressAccessible
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
role
|
||||
HTMLProgressAccessible::NativeRole() const
|
||||
{
|
||||
return roles::PROGRESSBAR;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
HTMLProgressAccessible::NativeState() const
|
||||
{
|
||||
uint64_t state = LeafAccessible::NativeState();
|
||||
|
||||
// An undetermined progressbar (i.e. without a value) has a mixed state.
|
||||
nsAutoString attrValue;
|
||||
mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::value,
|
||||
attrValue);
|
||||
if (attrValue.IsEmpty()) {
|
||||
state |= states::MIXED;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLProgressAccessible::IsWidget() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLProgressAccessible::Value(nsString& aValue) const
|
||||
{
|
||||
LeafAccessible::Value(aValue);
|
||||
if (!aValue.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
double maxValue = MaxValue();
|
||||
if (IsNaN(maxValue) || maxValue == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
double curValue = CurValue();
|
||||
if (IsNaN(curValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Treat the current value bigger than maximum as 100%.
|
||||
double percentValue = (curValue < maxValue) ? (curValue / maxValue) * 100
|
||||
: 100;
|
||||
|
||||
aValue.AppendFloat(percentValue);
|
||||
aValue.Append('%');
|
||||
}
|
||||
|
||||
double
|
||||
HTMLProgressAccessible::MaxValue() const
|
||||
{
|
||||
double value = LeafAccessible::MaxValue();
|
||||
if (!IsNaN(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
nsAutoString strValue;
|
||||
if (mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::max,
|
||||
strValue)) {
|
||||
nsresult result = NS_OK;
|
||||
value = strValue.ToDouble(&result);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
double
|
||||
HTMLProgressAccessible::MinValue() const
|
||||
{
|
||||
double value = LeafAccessible::MinValue();
|
||||
return IsNaN(value) ? 0 : value;
|
||||
}
|
||||
|
||||
double
|
||||
HTMLProgressAccessible::Step() const
|
||||
{
|
||||
double value = LeafAccessible::Step();
|
||||
return IsNaN(value) ? 0 : value;
|
||||
}
|
||||
|
||||
double
|
||||
HTMLProgressAccessible::CurValue() const
|
||||
{
|
||||
double value = LeafAccessible::CurValue();
|
||||
if (!IsNaN(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
nsAutoString attrValue;
|
||||
if (!mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::value,
|
||||
attrValue)) {
|
||||
return UnspecifiedNaN<double>();
|
||||
}
|
||||
|
||||
nsresult error = NS_OK;
|
||||
value = attrValue.ToDouble(&error);
|
||||
return NS_FAILED(error) ? UnspecifiedNaN<double>() : value;
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLProgressAccessible::SetCurValue(double aValue)
|
||||
{
|
||||
return false; // progress meters are readonly.
|
||||
}
|
||||
|
|
|
@ -13,11 +13,6 @@ namespace mozilla {
|
|||
class TextEditor;
|
||||
namespace a11y {
|
||||
|
||||
/**
|
||||
* Accessible for HTML progress element.
|
||||
*/
|
||||
typedef ProgressMeterAccessible<1> HTMLProgressMeterAccessible;
|
||||
|
||||
/**
|
||||
* Accessible for HTML input@type="radio" element.
|
||||
*/
|
||||
|
@ -270,6 +265,41 @@ protected:
|
|||
virtual ~HTMLFormAccessible() = default;
|
||||
};
|
||||
|
||||
/**
|
||||
* Accessible for HTML progress element.
|
||||
*/
|
||||
|
||||
class HTMLProgressAccessible : public LeafAccessible
|
||||
{
|
||||
public:
|
||||
HTMLProgressAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
||||
LeafAccessible(aContent, aDoc)
|
||||
{
|
||||
// Ignore 'ValueChange' DOM event in lieu of @value attribute change
|
||||
// notifications.
|
||||
mStateFlags |= eHasNumericValue | eIgnoreDOMUIEvent;
|
||||
mType = eProgressType;
|
||||
}
|
||||
|
||||
// Accessible
|
||||
virtual void Value(nsString& aValue) const override;
|
||||
virtual mozilla::a11y::role NativeRole() const override;
|
||||
virtual uint64_t NativeState() const override;
|
||||
|
||||
// Value
|
||||
virtual double MaxValue() const override;
|
||||
virtual double MinValue() const override;
|
||||
virtual double CurValue() const override;
|
||||
virtual double Step() const override;
|
||||
virtual bool SetCurValue(double aValue) override;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsWidget() const override;
|
||||
|
||||
protected:
|
||||
virtual ~HTMLProgressAccessible() {}
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -312,7 +312,7 @@ interface nsIAccessibleRole : nsISupports
|
|||
|
||||
/**
|
||||
* Represents a progress bar, dynamically showing the user the percent
|
||||
* complete of an operation in progress. It is used for xul:progressmeter,
|
||||
* complete of an operation in progress. It is used for html:progress,
|
||||
* role="progressbar".
|
||||
*/
|
||||
const unsigned long ROLE_PROGRESSBAR = 48;
|
||||
|
|
|
@ -5,5 +5,4 @@ support-files =
|
|||
[test_general.html]
|
||||
[test_number.html]
|
||||
[test_progress.html]
|
||||
[test_progress.xul]
|
||||
[test_range.html]
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="XUL progressmeter tests">
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="../common.js" />
|
||||
<script type="application/javascript"
|
||||
src="../value.js" />
|
||||
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
function doTest()
|
||||
{
|
||||
// progressmeter
|
||||
testValue("pm1", "50%", 50, 0, 100, 0);
|
||||
testValue("pm2", "50%", 500, 0, 1000, 0);
|
||||
testValue("pm3", "", 0, 0, 100, 0);
|
||||
testValue("pm4", "", 0, 0, 100, 0);
|
||||
|
||||
// aria progressbar
|
||||
testValue("ariapb1", "500", 500, 0, 1000, 0);
|
||||
testValue("ariapb2", "", 0, 0, 0, 0);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addA11yLoadEvent(doTest);
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<hbox flex="1" style="overflow: auto;">
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=489551"
|
||||
title="Values of sliders and progress bars in HTML 5 audio and video element's control sets are not percentages">
|
||||
Mozilla Bug 489551
|
||||
</a><br/>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
|
||||
<!-- progressmeter -->
|
||||
<vbox>
|
||||
<progressmeter id="pm1" value="50"/>
|
||||
<progressmeter id="pm2" value="500" max="1000"/>
|
||||
<progressmeter id="pm3"/>
|
||||
<progressmeter id="pm4" mode="undetermined"/>
|
||||
</vbox>
|
||||
|
||||
<!-- aria -->
|
||||
<description id="ariapb1" role="progressbar"
|
||||
aria-valuenow="500" aria-valuemin="0" aria-valuemax="1000"/>
|
||||
<description id="ariapb2" role="progressbar"/>
|
||||
</hbox>
|
||||
|
||||
</window>
|
||||
|
|
@ -15,11 +15,6 @@
|
|||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
/**
|
||||
* Used for XUL progressmeter element.
|
||||
*/
|
||||
typedef ProgressMeterAccessible<100> XULProgressMeterAccessible;
|
||||
|
||||
/**
|
||||
* Used for XUL button.
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче