Bug 1448584 - Remove nsContentUtils::CopyNewlineNormalizedUnicodeTo() as dead code. r?mccr8.
MozReview-Commit-ID: HqHtANlHk41
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -1626,147 +1626,16 @@ nsContentUtils::GetBidiKeyboard()
nsresult rv = CallGetService("@mozilla.org/widget/bidikeyboard;1", &sBidiKeyboard);
if (NS_FAILED(rv)) {
sBidiKeyboard = nullptr;
}
}
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
* all punctuation classes (P*). Note that this is a change from CSS2
* which excluded Pc and Pd.
*
* https://www.w3.org/TR/css-pseudo-4/#first-letter-pseudo
* "Punctuation (i.e, characters that belong to the Punctuation (P*) Unicode
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -504,24 +504,16 @@ public:
* A pointer to the found nsIDocument. nullptr if the subdocument
* cannot be found, or if either aDocument or aOuterWindowId were
* invalid. If the outer window ID belongs to aDocument itself, this
* will return a pointer to aDocument.
*/
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);
template<bool IsWhitespace(char16_t)>
static const nsDependentSubstring TrimWhitespace(const nsAString& aStr,
bool aTrimTrailing = true);
/**