diff --git a/editor/libeditor/base/nsEditPropertyAtomList.h b/editor/libeditor/base/nsEditPropertyAtomList.h new file mode 100644 index 000000000000..83e36accdb87 --- /dev/null +++ b/editor/libeditor/base/nsEditPropertyAtomList.h @@ -0,0 +1,167 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is editor atom table. + * + * The Initial Developer of the Original Code is + * Netscape communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2003 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Alec Flett + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/****** + + This file contains the list of all editor nsIAtoms and their values + + It is designed to be used as inline input to nsEditProperty.cpp *only* + through the magic of C preprocessing. + + All entries must be enclosed in the macro EDITOR_ATOM which will have cruel + and unusual things done to it + + It is recommended (but not strictly necessary) to keep all entries + in alphabetical order + + The first argument to EDITOR_ATOM is the C++ identifier of the atom + The second argument is the string value of the atom + + ******/ + + +EDITOR_ATOM(b, "b") +EDITOR_ATOM(big, "big") +EDITOR_ATOM(i, "i") +EDITOR_ATOM(small, "small") +EDITOR_ATOM(strike, "strike") +EDITOR_ATOM(sub, "sub") +EDITOR_ATOM(sup, "sup") +EDITOR_ATOM(tt, "tt") +EDITOR_ATOM(u, "u") +EDITOR_ATOM(em, "em") +EDITOR_ATOM(strong, "strong") +EDITOR_ATOM(dfn, "dfn") +EDITOR_ATOM(code, "code") +EDITOR_ATOM(samp, "samp") +EDITOR_ATOM(kbd, "kbd") +EDITOR_ATOM(var, "var") +EDITOR_ATOM(cite, "cite") +EDITOR_ATOM(abbr, "abbr") +EDITOR_ATOM(acronym, "acronym") +EDITOR_ATOM(font, "font") +EDITOR_ATOM(a, "a") +EDITOR_ATOM(href, "href") // Use to differentiate between "a" for link, "a" for named anchor +EDITOR_ATOM(name, "name") +EDITOR_ATOM(img, "img") +EDITOR_ATOM(object, "object") +EDITOR_ATOM(br, "br") +EDITOR_ATOM(script, "script") +EDITOR_ATOM(map, "map") +EDITOR_ATOM(q, "q") +EDITOR_ATOM(span, "span") +EDITOR_ATOM(bdo, "bdo") +EDITOR_ATOM(input, "input") +EDITOR_ATOM(select, "select") +EDITOR_ATOM(textarea, "textarea") +EDITOR_ATOM(label, "label") +EDITOR_ATOM(button, "button") + // block tags +EDITOR_ATOM(p, "p") +EDITOR_ATOM(div, "div") +EDITOR_ATOM(blockquote, "blockquote") +EDITOR_ATOM(h1, "h1") +EDITOR_ATOM(h2, "h2") +EDITOR_ATOM(h3, "h3") +EDITOR_ATOM(h4, "h4") +EDITOR_ATOM(h5, "h5") +EDITOR_ATOM(h6, "h6") +EDITOR_ATOM(ul, "ul") +EDITOR_ATOM(ol, "ol") +EDITOR_ATOM(dl, "dl") +EDITOR_ATOM(pre, "pre") +EDITOR_ATOM(noscript, "noscript") +EDITOR_ATOM(form, "form") +EDITOR_ATOM(hr, "hr") +EDITOR_ATOM(table, "table") +EDITOR_ATOM(fieldset, "fieldset") +EDITOR_ATOM(address, "address") + // Unclear from + // DTD, block? +EDITOR_ATOM(body, "body") +EDITOR_ATOM(head, "head") +EDITOR_ATOM(tr, "tr") +EDITOR_ATOM(td, "td") +EDITOR_ATOM(th, "th") +EDITOR_ATOM(caption, "caption") +EDITOR_ATOM(col, "col") +EDITOR_ATOM(colgroup, "colgroup") +EDITOR_ATOM(tbody, "tbody") +EDITOR_ATOM(thead, "thead") +EDITOR_ATOM(tfoot, "tfoot") +EDITOR_ATOM(li, "li") +EDITOR_ATOM(dt, "dt") +EDITOR_ATOM(dd, "dd") +EDITOR_ATOM(legend, "legend") + // inline properties +EDITOR_ATOM(color, "color") +EDITOR_ATOM(face, "face") +EDITOR_ATOM(size, "size") + +EDITOR_ATOM(cssBackgroundColor, "background-color") +EDITOR_ATOM(cssBackgroundImage, "background-image") +EDITOR_ATOM(cssBorder, "border") +EDITOR_ATOM(cssCaptionSide, "caption-side") +EDITOR_ATOM(cssColor, "color") +EDITOR_ATOM(cssFloat, "float") +EDITOR_ATOM(cssFontFamily, "font-family") +EDITOR_ATOM(cssFontSize, "font-size") +EDITOR_ATOM(cssFontStyle, "font-style") +EDITOR_ATOM(cssFontWeight, "font-weight") +EDITOR_ATOM(cssHeight, "height") +EDITOR_ATOM(cssListStyleType, "list-style-type") +EDITOR_ATOM(cssLeft, "left") +EDITOR_ATOM(cssMarginRight, "margin-right") +EDITOR_ATOM(cssMarginLeft, "margin-left") +EDITOR_ATOM(cssTextAlign, "text-align") +EDITOR_ATOM(cssTextDecoration, "text-decoration") +EDITOR_ATOM(cssTop, "top") +EDITOR_ATOM(cssVerticalAlign, "vertical-align") +EDITOR_ATOM(cssWhitespace, "white-space") +EDITOR_ATOM(cssWidth, "width") + +EDITOR_ATOM(cssMozUserSelect, "-moz-user-select") + +EDITOR_ATOM(cssPxUnit, "px") +EDITOR_ATOM(cssEmUnit, "em") +EDITOR_ATOM(cssCmUnit, "cm") +EDITOR_ATOM(cssPercentUnit, "%") +EDITOR_ATOM(cssInUnit, "in") +EDITOR_ATOM(cssMmUnit, "mm") +EDITOR_ATOM(cssPtUnit, "pt") +EDITOR_ATOM(cssPcUnit, "pc") +EDITOR_ATOM(cssExUnit, "ex") diff --git a/editor/libeditor/base/nsIEditProperty.h b/editor/libeditor/base/nsIEditProperty.h index 976917cbaba4..ef1b563af672 100644 --- a/editor/libeditor/base/nsIEditProperty.h +++ b/editor/libeditor/base/nsIEditProperty.h @@ -61,126 +61,13 @@ public: public: -/* we're still trying to decide how edit atoms will work. Until then, use these */ -// XXX: fix ASAP! - // inline tags - static nsIAtom *b; - static nsIAtom *big; - static nsIAtom *i; - static nsIAtom *small; - static nsIAtom *strike; - static nsIAtom *sub; - static nsIAtom *sup; - static nsIAtom *tt; - static nsIAtom *u; - static nsIAtom *em; - static nsIAtom *strong; - static nsIAtom *dfn; - static nsIAtom *code; - static nsIAtom *samp; - static nsIAtom *kbd; - static nsIAtom *var; - static nsIAtom *cite; - static nsIAtom *abbr; - static nsIAtom *acronym; - static nsIAtom *font; - static nsIAtom *a; - static nsIAtom *href; - static nsIAtom *name; - static nsIAtom *img; - static nsIAtom *object; - static nsIAtom *br; - static nsIAtom *script; - static nsIAtom *map; - static nsIAtom *q; - static nsIAtom *span; - static nsIAtom *bdo; - static nsIAtom *input; - static nsIAtom *select; - static nsIAtom *textarea; - static nsIAtom *label; - static nsIAtom *button; - // Block tags - static nsIAtom *p; - static nsIAtom *div; - static nsIAtom *blockquote; - static nsIAtom *h1; - static nsIAtom *h2; - static nsIAtom *h3; - static nsIAtom *h4; - static nsIAtom *h5; - static nsIAtom *h6; - static nsIAtom *ul; - static nsIAtom *ol; - static nsIAtom *dl; - static nsIAtom *pre; - static nsIAtom *noscript; - static nsIAtom *form; - static nsIAtom *hr; - static nsIAtom *table; - static nsIAtom *fieldset; - static nsIAtom *address; - // Assumed to be block: - static nsIAtom *body; - static nsIAtom *head; - static nsIAtom *tr; - static nsIAtom *td; - static nsIAtom *th; - static nsIAtom *caption; - static nsIAtom *col; - static nsIAtom *colgroup; - static nsIAtom *tbody; - static nsIAtom *thead; - static nsIAtom *tfoot; - static nsIAtom *li; - static nsIAtom *dt; - static nsIAtom *dd; - static nsIAtom *legend; - - /** properties **/ - static nsIAtom *color; - static nsIAtom *face; - static nsIAtom *size; +#define EDITOR_ATOM(name_, value_) static nsIAtom* name_; +#include "nsEditPropertyAtomList.h" +#undef EDITOR_ATOM /** special strings */ static nsString *allProperties; // this magic string represents the union of all inline style tags - // XXX: end temp code - - /** CSS strings */ - static nsIAtom *cssBackgroundColor; - static nsIAtom *cssBackgroundImage; - static nsIAtom *cssBorder; - static nsIAtom *cssCaptionSide; - static nsIAtom *cssColor; - static nsIAtom *cssFloat; - static nsIAtom *cssFontFamily; - static nsIAtom *cssFontSize; - static nsIAtom *cssFontStyle; - static nsIAtom *cssFontWeight; - static nsIAtom *cssHeight; - static nsIAtom *cssLeft; - static nsIAtom *cssListStyleType; - static nsIAtom *cssMarginLeft; - static nsIAtom *cssMarginRight; - static nsIAtom *cssTextAlign; - static nsIAtom *cssTextDecoration; - static nsIAtom *cssTop; - static nsIAtom *cssVerticalAlign; - static nsIAtom *cssWhitespace; - static nsIAtom *cssWidth; - - static nsIAtom *cssMozUserSelect; - - static nsIAtom *cssPxUnit; - static nsIAtom *cssEmUnit; - static nsIAtom *cssCmUnit; - static nsIAtom *cssPercentUnit; - static nsIAtom *cssInUnit; - static nsIAtom *cssMmUnit; - static nsIAtom *cssPtUnit; - static nsIAtom *cssPcUnit; - static nsIAtom *cssExUnit; }; extern nsresult NS_NewEditProperty(nsIEditProperty **aResult); diff --git a/editor/libeditor/html/nsEditProperty.cpp b/editor/libeditor/html/nsEditProperty.cpp index 86e04930e23c..bd48dd22719c 100644 --- a/editor/libeditor/html/nsEditProperty.cpp +++ b/editor/libeditor/html/nsEditProperty.cpp @@ -40,6 +40,7 @@ #include "nsEditProperty.h" #include "nsString.h" +#include "nsStaticAtom.h" // singleton instance static nsEditProperty *gInstance; @@ -49,115 +50,9 @@ NS_IMPL_ADDREF(nsEditProperty) NS_IMPL_RELEASE(nsEditProperty) -// XXX: remove when html atoms are exported from layout -// inline tags -nsIAtom * nsIEditProperty::b; -nsIAtom * nsIEditProperty::big; -nsIAtom * nsIEditProperty::i; -nsIAtom * nsIEditProperty::small; -nsIAtom * nsIEditProperty::strike; -nsIAtom * nsIEditProperty::sub; -nsIAtom * nsIEditProperty::sup; -nsIAtom * nsIEditProperty::tt; -nsIAtom * nsIEditProperty::u; -nsIAtom * nsIEditProperty::em; -nsIAtom * nsIEditProperty::strong; -nsIAtom * nsIEditProperty::dfn; -nsIAtom * nsIEditProperty::code; -nsIAtom * nsIEditProperty::samp; -nsIAtom * nsIEditProperty::kbd; -nsIAtom * nsIEditProperty::var; -nsIAtom * nsIEditProperty::cite; -nsIAtom * nsIEditProperty::abbr; -nsIAtom * nsIEditProperty::acronym; -nsIAtom * nsIEditProperty::font; -nsIAtom * nsIEditProperty::a; -nsIAtom * nsIEditProperty::href; -nsIAtom * nsIEditProperty::name; -nsIAtom * nsIEditProperty::img; -nsIAtom * nsIEditProperty::object; -nsIAtom * nsIEditProperty::br; -nsIAtom * nsIEditProperty::script; -nsIAtom * nsIEditProperty::map; -nsIAtom * nsIEditProperty::q; -nsIAtom * nsIEditProperty::span; -nsIAtom * nsIEditProperty::bdo; -nsIAtom * nsIEditProperty::input; -nsIAtom * nsIEditProperty::select; -nsIAtom * nsIEditProperty::textarea; -nsIAtom * nsIEditProperty::label; -nsIAtom * nsIEditProperty::button; -nsIAtom * nsIEditProperty::p; -nsIAtom * nsIEditProperty::div; -nsIAtom * nsIEditProperty::blockquote; -nsIAtom * nsIEditProperty::h1; -nsIAtom * nsIEditProperty::h2; -nsIAtom * nsIEditProperty::h3; -nsIAtom * nsIEditProperty::h4; -nsIAtom * nsIEditProperty::h5; -nsIAtom * nsIEditProperty::h6; -nsIAtom * nsIEditProperty::ul; -nsIAtom * nsIEditProperty::ol; -nsIAtom * nsIEditProperty::dl; -nsIAtom * nsIEditProperty::pre; -nsIAtom * nsIEditProperty::noscript; -nsIAtom * nsIEditProperty::form; -nsIAtom * nsIEditProperty::hr; -nsIAtom * nsIEditProperty::table; -nsIAtom * nsIEditProperty::fieldset; -nsIAtom * nsIEditProperty::address; -nsIAtom * nsIEditProperty::body; -nsIAtom * nsIEditProperty::head; -nsIAtom * nsIEditProperty::tr; -nsIAtom * nsIEditProperty::td; -nsIAtom * nsIEditProperty::th; -nsIAtom * nsIEditProperty::caption; -nsIAtom * nsIEditProperty::col; -nsIAtom * nsIEditProperty::colgroup; -nsIAtom * nsIEditProperty::tbody; -nsIAtom * nsIEditProperty::thead; -nsIAtom * nsIEditProperty::tfoot; -nsIAtom * nsIEditProperty::li; -nsIAtom * nsIEditProperty::dt; -nsIAtom * nsIEditProperty::dd; -nsIAtom * nsIEditProperty::legend; -nsIAtom * nsIEditProperty::color; -nsIAtom * nsIEditProperty::face; -nsIAtom * nsIEditProperty::size; - -nsIAtom * nsIEditProperty::cssBackgroundColor; -nsIAtom * nsIEditProperty::cssBackgroundImage; -nsIAtom * nsIEditProperty::cssBorder; -nsIAtom * nsIEditProperty::cssCaptionSide; -nsIAtom * nsIEditProperty::cssColor; -nsIAtom * nsIEditProperty::cssFloat; -nsIAtom * nsIEditProperty::cssFontFamily; -nsIAtom * nsIEditProperty::cssFontSize; -nsIAtom * nsIEditProperty::cssFontStyle; -nsIAtom * nsIEditProperty::cssFontWeight; -nsIAtom * nsIEditProperty::cssHeight; -nsIAtom * nsIEditProperty::cssLeft; -nsIAtom * nsIEditProperty::cssListStyleType; -nsIAtom * nsIEditProperty::cssMarginLeft; -nsIAtom * nsIEditProperty::cssMarginRight; -nsIAtom * nsIEditProperty::cssTextAlign; -nsIAtom * nsIEditProperty::cssTextDecoration; -nsIAtom * nsIEditProperty::cssTop; -nsIAtom * nsIEditProperty::cssVerticalAlign; -nsIAtom * nsIEditProperty::cssWhitespace; -nsIAtom * nsIEditProperty::cssWidth; - -nsIAtom * nsIEditProperty::cssMozUserSelect; - -nsIAtom * nsIEditProperty::cssPxUnit; -nsIAtom * nsIEditProperty::cssEmUnit; -nsIAtom * nsIEditProperty::cssCmUnit; -nsIAtom * nsIEditProperty::cssPercentUnit; -nsIAtom * nsIEditProperty::cssInUnit; -nsIAtom * nsIEditProperty::cssMmUnit; -nsIAtom * nsIEditProperty::cssPtUnit; -nsIAtom * nsIEditProperty::cssPcUnit; -nsIAtom * nsIEditProperty::cssExUnit; +#define EDITOR_ATOM(name_, value_) nsIAtom* nsIEditProperty::name_ = 0; +#include "nsEditPropertyAtomList.h" +#undef EDITOR_ATOM // special nsString * nsIEditProperty::allProperties; @@ -186,119 +81,14 @@ But what about BODY, TR, TD, TH, CAPTION, COL, COLGROUP, THEAD, TFOOT, LI, DT, D nsEditProperty::nsEditProperty() { // inline tags - nsIEditProperty::b = NS_NewAtom("b"); - nsIEditProperty::big = NS_NewAtom("big"); - nsIEditProperty::i = NS_NewAtom("i"); - nsIEditProperty::small = NS_NewAtom("small"); - nsIEditProperty::strike = NS_NewAtom("strike"); - nsIEditProperty::sub = NS_NewAtom("sub"); - nsIEditProperty::sup = NS_NewAtom("sup"); - nsIEditProperty::tt = NS_NewAtom("tt"); - nsIEditProperty::u = NS_NewAtom("u"); - nsIEditProperty::em = NS_NewAtom("em"); - nsIEditProperty::strong = NS_NewAtom("strong"); - nsIEditProperty::dfn = NS_NewAtom("dfn"); - nsIEditProperty::code = NS_NewAtom("code"); - nsIEditProperty::samp = NS_NewAtom("samp"); - nsIEditProperty::kbd = NS_NewAtom("kbd"); - nsIEditProperty::var = NS_NewAtom("var"); - nsIEditProperty::cite = NS_NewAtom("cite"); - nsIEditProperty::abbr = NS_NewAtom("abbr"); - nsIEditProperty::acronym = NS_NewAtom("acronym"); - nsIEditProperty::font = NS_NewAtom("font"); - nsIEditProperty::a = NS_NewAtom("a"); - nsIEditProperty::href = NS_NewAtom("href"); // Use to differentiate between "a" for link, "a" for named anchor - nsIEditProperty::name = NS_NewAtom("name"); - nsIEditProperty::img = NS_NewAtom("img"); - nsIEditProperty::object = NS_NewAtom("object"); - nsIEditProperty::br = NS_NewAtom("br"); - nsIEditProperty::script = NS_NewAtom("script"); - nsIEditProperty::map = NS_NewAtom("map"); - nsIEditProperty::q = NS_NewAtom("q"); - nsIEditProperty::span = NS_NewAtom("span"); - nsIEditProperty::bdo = NS_NewAtom("bdo"); - nsIEditProperty::input = NS_NewAtom("input"); - nsIEditProperty::select = NS_NewAtom("select"); - nsIEditProperty::textarea = NS_NewAtom("textarea"); - nsIEditProperty::label = NS_NewAtom("label"); - nsIEditProperty::button = NS_NewAtom("button"); - // block tags - nsIEditProperty::p = NS_NewAtom("p"); - nsIEditProperty::div = NS_NewAtom("div"); - nsIEditProperty::blockquote = NS_NewAtom("blockquote"); - nsIEditProperty::h1 = NS_NewAtom("h1"); - nsIEditProperty::h2 = NS_NewAtom("h2"); - nsIEditProperty::h3 = NS_NewAtom("h3"); - nsIEditProperty::h4 = NS_NewAtom("h4"); - nsIEditProperty::h5 = NS_NewAtom("h5"); - nsIEditProperty::h6 = NS_NewAtom("h6"); - nsIEditProperty::ul = NS_NewAtom("ul"); - nsIEditProperty::ol = NS_NewAtom("ol"); - nsIEditProperty::dl = NS_NewAtom("dl"); - nsIEditProperty::pre = NS_NewAtom("pre"); - nsIEditProperty::noscript = NS_NewAtom("noscript"); - nsIEditProperty::form = NS_NewAtom("form"); - nsIEditProperty::hr = NS_NewAtom("hr"); - nsIEditProperty::table = NS_NewAtom("table"); - nsIEditProperty::fieldset = NS_NewAtom("fieldset"); - nsIEditProperty::address = NS_NewAtom("address"); - // Unclear from - // DTD, block? - nsIEditProperty::body = NS_NewAtom("body"); - nsIEditProperty::head = NS_NewAtom("head"); - nsIEditProperty::tr = NS_NewAtom("tr"); - nsIEditProperty::td = NS_NewAtom("td"); - nsIEditProperty::th = NS_NewAtom("th"); - nsIEditProperty::caption = NS_NewAtom("caption"); - nsIEditProperty::col = NS_NewAtom("col"); - nsIEditProperty::colgroup = NS_NewAtom("colgroup"); - nsIEditProperty::tbody = NS_NewAtom("tbody"); - nsIEditProperty::thead = NS_NewAtom("thead"); - nsIEditProperty::tfoot = NS_NewAtom("tfoot"); - nsIEditProperty::li = NS_NewAtom("li"); - nsIEditProperty::dt = NS_NewAtom("dt"); - nsIEditProperty::dd = NS_NewAtom("dd"); - nsIEditProperty::legend = NS_NewAtom("legend"); - // inline - // properties - nsIEditProperty::color = NS_NewAtom("color"); - nsIEditProperty::face = NS_NewAtom("face"); - nsIEditProperty::size = NS_NewAtom("size"); + static const nsStaticAtom property_atoms[] = { +#define EDITOR_ATOM(name_, value_) { value_, &name_ }, +#include "nsEditPropertyAtomList.h" +#undef EDITOR_ATOM + }; + + NS_RegisterStaticAtoms(property_atoms, NS_ARRAY_LENGTH(property_atoms)); - nsIEditProperty::cssBackgroundColor = NS_NewAtom("background-color"); - nsIEditProperty::cssBackgroundImage = NS_NewAtom("background-image"); - nsIEditProperty::cssBorder = NS_NewAtom("border"); - nsIEditProperty::cssCaptionSide = NS_NewAtom("caption-side"); - nsIEditProperty::cssColor = NS_NewAtom("color"); - nsIEditProperty::cssFloat = NS_NewAtom("float"); - nsIEditProperty::cssFontFamily = NS_NewAtom("font-family"); - nsIEditProperty::cssFontSize = NS_NewAtom("font-size"); - nsIEditProperty::cssFontStyle = NS_NewAtom("font-style"); - nsIEditProperty::cssFontWeight = NS_NewAtom("font-weight"); - nsIEditProperty::cssHeight = NS_NewAtom("height"); - nsIEditProperty::cssListStyleType = NS_NewAtom("list-style-type"); - nsIEditProperty::cssLeft = NS_NewAtom("left"); - nsIEditProperty::cssMarginRight = NS_NewAtom("margin-right"); - nsIEditProperty::cssMarginLeft = NS_NewAtom("margin-left"); - nsIEditProperty::cssTextAlign = NS_NewAtom("text-align"); - nsIEditProperty::cssTextDecoration = NS_NewAtom("text-decoration"); - nsIEditProperty::cssTop = NS_NewAtom("top"); - nsIEditProperty::cssVerticalAlign = NS_NewAtom("vertical-align"); - nsIEditProperty::cssWhitespace = NS_NewAtom("white-space"); - nsIEditProperty::cssWidth = NS_NewAtom("width"); - - nsIEditProperty::cssMozUserSelect = NS_NewAtom("-moz-user-select"); - - nsIEditProperty::cssPxUnit = NS_NewAtom("px"); - nsIEditProperty::cssEmUnit = NS_NewAtom("em"); - nsIEditProperty::cssCmUnit = NS_NewAtom("cm"); - nsIEditProperty::cssPercentUnit = NS_NewAtom("%"); - nsIEditProperty::cssInUnit = NS_NewAtom("in"); - nsIEditProperty::cssMmUnit = NS_NewAtom("mm"); - nsIEditProperty::cssPtUnit = NS_NewAtom("pt"); - nsIEditProperty::cssPcUnit = NS_NewAtom("pc"); - nsIEditProperty::cssExUnit = NS_NewAtom("ex"); - // special if ( (nsIEditProperty::allProperties = new nsString) != nsnull ) nsIEditProperty::allProperties->Assign(NS_LITERAL_STRING("moz_allproperties")); @@ -306,114 +96,6 @@ nsEditProperty::nsEditProperty() nsEditProperty::~nsEditProperty() { - NS_IF_RELEASE(nsIEditProperty::b); - NS_IF_RELEASE(nsIEditProperty::big); - NS_IF_RELEASE(nsIEditProperty::i); - NS_IF_RELEASE(nsIEditProperty::small); - NS_IF_RELEASE(nsIEditProperty::strike); - NS_IF_RELEASE(nsIEditProperty::sub); - NS_IF_RELEASE(nsIEditProperty::sup); - NS_IF_RELEASE(nsIEditProperty::tt); - NS_IF_RELEASE(nsIEditProperty::u); - NS_IF_RELEASE(nsIEditProperty::em); - NS_IF_RELEASE(nsIEditProperty::strong); - NS_IF_RELEASE(nsIEditProperty::dfn); - NS_IF_RELEASE(nsIEditProperty::code); - NS_IF_RELEASE(nsIEditProperty::samp); - NS_IF_RELEASE(nsIEditProperty::kbd); - NS_IF_RELEASE(nsIEditProperty::var); - NS_IF_RELEASE(nsIEditProperty::cite); - NS_IF_RELEASE(nsIEditProperty::abbr); - NS_IF_RELEASE(nsIEditProperty::acronym); - NS_IF_RELEASE(nsIEditProperty::font); - NS_IF_RELEASE(nsIEditProperty::a); - NS_IF_RELEASE(nsIEditProperty::href); - NS_IF_RELEASE(nsIEditProperty::name); - NS_IF_RELEASE(nsIEditProperty::img); - NS_IF_RELEASE(nsIEditProperty::object); - NS_IF_RELEASE(nsIEditProperty::br); - NS_IF_RELEASE(nsIEditProperty::script); - NS_IF_RELEASE(nsIEditProperty::map); - NS_IF_RELEASE(nsIEditProperty::q); - NS_IF_RELEASE(nsIEditProperty::span); - NS_IF_RELEASE(nsIEditProperty::bdo); - NS_IF_RELEASE(nsIEditProperty::input); - NS_IF_RELEASE(nsIEditProperty::select); - NS_IF_RELEASE(nsIEditProperty::textarea); - NS_IF_RELEASE(nsIEditProperty::label); - NS_IF_RELEASE(nsIEditProperty::button); - NS_IF_RELEASE(nsIEditProperty::p); - NS_IF_RELEASE(nsIEditProperty::div); - NS_IF_RELEASE(nsIEditProperty::blockquote); - NS_IF_RELEASE(nsIEditProperty::h1); - NS_IF_RELEASE(nsIEditProperty::h2); - NS_IF_RELEASE(nsIEditProperty::h3); - NS_IF_RELEASE(nsIEditProperty::h4); - NS_IF_RELEASE(nsIEditProperty::h5); - NS_IF_RELEASE(nsIEditProperty::h6); - NS_IF_RELEASE(nsIEditProperty::ul); - NS_IF_RELEASE(nsIEditProperty::ol); - NS_IF_RELEASE(nsIEditProperty::dl); - NS_IF_RELEASE(nsIEditProperty::pre); - NS_IF_RELEASE(nsIEditProperty::noscript); - NS_IF_RELEASE(nsIEditProperty::form); - NS_IF_RELEASE(nsIEditProperty::hr); - NS_IF_RELEASE(nsIEditProperty::table); - NS_IF_RELEASE(nsIEditProperty::fieldset); - NS_IF_RELEASE(nsIEditProperty::address); - NS_IF_RELEASE(nsIEditProperty::body); - NS_IF_RELEASE(nsIEditProperty::head); - NS_IF_RELEASE(nsIEditProperty::tr); - NS_IF_RELEASE(nsIEditProperty::td); - NS_IF_RELEASE(nsIEditProperty::th); - NS_IF_RELEASE(nsIEditProperty::caption); - NS_IF_RELEASE(nsIEditProperty::col); - NS_IF_RELEASE(nsIEditProperty::colgroup); - NS_IF_RELEASE(nsIEditProperty::tbody); - NS_IF_RELEASE(nsIEditProperty::thead); - NS_IF_RELEASE(nsIEditProperty::tfoot); - NS_IF_RELEASE(nsIEditProperty::li); - NS_IF_RELEASE(nsIEditProperty::dt); - NS_IF_RELEASE(nsIEditProperty::dd); - NS_IF_RELEASE(nsIEditProperty::legend); - NS_IF_RELEASE(nsIEditProperty::color); - NS_IF_RELEASE(nsIEditProperty::face); - NS_IF_RELEASE(nsIEditProperty::size); - - NS_IF_RELEASE(nsIEditProperty::cssBackgroundColor); - NS_IF_RELEASE(nsIEditProperty::cssBackgroundImage); - NS_IF_RELEASE(nsIEditProperty::cssBorder); - NS_IF_RELEASE(nsIEditProperty::cssCaptionSide); - NS_IF_RELEASE(nsIEditProperty::cssColor); - NS_IF_RELEASE(nsIEditProperty::cssFloat); - NS_IF_RELEASE(nsIEditProperty::cssFontFamily); - NS_IF_RELEASE(nsIEditProperty::cssFontSize); - NS_IF_RELEASE(nsIEditProperty::cssFontStyle); - NS_IF_RELEASE(nsIEditProperty::cssFontWeight); - NS_IF_RELEASE(nsIEditProperty::cssHeight); - NS_IF_RELEASE(nsIEditProperty::cssListStyleType); - NS_IF_RELEASE(nsIEditProperty::cssLeft); - NS_IF_RELEASE(nsIEditProperty::cssMarginRight); - NS_IF_RELEASE(nsIEditProperty::cssMarginLeft); - NS_IF_RELEASE(nsIEditProperty::cssTextAlign); - NS_IF_RELEASE(nsIEditProperty::cssTextDecoration); - NS_IF_RELEASE(nsIEditProperty::cssTop); - NS_IF_RELEASE(nsIEditProperty::cssVerticalAlign); - NS_IF_RELEASE(nsIEditProperty::cssWhitespace); - NS_IF_RELEASE(nsIEditProperty::cssWidth); - - NS_IF_RELEASE(nsIEditProperty::cssMozUserSelect); - - NS_IF_RELEASE(nsIEditProperty::cssPxUnit); - NS_IF_RELEASE(nsIEditProperty::cssEmUnit); - NS_IF_RELEASE(nsIEditProperty::cssCmUnit); - NS_IF_RELEASE(nsIEditProperty::cssPercentUnit); - NS_IF_RELEASE(nsIEditProperty::cssInUnit); - NS_IF_RELEASE(nsIEditProperty::cssMmUnit); - NS_IF_RELEASE(nsIEditProperty::cssPtUnit); - NS_IF_RELEASE(nsIEditProperty::cssPcUnit); - NS_IF_RELEASE(nsIEditProperty::cssExUnit); - // special if (nsIEditProperty::allProperties) { delete (nsIEditProperty::allProperties); diff --git a/editor/txtsvc/src/nsTSAtomList.h b/editor/txtsvc/src/nsTSAtomList.h new file mode 100644 index 000000000000..3d89c6034d58 --- /dev/null +++ b/editor/txtsvc/src/nsTSAtomList.h @@ -0,0 +1,85 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is text services atom table. + * + * The Initial Developer of the Original Code is + * Netscape communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2003 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Alec Flett + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/****** + + This file contains the list of all text services nsIAtoms and their values + + It is designed to be used as inline input to nsTextServicesDocument.cpp *only* + through the magic of C preprocessing. + + All entries must be enclosed in the macro TS_ATOM which will have cruel + and unusual things done to it + + It is recommended (but not strictly necessary) to keep all entries + in alphabetical order + + The first argument to TS_ATOM is the C++ identifier of the atom + The second argument is the string value of the atom + + ******/ + +// OUTPUT_CLASS=nsTextServicesDocument +// MACRO_NAME=TS_ATOM + +TS_ATOM(sAAtom, "a") +TS_ATOM(sAddressAtom, "address") +TS_ATOM(sBigAtom, "big") +TS_ATOM(sBlinkAtom, "blink") +TS_ATOM(sBAtom, "b") +TS_ATOM(sCiteAtom, "cite") +TS_ATOM(sCodeAtom, "code") +TS_ATOM(sDfnAtom, "dfn") +TS_ATOM(sEmAtom, "em") +TS_ATOM(sFontAtom, "font") +TS_ATOM(sIAtom, "i") +TS_ATOM(sKbdAtom, "kbd") +TS_ATOM(sKeygenAtom, "keygen") +TS_ATOM(sNobrAtom, "nobr") +TS_ATOM(sSAtom, "s") +TS_ATOM(sSampAtom, "samp") +TS_ATOM(sSmallAtom, "small") +TS_ATOM(sSpacerAtom, "spacer") +TS_ATOM(sSpanAtom, "span") +TS_ATOM(sStrikeAtom, "strike") +TS_ATOM(sStrongAtom, "strong") +TS_ATOM(sSubAtom, "sub") +TS_ATOM(sSupAtom, "sup") +TS_ATOM(sTtAtom, "tt") +TS_ATOM(sUAtom, "u") +TS_ATOM(sVarAtom, "var") +TS_ATOM(sWbrAtom, "wbr") diff --git a/editor/txtsvc/src/nsTextServicesDocument.cpp b/editor/txtsvc/src/nsTextServicesDocument.cpp index d54a666c7afc..7db0691d9cb2 100644 --- a/editor/txtsvc/src/nsTextServicesDocument.cpp +++ b/editor/txtsvc/src/nsTextServicesDocument.cpp @@ -40,6 +40,7 @@ #include "nscore.h" #include "nsLayoutCID.h" #include "nsIAtom.h" +#include "nsStaticAtom.h" #include "nsString.h" #include "nsIEnumerator.h" #include "nsIContent.h" @@ -95,41 +96,21 @@ public: PRBool mIsValid; }; -// XXX: Should change these pointers to -// nsCOMPtr pointers! +#define TS_ATOM(name_, value_) nsIAtom* nsTextServicesDocument::name_ = 0; +#include "nsTSAtomList.h" +#undef TS_ATOM -nsIAtom *nsTextServicesDocument::sAAtom; -nsIAtom *nsTextServicesDocument::sAddressAtom; -nsIAtom *nsTextServicesDocument::sBigAtom; -nsIAtom *nsTextServicesDocument::sBlinkAtom; -nsIAtom *nsTextServicesDocument::sBAtom; -nsIAtom *nsTextServicesDocument::sCiteAtom; -nsIAtom *nsTextServicesDocument::sCodeAtom; -nsIAtom *nsTextServicesDocument::sDfnAtom; -nsIAtom *nsTextServicesDocument::sEmAtom; -nsIAtom *nsTextServicesDocument::sFontAtom; -nsIAtom *nsTextServicesDocument::sIAtom; -nsIAtom *nsTextServicesDocument::sKbdAtom; -nsIAtom *nsTextServicesDocument::sKeygenAtom; -nsIAtom *nsTextServicesDocument::sNobrAtom; -nsIAtom *nsTextServicesDocument::sSAtom; -nsIAtom *nsTextServicesDocument::sSampAtom; -nsIAtom *nsTextServicesDocument::sSmallAtom; -nsIAtom *nsTextServicesDocument::sSpacerAtom; -nsIAtom *nsTextServicesDocument::sSpanAtom; -nsIAtom *nsTextServicesDocument::sStrikeAtom; -nsIAtom *nsTextServicesDocument::sStrongAtom; -nsIAtom *nsTextServicesDocument::sSubAtom; -nsIAtom *nsTextServicesDocument::sSupAtom; -nsIAtom *nsTextServicesDocument::sTtAtom; -nsIAtom *nsTextServicesDocument::sUAtom; -nsIAtom *nsTextServicesDocument::sVarAtom; -nsIAtom *nsTextServicesDocument::sWbrAtom; PRInt32 nsTextServicesDocument::sInstanceCount; nsTextServicesDocument::nsTextServicesDocument() { +static const nsStaticAtom ts_atoms[] = { +#define TS_ATOM(name_, value_) { value_, &name_ }, +#include "nsTSAtomList.h" +#undef TS_ATOM +}; + mRefCnt = 0; mSelStartIndex = -1; @@ -140,35 +121,7 @@ nsTextServicesDocument::nsTextServicesDocument() mIteratorStatus = eIsDone; if (sInstanceCount <= 0) - { - sAAtom = NS_NewAtom("a"); - sAddressAtom = NS_NewAtom("address"); - sBigAtom = NS_NewAtom("big"); - sBlinkAtom = NS_NewAtom("blink"); - sBAtom = NS_NewAtom("b"); - sCiteAtom = NS_NewAtom("cite"); - sCodeAtom = NS_NewAtom("code"); - sDfnAtom = NS_NewAtom("dfn"); - sEmAtom = NS_NewAtom("em"); - sFontAtom = NS_NewAtom("font"); - sIAtom = NS_NewAtom("i"); - sKbdAtom = NS_NewAtom("kbd"); - sKeygenAtom = NS_NewAtom("keygen"); - sNobrAtom = NS_NewAtom("nobr"); - sSAtom = NS_NewAtom("s"); - sSampAtom = NS_NewAtom("samp"); - sSmallAtom = NS_NewAtom("small"); - sSpacerAtom = NS_NewAtom("spacer"); - sSpanAtom = NS_NewAtom("span"); - sStrikeAtom = NS_NewAtom("strike"); - sStrongAtom = NS_NewAtom("strong"); - sSubAtom = NS_NewAtom("sub"); - sSupAtom = NS_NewAtom("sup"); - sTtAtom = NS_NewAtom("tt"); - sUAtom = NS_NewAtom("u"); - sVarAtom = NS_NewAtom("var"); - sWbrAtom = NS_NewAtom("wbr"); - } + NS_RegisterStaticAtoms(ts_atoms, NS_ARRAY_LENGTH(ts_atoms)); ++sInstanceCount; } @@ -180,37 +133,6 @@ nsTextServicesDocument::~nsTextServicesDocument() ClearOffsetTable(); - if (sInstanceCount <= 1) - { - NS_IF_RELEASE(sAAtom); - NS_IF_RELEASE(sAddressAtom); - NS_IF_RELEASE(sBigAtom); - NS_IF_RELEASE(sBlinkAtom); - NS_IF_RELEASE(sBAtom); - NS_IF_RELEASE(sCiteAtom); - NS_IF_RELEASE(sCodeAtom); - NS_IF_RELEASE(sDfnAtom); - NS_IF_RELEASE(sEmAtom); - NS_IF_RELEASE(sFontAtom); - NS_IF_RELEASE(sIAtom); - NS_IF_RELEASE(sKbdAtom); - NS_IF_RELEASE(sKeygenAtom); - NS_IF_RELEASE(sNobrAtom); - NS_IF_RELEASE(sSAtom); - NS_IF_RELEASE(sSampAtom); - NS_IF_RELEASE(sSmallAtom); - NS_IF_RELEASE(sSpacerAtom); - NS_IF_RELEASE(sSpanAtom); - NS_IF_RELEASE(sStrikeAtom); - NS_IF_RELEASE(sStrongAtom); - NS_IF_RELEASE(sSubAtom); - NS_IF_RELEASE(sSupAtom); - NS_IF_RELEASE(sTtAtom); - NS_IF_RELEASE(sUAtom); - NS_IF_RELEASE(sVarAtom); - NS_IF_RELEASE(sWbrAtom); - } - --sInstanceCount; }