From 942157b59c283ae99ffad06c70e66b6c27f7c148 Mon Sep 17 00:00:00 2001 From: "glazman%netscape.com" Date: Fri, 11 May 2001 13:49:34 +0000 Subject: [PATCH] Advanced Dialog for CSS properties should rely on ElementCSSInlineStyle; b=80000, r=cmanske, sr=kin git-svn-id: svn://10.0.0.236/trunk@94648 18797224-902f-48f8-a5cc-f745e15eee43 --- .../ui/dialogs/content/EdAECSSAttributes.js | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/mozilla/editor/ui/dialogs/content/EdAECSSAttributes.js b/mozilla/editor/ui/dialogs/content/EdAECSSAttributes.js index 98ac86fd489..3f5795388c0 100644 --- a/mozilla/editor/ui/dialogs/content/EdAECSSAttributes.js +++ b/mozilla/editor/ui/dialogs/content/EdAECSSAttributes.js @@ -2,33 +2,35 @@ // build attribute list in tree form from element attributes function BuildCSSAttributeTable() { - dump("populating CSS Attributes tree\n"); - dump("elStyle: " + element.getAttribute("style") + "\n"); - var style = element.getAttribute("style"); - if(style == undefined || style == "") + // dump("populating CSS Attributes tree\n"); + // dump(" style=\"" + element.getAttribute("style") + "\"\n"); + + // get the CSS declaration from DOM 2 ElementCSSInlineStyle + var style = element.style; + + if(style == undefined) { - dump("no style attributes to add\n"); + dump("Inline styles undefined\n"); return; } - if(style.indexOf(";") == -1) { - if(style.indexOf(":") != -1) { - name = TrimString(style.split(":")[0]); - value = TrimString(style.split(":")[1]); - if ( !AddTreeItem( name, value, "CSSAList", CSSAttrs ) ) - dump("Failed to add CSS attribute: " + i + "\n"); - } else - return; - } - nvpairs = style.split(";"); - for(i = 0; i < nvpairs.length; i++) + + var l = style.length; + if(l == undefined || l == 0) { - if(nvpairs[i].indexOf(":") != -1) { - name = TrimString(nvpairs[i].split(":")[0]); - value = TrimString(nvpairs[i].split(":")[1]); - if( !AddTreeItem( name, value, "CSSAList", CSSAttrs ) ) - dump("Failed to add CSS attribute: " + i + "\n"); + if (l == undefined) { + dump("Failed to query the number of inline style declarations\n"); } + return; } + + for (i = 0; i < l; i++) { + name = style.item(i); + value = style.getPropertyValue(name); + // dump(" adding property '" + name + "' with value '" + value +"'\n"); + if ( !AddTreeItem( name, value, "CSSAList", CSSAttrs ) ) + dump("Failed to add CSS attribute: " + i + "\n"); + } + return; } // add an attribute to the tree widget