Bug 748238 - <meter> should not be a form control. r=bz

--HG--
rename : content/html/content/test/test_bug657938.html => content/html/content/test/forms/test_meter_element.html
This commit is contained in:
Mounir Lamouri 2012-06-07 20:42:45 +02:00
parent f7f5b9aa92
commit f40c8a09fa
10 changed files with 20 additions and 58 deletions

View File

@ -26,7 +26,6 @@ enum FormControlsTypes {
NS_FORM_SELECT,
NS_FORM_TEXTAREA,
NS_FORM_OBJECT,
NS_FORM_METER,
eFormControlsWithoutSubTypesMax,
// After this, all types will have sub-types which introduce new enum lists.
// eFormControlsWithoutSubTypesMax let us know if the previous types values

View File

@ -3109,7 +3109,8 @@ nsGenericHTMLElement::GetContextMenu(nsIDOMHTMLMenuElement** aContextMenu)
bool
nsGenericHTMLElement::IsLabelable() const
{
return Tag() == nsGkAtoms::progress;
return Tag() == nsGkAtoms::progress ||
Tag() == nsGkAtoms::meter;
}
//----------------------------------------------------------------------
@ -3472,8 +3473,7 @@ nsGenericHTMLFormElement::CanBeDisabled() const
return
type != NS_FORM_LABEL &&
type != NS_FORM_OBJECT &&
type != NS_FORM_OUTPUT &&
type != NS_FORM_METER;
type != NS_FORM_OUTPUT;
}
bool
@ -3770,7 +3770,6 @@ nsGenericHTMLFormElement::IsLabelable() const
return type & NS_FORM_INPUT_ELEMENT ||
type & NS_FORM_BUTTON_ELEMENT ||
// type == NS_FORM_KEYGEN ||
type == NS_FORM_METER ||
type == NS_FORM_OUTPUT ||
type == NS_FORM_SELECT ||
type == NS_FORM_TEXTAREA;

View File

@ -128,8 +128,7 @@ nsHTMLFieldSetElement::MatchListedElements(nsIContent* aContent, PRInt32 aNamesp
nsIAtom* aAtom, void* aData)
{
nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(aContent);
return formControl && formControl->GetType() != NS_FORM_LABEL &&
formControl->GetType() != NS_FORM_METER;
return formControl && formControl->GetType() != NS_FORM_LABEL;
}
NS_IMETHODIMP

View File

@ -191,7 +191,6 @@ ShouldBeInElements(nsIFormControl* aFormControl)
//
// NS_FORM_INPUT_IMAGE
// NS_FORM_LABEL
// NS_FORM_METER
return false;
}

View File

