Make nsSharable[C]String writable by overriding appropriate methods. Ensure that it doesn't store null buffer handle pointer internally, and override get() on nsXPIDL[C]String for backwards-compatibility. Collapse nsSharedBufferHandle and nsFlexBufferHandle into nsSharedBufferHandle which knows its length but can't have a storage start distinct from its data start. Convert string users who were working around broken nsSharableString::Assign back to using it. b=104663, 100751, 74726 r=jag sr=scc

git-svn-id: svn://10.0.0.236/trunk@109114 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dbaron%fas.harvard.edu
2001-11-28 05:22:57 +00:00
parent 4ae66f30c3
commit c0b306795b
35 changed files with 1368 additions and 425 deletions

View File

@@ -98,15 +98,20 @@ nsSharedBufferList::SplitBuffer( const Position& aSplitPosition, SplitDispositio
NS_ASSERTION(bufferToSplit, "bufferToSplit");
ptrdiff_t splitOffset = aSplitPosition.mPosInBuffer - bufferToSplit->DataStart();
Buffer::size_type splitOffset =
aSplitPosition.mPosInBuffer - bufferToSplit->DataStart();
NS_ASSERTION(0 <= splitOffset && splitOffset <= bufferToSplit->DataLength(), "|splitOffset| within buffer");
NS_ASSERTION(aSplitPosition.mPosInBuffer >= bufferToSplit->DataStart() &&
splitOffset <= bufferToSplit->DataLength(),
"|splitOffset| within buffer");
// if the caller specifically asked to split off the right side of the buffer-to-be-split
// or else if they asked for the minimum amount of work, and that turned out to be the right side...
// if the caller specifically asked to split off the right side of
// the buffer-to-be-split or else if they asked for the minimum
// amount of work, and that turned out to be the right side...
ptrdiff_t savedLength = mTotalDataLength;
if ( aSplitDirection==kSplitCopyRightData ||
( aSplitDirection==kSplitCopyLeastData && ((bufferToSplit->DataLength() >> 1) <= splitOffset) ) )
( aSplitDirection==kSplitCopyLeastData &&
((bufferToSplit->DataLength() >> 1) <= splitOffset) ) )
{
// ...then allocate a new buffer initializing it by copying all the data _after_ the split in the source buffer (i.e., `split right')
Buffer* new_buffer = NewSingleAllocationBuffer(bufferToSplit->DataStart()+splitOffset, PRUint32(bufferToSplit->DataLength()-splitOffset));