зеркало из https://github.com/mozilla/gecko-dev.git
Use editor transactions when modifying elements in editor DOM, b=102607, r=brade, sr=kin
This commit is contained in:
Родитель
c0f03fcc80
Коммит
d196bc33f5
|
@ -139,13 +139,14 @@ function UpdateCSSAttributes()
|
||||||
else
|
else
|
||||||
styleString += name + ": " + value + "; ";
|
styleString += name + ": " + value + "; ";
|
||||||
}
|
}
|
||||||
if (styleString.length > 0)
|
if (styleString)
|
||||||
{
|
{
|
||||||
gElement.removeAttribute("style");
|
// Use editor transactions if modifying the element directly in the document
|
||||||
gElement.setAttribute("style",styleString); // NOTE BUG 18894!!!
|
doRemoveAttribute("style");
|
||||||
|
doSetAttribute("style", styleString); // NOTE BUG 18894!!!
|
||||||
}
|
}
|
||||||
else if (gElement.getAttribute("style"))
|
else if (gElement.getAttribute("style"))
|
||||||
gElement.removeAttribute("style");
|
doRemoveAttribute("style");
|
||||||
}
|
}
|
||||||
|
|
||||||
function RemoveCSSAttribute()
|
function RemoveCSSAttribute()
|
||||||
|
|
|
@ -161,6 +161,7 @@ function ClearHTMLInputWidgets()
|
||||||
|
|
||||||
function onSelectHTMLTreeItem()
|
function onSelectHTMLTreeItem()
|
||||||
{
|
{
|
||||||
|
dump(" ** Calling onSelectHTMLTreeItem gDoOnSelectTree="+gDoOnSelectTree+"\n");
|
||||||
if (!gDoOnSelectTree)
|
if (!gDoOnSelectTree)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -187,6 +188,7 @@ function onSelectHTMLTreeItem()
|
||||||
|
|
||||||
function onInputHTMLAttributeName()
|
function onInputHTMLAttributeName()
|
||||||
{
|
{
|
||||||
|
dump(" ** Calling onInputHTMLAttributeName\n");
|
||||||
var attName = TrimString(dialog.AddHTMLAttributeNameInput.value).toLowerCase();
|
var attName = TrimString(dialog.AddHTMLAttributeNameInput.value).toLowerCase();
|
||||||
|
|
||||||
// Clear value widget, but prevent triggering update in tree
|
// Clear value widget, but prevent triggering update in tree
|
||||||
|
@ -289,6 +291,9 @@ function onInputHTMLAttributeValue()
|
||||||
// (Do not use "LimitStringLength()" and "forceInteger()"
|
// (Do not use "LimitStringLength()" and "forceInteger()"
|
||||||
// to avoid multiple reseting of input's value and flickering)
|
// to avoid multiple reseting of input's value and flickering)
|
||||||
var selectedItem = dialog.AddHTMLAttributeNameInput.selectedItem;
|
var selectedItem = dialog.AddHTMLAttributeNameInput.selectedItem;
|
||||||
|
|
||||||
|
dump("*** onInputHTMLAttributeValue: selectedItem="+selectedItem+"\n");
|
||||||
|
|
||||||
if (selectedItem)
|
if (selectedItem)
|
||||||
{
|
{
|
||||||
if ( selectedItem.getAttribute("forceOneChar") == "true" &&
|
if ( selectedItem.getAttribute("forceOneChar") == "true" &&
|
||||||
|
@ -356,14 +361,14 @@ function UpdateHTMLAttributes()
|
||||||
// exists for attributes that don't require a value
|
// exists for attributes that don't require a value
|
||||||
// This gets the attribute NODE from the attributes NamedNodeMap
|
// This gets the attribute NODE from the attributes NamedNodeMap
|
||||||
if (gElement.attributes.getNamedItem(name))
|
if (gElement.attributes.getNamedItem(name))
|
||||||
gElement.removeAttribute(name);
|
doRemoveAttribute(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set added or changed attributes
|
// Set added or changed attributes
|
||||||
for( i = 0; i < HTMLAList.childNodes.length; i++)
|
for( i = 0; i < HTMLAList.childNodes.length; i++)
|
||||||
{
|
{
|
||||||
var item = HTMLAList.childNodes[i];
|
var item = HTMLAList.childNodes[i];
|
||||||
gElement.setAttribute( GetTreeItemAttributeStr(item), GetTreeItemValueStr(item) );
|
doSetAttribute( GetTreeItemAttributeStr(item), GetTreeItemValueStr(item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,7 @@ function UpdateJSEAttributes()
|
||||||
{
|
{
|
||||||
name = JSERAttrs[i];
|
name = JSERAttrs[i];
|
||||||
if (gElement.getAttribute(name))
|
if (gElement.getAttribute(name))
|
||||||
gElement.removeAttribute(name);
|
doRemoveAttribute(gElement, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add events
|
// Add events
|
||||||
|
@ -193,7 +193,7 @@ function UpdateJSEAttributes()
|
||||||
var item = JSEAList.childNodes[i];
|
var item = JSEAList.childNodes[i];
|
||||||
|
|
||||||
// set the event handler
|
// set the event handler
|
||||||
gElement.setAttribute( GetTreeItemAttributeStr(item), GetTreeItemValueStr(item) );
|
doSetAttribute( GetTreeItemAttributeStr(item), GetTreeItemValueStr(item) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,10 +123,16 @@ function Startup()
|
||||||
**/
|
**/
|
||||||
function onOK()
|
function onOK()
|
||||||
{
|
{
|
||||||
// Update our gElement attributes
|
editorShell.BeginBatchChanges();
|
||||||
UpdateHTMLAttributes();
|
try {
|
||||||
UpdateCSSAttributes();
|
// Update our gElement attributes
|
||||||
UpdateJSEAttributes();
|
UpdateHTMLAttributes();
|
||||||
|
UpdateCSSAttributes();
|
||||||
|
UpdateJSEAttributes();
|
||||||
|
} catch(ex) {
|
||||||
|
dump(ex);
|
||||||
|
}
|
||||||
|
editorShell.EndBatchChanges();
|
||||||
|
|
||||||
window.opener.AdvancedEditOK = true;
|
window.opener.AdvancedEditOK = true;
|
||||||
SaveWindowLocation();
|
SaveWindowLocation();
|
||||||
|
@ -134,6 +140,25 @@ function onOK()
|
||||||
return true; // do close the window
|
return true; // do close the window
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helpers for removing and setting attributes
|
||||||
|
// Use editor transactions if modifying the element already in the document
|
||||||
|
// (Temporary element from a property dialog won't have a parent node)
|
||||||
|
function doRemoveAttribute(attrib)
|
||||||
|
{
|
||||||
|
if (gElement.parentNode)
|
||||||
|
editorShell.RemoveAttribute(gElement, attrib);
|
||||||
|
else
|
||||||
|
gElement.removeAttribute(attrib);
|
||||||
|
}
|
||||||
|
|
||||||
|
function doSetAttribute(attrib, value)
|
||||||
|
{
|
||||||
|
if (gElement.parentNode)
|
||||||
|
editorShell.SetAttribute(gElement, attrib, value);
|
||||||
|
else
|
||||||
|
gElement.setAttribute(attrib, value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function : bool CheckAttributeNameSimilarity ( string attName, array attArray );
|
* function : bool CheckAttributeNameSimilarity ( string attName, array attArray );
|
||||||
* parameters : attribute to look for, array of current attributes
|
* parameters : attribute to look for, array of current attributes
|
||||||
|
|
Загрузка…
Ссылка в новой задаче