@ -45,7 +45,7 @@
#include "nsAlgorithm.h"
class nsHTMLMeterElement : public nsGenericHTMLFormElement,
class nsHTMLMeterElement : public nsGenericHTMLElement,
public nsIDOMHTMLMeterElement
{
public:
@ -56,22 +56,17 @@ public:
NS_DECL_ISUPPORTS_INHERITED
/* nsIDOMNode */
NS_FORWARD_NSIDOMNODE(nsGenericHTMLFormElement::)
NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::)
/* nsIDOMElement */
NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFormElement::)
NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::)
/* nsIDOMHTMLElement */
NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFormElement::)
NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
/* nsIDOMHTMLMeterElement */
NS_DECL_NSIDOMHTMLMETERELEMENT
/* nsIFormControl */
NS_IMETHOD_(PRUint32) GetType() const { return NS_FORM_METER; }
NS_IMETHOD Reset();
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission);
virtual nsEventStates IntrinsicState() const;
nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const;
@ -126,7 +121,7 @@ NS_IMPL_NS_NEW_HTML_ELEMENT(Meter)
nsHTMLMeterElement::nsHTMLMeterElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericHTMLFormElement(aNodeInfo)
: nsGenericHTMLElement(aNodeInfo)
{
}
@ -143,30 +138,16 @@ NS_INTERFACE_TABLE_HEAD(nsHTMLMeterElement)
NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLMeterElement,
nsIDOMHTMLMeterElement)
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLMeterElement,
nsGenericHTMLFormElement)
nsGenericHTMLElement)
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLMeterElement)
NS_IMPL_ELEMENT_CLONE(nsHTMLMeterElement)
NS_IMETHODIMP
nsHTMLMeterElement::Reset()
{
/* The meter element is not resettable. */
return NS_OK;
}
NS_IMETHODIMP
nsHTMLMeterElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
{
/* The meter element is not submittable. */
return NS_OK;
}
nsEventStates
nsHTMLMeterElement::IntrinsicState() const
{
nsEventStates state = nsGenericHTMLFormElement::IntrinsicState();
nsEventStates state = nsGenericHTMLElement::IntrinsicState();
state |= GetOptimumState();
@ -185,16 +166,10 @@ nsHTMLMeterElement::ParseAttribute(PRInt32 aNamespaceID, nsIAtom* aAttribute,
}
}
return nsGenericHTMLFormElement::ParseAttribute(aNamespaceID, aAttribute,
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute,
aValue, aResult);
}
NS_IMETHODIMP
nsHTMLMeterElement::GetForm(nsIDOMHTMLFormElement** aForm)
{
return nsGenericHTMLFormElement::GetForm(aForm);
}
/*
* Value getters :
* const getters used by XPCOM methods and by IntrinsicState

View File

@ -264,7 +264,6 @@ _TEST_FILES = \
test_bug742030.html \
test_bug742549.html \
test_bug745685.html \
test_bug657938.html \
test_bug660238.html \
test_input_file_picker.html \
$(NULL)

View File

@ -40,6 +40,7 @@ _TEST_FILES = \
test_form_attribute-3.html \
test_form_attribute-4.html \
test_option_disabled.html \
test_meter_element.html \
$(NULL)
libs:: $(_TEST_FILES)

View File

@ -400,7 +400,7 @@ var forms = [
var elementNames = [
'button', 'fieldset', 'input', 'label', 'object', 'output', 'select',
'textarea', 'meter'
'textarea'
];
var todoElements = [

View File

@ -4,7 +4,7 @@
https://bugzilla.mozilla.org/show_bug.cgi?id=657938
-->
<head>
<title>Test for Bug 657938</title>
<title>Test for <meter></title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
@ -21,21 +21,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=657938
<pre id="test">
<script type="application/javascript">
/** Test for Bug 657938 **/
/** Test for <meter> **/
function checkFormIDLAttribute(aElement)
{
var form = document.forms[0];
var content = document.getElementById('content');
is(aElement.form, form, "The form IDL attribute should be the parent form");
content.removeChild(form);
content.appendChild(aElement);
is(aElement.form, null, "The form IDL attribute should be null");
// Cleaning-up.
content.appendChild(form);
form.appendChild(aElement);
is('form' in aElement, false, "<meter> shouldn't have a form attribute");
}
function checkAttribute(aElement, aAttribute, aNewValue, aExpectedValueForIDL)
@ -330,7 +320,7 @@ function checkNotResetableAndFormSubmission(aElement)
* element value should not appear.
*/
is(frames['submit_frame'].location.href,
'http://mochi.test:8888/tests/content/html/content/test/foo?a=tulip',
'http://mochi.test:8888/tests/content/html/content/test/forms/foo?a=tulip',
"The meter element value should not be submitted");
checkNotResetable();
@ -367,6 +357,7 @@ ok(m instanceof HTMLMeterElement,
is(m.constructor, HTMLMeterElement,
"The meter element constructor should be HTMLMeterElement");
// There is no such attribute.
checkFormIDLAttribute(m);
checkValueAttribute();

View File

@ -56,7 +56,7 @@ interface nsIDOMHTMLMeterElement : nsIDOMHTMLElement
attribute double low;
attribute double high;
attribute double optimum;
readonly attribute nsIDOMHTMLFormElement form;
/**
* The labels attribute will be done with bug 556743.
*/