Skip to content

Commit

Permalink
Bug 1824516 - Make parser/htmlparser buildable outside of a unified b…
Browse files Browse the repository at this point in the history
…uild environment r=andi

Differential Revision: https://phabricator.services.mozilla.com/D173616
  • Loading branch information
serge-sans-paille committed Mar 30, 2023
1 parent 1a6db52 commit 4fdac53
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 0 additions & 2 deletions parser/htmlparser/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,3 @@ FINAL_LIBRARY = "xul"
LOCAL_INCLUDES += [
"!/security/rlbox",
]

REQUIRES_UNIFIED_BUILD = True
1 change: 1 addition & 0 deletions parser/htmlparser/nsExpatDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "nsIInputStream.h"
#include "nsIParser.h"
#include "nsCycleCollectionParticipant.h"
#include "nsScanner.h"

#include "rlbox_expat.h"
#include "nsRLBoxExpatDriver.h"
Expand Down
14 changes: 9 additions & 5 deletions parser/htmlparser/nsScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/Encoding.h"
#include "mozilla/UniquePtr.h"
#include "nsDebug.h"
#include "nsReadableUtils.h"
#include "nsUTF8Utils.h" // for LossyConvertEncoding
Expand Down Expand Up @@ -189,11 +190,13 @@ nsresult nsScanner::Append(const nsAString& aBuffer) {
nsresult nsScanner::Append(const char* aBuffer, uint32_t aLen) {
nsresult res = NS_OK;
if (mUnicodeDecoder) {
CheckedInt<size_t> needed = mUnicodeDecoder->MaxUTF16BufferLength(aLen);
mozilla::CheckedInt<size_t> needed =
mUnicodeDecoder->MaxUTF16BufferLength(aLen);
if (!needed.isValid()) {
return NS_ERROR_OUT_OF_MEMORY;
}
CheckedInt<uint32_t> allocLen(1); // null terminator due to legacy sadness
mozilla::CheckedInt<uint32_t> allocLen(
1); // null terminator due to legacy sadness
allocLen += needed.value();
if (!allocLen.isValid()) {
return NS_ERROR_OUT_OF_MEMORY;
Expand All @@ -209,12 +212,13 @@ nsresult nsScanner::Append(const char* aBuffer, uint32_t aLen) {
// Do not use structured binding lest deal with [-Werror=unused-variable]
std::tie(result, read, written) =
mUnicodeDecoder->DecodeToUTF16WithoutReplacement(
AsBytes(Span(aBuffer, aLen)), Span(unichars, needed.value()),
AsBytes(mozilla::Span(aBuffer, aLen)),
mozilla::Span(unichars, needed.value()),
false); // Retain bug about failure to handle EOF
MOZ_ASSERT(result != kOutputFull);
MOZ_ASSERT(read <= aLen);
MOZ_ASSERT(written <= needed.value());
if (result != kInputEmpty) {
if (result != mozilla::kInputEmpty) {
// Since about:blank is empty, this line runs only for XML. Use a
// character that's illegal in XML instead of U+FFFD in order to make
// expat flag the error. There is no need to loop and convert more, since
Expand Down Expand Up @@ -279,7 +283,7 @@ void nsScanner::SetPosition(nsScannerIterator& aPosition, bool aTerminate) {

void nsScanner::AppendToBuffer(nsScannerString::Buffer* aBuf) {
if (!mSlidingBuffer) {
mSlidingBuffer = MakeUnique<nsScannerString>(aBuf);
mSlidingBuffer = mozilla::MakeUnique<nsScannerString>(aBuf);
mSlidingBuffer->BeginReading(mCurrentPosition);
mMarkPosition = mCurrentPosition;
} else {
Expand Down
2 changes: 0 additions & 2 deletions parser/htmlparser/nsScannerString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ int32_t nsScannerSubstring::CountChar(char16_t c) const {
if (!(lengthToExamine -= lengthToExamineInThisFragment)) return result;
iter.advance(lengthToExamineInThisFragment);
}
// never reached; quiets warnings
return 0;
}

void nsScannerSubstring::Rebind(const nsScannerSubstring& aString,
Expand Down

0 comments on commit 4fdac53

Please sign in to comment.