Bug 1448584 - Remove nsContentUtils::CopyNewlineNormalizedUnicodeTo() as dead code. r=mccr8.

MozReview-Commit-ID: HqHtANlHk41

--HG--
extra : rebase_source : 7751fd6deb74e5cf8b802587e3295c220d5d39a0
This commit is contained in:
Henri Sivonen 2018-03-24 21:06:33 +02:00
parent 66abf4340e
commit 5be2b559ca
2 changed files with 0 additions and 139 deletions

View File

@ -1631,137 +1631,6 @@ nsContentUtils::GetBidiKeyboard()
return sBidiKeyboard;
}
template <class OutputIterator>
struct NormalizeNewlinesCharTraits {
public:
typedef typename OutputIterator::value_type value_type;
public:
explicit NormalizeNewlinesCharTraits(OutputIterator& aIterator) : mIterator(aIterator) { }
void writechar(typename OutputIterator::value_type aChar) {
*mIterator++ = aChar;
}
private:
OutputIterator mIterator;
};
template <class CharT>
struct NormalizeNewlinesCharTraits<CharT*> {
public:
typedef CharT value_type;
public:
explicit NormalizeNewlinesCharTraits(CharT* aCharPtr) : mCharPtr(aCharPtr) { }
void writechar(CharT aChar) {
*mCharPtr++ = aChar;
}
private:
CharT* mCharPtr;
};
template <class OutputIterator>
class CopyNormalizeNewlines
{
public:
typedef typename OutputIterator::value_type value_type;
public:
explicit CopyNormalizeNewlines(OutputIterator* aDestination,
bool aLastCharCR = false) :
mLastCharCR(aLastCharCR),
mDestination(aDestination),
mWritten(0)
{ }
uint32_t GetCharsWritten() {
return mWritten;
}
bool IsLastCharCR() {
return mLastCharCR;
}
void write(const typename OutputIterator::value_type* aSource, uint32_t aSourceLength) {
const typename OutputIterator::value_type* done_writing = aSource + aSourceLength;
// If the last source buffer ended with a CR...
if (mLastCharCR) {
// ..and if the next one is a LF, then skip it since
// we've already written out a newline
if (aSourceLength && (*aSource == value_type('\n'))) {
++aSource;
}
mLastCharCR = false;
}
uint32_t num_written = 0;
while ( aSource < done_writing ) {
if (*aSource == value_type('\r')) {
mDestination->writechar('\n');
++aSource;
// If we've reached the end of the buffer, record
// that we wrote out a CR
if (aSource == done_writing) {
mLastCharCR = true;
}
// If the next character is a LF, skip it
else if (*aSource == value_type('\n')) {
++aSource;
}
}
else {
mDestination->writechar(*aSource++);
}
++num_written;
}
mWritten += num_written;
}
private:
bool mLastCharCR;
OutputIterator* mDestination;
uint32_t mWritten;
};
// static
uint32_t
nsContentUtils::CopyNewlineNormalizedUnicodeTo(const nsAString& aSource,
uint32_t aSrcOffset,
char16_t* aDest,
uint32_t aLength,
bool& aLastCharCR)
{
typedef NormalizeNewlinesCharTraits<char16_t*> sink_traits;
sink_traits dest_traits(aDest);
CopyNormalizeNewlines<sink_traits> normalizer(&dest_traits,aLastCharCR);
nsReadingIterator<char16_t> fromBegin, fromEnd;
copy_string(aSource.BeginReading(fromBegin).advance( int32_t(aSrcOffset) ),
aSource.BeginReading(fromEnd).advance( int32_t(aSrcOffset+aLength) ),
normalizer);
aLastCharCR = normalizer.IsLastCharCR();
return normalizer.GetCharsWritten();
}
// static
uint32_t
nsContentUtils::CopyNewlineNormalizedUnicodeTo(nsReadingIterator<char16_t>& aSrcStart, const nsReadingIterator<char16_t>& aSrcEnd, nsAString& aDest)
{
typedef nsWritingIterator<char16_t> WritingIterator;
typedef NormalizeNewlinesCharTraits<WritingIterator> sink_traits;
WritingIterator iter;
aDest.BeginWriting(iter);
sink_traits dest_traits(iter);
CopyNormalizeNewlines<sink_traits> normalizer(&dest_traits);
copy_string(aSrcStart, aSrcEnd, normalizer);
return normalizer.GetCharsWritten();
}
/**
* This is used to determine whether a character is in one of the classes
* which CSS says should be part of the first-letter. Currently, that is

View File

@ -509,14 +509,6 @@ public:
static nsIDocument* GetSubdocumentWithOuterWindowId(nsIDocument *aDocument,
uint64_t aOuterWindowId);
static uint32_t CopyNewlineNormalizedUnicodeTo(const nsAString& aSource,
uint32_t aSrcOffset,
char16_t* aDest,
uint32_t aLength,
bool& aLastCharCR);
static uint32_t CopyNewlineNormalizedUnicodeTo(nsReadingIterator<char16_t>& aSrcStart, const nsReadingIterator<char16_t>& aSrcEnd, nsAString& aDest);
static const nsDependentSubstring TrimCharsInSet(const char* aSet,
const nsAString& aValue);