diff --git a/content/base/src/nsTextFragment.cpp b/content/base/src/nsTextFragment.cpp new file mode 100644 index 00000000000..982399223dd --- /dev/null +++ b/content/base/src/nsTextFragment.cpp @@ -0,0 +1,369 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** 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 Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of 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 ***** */ +#include "nsTextFragment.h" +#include "nsString.h" +#include "nsCRT.h" +#include "nsReadableUtils.h" +#include "nsMemory.h" +#include "nsBidiUtils.h" +#include "nsUnicharUtils.h" + +// Static buffer used for newline fragments +static unsigned char sNewLineCharacter = '\n'; + + +nsTextFragment::~nsTextFragment() +{ + ReleaseText(); +} + +void +nsTextFragment::ReleaseText() +{ + if (mState.mLength && m1b && mState.mInHeap) { + unsigned char *buf = NS_CONST_CAST(unsigned char *, m1b); + + nsMemory::Free(buf); // m1b == m2b as far as nsMemory is concerned + } + + m1b = nsnull; + + // Set mState.mIs2b, mState.mInHeap, and mState.mLength = 0 with mAllBits; + mAllBits = 0; +} + +nsTextFragment::nsTextFragment(const nsTextFragment& aOther) + : m1b(nsnull), mAllBits(0) +{ + if (aOther.Is2b()) { + SetTo(aOther.Get2b(), aOther.GetLength()); + } else { + SetTo(aOther.Get1b(), aOther.GetLength()); + } +} + +nsTextFragment::nsTextFragment(const char *aString) + : m1b(nsnull), mAllBits(0) +{ + SetTo(aString, strlen(aString)); +} + +nsTextFragment::nsTextFragment(const PRUnichar *aString) + : m1b(nsnull), mAllBits(0) +{ + SetTo(aString, nsCRT::strlen(aString)); +} + +nsTextFragment::nsTextFragment(const nsString& aString) + : m1b(nsnull), mAllBits(0) +{ + SetTo(aString.get(), aString.Length()); +} + +nsTextFragment& +nsTextFragment::operator=(const nsTextFragment& aOther) +{ + if (aOther.Is2b()) { + SetTo(aOther.Get2b(), aOther.GetLength()); + } else { + SetTo(aOther.Get1b(), aOther.GetLength()); + } + + if (aOther.mState.mIsBidi) { + // Carry over BIDI state from aOther + mState.mIsBidi = PR_TRUE; + } + + return *this; +} + +nsTextFragment& +nsTextFragment::operator=(const char *aString) +{ + SetTo(aString, strlen(aString)); + + return *this; +} + +nsTextFragment& +nsTextFragment::operator=(const PRUnichar *aString) +{ + SetTo(aString, nsCRT::strlen(aString)); + + return *this; +} + +nsTextFragment& +nsTextFragment::operator=(const nsAString& aString) +{ + ReleaseText(); + + PRUint32 length = aString.Length(); + + if (length > 0) { + PRBool in_heap = PR_TRUE; + + if (IsASCII(aString)) { + if (length == 1 && aString.First() == '\n') { + m1b = &sNewLineCharacter; + + in_heap = PR_FALSE; + } else { + m1b = (unsigned char *)ToNewCString(aString); + } + + mState.mIs2b = PR_FALSE; + } else { + m2b = ToNewUnicode(aString); + mState.mIs2b = PR_TRUE; + } + + mState.mInHeap = in_heap; + mState.mLength = length; + } + + return *this; +} + +void +nsTextFragment::SetTo(PRUnichar *aBuffer, PRInt32 aLength, PRBool aRelease) +{ + ReleaseText(); + + m2b = aBuffer; + mState.mIs2b = PR_TRUE; + mState.mInHeap = aRelease; + mState.mLength = aLength; +} + +void +nsTextFragment::SetTo(const PRUnichar* aBuffer, PRInt32 aLength) +{ + ReleaseText(); + + if (aLength != 0) { + // See if we need to store the data in ucs2 or not + PRBool need2 = PR_FALSE; + const PRUnichar *ucp = aBuffer; + const PRUnichar *uend = aBuffer + aLength; + while (ucp < uend) { + PRUnichar ch = *ucp++; + if (ch >> 8) { + need2 = PR_TRUE; + break; + } + } + + if (need2) { + // Use ucs2 storage because we have to + m2b = (const PRUnichar *)nsMemory::Clone(aBuffer, + aLength * sizeof(PRUnichar)); + + if (!m2b) { + NS_ERROR("Failed to clone string buffer!"); + + return; + } + + // Setup our fields + mState.mIs2b = PR_TRUE; + mState.mInHeap = PR_TRUE; + mState.mLength = aLength; + } else { + // Use 1 byte storage because we can + + PRBool in_heap = PR_TRUE; + + if (aLength == 1 && *aBuffer == '\n') { + m1b = &sNewLineCharacter; + + in_heap = PR_FALSE; + } else { + unsigned char *nt = + (unsigned char *)nsMemory::Alloc(aLength * sizeof(char)); + + if (!nt) { + NS_ERROR("Failed to allocate string buffer!"); + + return; + } + + // Copy data + for (PRUint32 i = 0; i < (PRUint32)aLength; ++i) { + nt[i] = (unsigned char)aBuffer[i]; + } + + m1b = nt; + } + + // Setup our fields + mState.mIs2b = PR_FALSE; + mState.mInHeap = in_heap; + mState.mLength = aLength; + } + } +} + +void +nsTextFragment::SetTo(const char *aBuffer, PRInt32 aLength) +{ + ReleaseText(); + if (aLength != 0) { + PRBool in_heap = PR_TRUE; + + if (aLength == 1 && *aBuffer == '\n') { + m1b = &sNewLineCharacter; + + in_heap = PR_FALSE; + } else { + m1b = (unsigned char *)nsMemory::Clone(aBuffer, aLength * sizeof(char)); + + if (!m1b) { + NS_ERROR("Failed to allocate string buffer!"); + + return; + } + } + + // Setup our fields + mState.mIs2b = PR_FALSE; + mState.mInHeap = in_heap; + mState.mLength = aLength; + } +} + +void +nsTextFragment::AppendTo(nsAString& aString) const +{ + if (mState.mIs2b) { + aString.Append(m2b, mState.mLength); + } else { + AppendASCIItoUTF16(Substring((char *)m1b, ((char *)m1b) + mState.mLength), + aString); + } +} + +void +nsTextFragment::AppendTo(nsACString& aCString) const +{ + if (mState.mIs2b) { + LossyAppendUTF16toASCII(Substring((PRUnichar *)m2b, + (PRUnichar *)m2b + mState.mLength), + aCString); + } else { + aCString.Append((char *)m1b, mState.mLength); + } +} + +void +nsTextFragment::CopyTo(PRUnichar *aDest, PRInt32 aOffset, PRInt32 aCount) +{ + NS_ASSERTION(aOffset >= 0, "Bad offset passed to nsTextFragment::CopyTo()!"); + NS_ASSERTION(aCount >= 0, "Bad count passed to nsTextFragment::CopyTo()!"); + + if (aOffset < 0) { + aOffset = 0; + } + + if (aOffset + aCount > GetLength()) { + aCount = mState.mLength - aOffset; + } + + if (aCount != 0) { + if (mState.mIs2b) { + memcpy(aDest, m2b + aOffset, sizeof(PRUnichar) * aCount); + } else { + unsigned const char *cp = m1b + aOffset; + unsigned const char *end = cp + aCount; + while (cp < end) { + *aDest++ = PRUnichar(*cp++); + } + } + } +} + +void +nsTextFragment::CopyTo(char *aDest, PRInt32 aOffset, PRInt32 aCount) +{ + NS_ASSERTION(aOffset >= 0, "Bad offset passed to nsTextFragment::CopyTo()!"); + NS_ASSERTION(aCount >= 0, "Bad count passed to nsTextFragment::CopyTo()!"); + + if (aOffset < 0) { + aOffset = 0; + } + + if (aOffset + aCount > GetLength()) { + aCount = mState.mLength - aOffset; + } + + if (aCount != 0) { + if (mState.mIs2b) { + const PRUnichar *cp = m2b + aOffset; + const PRUnichar *end = cp + aCount; + while (cp < end) { + *aDest++ = (char)(*cp++); + } + } else { + memcpy(aDest, m1b + aOffset, sizeof(char) * aCount); + } + } +} + +// To save time we only do this when we really want to know, not during +// every allocation +void +nsTextFragment::SetBidiFlag() +{ + if (mState.mIs2b && !mState.mIsBidi) { + const PRUnichar* cp = m2b; + const PRUnichar* end = cp + mState.mLength; + while (cp < end) { + PRUnichar ch1 = *cp++; + PRUint32 utf32Char = ch1; + if (IS_HIGH_SURROGATE(ch1) && + cp < end && + IS_LOW_SURROGATE(*cp)) { + PRUnichar ch2 = *cp++; + utf32Char = SURROGATE_TO_UCS4(ch1, ch2); + } + if (UTF32_CHAR_IS_BIDI(utf32Char) ) { + mState.mIsBidi = PR_TRUE; + break; + } + } + } +} diff --git a/content/xul/content/src/nsXULAtomList.h b/content/xul/content/src/nsXULAtomList.h new file mode 100644 index 00000000000..e1e39d32c66 --- /dev/null +++ b/content/xul/content/src/nsXULAtomList.h @@ -0,0 +1,312 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** 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 mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Original Author: David W. Hyatt (hyatt@netscape.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either of 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 XUL nsIAtoms and their values + + It is designed to be used as inline input to nsXULAtoms.cpp *only* + through the magic of C preprocessing. + + All entires must be enclosed in the macro XUL_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 XUL_ATOM is the C++ identifier of the atom + The second argument is the string value of the atom + + ******/ + +// OUTPUT_CLASS=nsXULAtoms +// MACRO_NAME=XUL_ATOM + +XUL_ATOM(button, "button") +XUL_ATOM(spinner, "spinner") +XUL_ATOM(scrollbar, "scrollbar") +XUL_ATOM(nativescrollbar, "nativescrollbar") +XUL_ATOM(scrollcorner, "scrollcorner") +XUL_ATOM(slider, "slider") +XUL_ATOM(palettename, "palettename") +XUL_ATOM(fontpicker, "fontpicker") +XUL_ATOM(text, "text") +XUL_ATOM(toolbar, "toolbar") +XUL_ATOM(toolbaritem, "toolbaritem") +XUL_ATOM(toolbarbutton, "toolbarbutton") +XUL_ATOM(toolbox, "toolbox") +XUL_ATOM(image, "image") +XUL_ATOM(validate, "validate") +XUL_ATOM(description, "description") +XUL_ATOM(gripper, "gripper") + + // The tree atoms +XUL_ATOM(allowevents, "allowevents") // Lets events be handled on the cell contents or in menus. +XUL_ATOM(sizemode, "sizemode") // when set, measure strings to determine preferred width + +XUL_ATOM(open, "open") // Whether or not a menu, tree, etc. is open +XUL_ATOM(closed, "closed") +XUL_ATOM(focus, "focus") + +XUL_ATOM(tree, "tree") +XUL_ATOM(treecols, "treecols") +XUL_ATOM(treecol, "treecol") +XUL_ATOM(treechildren, "treechildren") +XUL_ATOM(treeitem, "treeitem") +XUL_ATOM(treerow, "treerow") +XUL_ATOM(treeseparator, "treeseparator") +XUL_ATOM(treecell, "treecell") + +XUL_ATOM(primary, "primary") +XUL_ATOM(cycler, "cycler") +XUL_ATOM(editable, "editable") +XUL_ATOM(current, "current") +XUL_ATOM(seltype, "seltype") +XUL_ATOM(sorted, "sorted") +XUL_ATOM(dragSession, "dragSession") +XUL_ATOM(dropOn, "dropOn") +XUL_ATOM(dropBefore, "dropBefore") +XUL_ATOM(dropAfter, "dropAfter") +XUL_ATOM(checked, "checked") +XUL_ATOM(progressNormal, "progressNormal") +XUL_ATOM(progressUndetermined, "progressUndetermined") +XUL_ATOM(odd, "odd") +XUL_ATOM(even, "even") + +XUL_ATOM(menubar, "menubar") // An XP menu bar. +XUL_ATOM(menu, "menu") // Represents an XP menu +XUL_ATOM(menuitem, "menuitem") // Represents an XP menu item +XUL_ATOM(menupopup, "menupopup") // The XP menu's children. +XUL_ATOM(menutobedisplayed, "menutobedisplayed") // The menu is about to be displayed at the next sync w/ frame +XUL_ATOM(menuactive, "_moz-menuactive") // Whether or not a menu is active (without necessarily being open) +XUL_ATOM(accesskey, "accesskey") // The shortcut key for a menu or menu item +XUL_ATOM(acceltext, "acceltext") // Text to use for the accelerator +XUL_ATOM(popupgroup, "popupgroup") // Contains popup menus, context menus, and tooltips +XUL_ATOM(popup, "popup") // The popup for a context menu, popup menu, or tooltip +XUL_ATOM(menugenerated, "menugenerated") // Internal +XUL_ATOM(popupanchor, "popupanchor") // Anchor for popups +XUL_ATOM(popupalign, "popupalign") // Alignment for popups +XUL_ATOM(ignorekeys, "ignorekeys") // Alignment for popups +XUL_ATOM(sizetopopup, "sizetopopup") // Whether or not menus size to their popup children (used by menulists) + +XUL_ATOM(key, "key") // The key element / attribute +XUL_ATOM(keycode, "keycode") // The keycode attribute +XUL_ATOM(keytext, "keytext") // The keytext attribute +XUL_ATOM(modifiers, "modifiers") // The modifiers attribute +XUL_ATOM(broadcaster, "broadcaster") // A broadcaster +XUL_ATOM(observes, "observes") // The observes element +XUL_ATOM(templateAtom, "template") // A XUL template + +// Bogus atoms that people use that are just data containers +XUL_ATOM(broadcasterset, "broadcasterset") +XUL_ATOM(commands, "commands") +XUL_ATOM(commandset, "commandset") + +XUL_ATOM(progressmeter, "progressmeter") +XUL_ATOM(crop, "crop") + +XUL_ATOM(mode, "mode") +XUL_ATOM(equalsize, "equalsize") +XUL_ATOM(pack, "pack") +XUL_ATOM(box, "box") +XUL_ATOM(hbox, "hbox") +XUL_ATOM(vbox, "vbox") +XUL_ATOM(scrollbox, "scrollbox") +XUL_ATOM(mousethrough, "mousethrough") +XUL_ATOM(flex, "flex") +XUL_ATOM(ordinal, "ordinal") +XUL_ATOM(spring, "spring") +XUL_ATOM(orient, "orient") +XUL_ATOM(minwidth, "minwidth") +XUL_ATOM(minheight, "minheight") +XUL_ATOM(maxwidth, "maxwidth") +XUL_ATOM(maxheight, "maxheight") + +XUL_ATOM(autorepeatbutton, "autorepeatbutton") + +XUL_ATOM(bulletinboard, "bulletinboard") + +XUL_ATOM(stack, "stack") +XUL_ATOM(deck, "deck") +XUL_ATOM(tabbox, "tabbox") +XUL_ATOM(tab, "tab") +XUL_ATOM(tabpanels, "tabpanels") +XUL_ATOM(tabpanel, "tabpanel") +XUL_ATOM(index, "index") +XUL_ATOM(maxpos, "maxpos") +XUL_ATOM(curpos, "curpos") +XUL_ATOM(smooth, "smooth") +XUL_ATOM(scrollbarbutton, "scrollbarbutton") +XUL_ATOM(increment, "increment") +XUL_ATOM(pageincrement, "pageincrement") +XUL_ATOM(thumb, "thumb") +XUL_ATOM(toggled, "toggled") +XUL_ATOM(grippy, "grippy") +XUL_ATOM(splitter, "splitter") +XUL_ATOM(collapse, "collapse") +XUL_ATOM(collapsed, "collapsed") +XUL_ATOM(resizebefore, "resizebefore") +XUL_ATOM(resizeafter, "resizeafter") +XUL_ATOM(state, "state") +XUL_ATOM(debug, "debug") + +XUL_ATOM(fixed, "fixed") + +// grid +XUL_ATOM(grid, "grid") +XUL_ATOM(rows, "rows") +XUL_ATOM(columns, "columns") +XUL_ATOM(row, "row") +XUL_ATOM(column, "column") + +XUL_ATOM(container, "container") +XUL_ATOM(leaf,"leaf") + +XUL_ATOM(widget, "widget") +XUL_ATOM(window, "window") +XUL_ATOM(page, "page") +XUL_ATOM(dialog, "dialog") +XUL_ATOM(wizard, "wizard") + +XUL_ATOM(iframe, "iframe") +XUL_ATOM(browser, "browser") +XUL_ATOM(editor, "editor") + +// + +XUL_ATOM(control, "control") +XUL_ATOM(checkbox, "checkbox") +XUL_ATOM(radio, "radio") +XUL_ATOM(radiogroup, "radiogroup") +XUL_ATOM(menulist, "menulist") +XUL_ATOM(menubutton, "menubutton") +XUL_ATOM(textbox, "textbox") +XUL_ATOM(textarea, "textarea") +XUL_ATOM(listbox, "listbox") +XUL_ATOM(listcols, "listcols") +XUL_ATOM(listcol, "listcol") +XUL_ATOM(listhead, "listhead") +XUL_ATOM(listheader, "listheader") +XUL_ATOM(listrows, "listrows") +XUL_ATOM(listboxbody, "listboxbody") +XUL_ATOM(listitem, "listitem") +XUL_ATOM(listcell, "listcell") +XUL_ATOM(tooltip, "tooltip") +XUL_ATOM(titletip, "titletip") +XUL_ATOM(tooltiptext, "tooltiptext") +XUL_ATOM(context, "context") +XUL_ATOM(contextmenu, "contextmenu") +XUL_ATOM(style, "style") +XUL_ATOM(selected, "selected") +XUL_ATOM(clazz, "class") +XUL_ATOM(id, "id") +XUL_ATOM(persist, "persist") +XUL_ATOM(ref, "ref") +XUL_ATOM(command, "command") +XUL_ATOM(value, "value") +XUL_ATOM(label, "label") +XUL_ATOM(width, "width") +XUL_ATOM(height, "height") +XUL_ATOM(left, "left") +XUL_ATOM(top, "top") +XUL_ATOM(events, "events") +XUL_ATOM(targets, "targets") +XUL_ATOM(uri, "uri") +XUL_ATOM(empty, "empty") +XUL_ATOM(textnode, "textnode") +XUL_ATOM(rule, "rule") +XUL_ATOM(action, "action") +XUL_ATOM(containment, "containment") +XUL_ATOM(flags, "flags") +XUL_ATOM(Template, "template") +XUL_ATOM(member, "member") +XUL_ATOM(conditions, "conditions") +XUL_ATOM(property, "property") +XUL_ATOM(instanceOf, "instanceOf") +XUL_ATOM(xulcontentsgenerated, "xulcontentsgenerated") +XUL_ATOM(parent, "parent") +XUL_ATOM(iscontainer, "iscontainer") +XUL_ATOM(isempty, "isempty") +XUL_ATOM(bindings, "bindings") +XUL_ATOM(binding, "binding") +XUL_ATOM(triple, "triple") +XUL_ATOM(subject, "subject") +XUL_ATOM(predicate, "predicate") +XUL_ATOM(child, "child") +XUL_ATOM(object, "object") +XUL_ATOM(tag, "tag") +XUL_ATOM(content, "content") +XUL_ATOM(coalesceduplicatearcs, "coalesceduplicatearcs") +XUL_ATOM(allownegativeassertions, "allownegativeassertions") +XUL_ATOM(datasources, "datasources") +XUL_ATOM(statedatasource,"statedatasource") +XUL_ATOM(commandupdater, "commandupdater") +XUL_ATOM(keyset, "keyset") +XUL_ATOM(element, "element") +XUL_ATOM(attribute, "attribute") +XUL_ATOM(overlay, "overlay") +XUL_ATOM(insertbefore, "insertbefore") +XUL_ATOM(insertafter, "insertafter") +XUL_ATOM(position, "position") +XUL_ATOM(removeelement, "removeelement") +XUL_ATOM(blankrow, "blankrow") +XUL_ATOM(titlebar, "titlebar") +XUL_ATOM(resizer, "resizer") +XUL_ATOM(dir, "dir") +XUL_ATOM(properties, "properties") +XUL_ATOM(resource, "resource") +XUL_ATOM(sort, "sort") +XUL_ATOM(sortLocked, "sortLocked") +XUL_ATOM(sortDirection, "sortDirection") +XUL_ATOM(sortActive, "sortActive") +XUL_ATOM(sortResource, "sortResource") +XUL_ATOM(sortResource2, "sortResource2") +XUL_ATOM(sortSeparators, "sortSeparators") +XUL_ATOM(sortStaticsLast, "sortStaticsLast") +XUL_ATOM(selectedIndex, "selectedIndex") +XUL_ATOM(staticHint, "staticHint") +XUL_ATOM(_star, "*") +XUL_ATOM(defaultz, "default") +XUL_ATOM(screenX, "screenX") +XUL_ATOM(screenY, "screenY") +XUL_ATOM(type, "type") +XUL_ATOM(hidechrome, "hidechrome") +XUL_ATOM(popupset, "popupset") +XUL_ATOM(parsetype, "parsetype") +XUL_ATOM(canvas, "canvas") +XUL_ATOM(infer, "infer") diff --git a/content/xul/content/src/nsXULAtoms.cpp b/content/xul/content/src/nsXULAtoms.cpp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/content/xul/content/src/nsXULAtoms.h b/content/xul/content/src/nsXULAtoms.h new file mode 100644 index 00000000000..21f5893fd0a --- /dev/null +++ b/content/xul/content/src/nsXULAtoms.h @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** 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 mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Original Author: David W. Hyatt (hyatt@netscape.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either of 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 ***** */ +#ifndef nsXULAtoms_h___ +#define nsXULAtoms_h___ + +#include "nsIAtom.h" + +/** + * This class wraps up the creation and destruction of the standard + * set of xul atoms used during normal xul handling. This object + * is created when the first xul content object is created, and + * destroyed when the last such content object is destroyed. + */ +class nsXULAtoms { +public: + + static void AddRefAtoms(); + + /* Declare all atoms + + The atom names and values are stored in nsCSSAtomList.h and + are brought to you by the magic of C preprocessing + + Add new atoms to nsCSSAtomList and all support logic will be auto-generated + */ +#define XUL_ATOM(_name, _value) static nsIAtom* _name; +#include "nsXULAtomList.h" +#undef XUL_ATOM + +}; + +#endif /* nsXULAtoms_h___ */