зеркало из https://github.com/mozilla/pjs.git
Fixed up handling of form element attributes slightly to match navigators handling of ALIGN; this is compatible with nav/IE and with the HTML4 DTD (because ALIGN is deprecated)
This commit is contained in:
Родитель
f151795800
Коммит
b7f723b107
|
@ -1246,15 +1246,16 @@ nsGenericHTMLElement::ColorToString(const nsHTMLValue& aValue,
|
|||
static nsGenericHTMLElement::EnumTable kAlignTable[] = {
|
||||
{ "left", NS_STYLE_TEXT_ALIGN_LEFT },
|
||||
{ "right", NS_STYLE_TEXT_ALIGN_RIGHT },
|
||||
|
||||
{ "texttop", NS_STYLE_VERTICAL_ALIGN_TEXT_TOP },
|
||||
{ "baseline", NS_STYLE_VERTICAL_ALIGN_BASELINE },
|
||||
{ "center", NS_STYLE_TEXT_ALIGN_CENTER },
|
||||
{ "center", NS_STYLE_VERTICAL_ALIGN_MIDDLE },
|
||||
{ "bottom", NS_STYLE_VERTICAL_ALIGN_BOTTOM },
|
||||
{ "top", NS_STYLE_VERTICAL_ALIGN_TOP },
|
||||
{ "middle", NS_STYLE_VERTICAL_ALIGN_MIDDLE },
|
||||
{ "absbottom", NS_STYLE_VERTICAL_ALIGN_BOTTOM },
|
||||
{ "abscenter", NS_STYLE_VERTICAL_ALIGN_MIDDLE },
|
||||
{ "absmiddle", NS_STYLE_VERTICAL_ALIGN_MIDDLE },
|
||||
{ "abscenter", NS_STYLE_VERTICAL_ALIGN_MIDDLE },/* XXX not the same as ebina */
|
||||
{ "absmiddle", NS_STYLE_VERTICAL_ALIGN_MIDDLE },/* XXX ditto */
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
|
@ -1267,15 +1268,6 @@ static nsGenericHTMLElement::EnumTable kDivAlignTable[] = {
|
|||
{ 0 }
|
||||
};
|
||||
|
||||
static nsGenericHTMLElement::EnumTable kFormAlignTable[] = {
|
||||
{ "left", NS_STYLE_TEXT_ALIGN_LEFT },
|
||||
{ "right", NS_STYLE_TEXT_ALIGN_RIGHT },
|
||||
{ "bottom", NS_STYLE_VERTICAL_ALIGN_BOTTOM },
|
||||
{ "top", NS_STYLE_VERTICAL_ALIGN_TOP },
|
||||
{ "middle", NS_STYLE_VERTICAL_ALIGN_MIDDLE },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static nsGenericHTMLElement::EnumTable kFrameborderQuirksTable[] = {
|
||||
{ "yes", NS_STYLE_FRAME_YES },
|
||||
{ "no", NS_STYLE_FRAME_NO },
|
||||
|
@ -1354,20 +1346,6 @@ nsGenericHTMLElement::AlignValueToString(const nsHTMLValue& aValue,
|
|||
return EnumValueToString(aValue, kAlignTable, aResult);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGenericHTMLElement::ParseFormAlignValue(const nsString& aString,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
return ParseEnumValue(aString, kFormAlignTable, aResult);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGenericHTMLElement::FormAlignValueToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult)
|
||||
{
|
||||
return EnumValueToString(aValue, kFormAlignTable, aResult);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGenericHTMLElement::TableHAlignValueToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult)
|
||||
|
|
|
@ -145,9 +145,6 @@ public:
|
|||
|
||||
static PRBool ParseAlignValue(const nsString& aString, nsHTMLValue& aResult);
|
||||
|
||||
static PRBool ParseFormAlignValue(const nsString& aString,
|
||||
nsHTMLValue& aResult);
|
||||
|
||||
static PRBool ParseDivAlignValue(const nsString& aString,
|
||||
nsHTMLValue& aResult);
|
||||
|
||||
|
@ -166,8 +163,6 @@ public:
|
|||
static PRBool AlignValueToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
static PRBool FormAlignValueToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
static PRBool DivAlignValueToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
|
|
|
@ -130,6 +130,12 @@ protected:
|
|||
nsIWidget* mWidget; // XXX this needs to go away when FindFrameWithContent is efficient
|
||||
nsIForm* mForm;
|
||||
PRInt32 mType;
|
||||
|
||||
PRBool IsImage() const {
|
||||
nsAutoString tmp;
|
||||
mInner.GetAttribute(nsHTMLAtoms::type, tmp);
|
||||
return tmp.EqualsIgnoreCase("image");
|
||||
}
|
||||
};
|
||||
|
||||
// construction, destruction
|
||||
|
@ -455,8 +461,8 @@ static nsGenericHTMLElement::EnumTable kInputTypeTable[] = {
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
const nsString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::type) {
|
||||
nsGenericHTMLElement::EnumTable *table = kInputTypeTable;
|
||||
|
@ -503,8 +509,9 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute,
|
|||
nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer);
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (nsGenericHTMLElement::ParseFormAlignValue(aValue, aResult)) {
|
||||
else if (IsImage()) {
|
||||
if (nsGenericHTMLElement::ParseImageAttribute(aAttribute,
|
||||
aValue, aResult)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
|
@ -517,8 +524,8 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::AttributeToString(nsIAtom* aAttribute,
|
||||
nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::type) {
|
||||
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
|
||||
|
@ -526,11 +533,10 @@ nsHTMLInputElement::AttributeToString(nsIAtom* aAttribute,
|
|||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
|
||||
nsGenericHTMLElement::FormAlignValueToString(aValue, aResult);
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
else if (IsImage() &&
|
||||
nsGenericHTMLElement::ImageAttributeToString(aAttribute,
|
||||
aValue, aResult)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
|
|
@ -355,11 +355,6 @@ nsHTMLSelectElement::StringToAttribute(nsIAtom* aAttribute,
|
|||
nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer);
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (nsGenericHTMLElement::ParseFormAlignValue(aValue, aResult)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
return NS_CONTENT_ATTR_NOT_THERE;
|
||||
}
|
||||
|
||||
|
@ -368,12 +363,6 @@ nsHTMLSelectElement::AttributeToString(nsIAtom* aAttribute,
|
|||
nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
|
||||
nsGenericHTMLElement::FormAlignValueToString(aValue, aResult);
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
|
|
|
@ -319,12 +319,7 @@ nsHTMLTextAreaElement::StringToAttribute(nsIAtom* aAttribute,
|
|||
const nsString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (nsGenericHTMLElement::ParseFormAlignValue(aValue, aResult)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::disabled) {
|
||||
if (aAttribute == nsHTMLAtoms::disabled) {
|
||||
aResult.SetEmptyValue();
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
|
@ -352,12 +347,6 @@ nsHTMLTextAreaElement::AttributeToString(nsIAtom* aAttribute,
|
|||
nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
|
||||
nsGenericHTMLElement::FormAlignValueToString(aValue, aResult);
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
|
|
|
@ -1246,15 +1246,16 @@ nsGenericHTMLElement::ColorToString(const nsHTMLValue& aValue,
|
|||
static nsGenericHTMLElement::EnumTable kAlignTable[] = {
|
||||
{ "left", NS_STYLE_TEXT_ALIGN_LEFT },
|
||||
{ "right", NS_STYLE_TEXT_ALIGN_RIGHT },
|
||||
|
||||
{ "texttop", NS_STYLE_VERTICAL_ALIGN_TEXT_TOP },
|
||||
{ "baseline", NS_STYLE_VERTICAL_ALIGN_BASELINE },
|
||||
{ "center", NS_STYLE_TEXT_ALIGN_CENTER },
|
||||
{ "center", NS_STYLE_VERTICAL_ALIGN_MIDDLE },
|
||||
{ "bottom", NS_STYLE_VERTICAL_ALIGN_BOTTOM },
|
||||
{ "top", NS_STYLE_VERTICAL_ALIGN_TOP },
|
||||
{ "middle", NS_STYLE_VERTICAL_ALIGN_MIDDLE },
|
||||
{ "absbottom", NS_STYLE_VERTICAL_ALIGN_BOTTOM },
|
||||
{ "abscenter", NS_STYLE_VERTICAL_ALIGN_MIDDLE },
|
||||
{ "absmiddle", NS_STYLE_VERTICAL_ALIGN_MIDDLE },
|
||||
{ "abscenter", NS_STYLE_VERTICAL_ALIGN_MIDDLE },/* XXX not the same as ebina */
|
||||
{ "absmiddle", NS_STYLE_VERTICAL_ALIGN_MIDDLE },/* XXX ditto */
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
|
@ -1267,15 +1268,6 @@ static nsGenericHTMLElement::EnumTable kDivAlignTable[] = {
|
|||
{ 0 }
|
||||
};
|
||||
|
||||
static nsGenericHTMLElement::EnumTable kFormAlignTable[] = {
|
||||
{ "left", NS_STYLE_TEXT_ALIGN_LEFT },
|
||||
{ "right", NS_STYLE_TEXT_ALIGN_RIGHT },
|
||||
{ "bottom", NS_STYLE_VERTICAL_ALIGN_BOTTOM },
|
||||
{ "top", NS_STYLE_VERTICAL_ALIGN_TOP },
|
||||
{ "middle", NS_STYLE_VERTICAL_ALIGN_MIDDLE },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static nsGenericHTMLElement::EnumTable kFrameborderQuirksTable[] = {
|
||||
{ "yes", NS_STYLE_FRAME_YES },
|
||||
{ "no", NS_STYLE_FRAME_NO },
|
||||
|
@ -1354,20 +1346,6 @@ nsGenericHTMLElement::AlignValueToString(const nsHTMLValue& aValue,
|
|||
return EnumValueToString(aValue, kAlignTable, aResult);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGenericHTMLElement::ParseFormAlignValue(const nsString& aString,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
return ParseEnumValue(aString, kFormAlignTable, aResult);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGenericHTMLElement::FormAlignValueToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult)
|
||||
{
|
||||
return EnumValueToString(aValue, kFormAlignTable, aResult);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGenericHTMLElement::TableHAlignValueToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult)
|
||||
|
|
|
@ -145,9 +145,6 @@ public:
|
|||
|
||||
static PRBool ParseAlignValue(const nsString& aString, nsHTMLValue& aResult);
|
||||
|
||||
static PRBool ParseFormAlignValue(const nsString& aString,
|
||||
nsHTMLValue& aResult);
|
||||
|
||||
static PRBool ParseDivAlignValue(const nsString& aString,
|
||||
nsHTMLValue& aResult);
|
||||
|
||||
|
@ -166,8 +163,6 @@ public:
|
|||
static PRBool AlignValueToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
static PRBool FormAlignValueToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
static PRBool DivAlignValueToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
|
|
|
@ -130,6 +130,12 @@ protected:
|
|||
nsIWidget* mWidget; // XXX this needs to go away when FindFrameWithContent is efficient
|
||||
nsIForm* mForm;
|
||||
PRInt32 mType;
|
||||
|
||||
PRBool IsImage() const {
|
||||
nsAutoString tmp;
|
||||
mInner.GetAttribute(nsHTMLAtoms::type, tmp);
|
||||
return tmp.EqualsIgnoreCase("image");
|
||||
}
|
||||
};
|
||||
|
||||
// construction, destruction
|
||||
|
@ -455,8 +461,8 @@ static nsGenericHTMLElement::EnumTable kInputTypeTable[] = {
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
const nsString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::type) {
|
||||
nsGenericHTMLElement::EnumTable *table = kInputTypeTable;
|
||||
|
@ -503,8 +509,9 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute,
|
|||
nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer);
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (nsGenericHTMLElement::ParseFormAlignValue(aValue, aResult)) {
|
||||
else if (IsImage()) {
|
||||
if (nsGenericHTMLElement::ParseImageAttribute(aAttribute,
|
||||
aValue, aResult)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
|
@ -517,8 +524,8 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::AttributeToString(nsIAtom* aAttribute,
|
||||
nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::type) {
|
||||
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
|
||||
|
@ -526,11 +533,10 @@ nsHTMLInputElement::AttributeToString(nsIAtom* aAttribute,
|
|||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
|
||||
nsGenericHTMLElement::FormAlignValueToString(aValue, aResult);
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
else if (IsImage() &&
|
||||
nsGenericHTMLElement::ImageAttributeToString(aAttribute,
|
||||
aValue, aResult)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
|
|
@ -355,11 +355,6 @@ nsHTMLSelectElement::StringToAttribute(nsIAtom* aAttribute,
|
|||
nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer);
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (nsGenericHTMLElement::ParseFormAlignValue(aValue, aResult)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
return NS_CONTENT_ATTR_NOT_THERE;
|
||||
}
|
||||
|
||||
|
@ -368,12 +363,6 @@ nsHTMLSelectElement::AttributeToString(nsIAtom* aAttribute,
|
|||
nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
|
||||
nsGenericHTMLElement::FormAlignValueToString(aValue, aResult);
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
|
|
|
@ -319,12 +319,7 @@ nsHTMLTextAreaElement::StringToAttribute(nsIAtom* aAttribute,
|
|||
const nsString& aValue,
|
||||
nsHTMLValue& aResult)
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (nsGenericHTMLElement::ParseFormAlignValue(aValue, aResult)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::disabled) {
|
||||
if (aAttribute == nsHTMLAtoms::disabled) {
|
||||
aResult.SetEmptyValue();
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
|
@ -352,12 +347,6 @@ nsHTMLTextAreaElement::AttributeToString(nsIAtom* aAttribute,
|
|||
nsHTMLValue& aValue,
|
||||
nsString& aResult) const
|
||||
{
|
||||
if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
|
||||
nsGenericHTMLElement::FormAlignValueToString(aValue, aResult);
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче