Bug 564591: Speed up BindToTree/UnbindFromTree by only doing accesskey related work if the accesskey attribute is set. r=smaug

This commit is contained in:
Jonas Sicking 2010-06-03 18:08:57 -07:00
Родитель 1821e61c09
Коммит 76f022838b
6 изменённых файлов: 52 добавлений и 22 удалений

Просмотреть файл

@ -170,9 +170,12 @@ enum {
// Set if the node is an element.
NODE_IS_ELEMENT = 0x00200000U,
// Set if the node has the accesskey attribute set.
NODE_HAS_ACCESSKEY = 0x00400000U,
// Four bits for the script-type ID
NODE_SCRIPT_TYPE_OFFSET = 22,
NODE_SCRIPT_TYPE_OFFSET = 23,
NODE_SCRIPT_TYPE_SIZE = 4,

Просмотреть файл

@ -501,10 +501,25 @@ protected:
/**
* Register or unregister an access key to this element based on the
* accesskey attribute.
* @param aDoReg true to register, false to unregister
*/
void RegAccessKey()
{
if (HasFlag(NODE_HAS_ACCESSKEY)) {
RegUnRegAccessKey(PR_TRUE);
}
}
void UnregAccessKey()
{
if (HasFlag(NODE_HAS_ACCESSKEY)) {
RegUnRegAccessKey(PR_FALSE);
}
}
private:
void RegUnRegAccessKey(PRBool aDoReg);
protected:
/**
* Determine whether an attribute is an event (onclick, etc.)
* @param aName the attribute

Просмотреть файл

@ -208,7 +208,7 @@ nsHTMLAnchorElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument) {
RegUnRegAccessKey(PR_TRUE);
RegAccessKey();
}
// Prefetch links
@ -226,7 +226,7 @@ nsHTMLAnchorElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
Link::ResetLinkState(false);
if (IsInDoc()) {
RegUnRegAccessKey(PR_FALSE);
UnregAccessKey();
}
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
@ -434,7 +434,7 @@ nsHTMLAnchorElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
PRBool aNotify)
{
if (aName == nsGkAtoms::accesskey && kNameSpaceID_None == aNameSpaceID) {
RegUnRegAccessKey(PR_FALSE);
UnregAccessKey();
}
bool reset = false;
@ -460,7 +460,8 @@ nsHTMLAnchorElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
if (aName == nsGkAtoms::accesskey && kNameSpaceID_None == aNameSpaceID &&
!aValue.IsEmpty()) {
RegUnRegAccessKey(PR_TRUE);
SetFlags(NODE_HAS_ACCESSKEY);
RegAccessKey();
}
return rv;
@ -472,7 +473,9 @@ nsHTMLAnchorElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
{
if (aAttribute == nsGkAtoms::accesskey &&
kNameSpaceID_None == aNameSpaceID) {
RegUnRegAccessKey(PR_FALSE);
// Have to unregister before clearing flag. See UnregAccessKey
UnregAccessKey();
UnsetFlags(NODE_HAS_ACCESSKEY);
}
nsresult rv = nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute,

Просмотреть файл

@ -214,7 +214,7 @@ nsHTMLAreaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument) {
RegUnRegAccessKey(PR_TRUE);
RegAccessKey();
}
return rv;
@ -228,7 +228,7 @@ nsHTMLAreaElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
Link::ResetLinkState(false);
if (IsInDoc()) {
RegUnRegAccessKey(PR_FALSE);
UnregAccessKey();
}
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
@ -240,7 +240,7 @@ nsHTMLAreaElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
PRBool aNotify)
{
if (aName == nsGkAtoms::accesskey && aNameSpaceID == kNameSpaceID_None) {
RegUnRegAccessKey(PR_FALSE);
UnregAccessKey();
}
nsresult rv =
@ -257,7 +257,8 @@ nsHTMLAreaElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
if (aName == nsGkAtoms::accesskey && aNameSpaceID == kNameSpaceID_None &&
!aValue.IsEmpty()) {
RegUnRegAccessKey(PR_TRUE);
SetFlags(NODE_HAS_ACCESSKEY);
RegAccessKey();
}
return rv;
@ -269,7 +270,9 @@ nsHTMLAreaElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
{
if (aAttribute == nsGkAtoms::accesskey &&
aNameSpaceID == kNameSpaceID_None) {
RegUnRegAccessKey(PR_FALSE);
// Have to unregister before clearing flag. See UnregAccessKey
UnregAccessKey();
UnsetFlags(NODE_HAS_ACCESSKEY);
}
nsresult rv = nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute,

Просмотреть файл

@ -208,7 +208,7 @@ nsHTMLLabelElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument) {
RegUnRegAccessKey(PR_TRUE);
RegAccessKey();
}
return rv;
@ -218,7 +218,7 @@ void
nsHTMLLabelElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
{
if (IsInDoc()) {
RegUnRegAccessKey(PR_FALSE);
UnregAccessKey();
}
nsGenericHTMLFormElement::UnbindFromTree(aDeep, aNullParent);
@ -362,7 +362,7 @@ nsHTMLLabelElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom* aPref
const nsAString& aValue, PRBool aNotify)
{
if (aName == nsGkAtoms::accesskey && kNameSpaceID_None == aNameSpaceID) {
RegUnRegAccessKey(PR_FALSE);
UnregAccessKey();
}
nsresult rv =
@ -371,7 +371,8 @@ nsHTMLLabelElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom* aPref
if (aName == nsGkAtoms::accesskey && kNameSpaceID_None == aNameSpaceID &&
!aValue.IsEmpty()) {
RegUnRegAccessKey(PR_TRUE);
SetFlags(NODE_HAS_ACCESSKEY);
RegAccessKey();
}
return rv;
@ -383,7 +384,9 @@ nsHTMLLabelElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
{
if (aAttribute == nsGkAtoms::accesskey &&
kNameSpaceID_None == aNameSpaceID) {
RegUnRegAccessKey(PR_FALSE);
// Have to unregister before clearing flag. See UnregAccessKey
UnregAccessKey();
UnsetFlags(NODE_HAS_ACCESSKEY);
}
return nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify);

Просмотреть файл

@ -219,14 +219,15 @@ nsHTMLLegendElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
PRBool accesskey = (aAttribute == nsGkAtoms::accesskey &&
aNameSpaceID == kNameSpaceID_None);
if (accesskey) {
RegUnRegAccessKey(PR_FALSE);
UnregAccessKey();
}
nsresult rv = nsGenericHTMLFormElement::SetAttr(aNameSpaceID, aAttribute,
aPrefix, aValue, aNotify);
if (accesskey && !aValue.IsEmpty()) {
RegUnRegAccessKey(PR_TRUE);
SetFlags(NODE_HAS_ACCESSKEY);
RegAccessKey();
}
return rv;
@ -238,7 +239,9 @@ nsHTMLLegendElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
{
if (aAttribute == nsGkAtoms::accesskey &&
aNameSpaceID == kNameSpaceID_None) {
RegUnRegAccessKey(PR_FALSE);
// Have to unregister before clearing flag. See UnregAccessKey
UnregAccessKey();
UnsetFlags(NODE_HAS_ACCESSKEY);
}
return nsGenericHTMLFormElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify);
@ -261,7 +264,7 @@ nsHTMLLegendElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument) {
RegUnRegAccessKey(PR_TRUE);
RegAccessKey();
}
return rv;
@ -271,7 +274,7 @@ void
nsHTMLLegendElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
{
if (IsInDoc()) {
RegUnRegAccessKey(PR_FALSE);
UnregAccessKey();
}
nsGenericHTMLFormElement::UnbindFromTree(aDeep, aNullParent);