зеркало из https://github.com/mozilla/gecko-dev.git
Bug 64931 and bug 70551: new macros to implement attributes
with a default value for HTML elements. Converted table* elements to use these new macros. More to follow. r=sicking@bigfoot.com sr=jst@netscape.com
This commit is contained in:
Родитель
8b4e97ced4
Коммит
f014542c7c
|
@ -677,14 +677,26 @@ protected:
|
|||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given string
|
||||
* valued content property. The method uses the generic SetAttr and
|
||||
* GetAttribute methods.
|
||||
* valued content property. The method uses the generic GetAttr and
|
||||
* SetAttr methods.
|
||||
*/
|
||||
#define NS_IMPL_STRING_ATTR(_class, _method, _atom) \
|
||||
NS_IMPL_STRING_ATTR_DEFAULT_VALUE(_class, _method, _atom, "")
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given string
|
||||
* valued content property with a default value.
|
||||
* The method uses the generic GetAttr and SetAttr methods.
|
||||
*/
|
||||
#define NS_IMPL_STRING_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(nsAWritableString& aValue) \
|
||||
{ \
|
||||
GetAttr(kNameSpaceID_HTML, nsHTMLAtoms::_atom, aValue); \
|
||||
nsresult rv = GetAttr(kNameSpaceID_HTML, \
|
||||
nsHTMLAtoms::_atom, aValue); \
|
||||
if (rv == NS_CONTENT_ATTR_NOT_THERE) { \
|
||||
aValue.Assign(NS_LITERAL_STRING(_default)); \
|
||||
} \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
|
@ -696,16 +708,15 @@ protected:
|
|||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given boolean
|
||||
* valued content property. The method uses the generic SetAttr and
|
||||
* GetAttribute methods.
|
||||
* valued content property. The method uses the generic GetAttr and
|
||||
* SetAttr methods.
|
||||
*/
|
||||
#define NS_IMPL_BOOL_ATTR(_class, _method, _atom) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(PRBool* aValue) \
|
||||
{ \
|
||||
nsHTMLValue val; \
|
||||
nsresult rv; \
|
||||
rv = GetHTMLAttribute(nsHTMLAtoms::_atom, val); \
|
||||
nsresult rv = GetHTMLAttribute(nsHTMLAtoms::_atom, val); \
|
||||
*aValue = NS_CONTENT_ATTR_NOT_THERE != rv; \
|
||||
return NS_OK; \
|
||||
} \
|
||||
|
@ -724,15 +735,23 @@ protected:
|
|||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given integer
|
||||
* valued content property. The method uses the generic SetAttr and
|
||||
* GetAttribute methods.
|
||||
* valued content property. The method uses the generic GetAttr and
|
||||
* SetAttr methods.
|
||||
*/
|
||||
#define NS_IMPL_INT_ATTR(_class, _method, _atom) \
|
||||
NS_IMPL_INT_ATTR_DEFAULT_VALUE(_class, _method, _atom, -1)
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given integer
|
||||
* valued content property with a default value.
|
||||
* The method uses the generic GetAttr and SetAttr methods.
|
||||
*/
|
||||
#define NS_IMPL_INT_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(PRInt32* aValue) \
|
||||
{ \
|
||||
nsHTMLValue value; \
|
||||
*aValue = -1; \
|
||||
*aValue = _default; \
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == \
|
||||
GetHTMLAttribute(nsHTMLAtoms::_atom, value)) { \
|
||||
if (value.GetUnit() == eHTMLUnit_Integer) { \
|
||||
|
@ -751,14 +770,22 @@ protected:
|
|||
/**
|
||||
* A macro to implement the getter and the setter for a given pixel
|
||||
* valued content property. The method uses the generic GetAttr and
|
||||
* SetAttr methods
|
||||
* SetAttr methods.
|
||||
*/
|
||||
#define NS_IMPL_PIXEL_ATTR(_class, _method, _atom) \
|
||||
NS_IMPL_PIXEL_ATTR_DEFAULT_VALUE(_class, _method, _atom, -1)
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and the setter for a given pixel
|
||||
* valued content property with a default value.
|
||||
* The method uses the generic GetAttr and SetAttr methods.
|
||||
*/
|
||||
#define NS_IMPL_PIXEL_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(PRInt32* aValue) \
|
||||
{ \
|
||||
nsHTMLValue value; \
|
||||
*aValue = -1; \
|
||||
*aValue = _default; \
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == \
|
||||
GetHTMLAttribute(nsHTMLAtoms::_atom, value)) { \
|
||||
if (value.GetUnit() == eHTMLUnit_Pixel) { \
|
||||
|
|
|
@ -281,18 +281,18 @@ nsHTMLTableCellElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
|
|||
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Abbr, abbr)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Align, align)
|
||||
NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableCellElement, Align, align, "left")
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Axis, axis)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, BgColor, bgcolor)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Ch, _char)
|
||||
NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableCellElement, Ch, _char, ".")
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, ChOff, charoff)
|
||||
NS_IMPL_INT_ATTR(nsHTMLTableCellElement, ColSpan, colspan)
|
||||
NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLTableCellElement, ColSpan, colspan, 1)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Headers, headers)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Height, height)
|
||||
NS_IMPL_BOOL_ATTR(nsHTMLTableCellElement, NoWrap, nowrap)
|
||||
NS_IMPL_INT_ATTR(nsHTMLTableCellElement, RowSpan, rowspan)
|
||||
NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLTableCellElement, RowSpan, rowspan, 1)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Scope, scope)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, VAlign, valign)
|
||||
NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableCellElement, VAlign, valign, "middle")
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Width, width)
|
||||
|
||||
|
||||
|
|
|
@ -166,11 +166,11 @@ nsHTMLTableColElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
|||
}
|
||||
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableColElement, Align, align)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableColElement, Ch, _char)
|
||||
NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableColElement, Align, align, "left")
|
||||
NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableColElement, Ch, _char, ".")
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableColElement, ChOff, charoff)
|
||||
NS_IMPL_INT_ATTR(nsHTMLTableColElement, Span, span)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableColElement, VAlign, valign)
|
||||
NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLTableColElement, Span, span, 1)
|
||||
NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableColElement, VAlign, valign, "middle")
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableColElement, Width, width)
|
||||
|
||||
|
||||
|
|
|
@ -521,11 +521,11 @@ nsHTMLTableRowElement::DeleteCell(PRInt32 aValue)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, Align, align)
|
||||
NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableRowElement, Align, align, "left")
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, BgColor, bgcolor)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, Ch, _char)
|
||||
NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableRowElement, Ch, _char, ".")
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, ChOff, charoff)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, VAlign, valign)
|
||||
NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableRowElement, VAlign, valign, "middle")
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -172,9 +172,9 @@ nsHTMLTableSectionElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
|||
}
|
||||
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableSectionElement, Align, align)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableSectionElement, VAlign, valign)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableSectionElement, Ch, _char)
|
||||
NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableSectionElement, Align, align, "left")
|
||||
NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableSectionElement, VAlign, valign, "middle")
|
||||
NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableSectionElement, Ch, _char, ".")
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTableSectionElement, ChOff, charoff)
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче