зеркало из https://github.com/mozilla/gecko-dev.git
Checking in fix for bug 349465 again since it didn't affect Ts/Tp.
This commit is contained in:
Родитель
fc88af4d70
Коммит
1c221a6a94
|
@ -726,6 +726,10 @@ public:
|
|||
return slots ? slots->mAttributeMap.get() : nsnull;
|
||||
}
|
||||
|
||||
virtual void RecompileScriptEventListeners()
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Set attribute and (if needed) notify documentobservers and fire off
|
||||
|
|
|
@ -366,6 +366,10 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep,
|
|||
nodeInfo = newNodeInfo;
|
||||
}
|
||||
|
||||
nsGenericElement *elem = aNode->IsNodeOfType(nsINode::eELEMENT) ?
|
||||
NS_STATIC_CAST(nsGenericElement*, aNode) :
|
||||
nsnull;
|
||||
|
||||
nsCOMPtr<nsINode> clone;
|
||||
if (aClone) {
|
||||
rv = aNode->Clone(nodeInfo, getter_AddRefs(clone));
|
||||
|
@ -390,6 +394,10 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep,
|
|||
else if (nodeInfoManager) {
|
||||
aNode->mNodeInfo.swap(newNodeInfo);
|
||||
|
||||
if (elem) {
|
||||
elem->RecompileScriptEventListeners();
|
||||
}
|
||||
|
||||
if (aCx) {
|
||||
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
||||
if (xpc) {
|
||||
|
@ -405,9 +413,8 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep,
|
|||
}
|
||||
}
|
||||
|
||||
if (aNode->IsNodeOfType(nsINode::eELEMENT)) {
|
||||
if (elem) {
|
||||
// aNode's attributes.
|
||||
nsGenericElement *elem = NS_STATIC_CAST(nsGenericElement*, aNode);
|
||||
const nsDOMAttributeMap *map = elem->GetAttributeMap();
|
||||
if (map) {
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
|
|
|
@ -4118,3 +4118,26 @@ nsGenericHTMLElement::SyncEditorsOnSubtree(nsIContent* content)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsGenericHTMLElement::RecompileScriptEventListeners()
|
||||
{
|
||||
PRInt32 i, count = mAttrsAndChildren.AttrCount();
|
||||
for (i = 0; i < count; ++i) {
|
||||
const nsAttrName *name = mAttrsAndChildren.AttrNameAt(i);
|
||||
|
||||
// Eventlistenener-attributes are always in the null namespace
|
||||
if (!name->IsAtom()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsIAtom *attr = name->Atom();
|
||||
if (!IsEventName(attr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsAutoString value;
|
||||
GetAttr(kNameSpaceID_None, attr, value);
|
||||
AddScriptEventListener(attr, value, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -537,6 +537,8 @@ public:
|
|||
*/
|
||||
already_AddRefed<nsIDOMHTMLFormElement> FindForm(nsIForm* aCurrentForm = nsnull);
|
||||
|
||||
virtual void RecompileScriptEventListeners();
|
||||
|
||||
/**
|
||||
* See if the document being tested has nav-quirks mode enabled.
|
||||
* @param doc the document
|
||||
|
|
|
@ -1004,3 +1004,26 @@ nsSVGElement::ReportAttributeParseFailure(nsIDocument* aDocument,
|
|||
"AttributeParseWarning",
|
||||
strings, NS_ARRAY_LENGTH(strings));
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGElement::RecompileScriptEventListeners()
|
||||
{
|
||||
PRInt32 i, count = mAttrsAndChildren.AttrCount();
|
||||
for (i = 0; i < count; ++i) {
|
||||
const nsAttrName *name = mAttrsAndChildren.AttrNameAt(i);
|
||||
|
||||
// Eventlistenener-attributes are always in the null namespace
|
||||
if (!name->IsAtom()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsIAtom *attr = name->Atom();
|
||||
if (!IsEventName(attr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsAutoString value;
|
||||
GetAttr(kNameSpaceID_None, attr, value);
|
||||
AddScriptEventListener(GetEventNameForAttr(attr), value, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,6 +127,8 @@ public:
|
|||
void GetAnimatedLengthValues(float *aFirst, ...);
|
||||
void GetAnimatedNumberValues(float *aFirst, ...);
|
||||
|
||||
virtual void RecompileScriptEventListeners();
|
||||
|
||||
protected:
|
||||
virtual nsresult BeforeSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
|
||||
const nsAString* aValue, PRBool aNotify);
|
||||
|
|
|
@ -755,7 +755,6 @@ nsXULElement::CompileEventHandler(nsIScriptContext* aContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsXULElement::AddListenerFor(const nsAttrName& aName,
|
||||
PRBool aCompileEventHandlers)
|
||||
|
@ -909,37 +908,7 @@ nsXULElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// we need to (re-)initialize several attributes that are dependant on
|
||||
// the document. Do that now.
|
||||
PRInt32 count = mAttrsAndChildren.AttrCount();
|
||||
PRBool haveLocalAttributes = (count > 0);
|
||||
PRInt32 i;
|
||||
for (i = 0; i < count; i++) {
|
||||
AddListenerFor(*mAttrsAndChildren.AttrNameAt(i),
|
||||
aCompileEventHandlers);
|
||||
}
|
||||
|
||||
if (mPrototype) {
|
||||
// If we have a prototype, the node we are binding to should
|
||||
// have the same script-type - otherwise we will compile the
|
||||
// event handlers incorrectly.
|
||||
NS_ASSERTION(mPrototype->mScriptTypeID == GetScriptTypeID(),
|
||||
"Prototype and node confused about default language?");
|
||||
PRInt32 count = mPrototype->mNumAttributes;
|
||||
for (i = 0; i < count; i++) {
|
||||
nsXULPrototypeAttribute *protoattr =
|
||||
&mPrototype->mAttributes[i];
|
||||
|
||||
// Don't clobber a locally modified attribute.
|
||||
if (haveLocalAttributes &&
|
||||
mAttrsAndChildren.GetAttr(protoattr->mName.LocalName(),
|
||||
protoattr->mName.NamespaceID())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AddListenerFor(protoattr->mName, aCompileEventHandlers);
|
||||
}
|
||||
}
|
||||
RecompileScriptEventListeners();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2534,6 +2503,63 @@ nsXULElement::BoolAttrIsTrue(nsIAtom* aName)
|
|||
attr->GetAtomValue() == nsXULAtoms::_true;
|
||||
}
|
||||
|
||||
void
|
||||
nsXULElement::RecompileScriptEventListeners()
|
||||
{
|
||||
PRInt32 i, count = mAttrsAndChildren.AttrCount();
|
||||
PRBool haveLocalAttributes = (count > 0);
|
||||
for (i = 0; i < count; ++i) {
|
||||
const nsAttrName *name = mAttrsAndChildren.AttrNameAt(i);
|
||||
|
||||
// Eventlistenener-attributes are always in the null namespace
|
||||
if (!name->IsAtom()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsIAtom *attr = name->Atom();
|
||||
if (!IsEventHandler(attr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsAutoString value;
|
||||
GetAttr(kNameSpaceID_None, attr, value);
|
||||
AddScriptEventListener(attr, value, PR_TRUE);
|
||||
}
|
||||
|
||||
if (mPrototype) {
|
||||
// If we have a prototype, the node we are binding to should
|
||||
// have the same script-type - otherwise we will compile the
|
||||
// event handlers incorrectly.
|
||||
NS_ASSERTION(mPrototype->mScriptTypeID == GetScriptTypeID(),
|
||||
"Prototype and node confused about default language?");
|
||||
|
||||
count = mPrototype->mNumAttributes;
|
||||
for (i = 0; i < count; ++i) {
|
||||
const nsAttrName &name = mPrototype->mAttributes[i].mName;
|
||||
|
||||
// Eventlistenener-attributes are always in the null namespace
|
||||
if (!name.IsAtom()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsIAtom *attr = name.Atom();
|
||||
|
||||
// Don't clobber a locally modified attribute.
|
||||
if (haveLocalAttributes && mAttrsAndChildren.GetAttr(attr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!IsEventHandler(attr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsAutoString value;
|
||||
GetAttr(kNameSpaceID_None, attr, value);
|
||||
AddScriptEventListener(attr, value, PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// nsXULPrototypeAttribute
|
||||
|
|
|
@ -573,6 +573,8 @@ public:
|
|||
|
||||
nsresult GetStyle(nsIDOMCSSStyleDeclaration** aStyle);
|
||||
|
||||
virtual void RecompileScriptEventListeners();
|
||||
|
||||
protected:
|
||||
nsXULElement(nsINodeInfo* aNodeInfo);
|
||||
virtual ~nsXULElement(void);
|
||||
|
|
Загрузка…
Ссылка в новой задаче