Remove content ids. Bug 166637, r=sicking, sr=peterv

This commit is contained in:
bzbarsky%mit.edu 2005-11-29 16:47:18 +00:00
Родитель ee8bd891bf
Коммит 617285d1ac
18 изменённых файлов: 39 добавлений и 170 удалений

Просмотреть файл

@ -277,7 +277,6 @@ PRInt32 nsDocAccessibleWrap::GetChildIDFor(nsIAccessible* aAccessible)
{
// A child ID of the window is required, when we use NotifyWinEvent, so that the 3rd party application
// can call back and get the IAccessible the event occured on.
// We use the unique ID exposed through nsIContent::GetContentID()
void *uniqueID;
nsCOMPtr<nsIAccessNode> accessNode(do_QueryInterface(aAccessible));

Просмотреть файл

@ -68,8 +68,8 @@ class nsAttrValue;
// IID for the nsIContent interface
#define NS_ICONTENT_IID \
{ 0x6a654488, 0xcbb3, 0x49d4, \
{ 0xad, 0x2d, 0x68, 0x4b, 0xad, 0xd5, 0xa7, 0x5d } }
{ 0x5d098839, 0x389d, 0x41db, \
{ 0x8f, 0x53, 0x59, 0x07, 0xbf, 0x90, 0x0d, 0x4e } }
/**
* A node of content in a document's content model. This interface
@ -490,27 +490,6 @@ public:
PRUint32 aFlags,
nsEventStatus* aEventStatus) = 0;
/**
* Get a unique ID for this piece of content.
* This ID is used as a key to store state information
* about this content object and its associated frame object.
* The state information is stored in a dictionary that is
* manipulated by the frame manager (nsIFrameManager) inside layout.
* An opaque pointer to this dictionary is passed to the session
* history as a handle associated with the current document's state
*
* These methods are DEPRECATED, DON'T USE THEM!!!
*
*/
virtual PRUint32 ContentID() const = 0;
/**
* Set the unique content ID for this content.
* @param aID the ID to set
*/
virtual void SetContentID(PRUint32 aID)
{
}
/**
* Set the focus on this content. This is generally something for the event
* state manager to do, not ordinary people. Ordinary people should do

Просмотреть файл

@ -93,15 +93,8 @@ class nsIDOMUserDataHandler;
// IID for the nsIDocument interface
#define NS_IDOCUMENT_IID \
{ 0x6120dffe, 0xf8fc, 0x47b1, \
{ 0x98, 0xd3, 0x97, 0x68, 0x0c, 0xc9, 0xc3, 0xcd } }
// The base value for the content ID counter.
// This counter is used by the document to
// assign a monotonically increasing ID to each content
// object it creates
#define NS_CONTENT_ID_COUNTER_BASE 10000
{ 0x65d26965, 0x8fed, 0x4f55, \
{ 0x80, 0xef, 0xaa, 0xd0, 0x1d, 0xd6, 0x92, 0xfd } }
// Flag for AddStyleSheet().
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
@ -118,7 +111,6 @@ public:
nsIDocument()
: mCharacterSet(NS_LITERAL_CSTRING("ISO-8859-1")),
mNextContentID(NS_CONTENT_ID_COUNTER_BASE),
mNodeInfoManager(nsnull),
mPartID(0)
{
@ -587,11 +579,6 @@ public:
*/
virtual void FlushPendingNotifications(mozFlushType aType) = 0;
PRInt32 GetAndIncrementContentID()
{
return mNextContentID++;
}
nsIBindingManager* BindingManager() const
{
return mBindingManager;
@ -959,10 +946,6 @@ protected:
// such element exists.
nsIContent* mRootContent;
// A content ID counter used to give a monotonically increasing ID
// to the content objects in the document's content model
PRInt32 mNextContentID;
nsCOMPtr<nsIBindingManager> mBindingManager;
nsNodeInfoManager* mNodeInfoManager; // [STRONG]

Просмотреть файл

@ -1423,7 +1423,7 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent,
PRUint32 partID = aDocument ? aDocument->GetPartID() : 0;
// SpecialStateID case - e.g. scrollbars around the content window
// The key in this case is the special state id (always < min(contentID))
// The key in this case is a special state id
if (nsIStatefulFrame::eNoID != aID) {
KeyAppendInt(partID, aKey); // first append a partID
KeyAppendInt(aID, aKey);
@ -1434,8 +1434,7 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent,
NS_ENSURE_TRUE(aContent, NS_ERROR_FAILURE);
// Don't capture state for anonymous content
PRUint32 contentID = aContent->ContentID();
if (!contentID) {
if (aContent->IsNativeAnonymous() || aContent->GetBindingParent()) {
return NS_OK;
}
@ -1447,6 +1446,9 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent,
nsCOMPtr<nsIHTMLDocument> htmlDocument(do_QueryInterface(aContent->GetCurrentDoc()));
KeyAppendInt(partID, aKey); // first append a partID
// Make sure we can't possibly collide with an nsIStatefulFrame
// special id of some sort
KeyAppendInt(nsIStatefulFrame::eNoID, aKey);
PRBool generatedUniqueKey = PR_FALSE;
if (htmlDocument) {
@ -1459,16 +1461,19 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent,
NS_ENSURE_TRUE(htmlForms && htmlFormControls, NS_ERROR_OUT_OF_MEMORY);
// If we have a form control and can calculate form information, use
// that as the key - it is more reliable than contentID.
// If we have a form control and can calculate form information, use that
// as the key - it is more reliable than just recording position in the
// DOM.
// XXXbz Is it, really? We have bugs on this, I think...
// Important to have a unique key, and tag/type/name may not be.
//
// If the control has a form, the format of the key is:
// type>IndOfFormInDoc>IndOfControlInForm>FormName>name
// f>type>IndOfFormInDoc>IndOfControlInForm>FormName>name
// else:
// type>IndOfControlInDoc>name
// d>type>IndOfControlInDoc>name
//
// XXX We don't need to use index if name is there
// XXXbz We don't? Why not? I don't follow.
//
nsCOMPtr<nsIFormControl> control(do_QueryInterface(aContent));
if (control && htmlFormControls && htmlForms) {
@ -1487,6 +1492,8 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent,
return NS_OK;
}
KeyAppendString(NS_LITERAL_CSTRING("f"), aKey);
// Append the index of the form in the document
nsCOMPtr<nsIContent> formContent(do_QueryInterface(formElement));
index = htmlForms->IndexOf(formContent, PR_FALSE);
@ -1520,6 +1527,8 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent,
} else {
KeyAppendString(NS_LITERAL_CSTRING("d"), aKey);
// If not in a form, add index of control in document
// Less desirable than indexing by form info.
@ -1543,10 +1552,22 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent,
}
if (!generatedUniqueKey) {
// Either we didn't have a form control or we aren't in an HTML document
// so we can't figure out form info, hash by content ID instead :(
KeyAppendInt(contentID, aKey);
// Either we didn't have a form control or we aren't in an HTML document so
// we can't figure out form info. First append a character that is not "d"
// or "f" to disambiguate from the case when we were a form control in an
// HTML document.
KeyAppendString(NS_LITERAL_CSTRING("o"), aKey);
// Now start at aContent and append the indices of it and all its ancestors
// in their containers. That should at least pin down its position in the
// DOM...
nsIContent* parent = aContent->GetParent();
nsIContent* content = aContent;
while (parent) {
KeyAppendInt(parent->IndexOf(content), aKey);
content = parent;
parent = content->GetParent();
}
}
return NS_OK;

Просмотреть файл

@ -4873,8 +4873,6 @@ nsDocument::CreateElement(nsINodeInfo *aNodeInfo, PRInt32 aElementType,
aNodeInfo);
NS_ENSURE_SUCCESS(rv, rv);
content->SetContentID(mNextContentID++);
content.swap(*aResult);
return NS_OK;

Просмотреть файл

@ -900,12 +900,6 @@ nsGenericDOMDataNode::HandleDOMEvent(nsPresContext* aPresContext,
return ret;
}
PRUint32
nsGenericDOMDataNode::ContentID() const
{
return 0;
}
PRUint32
nsGenericDOMDataNode::GetChildCount() const
{

Просмотреть файл

@ -209,7 +209,6 @@ public:
nsEvent* aEvent, nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
nsEventStatus* aEventStatus);
virtual PRUint32 ContentID() const;
virtual nsresult RangeAdd(nsIDOMRange* aRange);
virtual void RangeRemove(nsIDOMRange* aRange);
virtual const nsVoidArray *GetRangeList() const;

Просмотреть файл

@ -765,9 +765,8 @@ nsDOMEventRTTearoff::AddEventListener(const nsAString& aType,
//----------------------------------------------------------------------
nsDOMSlots::nsDOMSlots(PtrBits aFlags)
: mFlags(aFlags & ~GENERIC_ELEMENT_CONTENT_ID_MASK),
mBindingParent(nsnull),
mContentID(aFlags >> GENERIC_ELEMENT_CONTENT_ID_BITS_OFFSET)
: mFlags(aFlags),
mBindingParent(nsnull)
{
}
@ -789,8 +788,7 @@ nsDOMSlots::~nsDOMSlots()
PRBool
nsDOMSlots::IsEmpty()
{
return (!mChildNodes && !mStyle && !mAttributeMap && !mBindingParent &&
mContentID < GENERIC_ELEMENT_CONTENT_ID_MAX_VALUE);
return (!mChildNodes && !mStyle && !mAttributeMap && !mBindingParent);
}
PR_STATIC_CALLBACK(void)
@ -2236,37 +2234,6 @@ nsGenericElement::HandleDOMEvent(nsPresContext* aPresContext,
return ret;
}
PRUint32
nsGenericElement::ContentID() const
{
nsDOMSlots *slots = GetExistingDOMSlots();
if (slots) {
return slots->mContentID;
}
PtrBits flags = GetFlags();
return flags >> GENERIC_ELEMENT_CONTENT_ID_BITS_OFFSET;
}
void
nsGenericElement::SetContentID(PRUint32 aID)
{
// This should be in the constructor!!!
if (HasDOMSlots() || aID > GENERIC_ELEMENT_CONTENT_ID_MAX_VALUE) {
nsDOMSlots *slots = GetDOMSlots();
if (slots) {
slots->mContentID = aID;
}
} else {
UnsetFlags(GENERIC_ELEMENT_CONTENT_ID_MASK);
SetFlags(aID << GENERIC_ELEMENT_CONTENT_ID_BITS_OFFSET);
}
}
NS_IMETHODIMP
nsGenericElement::MaybeTriggerAutoLink(nsIDocShell *aShell)
{

Просмотреть файл

@ -97,20 +97,6 @@ typedef unsigned long PtrBits;
/** Three bits are element type specific. */
#define ELEMENT_TYPE_SPECIFIC_BITS_OFFSET 6
/** The number of bits to shift the bit field to get at the content ID */
#define GENERIC_ELEMENT_CONTENT_ID_BITS_OFFSET 9
/** This mask masks out the bits that are used for the content ID */
#define GENERIC_ELEMENT_CONTENT_ID_MASK \
((~PtrBits(0)) << GENERIC_ELEMENT_CONTENT_ID_BITS_OFFSET)
/**
* The largest value for content ID that fits in
* GENERIC_ELEMENT_CONTENT_ID_MASK
*/
#define GENERIC_ELEMENT_CONTENT_ID_MAX_VALUE \
((PRUint32)((~PtrBits(0)) >> GENERIC_ELEMENT_CONTENT_ID_BITS_OFFSET))
/**
* Class that implements the nsIDOMNodeList interface (a list of children of
@ -187,9 +173,6 @@ public:
*/
nsIControllers* mControllers; // [OWNER]
};
// DEPRECATED, DON'T USE THIS
PRUint32 mContentID;
};
class RangeListMapEntry : public PLDHashEntryHdr
@ -416,8 +399,6 @@ public:
nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
nsEventStatus* aEventStatus);
virtual PRUint32 ContentID() const;
virtual void SetContentID(PRUint32 aID);
virtual void SetFocus(nsPresContext* aContext);
virtual nsIContent *GetBindingParent() const;
virtual PRBool IsContentOfType(PRUint32 aFlags) const;
@ -903,10 +884,6 @@ protected:
void SetFlags(PtrBits aFlagsToSet)
{
NS_ASSERTION(!((aFlagsToSet & GENERIC_ELEMENT_CONTENT_ID_MASK) &&
(aFlagsToSet & ~GENERIC_ELEMENT_CONTENT_ID_MASK)),
"Whaaa, don't set content ID bits and flags together!!!");
nsDOMSlots *slots = GetExistingDOMSlots();
if (slots) {
@ -920,10 +897,6 @@ protected:
void UnsetFlags(PtrBits aFlagsToUnset)
{
NS_ASSERTION(!((aFlagsToUnset & GENERIC_ELEMENT_CONTENT_ID_MASK) &&
(aFlagsToUnset & ~GENERIC_ELEMENT_CONTENT_ID_MASK)),
"Whaaa, don't set content ID bits and flags together!!!");
nsDOMSlots *slots = GetExistingDOMSlots();
if (slots) {

Просмотреть файл

@ -311,15 +311,6 @@ nsGenericHTMLElement::CopyInnerTo(nsGenericElement* aDst, PRBool aDeep) const
nsIDocument *newDoc = aDst->GetOwnerDoc();
PRInt32 id;
if (newDoc) {
id = newDoc->GetAndIncrementContentID();
} else {
id = PR_INT32_MAX;
}
aDst->SetContentID(id);
if (aDeep) {
nsIDocument *doc = GetOwnerDoc();
if (doc == newDoc) {

Просмотреть файл

@ -885,8 +885,6 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
return nsnull;
}
result->SetContentID(mDocument->GetAndIncrementContentID());
return result;
}
@ -3591,8 +3589,6 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode)
result = NS_NewHTMLElement(getter_AddRefs(element), nodeInfo);
NS_ENSURE_SUCCESS(result, result);
element->SetContentID(mDocument->GetAndIncrementContentID());
nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(element));
if (ssle) {

Просмотреть файл

@ -921,10 +921,6 @@ nsXMLContentSink::HandleStartElement(const PRUnichar *aName,
getter_AddRefs(content), &appendContent);
NS_ENSURE_SUCCESS(result, result);
if (mDocument) {
content->SetContentID(mDocument->GetAndIncrementContentID());
}
// Set the ID attribute atom on the node info object for this node
// This must occur before the attributes are added so the name
// of the id attribute is known.

Просмотреть файл

@ -1998,17 +1998,6 @@ nsXULElement::HandleDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent,
}
PRUint32
nsXULElement::ContentID() const
{
return 0;
}
void
nsXULElement::SetContentID(PRUint32 aID)
{
}
nsresult
nsXULElement::RangeAdd(nsIDOMRange* aRange)
{

Просмотреть файл

@ -502,9 +502,6 @@ public:
PRUint32 aFlags,
nsEventStatus* aEventStatus);
virtual PRUint32 ContentID() const;
virtual void SetContentID(PRUint32 aID);
virtual nsresult RangeAdd(nsIDOMRange* aRange);
virtual void RangeRemove(nsIDOMRange* aRange);
virtual const nsVoidArray *GetRangeList() const;

Просмотреть файл

@ -68,7 +68,6 @@
#include "nsDOMError.h"
#include "nsIBoxObject.h"
#include "nsIChromeRegistry.h"
#include "nsIContentSink.h" // for NS_CONTENT_ID_COUNTER_BASE
#include "nsIScrollableView.h"
#include "nsIContentViewer.h"
#include "nsGUIEvent.h"
@ -3476,8 +3475,6 @@ nsXULDocument::CreateElementFromPrototype(nsXULPrototypeElement* aPrototype,
if (NS_FAILED(rv)) return rv;
}
result->SetContentID(mNextContentID++);
result.swap(*aResult);
return NS_OK;

Просмотреть файл

@ -371,7 +371,6 @@ nsContentDLF::CreateBlankDocument(nsILoadGroup *aLoadGroup, nsIDocument **aDocum
rv = htmlElement->AppendChildTo(headElement, PR_FALSE);
if (NS_SUCCEEDED(rv)) {
bodyElement->SetContentID(blankDoc->GetAndIncrementContentID());
// XXXbz Why not notifying here?
htmlElement->AppendChildTo(bodyElement, PR_FALSE);
}

Просмотреть файл

@ -17,9 +17,6 @@ class nsIStatefulFrame : public nsISupports {
// If you create a special type stateful frame (e.g. scroll) that needs
// to be captured outside of the standard pass through the frames, you'll need
// a special ID by which to refer to that type.
//
// There is space reserved between standard ID's and special ID's by the
// offset NS_CONTENT_ID_COUNTER_BASE
enum SpecialStateID {eNoID=0, eDocumentScrollState};
NS_IMETHOD SaveState(nsPresContext* aPresContext, nsPresState** aState) = 0;

Просмотреть файл

@ -58,12 +58,6 @@ class nsIParser;
{ 0x94ec4df1, 0x6885, 0x4b1f, \
{ 0x85, 0x10, 0xe3, 0x5f, 0x4f, 0x36, 0xea, 0xaa } }
// The base value for the content ID counter.
// Values greater than or equal to this base value are used
// by each of the content sinks to assign unique values
// to the content objects created by them.
#define NS_CONTENT_ID_COUNTER_BASE 10000
class nsIContentSink : public nsISupports {
public: