mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 786533 - Replace NS_MIN/NS_MAX with std::min/std::max and #include <algorithm> where needed. r=ehsan
This commit is contained in:
parent
6161ce5bd7
commit
6c53161814
@ -8,6 +8,7 @@
|
||||
#include "Accessible-inl.h"
|
||||
#include "DocAccessible-inl.h"
|
||||
#include "TextLeafAccessible.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
@ -19,7 +20,7 @@ TextUpdater::Run(DocAccessible* aDocument, TextLeafAccessible* aTextLeaf,
|
||||
|
||||
const nsString& oldText = aTextLeaf->Text();
|
||||
uint32_t oldLen = oldText.Length(), newLen = aNewText.Length();
|
||||
uint32_t minLen = NS_MIN(oldLen, newLen);
|
||||
uint32_t minLen = std::min(oldLen, newLen);
|
||||
|
||||
// Skip coinciding begin substrings.
|
||||
uint32_t skipStart = 0;
|
||||
@ -55,7 +56,7 @@ TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
|
||||
"Text leaf hasn't offset within hyper text!");
|
||||
|
||||
uint32_t oldLen = aOldText.Length(), newLen = aNewText.Length();
|
||||
uint32_t minLen = NS_MIN(oldLen, newLen);
|
||||
uint32_t minLen = std::min(oldLen, newLen);
|
||||
|
||||
// Trim coinciding substrings from the end.
|
||||
uint32_t skipEnd = 0;
|
||||
@ -120,7 +121,7 @@ TextUpdater::DoUpdate(const nsAString& aNewText, const nsAString& aOldText,
|
||||
uint32_t left = row[colIdx - 1];
|
||||
uint32_t up = prevRow[colIdx];
|
||||
uint32_t upleft = prevRow[colIdx - 1];
|
||||
row[colIdx] = NS_MIN(upleft, NS_MIN(left, up)) + 1;
|
||||
row[colIdx] = std::min(upleft, std::min(left, up)) + 1;
|
||||
} else {
|
||||
row[colIdx] = prevRow[colIdx - 1];
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "nsTextFragment.h"
|
||||
#include "mozilla/Selection.h"
|
||||
#include "gfxSkipChars.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::a11y;
|
||||
@ -178,7 +179,7 @@ HyperTextAccessible::GetBoundsForString(nsIFrame* aFrame, uint32_t aStartRendere
|
||||
frame->GetOffsets(startFrameTextOffset, endFrameTextOffset);
|
||||
int32_t frameTotalTextLength = endFrameTextOffset - startFrameTextOffset;
|
||||
int32_t seekLength = endContentOffset - startContentOffset;
|
||||
int32_t frameSubStringLength = NS_MIN(frameTotalTextLength - startContentOffsetInFrame, seekLength);
|
||||
int32_t frameSubStringLength = std::min(frameTotalTextLength - startContentOffsetInFrame, seekLength);
|
||||
|
||||
// Add the point where the string starts to the frameScreenRect
|
||||
nsPoint frameTextStartPoint;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "nsIMIMEHeaderParam.h"
|
||||
|
||||
#include "nsMimeTypes.h"
|
||||
#include <algorithm>
|
||||
|
||||
#define TYPE_ATOM "application/atom+xml"
|
||||
#define TYPE_RSS "application/rss+xml"
|
||||
@ -286,10 +287,10 @@ nsFeedSniffer::GetMIMETypeFromContent(nsIRequest* request,
|
||||
const char* testData;
|
||||
if (mDecodedData.IsEmpty()) {
|
||||
testData = (const char*)data;
|
||||
length = NS_MIN(length, MAX_BYTES);
|
||||
length = std::min(length, MAX_BYTES);
|
||||
} else {
|
||||
testData = mDecodedData.get();
|
||||
length = NS_MIN(mDecodedData.Length(), MAX_BYTES);
|
||||
length = std::min(mDecodedData.Length(), MAX_BYTES);
|
||||
}
|
||||
|
||||
// The strategy here is based on that described in:
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsHTMLCSSStyleSheet.h"
|
||||
#include "nsCSSParser.h"
|
||||
#include "nsStyledElement.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -1451,7 +1452,7 @@ nsAttrValue::ParseSpecialIntValue(const nsAString& aString)
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t val = NS_MAX(originalVal, 0);
|
||||
int32_t val = std::max(originalVal, 0);
|
||||
|
||||
// % (percent)
|
||||
if (isPercent || tmp.RFindChar('%') >= 0) {
|
||||
@ -1481,8 +1482,8 @@ nsAttrValue::ParseIntWithBounds(const nsAString& aString,
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t val = NS_MAX(originalVal, aMin);
|
||||
val = NS_MIN(val, aMax);
|
||||
int32_t val = std::max(originalVal, aMin);
|
||||
val = std::min(val, aMax);
|
||||
strict = strict && (originalVal == val);
|
||||
SetIntValueAndType(val, eInteger, strict ? nullptr : &aString);
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include <algorithm>
|
||||
|
||||
// Form related includes
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
@ -567,7 +568,7 @@ nsContentList::Item(uint32_t aIndex, bool aDoFlush)
|
||||
}
|
||||
|
||||
if (mState != LIST_UP_TO_DATE)
|
||||
PopulateSelf(NS_MIN(aIndex, UINT32_MAX - 1) + 1);
|
||||
PopulateSelf(std::min(aIndex, UINT32_MAX - 1) + 1);
|
||||
|
||||
ASSERT_IN_SYNC;
|
||||
NS_ASSERTION(!mRootNode || mState != LIST_DIRTY,
|
||||
|
@ -123,6 +123,7 @@
|
||||
#include "nsILoadContext.h"
|
||||
#include "nsTextFragment.h"
|
||||
#include "mozilla/Selection.h"
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef IBMBIDI
|
||||
#include "nsIBidiKeyboard.h"
|
||||
@ -1928,7 +1929,7 @@ nsContentUtils::GetCommonAncestor(nsINode* aNode1,
|
||||
uint32_t pos2 = parents2.Length();
|
||||
nsINode* parent = nullptr;
|
||||
uint32_t len;
|
||||
for (len = NS_MIN(pos1, pos2); len > 0; --len) {
|
||||
for (len = std::min(pos1, pos2); len > 0; --len) {
|
||||
nsINode* child1 = parents1.ElementAt(--pos1);
|
||||
nsINode* child2 = parents2.ElementAt(--pos2);
|
||||
if (child1 != child2) {
|
||||
@ -1979,7 +1980,7 @@ nsContentUtils::ComparePoints(nsINode* aParent1, int32_t aOffset1,
|
||||
// Find where the parent chains differ
|
||||
nsINode* parent = parents1.ElementAt(pos1);
|
||||
uint32_t len;
|
||||
for (len = NS_MIN(pos1, pos2); len > 0; --len) {
|
||||
for (len = std::min(pos1, pos2); len > 0; --len) {
|
||||
nsINode* child1 = parents1.ElementAt(--pos1);
|
||||
nsINode* child2 = parents2.ElementAt(--pos2);
|
||||
if (child1 != child2) {
|
||||
@ -4714,7 +4715,7 @@ nsContentUtils::GetLocalizedEllipsis()
|
||||
static PRUnichar sBuf[4] = { 0, 0, 0, 0 };
|
||||
if (!sBuf[0]) {
|
||||
nsAdoptingString tmp = Preferences::GetLocalizedString("intl.ellipsis");
|
||||
uint32_t len = NS_MIN(uint32_t(tmp.Length()),
|
||||
uint32_t len = std::min(uint32_t(tmp.Length()),
|
||||
uint32_t(ArrayLength(sBuf) - 1));
|
||||
CopyUnicodeTo(tmp, 0, sBuf, len);
|
||||
if (!sBuf[0])
|
||||
@ -6733,8 +6734,8 @@ nsContentUtils::GetSelectionInTextControl(Selection* aSelection,
|
||||
}
|
||||
|
||||
// Make sure aOutStartOffset <= aOutEndOffset.
|
||||
aOutStartOffset = NS_MIN(anchorOffset, focusOffset);
|
||||
aOutEndOffset = NS_MAX(anchorOffset, focusOffset);
|
||||
aOutStartOffset = std::min(anchorOffset, focusOffset);
|
||||
aOutEndOffset = std::max(anchorOffset, focusOffset);
|
||||
}
|
||||
|
||||
nsIEditor*
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -883,7 +884,7 @@ nsCORSPreflightListener::AddResultToCache(nsIRequest *aRequest)
|
||||
}
|
||||
age = age * 10 + (*iter - '0');
|
||||
// Cap at 24 hours. This also avoids overflow
|
||||
age = NS_MIN(age, 86400U);
|
||||
age = std::min(age, 86400U);
|
||||
++iter;
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -94,7 +95,7 @@ nsDOMMultipartFile::CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
if (skipStart < l) {
|
||||
uint64_t upperBound = NS_MIN<uint64_t>(l - skipStart, length);
|
||||
uint64_t upperBound = std::min<uint64_t>(l - skipStart, length);
|
||||
|
||||
nsCOMPtr<nsIDOMBlob> firstBlob;
|
||||
rv = blob->Slice(skipStart, skipStart + upperBound,
|
||||
@ -133,7 +134,7 @@ nsDOMMultipartFile::CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
} else {
|
||||
blobs.AppendElement(blob);
|
||||
}
|
||||
length -= NS_MIN<uint64_t>(l, length);
|
||||
length -= std::min<uint64_t>(l, length);
|
||||
}
|
||||
|
||||
// we can create our blob now
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include <algorithm>
|
||||
|
||||
class nsDOMMultipartFile : public nsDOMFile,
|
||||
public nsIJSNativeInitializer
|
||||
@ -133,7 +134,7 @@ protected:
|
||||
|
||||
// Start at 1 or we'll loop forever.
|
||||
CheckedUint32 bufferLen =
|
||||
NS_MAX<uint32_t>(static_cast<uint32_t>(mDataBufferLen), 1);
|
||||
std::max<uint32_t>(static_cast<uint32_t>(mDataBufferLen), 1);
|
||||
while (bufferLen.isValid() && bufferLen.value() < mDataLen + aSize)
|
||||
bufferLen *= 2;
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Util.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef MOZ_LOGGING
|
||||
// so we can get logging even in release builds
|
||||
@ -6523,8 +6524,8 @@ nsDocument::GetViewportInfo(uint32_t aDisplayWidth,
|
||||
mScaleMinFloat = kViewportMinScale;
|
||||
}
|
||||
|
||||
mScaleMinFloat = NS_MIN((double)mScaleMinFloat, kViewportMaxScale);
|
||||
mScaleMinFloat = NS_MAX((double)mScaleMinFloat, kViewportMinScale);
|
||||
mScaleMinFloat = std::min((double)mScaleMinFloat, kViewportMaxScale);
|
||||
mScaleMinFloat = std::max((double)mScaleMinFloat, kViewportMinScale);
|
||||
|
||||
nsAutoString maxScaleStr;
|
||||
GetHeaderData(nsGkAtoms::viewport_maximum_scale, maxScaleStr);
|
||||
@ -6538,8 +6539,8 @@ nsDocument::GetViewportInfo(uint32_t aDisplayWidth,
|
||||
mScaleMaxFloat = kViewportMaxScale;
|
||||
}
|
||||
|
||||
mScaleMaxFloat = NS_MIN((double)mScaleMaxFloat, kViewportMaxScale);
|
||||
mScaleMaxFloat = NS_MAX((double)mScaleMaxFloat, kViewportMinScale);
|
||||
mScaleMaxFloat = std::min((double)mScaleMaxFloat, kViewportMaxScale);
|
||||
mScaleMaxFloat = std::max((double)mScaleMaxFloat, kViewportMinScale);
|
||||
|
||||
nsAutoString scaleStr;
|
||||
GetHeaderData(nsGkAtoms::viewport_initial_scale, scaleStr);
|
||||
@ -6626,26 +6627,26 @@ nsDocument::GetViewportInfo(uint32_t aDisplayWidth,
|
||||
height = aDisplayHeight / pixelRatio;
|
||||
}
|
||||
|
||||
width = NS_MIN(width, kViewportMaxWidth);
|
||||
width = NS_MAX(width, kViewportMinWidth);
|
||||
width = std::min(width, kViewportMaxWidth);
|
||||
width = std::max(width, kViewportMinWidth);
|
||||
|
||||
// Also recalculate the default zoom, if it wasn't specified in the metadata,
|
||||
// and the width is specified.
|
||||
if (mScaleStrEmpty && !mWidthStrEmpty) {
|
||||
scaleFloat = NS_MAX(scaleFloat, float(aDisplayWidth) / float(width));
|
||||
scaleFloat = std::max(scaleFloat, float(aDisplayWidth) / float(width));
|
||||
}
|
||||
|
||||
height = NS_MIN(height, kViewportMaxHeight);
|
||||
height = NS_MAX(height, kViewportMinHeight);
|
||||
height = std::min(height, kViewportMaxHeight);
|
||||
height = std::max(height, kViewportMinHeight);
|
||||
|
||||
// We need to perform a conversion, but only if the initial or maximum
|
||||
// scale were set explicitly by the user.
|
||||
if (mValidScaleFloat) {
|
||||
width = NS_MAX(width, (uint32_t)(aDisplayWidth / scaleFloat));
|
||||
height = NS_MAX(height, (uint32_t)(aDisplayHeight / scaleFloat));
|
||||
width = std::max(width, (uint32_t)(aDisplayWidth / scaleFloat));
|
||||
height = std::max(height, (uint32_t)(aDisplayHeight / scaleFloat));
|
||||
} else if (mValidMaxScale) {
|
||||
width = NS_MAX(width, (uint32_t)(aDisplayWidth / scaleMaxFloat));
|
||||
height = NS_MAX(height, (uint32_t)(aDisplayHeight / scaleMaxFloat));
|
||||
width = std::max(width, (uint32_t)(aDisplayWidth / scaleMaxFloat));
|
||||
height = std::max(height, (uint32_t)(aDisplayHeight / scaleMaxFloat));
|
||||
}
|
||||
|
||||
nsViewportInfo ret(scaleFloat, scaleMinFloat, scaleMaxFloat, width, height,
|
||||
@ -6759,7 +6760,7 @@ nsDocument::FlushPendingNotifications(mozFlushType aType)
|
||||
if (mParentDocument && IsSafeToFlush()) {
|
||||
mozFlushType parentType = aType;
|
||||
if (aType >= Flush_Style)
|
||||
parentType = NS_MAX(Flush_Layout, aType);
|
||||
parentType = std::max(Flush_Layout, aType);
|
||||
mParentDocument->FlushPendingNotifications(parentType);
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "xpcpublic.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/StructuredCloneUtils.h"
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
@ -949,7 +950,7 @@ nsFrameScriptExecutor::TryCacheLoadAndCompileScript(const nsAString& aURL,
|
||||
return;
|
||||
}
|
||||
nsCString buffer;
|
||||
uint32_t avail = (uint32_t)NS_MIN(avail64, (uint64_t)UINT32_MAX);
|
||||
uint32_t avail = (uint32_t)std::min(avail64, (uint64_t)UINT32_MAX);
|
||||
if (NS_FAILED(NS_ReadInputStreamToString(input, buffer, avail))) {
|
||||
return;
|
||||
}
|
||||
|
@ -104,6 +104,7 @@
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
#include "WrapperFactory.h"
|
||||
#include "DocumentType.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -806,7 +807,7 @@ nsINode::CompareDocumentPosition(nsINode& aOtherNode) const
|
||||
// Find where the parent chain differs and check indices in the parent.
|
||||
const nsINode* parent = top1;
|
||||
uint32_t len;
|
||||
for (len = NS_MIN(pos1, pos2); len > 0; --len) {
|
||||
for (len = std::min(pos1, pos2); len > 0; --len) {
|
||||
const nsINode* child1 = parents1.ElementAt(--pos1);
|
||||
const nsINode* child2 = parents2.ElementAt(--pos2);
|
||||
if (child1 != child2) {
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsCrossSiteListenerProxy.h"
|
||||
#include <algorithm>
|
||||
|
||||
/**
|
||||
* This class manages loading a single XML document
|
||||
@ -342,7 +343,7 @@ nsSyncLoadService::PushSyncStreamToListener(nsIInputStream* aIn,
|
||||
if (NS_FAILED(rv)) {
|
||||
chunkSize = 4096;
|
||||
}
|
||||
chunkSize = NS_MIN(int64_t(UINT16_MAX), chunkSize);
|
||||
chunkSize = std::min(int64_t(UINT16_MAX), chunkSize);
|
||||
|
||||
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream), aIn,
|
||||
chunkSize);
|
||||
@ -370,7 +371,7 @@ nsSyncLoadService::PushSyncStreamToListener(nsIInputStream* aIn,
|
||||
readCount = UINT32_MAX;
|
||||
|
||||
rv = aListener->OnDataAvailable(aChannel, nullptr, aIn,
|
||||
(uint32_t)NS_MIN(sourceOffset, (uint64_t)UINT32_MAX),
|
||||
(uint32_t)std::min(sourceOffset, (uint64_t)UINT32_MAX),
|
||||
(uint32_t)readCount);
|
||||
if (NS_FAILED(rv)) {
|
||||
break;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "nsUTF8Utils.h"
|
||||
#include "mozilla/SSE.h"
|
||||
#include "nsTextFragmentImpl.h"
|
||||
#include <algorithm>
|
||||
|
||||
#define TEXTFRAG_WHITE_AFTER_NEWLINE 50
|
||||
#define TEXTFRAG_MAX_NEWLINES 7
|
||||
@ -127,7 +128,7 @@ FirstNon8BitUnvectorized(const PRUnichar *str, const PRUnichar *end)
|
||||
|
||||
// Align ourselves to a word boundary.
|
||||
int32_t alignLen =
|
||||
NS_MIN(len, int32_t(((-NS_PTR_TO_INT32(str)) & alignMask) / sizeof(PRUnichar)));
|
||||
std::min(len, int32_t(((-NS_PTR_TO_INT32(str)) & alignMask) / sizeof(PRUnichar)));
|
||||
for (; i < alignLen; i++) {
|
||||
if (str[i] > 255)
|
||||
return i;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "nscore.h"
|
||||
#include "nsAlgorithm.h"
|
||||
#include "nsTextFragmentImpl.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
namespace SSE2 {
|
||||
@ -33,7 +34,7 @@ FirstNon8Bit(const PRUnichar *str, const PRUnichar *end)
|
||||
// Align ourselves to a 16-byte boundary, as required by _mm_load_si128
|
||||
// (i.e. MOVDQA).
|
||||
int32_t alignLen =
|
||||
NS_MIN(len, int32_t(((-NS_PTR_TO_INT32(str)) & 0xf) / sizeof(PRUnichar)));
|
||||
std::min(len, int32_t(((-NS_PTR_TO_INT32(str)) & 0xf) / sizeof(PRUnichar)));
|
||||
for (; i < alignLen; i++) {
|
||||
if (str[i] > 255)
|
||||
return i;
|
||||
|
@ -3,6 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsViewportInfo.h"
|
||||
#include <algorithm>
|
||||
|
||||
void
|
||||
nsViewportInfo::SetDefaultZoom(const double aDefaultZoom)
|
||||
@ -16,8 +17,8 @@ nsViewportInfo::ConstrainViewportValues()
|
||||
{
|
||||
// Constrain the min/max zoom as specified at:
|
||||
// dev.w3.org/csswg/css-device-adapt section 6.2
|
||||
mMaxZoom = NS_MAX(mMinZoom, mMaxZoom);
|
||||
mMaxZoom = std::max(mMinZoom, mMaxZoom);
|
||||
|
||||
mDefaultZoom = NS_MIN(mDefaultZoom, mMaxZoom);
|
||||
mDefaultZoom = NS_MAX(mDefaultZoom, mMinZoom);
|
||||
mDefaultZoom = std::min(mDefaultZoom, mMaxZoom);
|
||||
mDefaultZoom = std::max(mDefaultZoom, mMinZoom);
|
||||
}
|
||||
|
@ -302,10 +302,10 @@ public:
|
||||
|
||||
// We need to enlarge and possibly offset our temporary surface
|
||||
// so that things outside of the canvas may cast shadows.
|
||||
mTempRect.Inflate(Margin(blurRadius + NS_MAX<Float>(state.shadowOffset.x, 0),
|
||||
blurRadius + NS_MAX<Float>(state.shadowOffset.y, 0),
|
||||
blurRadius + NS_MAX<Float>(-state.shadowOffset.x, 0),
|
||||
blurRadius + NS_MAX<Float>(-state.shadowOffset.y, 0)));
|
||||
mTempRect.Inflate(Margin(blurRadius + std::max<Float>(state.shadowOffset.x, 0),
|
||||
blurRadius + std::max<Float>(state.shadowOffset.y, 0),
|
||||
blurRadius + std::max<Float>(-state.shadowOffset.x, 0),
|
||||
blurRadius + std::max<Float>(-state.shadowOffset.y, 0)));
|
||||
|
||||
if (aBounds) {
|
||||
// We actually include the bounds of the shadow blur, this makes it
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "WebGLTexelConversions.h"
|
||||
#include "WebGLValidateStrings.h"
|
||||
#include <algorithm>
|
||||
|
||||
// needed to check if current OS is lower than 10.7
|
||||
#if defined(MOZ_WIDGET_COCOA)
|
||||
@ -3283,12 +3284,12 @@ WebGLContext::ReadPixels(WebGLint x, WebGLint y, WebGLsizei width,
|
||||
}
|
||||
|
||||
// compute the parameters of the subrect we're actually going to call glReadPixels on
|
||||
GLint subrect_x = NS_MAX(x, 0);
|
||||
GLint subrect_end_x = NS_MIN(x+width, framebufferWidth);
|
||||
GLint subrect_x = std::max(x, 0);
|
||||
GLint subrect_end_x = std::min(x+width, framebufferWidth);
|
||||
GLsizei subrect_width = subrect_end_x - subrect_x;
|
||||
|
||||
GLint subrect_y = NS_MAX(y, 0);
|
||||
GLint subrect_end_y = NS_MIN(y+height, framebufferHeight);
|
||||
GLint subrect_y = std::max(y, 0);
|
||||
GLint subrect_end_y = std::min(y+height, framebufferHeight);
|
||||
GLsizei subrect_height = subrect_end_y - subrect_y;
|
||||
|
||||
if (subrect_width < 0 || subrect_height < 0 ||
|
||||
|
@ -33,7 +33,7 @@ WebGLProgram::UpdateInfo()
|
||||
mAttribMaxNameLength = 0;
|
||||
|
||||
for (size_t i = 0; i < mAttachedShaders.Length(); i++)
|
||||
mAttribMaxNameLength = NS_MAX(mAttribMaxNameLength, mAttachedShaders[i]->mAttribMaxNameLength);
|
||||
mAttribMaxNameLength = std::max(mAttribMaxNameLength, mAttachedShaders[i]->mAttribMaxNameLength);
|
||||
|
||||
GLint attribCount;
|
||||
mContext->gl->fGetProgramiv(mGLName, LOCAL_GL_ACTIVE_ATTRIBUTES, &attribCount);
|
||||
@ -411,13 +411,13 @@ bool WebGLContext::ValidateCompressedTextureSize(WebGLenum target, WebGLint leve
|
||||
case LOCAL_GL_COMPRESSED_RGB_PVRTC_4BPPV1:
|
||||
case LOCAL_GL_COMPRESSED_RGBA_PVRTC_4BPPV1:
|
||||
{
|
||||
required_byteLength = CheckedUint32(NS_MAX(width, 8)) * CheckedUint32(NS_MAX(height, 8)) / 2;
|
||||
required_byteLength = CheckedUint32(std::max(width, 8)) * CheckedUint32(std::max(height, 8)) / 2;
|
||||
break;
|
||||
}
|
||||
case LOCAL_GL_COMPRESSED_RGB_PVRTC_2BPPV1:
|
||||
case LOCAL_GL_COMPRESSED_RGBA_PVRTC_2BPPV1:
|
||||
{
|
||||
required_byteLength = CheckedUint32(NS_MAX(width, 16)) * CheckedUint32(NS_MAX(height, 8)) / 4;
|
||||
required_byteLength = CheckedUint32(std::max(width, 16)) * CheckedUint32(std::max(height, 8)) / 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -741,7 +741,7 @@ WebGLContext::ValidateUniformArraySetter(const char* name, uint32_t expectedElem
|
||||
return false;
|
||||
}
|
||||
numElementsToUpload =
|
||||
NS_MIN(info.arraySize, arrayLength / expectedElemSize);
|
||||
std::min(info.arraySize, arrayLength / expectedElemSize);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -792,7 +792,7 @@ WebGLContext::ValidateUniformMatrixArraySetter(const char* name, int dim, WebGLU
|
||||
return false;
|
||||
}
|
||||
numElementsToUpload =
|
||||
NS_MIN(info.arraySize, arrayLength / (expectedElemSize));
|
||||
std::min(info.arraySize, arrayLength / (expectedElemSize));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -960,7 +960,7 @@ WebGLContext::InitAndValidateGL()
|
||||
error = gl->GetAndClearError();
|
||||
switch (error) {
|
||||
case LOCAL_GL_NO_ERROR:
|
||||
mGLMaxVaryingVectors = NS_MIN(maxVertexOutputComponents, minFragmentInputComponents) / 4;
|
||||
mGLMaxVaryingVectors = std::min(maxVertexOutputComponents, minFragmentInputComponents) / 4;
|
||||
break;
|
||||
case LOCAL_GL_INVALID_ENUM:
|
||||
mGLMaxVaryingVectors = 16; // = 64/4, 64 is the min value for maxVertexOutputComponents in OpenGL 3.2 spec
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -333,7 +334,7 @@ struct TreeForType<uint16_t>
|
||||
template<typename T>
|
||||
void WebGLElementArrayCacheTree<T>::Invalidate(size_t firstByte, size_t lastByte)
|
||||
{
|
||||
lastByte = NS_MIN(lastByte, mNumLeaves * sElementsPerLeaf * sizeof(T) - 1);
|
||||
lastByte = std::min(lastByte, mNumLeaves * sElementsPerLeaf * sizeof(T) - 1);
|
||||
if (firstByte > lastByte) {
|
||||
return;
|
||||
}
|
||||
@ -342,8 +343,8 @@ void WebGLElementArrayCacheTree<T>::Invalidate(size_t firstByte, size_t lastByte
|
||||
size_t lastLeaf = LeafForByte(lastByte);
|
||||
|
||||
if (mInvalidated) {
|
||||
mFirstInvalidatedLeaf = NS_MIN(firstLeaf, mFirstInvalidatedLeaf);
|
||||
mLastInvalidatedLeaf = NS_MAX(lastLeaf, mLastInvalidatedLeaf);
|
||||
mFirstInvalidatedLeaf = std::min(firstLeaf, mFirstInvalidatedLeaf);
|
||||
mLastInvalidatedLeaf = std::max(lastLeaf, mLastInvalidatedLeaf);
|
||||
} else {
|
||||
mInvalidated = true;
|
||||
mFirstInvalidatedLeaf = firstLeaf;
|
||||
@ -380,9 +381,9 @@ void WebGLElementArrayCacheTree<T>::Update()
|
||||
while (treeIndex <= lastTreeIndex) {
|
||||
T m = 0;
|
||||
size_t a = srcIndex;
|
||||
size_t srcIndexNextLeaf = NS_MIN(a + sElementsPerLeaf, numberOfElements);
|
||||
size_t srcIndexNextLeaf = std::min(a + sElementsPerLeaf, numberOfElements);
|
||||
for (; srcIndex < srcIndexNextLeaf; srcIndex++) {
|
||||
m = NS_MAX(m, mParent.Element<T>(srcIndex));
|
||||
m = std::max(m, mParent.Element<T>(srcIndex));
|
||||
}
|
||||
mTreeData[treeIndex] = m;
|
||||
treeIndex++;
|
||||
@ -399,7 +400,7 @@ void WebGLElementArrayCacheTree<T>::Update()
|
||||
|
||||
// fast-exit case where only one node is invalidated at the current level
|
||||
if (firstTreeIndex == lastTreeIndex) {
|
||||
mTreeData[firstTreeIndex] = NS_MAX(mTreeData[LeftChildNode(firstTreeIndex)], mTreeData[RightChildNode(firstTreeIndex)]);
|
||||
mTreeData[firstTreeIndex] = std::max(mTreeData[LeftChildNode(firstTreeIndex)], mTreeData[RightChildNode(firstTreeIndex)]);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -418,7 +419,7 @@ void WebGLElementArrayCacheTree<T>::Update()
|
||||
child = RightNeighborNode(child);
|
||||
T b = mTreeData[child];
|
||||
child = RightNeighborNode(child);
|
||||
mTreeData[parent] = NS_MAX(a, b);
|
||||
mTreeData[parent] = std::max(a, b);
|
||||
parent = RightNeighborNode(parent);
|
||||
}
|
||||
}
|
||||
@ -429,7 +430,7 @@ void WebGLElementArrayCacheTree<T>::Update()
|
||||
child = RightNeighborNode(child);
|
||||
T b = mTreeData[child];
|
||||
child = RightNeighborNode(child);
|
||||
mTreeData[parent] = NS_MAX(a, b);
|
||||
mTreeData[parent] = std::max(a, b);
|
||||
parent = RightNeighborNode(parent);
|
||||
}
|
||||
}
|
||||
@ -510,14 +511,14 @@ bool WebGLElementArrayCache::Validate(uint32_t maxAllowed, size_t firstElement,
|
||||
|
||||
// before calling tree->Validate, we have to validate ourselves the boundaries of the elements span,
|
||||
// to round them to the nearest multiple of sElementsPerLeaf.
|
||||
size_t firstElementAdjustmentEnd = NS_MIN(lastElement,
|
||||
size_t firstElementAdjustmentEnd = std::min(lastElement,
|
||||
tree->LastElementUnderSameLeaf(firstElement));
|
||||
while (firstElement <= firstElementAdjustmentEnd) {
|
||||
if (elements[firstElement] > maxAllowedT)
|
||||
return false;
|
||||
firstElement++;
|
||||
}
|
||||
size_t lastElementAdjustmentEnd = NS_MAX(firstElement,
|
||||
size_t lastElementAdjustmentEnd = std::max(firstElement,
|
||||
tree->FirstElementUnderSameLeaf(lastElement));
|
||||
while (lastElement >= lastElementAdjustmentEnd) {
|
||||
if (elements[lastElement] > maxAllowedT)
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "WebGLContext.h"
|
||||
#include "WebGLTexture.h"
|
||||
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -81,8 +82,8 @@ WebGLTexture::DoesTexture2DMipmapHaveAllLevelsConsistentlyDefined(size_t face) c
|
||||
const ImageInfo& actual = ImageInfoAt(level, face);
|
||||
if (actual != expected)
|
||||
return false;
|
||||
expected.mWidth = NS_MAX(1, expected.mWidth >> 1);
|
||||
expected.mHeight = NS_MAX(1, expected.mHeight >> 1);
|
||||
expected.mWidth = std::max(1, expected.mWidth >> 1);
|
||||
expected.mHeight = std::max(1, expected.mHeight >> 1);
|
||||
|
||||
// if the current level has size 1x1, we can stop here: the spec doesn't seem to forbid the existence
|
||||
// of extra useless levels.
|
||||
@ -172,7 +173,7 @@ WebGLTexture::SetCustomMipmap() {
|
||||
ImageInfo imageInfo = ImageInfoAt(0, 0);
|
||||
NS_ASSERTION(imageInfo.IsPowerOfTwo(), "this texture is NPOT, so how could GenerateMipmap() ever accept it?");
|
||||
|
||||
WebGLsizei size = NS_MAX(imageInfo.mWidth, imageInfo.mHeight);
|
||||
WebGLsizei size = std::max(imageInfo.mWidth, imageInfo.mHeight);
|
||||
|
||||
// so, the size is a power of two, let's find its log in base 2.
|
||||
size_t maxLevel = 0;
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "mozilla/LinkedList.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -153,7 +154,7 @@ protected:
|
||||
FakeBlackStatus mFakeBlackStatus;
|
||||
|
||||
void EnsureMaxLevelWithCustomImagesAtLeast(size_t aMaxLevelWithCustomImages) {
|
||||
mMaxLevelWithCustomImages = NS_MAX(mMaxLevelWithCustomImages, aMaxLevelWithCustomImages);
|
||||
mMaxLevelWithCustomImages = std::max(mMaxLevelWithCustomImages, aMaxLevelWithCustomImages);
|
||||
mImageInfos.EnsureLengthAtLeast((mMaxLevelWithCustomImages + 1) * mFacesCount);
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "nsIMEStateManager.h"
|
||||
#include "nsIObjectFrame.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
@ -186,7 +187,7 @@ static uint32_t CountNewlinesInXPLength(nsIContent* aContent,
|
||||
NS_ABORT_IF_FALSE(
|
||||
(aXPLength == UINT32_MAX || aXPLength <= text->GetLength()),
|
||||
"aXPLength is out-of-bounds");
|
||||
const uint32_t length = NS_MIN(aXPLength, text->GetLength());
|
||||
const uint32_t length = std::min(aXPLength, text->GetLength());
|
||||
uint32_t newlines = 0;
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
if (text->CharAt(i) == '\n') {
|
||||
@ -247,7 +248,7 @@ nsContentEventHandler::GetNativeTextLength(nsIContent* aContent, uint32_t aMaxLe
|
||||
const nsTextFragment* text = aContent->GetText();
|
||||
if (!text)
|
||||
return 0;
|
||||
uint32_t length = NS_MIN(text->GetLength(), aMaxLength);
|
||||
uint32_t length = std::min(text->GetLength(), aMaxLength);
|
||||
return length + textLengthDifference;
|
||||
} else if (IsContentBR(aContent)) {
|
||||
#if defined(XP_WIN)
|
||||
@ -1010,7 +1011,7 @@ static void AdjustRangeForSelection(nsIContent* aRoot,
|
||||
brContent = node->GetChildAt(--offset - 1);
|
||||
}
|
||||
*aNode = node;
|
||||
*aOffset = NS_MAX(offset, 0);
|
||||
*aOffset = std::max(offset, 0);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "nsIDocShellTreeNode.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include <algorithm>
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsXULPopupManager.h"
|
||||
#endif
|
||||
@ -3847,7 +3848,7 @@ nsEventStateManager::SetCursor(int32_t aCursor, imgIContainer* aContainer,
|
||||
aContainer->GetWidth(&imgWidth);
|
||||
aContainer->GetHeight(&imgHeight);
|
||||
|
||||
// XXX NS_MAX(NS_lround(x), 0)?
|
||||
// XXX std::max(NS_lround(x), 0)?
|
||||
hotspotX = aHotspotX > 0.0f
|
||||
? uint32_t(aHotspotX + 0.5f) : uint32_t(0);
|
||||
if (hotspotX >= uint32_t(imgWidth))
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "nsJSUtils.h"
|
||||
#include "AudioSampleFormat.h"
|
||||
#include "AudioChannelCommon.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -166,7 +167,7 @@ nsHTMLAudioElement::MozWriteAudio(const JS::Value& aData, JSContext* aCx, uint32
|
||||
}
|
||||
|
||||
// Don't write more than can be written without blocking.
|
||||
uint32_t writeLen = NS_MIN(mAudioStream->Available(), dataLength / mChannels);
|
||||
uint32_t writeLen = std::min(mAudioStream->Available(), dataLength / mChannels);
|
||||
|
||||
float* frames = JS_GetFloat32ArrayData(tsrc);
|
||||
// Convert the samples back to integers as we are using fixed point audio in
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "nsEventListenerManager.h"
|
||||
|
||||
#include "nsRuleData.h"
|
||||
#include <algorithm>
|
||||
|
||||
// input type=radio
|
||||
#include "nsIRadioGroupContainer.h"
|
||||
@ -1505,10 +1506,10 @@ nsHTMLInputElement::ApplyStep(int32_t aStep)
|
||||
value = max;
|
||||
// If we go down, we want to clamp on min.
|
||||
} else if (aStep < 0 && min == min) {
|
||||
value = NS_MAX(value, min);
|
||||
value = std::max(value, min);
|
||||
// If we go up, we want to clamp on max.
|
||||
} else if (aStep > 0 && max == max) {
|
||||
value = NS_MIN(value, max);
|
||||
value = std::min(value, max);
|
||||
}
|
||||
|
||||
SetValue(value);
|
||||
|
@ -76,6 +76,7 @@
|
||||
#include "nsIPowerManagerService.h"
|
||||
#include <cstdlib> // for std::abs(int/long)
|
||||
#include <cmath> // for std::abs(float/double)
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef MOZ_OGG
|
||||
#include "OggDecoder.h"
|
||||
@ -1312,10 +1313,10 @@ NS_IMETHODIMP nsHTMLMediaElement::SetCurrentTime(double aCurrentTime)
|
||||
}
|
||||
|
||||
// Clamp the time to [0, duration] as required by the spec.
|
||||
double clampedTime = NS_MAX(0.0, aCurrentTime);
|
||||
double clampedTime = std::max(0.0, aCurrentTime);
|
||||
double duration = mDecoder->GetDuration();
|
||||
if (duration >= 0) {
|
||||
clampedTime = NS_MIN(clampedTime, duration);
|
||||
clampedTime = std::min(clampedTime, duration);
|
||||
}
|
||||
|
||||
mPlayingBeforeSeek = IsPotentiallyPlaying();
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "nsAttrValueInlines.h"
|
||||
#include "nsEventStateManager.h"
|
||||
#include "nsAlgorithm.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
@ -174,7 +175,7 @@ nsHTMLMeterElement::GetMax() const
|
||||
max = kDefaultMax;
|
||||
}
|
||||
|
||||
return NS_MAX(max, GetMin());
|
||||
return std::max(max, GetMin());
|
||||
}
|
||||
|
||||
double
|
||||
@ -203,7 +204,7 @@ nsHTMLMeterElement::GetValue() const
|
||||
return min;
|
||||
}
|
||||
|
||||
return NS_MIN(value, GetMax());
|
||||
return std::min(value, GetMax());
|
||||
}
|
||||
|
||||
double
|
||||
@ -231,7 +232,7 @@ nsHTMLMeterElement::GetLow() const
|
||||
return min;
|
||||
}
|
||||
|
||||
return NS_MIN(low, GetMax());
|
||||
return std::min(low, GetMax());
|
||||
}
|
||||
|
||||
double
|
||||
@ -259,7 +260,7 @@ nsHTMLMeterElement::GetHigh() const
|
||||
return max;
|
||||
}
|
||||
|
||||
return NS_MAX(high, GetLow());
|
||||
return std::max(high, GetLow());
|
||||
}
|
||||
|
||||
double
|
||||
@ -292,7 +293,7 @@ nsHTMLMeterElement::GetOptimum() const
|
||||
return min;
|
||||
}
|
||||
|
||||
return NS_MIN(optimum, max);
|
||||
return std::min(optimum, max);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "nsAttrValue.h"
|
||||
#include "nsAttrValueInlines.h"
|
||||
#include "nsEventStateManager.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
@ -133,7 +134,7 @@ nsHTMLProgressElement::GetValue(double* aValue)
|
||||
double max;
|
||||
GetMax(&max);
|
||||
|
||||
*aValue = NS_MIN(*aValue, max);
|
||||
*aValue = std::min(*aValue, max);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include <algorithm>
|
||||
|
||||
#define AUTOMATIC_IMAGE_RESIZING_PREF "browser.enable_automatic_image_resizing"
|
||||
#define CLICK_IMAGE_RESIZING_PREF "browser.enable_click_image_resizing"
|
||||
@ -112,7 +113,7 @@ protected:
|
||||
nsresult ScrollImageTo(int32_t aX, int32_t aY, bool restoreImage);
|
||||
|
||||
float GetRatio() {
|
||||
return NS_MIN((float)mVisibleWidth / mImageWidth,
|
||||
return std::min((float)mVisibleWidth / mImageWidth,
|
||||
(float)mVisibleHeight / mImageHeight);
|
||||
}
|
||||
|
||||
@ -415,8 +416,8 @@ ImageDocument::ShrinkToFit()
|
||||
// Keep image content alive while changing the attributes.
|
||||
nsCOMPtr<nsIContent> imageContent = mImageContent;
|
||||
nsCOMPtr<nsIDOMHTMLImageElement> image = do_QueryInterface(mImageContent);
|
||||
image->SetWidth(NS_MAX(1, NSToCoordFloor(GetRatio() * mImageWidth)));
|
||||
image->SetHeight(NS_MAX(1, NSToCoordFloor(GetRatio() * mImageHeight)));
|
||||
image->SetWidth(std::max(1, NSToCoordFloor(GetRatio() * mImageWidth)));
|
||||
image->SetHeight(std::max(1, NSToCoordFloor(GetRatio() * mImageHeight)));
|
||||
|
||||
// The view might have been scrolled when zooming in, scroll back to the
|
||||
// origin now that we're showing a shrunk-to-window version.
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define MOZILLA_AUDIOSAMPLEFORMAT_H_
|
||||
|
||||
#include "nsAlgorithm.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -74,7 +75,7 @@ template <> inline int16_t
|
||||
FloatToAudioSample<int16_t>(float aValue)
|
||||
{
|
||||
float v = aValue*32768.0f;
|
||||
float clamped = NS_MAX(-32768.0f, NS_MIN(32767.0f, v));
|
||||
float clamped = std::max(-32768.0f, std::min(32767.0f, v));
|
||||
return int16_t(clamped);
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "VideoUtils.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include <algorithm>
|
||||
extern "C" {
|
||||
#include "sydneyaudio/sydney_audio.h"
|
||||
}
|
||||
@ -99,7 +100,7 @@ static int PrefChanged(const char* aPref, void* aClosure)
|
||||
gVolumeScale = 1.0;
|
||||
} else {
|
||||
NS_ConvertUTF16toUTF8 utf8(value);
|
||||
gVolumeScale = NS_MAX<double>(0, PR_strtod(utf8.get(), nullptr));
|
||||
gVolumeScale = std::max<double>(0, PR_strtod(utf8.get(), nullptr));
|
||||
}
|
||||
} else if (strcmp(aPref, PREF_USE_CUBEB) == 0) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
@ -115,7 +116,7 @@ static int PrefChanged(const char* aPref, void* aClosure)
|
||||
// audible.
|
||||
uint32_t value = Preferences::GetUint(aPref, 100);
|
||||
MutexAutoLock lock(*gAudioPrefsLock);
|
||||
gCubebLatency = NS_MIN<uint32_t>(NS_MAX<uint32_t>(value, 20), 1000);
|
||||
gCubebLatency = std::min<uint32_t>(std::max<uint32_t>(value, 20), 1000);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -553,7 +554,7 @@ public:
|
||||
|
||||
uint32_t end = (mStart + mCount) % mCapacity;
|
||||
|
||||
uint32_t toCopy = NS_MIN(mCapacity - end, aLength);
|
||||
uint32_t toCopy = std::min(mCapacity - end, aLength);
|
||||
memcpy(&mBuffer[end], aSrc, toCopy);
|
||||
memcpy(&mBuffer[0], aSrc + toCopy, aLength - toCopy);
|
||||
mCount += aLength;
|
||||
@ -568,7 +569,7 @@ public:
|
||||
NS_ABORT_IF_FALSE(aSize <= Length(), "Request too large.");
|
||||
|
||||
*aData1 = &mBuffer[mStart];
|
||||
*aSize1 = NS_MIN(mCapacity - mStart, aSize);
|
||||
*aSize1 = std::min(mCapacity - mStart, aSize);
|
||||
*aData2 = &mBuffer[0];
|
||||
*aSize2 = aSize - *aSize1;
|
||||
mCount -= *aSize1 + *aSize2;
|
||||
@ -773,7 +774,7 @@ BufferedAudioStream::Write(const AudioDataValue* aBuf, uint32_t aFrames)
|
||||
uint32_t bytesToCopy = FramesToBytes(aFrames);
|
||||
|
||||
while (bytesToCopy > 0) {
|
||||
uint32_t available = NS_MIN(bytesToCopy, mBuffer.Available());
|
||||
uint32_t available = std::min(bytesToCopy, mBuffer.Available());
|
||||
NS_ABORT_IF_FALSE(available % mBytesPerFrame == 0,
|
||||
"Must copy complete frames.");
|
||||
|
||||
@ -922,7 +923,7 @@ BufferedAudioStream::GetPositionInFramesUnlocked()
|
||||
if (position >= mLostFrames) {
|
||||
adjustedPosition = position - mLostFrames;
|
||||
}
|
||||
return NS_MIN<uint64_t>(adjustedPosition, INT64_MAX);
|
||||
return std::min<uint64_t>(adjustedPosition, INT64_MAX);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -945,7 +946,7 @@ BufferedAudioStream::GetUnprocessed(void* aBuffer, long aFrames)
|
||||
wpos += FramesToBytes(flushedFrames);
|
||||
}
|
||||
uint32_t toPopBytes = FramesToBytes(aFrames - flushedFrames);
|
||||
uint32_t available = NS_MIN(toPopBytes, mBuffer.Length());
|
||||
uint32_t available = std::min(toPopBytes, mBuffer.Length());
|
||||
|
||||
void* input[2];
|
||||
uint32_t input_size[2];
|
||||
@ -973,7 +974,7 @@ BufferedAudioStream::GetTimeStretched(void* aBuffer, long aFrames)
|
||||
if (mTimeStretcher->numSamples() <= static_cast<uint32_t>(aFrames)) {
|
||||
void* input[2];
|
||||
uint32_t input_size[2];
|
||||
available = NS_MIN(mBuffer.Length(), toPopBytes);
|
||||
available = std::min(mBuffer.Length(), toPopBytes);
|
||||
if (available != toPopBytes) {
|
||||
lowOnBufferedData = true;
|
||||
}
|
||||
@ -995,7 +996,7 @@ long
|
||||
BufferedAudioStream::DataCallback(void* aBuffer, long aFrames)
|
||||
{
|
||||
MonitorAutoLock mon(mMonitor);
|
||||
uint32_t available = NS_MIN(static_cast<uint32_t>(FramesToBytes(aFrames)), mBuffer.Length());
|
||||
uint32_t available = std::min(static_cast<uint32_t>(FramesToBytes(aFrames)), mBuffer.Length());
|
||||
NS_ABORT_IF_FALSE(available % mBytesPerFrame == 0, "Must copy complete frames");
|
||||
uint32_t underrunFrames = 0;
|
||||
uint32_t servicedFrames = 0;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "mozilla/XPCOM.h"
|
||||
#include "FileBlockCache.h"
|
||||
#include "VideoUtils.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -247,7 +248,7 @@ nsresult FileBlockCache::Read(int64_t aOffset,
|
||||
while (bytesToRead > 0) {
|
||||
int32_t blockIndex = static_cast<int32_t>(offset / BLOCK_SIZE);
|
||||
int32_t start = offset % BLOCK_SIZE;
|
||||
int32_t amount = NS_MIN(BLOCK_SIZE - start, bytesToRead);
|
||||
int32_t amount = std::min(BLOCK_SIZE - start, bytesToRead);
|
||||
|
||||
// If the block is not yet written to file, we can just read from
|
||||
// the memory buffer, otherwise we need to read from file.
|
||||
@ -298,7 +299,7 @@ nsresult FileBlockCache::MoveBlock(int32_t aSourceBlockIndex, int32_t aDestBlock
|
||||
if (!mIsOpen)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mBlockChanges.EnsureLengthAtLeast(NS_MAX(aSourceBlockIndex, aDestBlockIndex) + 1);
|
||||
mBlockChanges.EnsureLengthAtLeast(std::max(aSourceBlockIndex, aDestBlockIndex) + 1);
|
||||
|
||||
// The source block's contents may be the destination of another pending
|
||||
// move, which in turn can be the destination of another pending move,
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "FileBlockCache.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsAnonymousTemporaryFile.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -643,8 +644,8 @@ static int32_t GetMaxBlocks()
|
||||
// Cache size is in KB
|
||||
int32_t cacheSize = Preferences::GetInt("media.cache_size", 500*1024);
|
||||
int64_t maxBlocks = static_cast<int64_t>(cacheSize)*1024/MediaCache::BLOCK_SIZE;
|
||||
maxBlocks = NS_MAX<int64_t>(maxBlocks, 1);
|
||||
return int32_t(NS_MIN<int64_t>(maxBlocks, INT32_MAX));
|
||||
maxBlocks = std::max<int64_t>(maxBlocks, 1);
|
||||
return int32_t(std::min<int64_t>(maxBlocks, INT32_MAX));
|
||||
}
|
||||
|
||||
int32_t
|
||||
@ -720,14 +721,14 @@ MediaCache::FindReusableBlock(TimeStamp aNow,
|
||||
{
|
||||
mReentrantMonitor.AssertCurrentThreadIn();
|
||||
|
||||
uint32_t length = NS_MIN(uint32_t(aMaxSearchBlockIndex), mIndex.Length());
|
||||
uint32_t length = std::min(uint32_t(aMaxSearchBlockIndex), mIndex.Length());
|
||||
|
||||
if (aForStream && aForStreamBlock > 0 &&
|
||||
uint32_t(aForStreamBlock) <= aForStream->mBlocks.Length()) {
|
||||
int32_t prevCacheBlock = aForStream->mBlocks[aForStreamBlock - 1];
|
||||
if (prevCacheBlock >= 0) {
|
||||
uint32_t freeBlockScanEnd =
|
||||
NS_MIN(length, prevCacheBlock + FREE_BLOCK_SCAN_LIMIT);
|
||||
std::min(length, prevCacheBlock + FREE_BLOCK_SCAN_LIMIT);
|
||||
for (uint32_t i = prevCacheBlock; i < freeBlockScanEnd; ++i) {
|
||||
if (IsBlockFree(i))
|
||||
return i;
|
||||
@ -948,7 +949,7 @@ MediaCache::PredictNextUse(TimeStamp aNow, int32_t aBlock)
|
||||
int64_t millisecondsAhead =
|
||||
bytesAhead*1000/bo->mStream->mPlaybackBytesPerSecond;
|
||||
prediction = TimeDuration::FromMilliseconds(
|
||||
NS_MIN<int64_t>(millisecondsAhead, INT32_MAX));
|
||||
std::min<int64_t>(millisecondsAhead, INT32_MAX));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -976,7 +977,7 @@ MediaCache::PredictNextUseForIncomingData(MediaCacheStream* aStream)
|
||||
return TimeDuration(0);
|
||||
int64_t millisecondsAhead = bytesAhead*1000/aStream->mPlaybackBytesPerSecond;
|
||||
return TimeDuration::FromMilliseconds(
|
||||
NS_MIN<int64_t>(millisecondsAhead, INT32_MAX));
|
||||
std::min<int64_t>(millisecondsAhead, INT32_MAX));
|
||||
}
|
||||
|
||||
enum StreamAction { NONE, SEEK, SEEK_AND_RESUME, RESUME, SUSPEND };
|
||||
@ -1026,7 +1027,7 @@ MediaCache::Update()
|
||||
continue;
|
||||
}
|
||||
TimeDuration predictedUse = PredictNextUse(now, blockIndex);
|
||||
latestPredictedUseForOverflow = NS_MAX(latestPredictedUseForOverflow, predictedUse);
|
||||
latestPredictedUseForOverflow = std::max(latestPredictedUseForOverflow, predictedUse);
|
||||
}
|
||||
|
||||
// Now try to move overflowing blocks to the main part of the cache.
|
||||
@ -1562,7 +1563,7 @@ MediaCache::NoteSeek(MediaCacheStream* aStream, int64_t aOldOffset)
|
||||
// be converted.
|
||||
int32_t blockIndex = aOldOffset/BLOCK_SIZE;
|
||||
int32_t endIndex =
|
||||
NS_MIN<int64_t>((aStream->mStreamOffset + BLOCK_SIZE - 1)/BLOCK_SIZE,
|
||||
std::min<int64_t>((aStream->mStreamOffset + BLOCK_SIZE - 1)/BLOCK_SIZE,
|
||||
aStream->mBlocks.Length());
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
while (blockIndex < endIndex) {
|
||||
@ -1582,7 +1583,7 @@ MediaCache::NoteSeek(MediaCacheStream* aStream, int64_t aOldOffset)
|
||||
int32_t blockIndex =
|
||||
(aStream->mStreamOffset + BLOCK_SIZE - 1)/BLOCK_SIZE;
|
||||
int32_t endIndex =
|
||||
NS_MIN<int64_t>((aOldOffset + BLOCK_SIZE - 1)/BLOCK_SIZE,
|
||||
std::min<int64_t>((aOldOffset + BLOCK_SIZE - 1)/BLOCK_SIZE,
|
||||
aStream->mBlocks.Length());
|
||||
while (blockIndex < endIndex) {
|
||||
int32_t cacheBlockIndex = aStream->mBlocks[endIndex - 1];
|
||||
@ -1626,7 +1627,7 @@ MediaCacheStream::NotifyDataStarted(int64_t aOffset)
|
||||
if (mStreamLength >= 0) {
|
||||
// If we started reading at a certain offset, then for sure
|
||||
// the stream is at least that long.
|
||||
mStreamLength = NS_MAX(mStreamLength, mChannelOffset);
|
||||
mStreamLength = std::max(mStreamLength, mChannelOffset);
|
||||
}
|
||||
// Ensure that |mDownloadCancelled| is set to false since we have new data.
|
||||
if (mDownloadCancelled) {
|
||||
@ -1671,7 +1672,7 @@ MediaCacheStream::NotifyDataReceived(int64_t aSize, const char* aData,
|
||||
while (size > 0) {
|
||||
uint32_t blockIndex = mChannelOffset/BLOCK_SIZE;
|
||||
int32_t blockOffset = int32_t(mChannelOffset - blockIndex*BLOCK_SIZE);
|
||||
int32_t chunkSize = NS_MIN<int64_t>(BLOCK_SIZE - blockOffset, size);
|
||||
int32_t chunkSize = std::min<int64_t>(BLOCK_SIZE - blockOffset, size);
|
||||
|
||||
// This gets set to something non-null if we have a whole block
|
||||
// of data to write to the cache
|
||||
@ -1712,7 +1713,7 @@ MediaCacheStream::NotifyDataReceived(int64_t aSize, const char* aData,
|
||||
while (MediaCacheStream* stream = iter.Next()) {
|
||||
if (stream->mStreamLength >= 0) {
|
||||
// The stream is at least as long as what we've read
|
||||
stream->mStreamLength = NS_MAX(stream->mStreamLength, mChannelOffset);
|
||||
stream->mStreamLength = std::max(stream->mStreamLength, mChannelOffset);
|
||||
}
|
||||
stream->mClient->CacheClientNotifyDataReceived();
|
||||
}
|
||||
@ -1972,9 +1973,9 @@ MediaCacheStream::GetCachedDataEndInternal(int64_t aOffset)
|
||||
if (mStreamLength >= 0) {
|
||||
// The last block in the cache may only be partially valid, so limit
|
||||
// the cached range to the stream length
|
||||
result = NS_MIN(result, mStreamLength);
|
||||
result = std::min(result, mStreamLength);
|
||||
}
|
||||
return NS_MAX(result, aOffset);
|
||||
return std::max(result, aOffset);
|
||||
}
|
||||
|
||||
int64_t
|
||||
@ -2103,7 +2104,7 @@ MediaCacheStream::Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
|
||||
uint32_t streamBlock = uint32_t(mStreamOffset/BLOCK_SIZE);
|
||||
uint32_t offsetInStreamBlock =
|
||||
uint32_t(mStreamOffset - streamBlock*BLOCK_SIZE);
|
||||
int64_t size = NS_MIN(aCount - count, BLOCK_SIZE - offsetInStreamBlock);
|
||||
int64_t size = std::min(aCount - count, BLOCK_SIZE - offsetInStreamBlock);
|
||||
|
||||
if (mStreamLength >= 0) {
|
||||
// Don't try to read beyond the end of the stream
|
||||
@ -2112,9 +2113,9 @@ MediaCacheStream::Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
|
||||
// Get out of here and return NS_OK
|
||||
break;
|
||||
}
|
||||
size = NS_MIN(size, bytesRemaining);
|
||||
size = std::min(size, bytesRemaining);
|
||||
// Clamp size until 64-bit file size issues (bug 500784) are fixed.
|
||||
size = NS_MIN(size, int64_t(INT32_MAX));
|
||||
size = std::min(size, int64_t(INT32_MAX));
|
||||
}
|
||||
|
||||
int32_t bytes;
|
||||
@ -2145,7 +2146,7 @@ MediaCacheStream::Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
|
||||
// We can just use the data in mPartialBlockBuffer. In fact we should
|
||||
// use it rather than waiting for the block to fill and land in
|
||||
// the cache.
|
||||
bytes = NS_MIN<int64_t>(size, streamWithPartialBlock->mChannelOffset - mStreamOffset);
|
||||
bytes = std::min<int64_t>(size, streamWithPartialBlock->mChannelOffset - mStreamOffset);
|
||||
memcpy(aBuffer,
|
||||
reinterpret_cast<char*>(streamWithPartialBlock->mPartialBlockBuffer) + offsetInStreamBlock, bytes);
|
||||
if (mCurrentMode == MODE_METADATA) {
|
||||
@ -2213,7 +2214,7 @@ MediaCacheStream::ReadFromCache(char* aBuffer,
|
||||
uint32_t streamBlock = uint32_t(streamOffset/BLOCK_SIZE);
|
||||
uint32_t offsetInStreamBlock =
|
||||
uint32_t(streamOffset - streamBlock*BLOCK_SIZE);
|
||||
int64_t size = NS_MIN<int64_t>(aCount - count, BLOCK_SIZE - offsetInStreamBlock);
|
||||
int64_t size = std::min<int64_t>(aCount - count, BLOCK_SIZE - offsetInStreamBlock);
|
||||
|
||||
if (mStreamLength >= 0) {
|
||||
// Don't try to read beyond the end of the stream
|
||||
@ -2221,9 +2222,9 @@ MediaCacheStream::ReadFromCache(char* aBuffer,
|
||||
if (bytesRemaining <= 0) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
size = NS_MIN(size, bytesRemaining);
|
||||
size = std::min(size, bytesRemaining);
|
||||
// Clamp size until 64-bit file size issues (bug 500784) are fixed.
|
||||
size = NS_MIN(size, int64_t(INT32_MAX));
|
||||
size = std::min(size, int64_t(INT32_MAX));
|
||||
}
|
||||
|
||||
int32_t bytes;
|
||||
@ -2233,7 +2234,7 @@ MediaCacheStream::ReadFromCache(char* aBuffer,
|
||||
// We can just use the data in mPartialBlockBuffer. In fact we should
|
||||
// use it rather than waiting for the block to fill and land in
|
||||
// the cache.
|
||||
bytes = NS_MIN<int64_t>(size, mChannelOffset - streamOffset);
|
||||
bytes = std::min<int64_t>(size, mChannelOffset - streamOffset);
|
||||
memcpy(aBuffer + count,
|
||||
reinterpret_cast<char*>(mPartialBlockBuffer) + offsetInStreamBlock, bytes);
|
||||
} else {
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include <cstdlib> // for std::abs(int/long)
|
||||
#include <cmath> // for std::abs(float/double)
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef MOZ_WMF
|
||||
#include "WMFDecoder.h"
|
||||
@ -899,12 +900,12 @@ void MediaDecoder::UpdatePlaybackRate()
|
||||
uint32_t rate = uint32_t(ComputePlaybackRate(&reliable));
|
||||
if (reliable) {
|
||||
// Avoid passing a zero rate
|
||||
rate = NS_MAX(rate, 1u);
|
||||
rate = std::max(rate, 1u);
|
||||
}
|
||||
else {
|
||||
// Set a minimum rate of 10,000 bytes per second ... sometimes we just
|
||||
// don't have good data
|
||||
rate = NS_MAX(rate, 10000u);
|
||||
rate = std::max(rate, 10000u);
|
||||
}
|
||||
mResource->SetPlaybackRate(rate);
|
||||
}
|
||||
@ -1332,7 +1333,7 @@ void MediaDecoder::MoveLoadsToBackground()
|
||||
void MediaDecoder::UpdatePlaybackOffset(int64_t aOffset)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
|
||||
mPlaybackPosition = NS_MAX(aOffset, mPlaybackPosition);
|
||||
mPlaybackPosition = std::max(aOffset, mPlaybackPosition);
|
||||
}
|
||||
|
||||
bool MediaDecoder::OnStateMachineThread() const
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "mozilla/mozalloc.h"
|
||||
#include "mozilla/StandardInteger.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -420,7 +421,7 @@ VideoData* MediaDecoderReader::FindStartTime(int64_t& aOutStartTime)
|
||||
}
|
||||
}
|
||||
|
||||
int64_t startTime = NS_MIN(videoStartTime, audioStartTime);
|
||||
int64_t startTime = std::min(videoStartTime, audioStartTime);
|
||||
if (startTime != INT64_MAX) {
|
||||
aOutStartTime = startTime;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "prenv.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -626,8 +627,8 @@ void MediaDecoderStateMachine::SendStreamData()
|
||||
mediaStream->EndTrack(TRACK_AUDIO);
|
||||
stream->mHaveSentFinishAudio = true;
|
||||
}
|
||||
minLastAudioPacketTime = NS_MIN(minLastAudioPacketTime, stream->mLastAudioPacketTime);
|
||||
endPosition = NS_MAX(endPosition,
|
||||
minLastAudioPacketTime = std::min(minLastAudioPacketTime, stream->mLastAudioPacketTime);
|
||||
endPosition = std::max(endPosition,
|
||||
TicksToTimeRoundDown(mInfo.mAudioRate, stream->mAudioFramesWritten));
|
||||
}
|
||||
|
||||
@ -672,7 +673,7 @@ void MediaDecoderStateMachine::SendStreamData()
|
||||
mediaStream->EndTrack(TRACK_VIDEO);
|
||||
stream->mHaveSentFinishVideo = true;
|
||||
}
|
||||
endPosition = NS_MAX(endPosition,
|
||||
endPosition = std::max(endPosition,
|
||||
TicksToTimeRoundDown(RATE_VIDEO, stream->mNextVideoTime - stream->mInitialTime));
|
||||
}
|
||||
|
||||
@ -691,7 +692,7 @@ void MediaDecoderStateMachine::SendStreamData()
|
||||
if (mAudioCaptured) {
|
||||
// Discard audio packets that are no longer needed.
|
||||
int64_t audioPacketTimeToDiscard =
|
||||
NS_MIN(minLastAudioPacketTime, mStartTime + mCurrentFrameTime);
|
||||
std::min(minLastAudioPacketTime, mStartTime + mCurrentFrameTime);
|
||||
while (true) {
|
||||
nsAutoPtr<AudioData> a(mReader->AudioQueue().PopFront());
|
||||
if (!a)
|
||||
@ -875,8 +876,8 @@ void MediaDecoderStateMachine::DecodeLoop()
|
||||
!HasLowUndecodedData())
|
||||
{
|
||||
lowAudioThreshold =
|
||||
NS_MIN(THRESHOLD_FACTOR * DurationToUsecs(decodeTime), AMPLE_AUDIO_USECS);
|
||||
ampleAudioThreshold = NS_MAX(THRESHOLD_FACTOR * lowAudioThreshold,
|
||||
std::min(THRESHOLD_FACTOR * DurationToUsecs(decodeTime), AMPLE_AUDIO_USECS);
|
||||
ampleAudioThreshold = std::max(THRESHOLD_FACTOR * lowAudioThreshold,
|
||||
ampleAudioThreshold);
|
||||
LOG(PR_LOG_DEBUG,
|
||||
("Slow video decode, set lowAudioThreshold=%lld ampleAudioThreshold=%lld",
|
||||
@ -1083,7 +1084,7 @@ void MediaDecoderStateMachine::AudioLoop()
|
||||
// we pushed to the audio hardware. We must push silence into the audio
|
||||
// hardware so that the next audio chunk begins playback at the correct
|
||||
// time.
|
||||
missingFrames = NS_MIN<int64_t>(UINT32_MAX, missingFrames.value());
|
||||
missingFrames = std::min<int64_t>(UINT32_MAX, missingFrames.value());
|
||||
LOG(PR_LOG_DEBUG, ("%p Decoder playing %d frames of silence",
|
||||
mDecoder.get(), int32_t(missingFrames.value())));
|
||||
framesWritten = PlaySilence(static_cast<uint32_t>(missingFrames.value()),
|
||||
@ -1137,7 +1138,7 @@ void MediaDecoderStateMachine::AudioLoop()
|
||||
mState != DECODER_STATE_SHUTDOWN)
|
||||
{
|
||||
const int64_t DRAIN_BLOCK_USECS = 100000;
|
||||
Wait(NS_MIN(mAudioEndTime - position, DRAIN_BLOCK_USECS));
|
||||
Wait(std::min(mAudioEndTime - position, DRAIN_BLOCK_USECS));
|
||||
oldPosition = position;
|
||||
position = GetMediaTime();
|
||||
}
|
||||
@ -1181,7 +1182,7 @@ uint32_t MediaDecoderStateMachine::PlaySilence(uint32_t aFrames,
|
||||
NS_ASSERTION(OnAudioThread(), "Only call on audio thread.");
|
||||
NS_ASSERTION(!mAudioStream->IsPaused(), "Don't play when paused");
|
||||
uint32_t maxFrames = SILENCE_BYTES_CHUNK / aChannels / sizeof(AudioDataValue);
|
||||
uint32_t frames = NS_MIN(aFrames, maxFrames);
|
||||
uint32_t frames = std::min(aFrames, maxFrames);
|
||||
WriteSilence(mAudioStream, frames);
|
||||
// Dispatch events to the DOM for the audio just written.
|
||||
mEventManager.QueueWrittenAudioData(nullptr, frames * aChannels,
|
||||
@ -1494,7 +1495,7 @@ void MediaDecoderStateMachine::NotifyDataArrived(const char* aBuffer,
|
||||
double end = 0;
|
||||
buffered.End(length - 1, &end);
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mEndTime = NS_MAX<int64_t>(mEndTime, end * USECS_PER_S);
|
||||
mEndTime = std::max<int64_t>(mEndTime, end * USECS_PER_S);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1528,8 +1529,8 @@ void MediaDecoderStateMachine::Seek(double aTime)
|
||||
// Bound the seek time to be inside the media range.
|
||||
NS_ASSERTION(mStartTime != -1, "Should know start time by now");
|
||||
NS_ASSERTION(mEndTime != -1, "Should know end time by now");
|
||||
mSeekTime = NS_MIN(mSeekTime, mEndTime);
|
||||
mSeekTime = NS_MAX(mStartTime, mSeekTime);
|
||||
mSeekTime = std::min(mSeekTime, mEndTime);
|
||||
mSeekTime = std::max(mStartTime, mSeekTime);
|
||||
mBasePosition = mSeekTime;
|
||||
LOG(PR_LOG_DEBUG, ("%p Changed state to SEEKING (to %f)", mDecoder.get(), aTime));
|
||||
mState = DECODER_STATE_SEEKING;
|
||||
@ -2190,7 +2191,7 @@ nsresult MediaDecoderStateMachine::RunStateMachine()
|
||||
StopAudioThread();
|
||||
if (mDecoder->GetState() == MediaDecoder::PLAY_STATE_PLAYING) {
|
||||
int64_t videoTime = HasVideo() ? mVideoFrameEndTime : 0;
|
||||
int64_t clockTime = NS_MAX(mEndTime, NS_MAX(videoTime, GetAudioClock()));
|
||||
int64_t clockTime = std::max(mEndTime, std::max(videoTime, GetAudioClock()));
|
||||
UpdatePlaybackPosition(clockTime);
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
NS_NewRunnableMethod(mDecoder, &MediaDecoder::PlaybackEnded);
|
||||
@ -2403,7 +2404,7 @@ void MediaDecoderStateMachine::AdvanceFrame()
|
||||
// advance the clock to after the media end time.
|
||||
if (mVideoFrameEndTime != -1 || mAudioEndTime != -1) {
|
||||
// These will be non -1 if we've displayed a video frame, or played an audio frame.
|
||||
clock_time = NS_MIN(clock_time, NS_MAX(mVideoFrameEndTime, mAudioEndTime));
|
||||
clock_time = std::min(clock_time, std::max(mVideoFrameEndTime, mAudioEndTime));
|
||||
if (clock_time > GetMediaTime()) {
|
||||
// Only update the playback position if the clock time is greater
|
||||
// than the previous playback position. The audio clock can
|
||||
@ -2425,7 +2426,7 @@ void MediaDecoderStateMachine::AdvanceFrame()
|
||||
void MediaDecoderStateMachine::Wait(int64_t aUsecs) {
|
||||
NS_ASSERTION(OnAudioThread(), "Only call on the audio thread");
|
||||
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
|
||||
TimeStamp end = TimeStamp::Now() + UsecsToDuration(NS_MAX<int64_t>(USECS_PER_MS, aUsecs));
|
||||
TimeStamp end = TimeStamp::Now() + UsecsToDuration(std::max<int64_t>(USECS_PER_MS, aUsecs));
|
||||
TimeStamp now;
|
||||
while ((now = TimeStamp::Now()) < end &&
|
||||
mState != DECODER_STATE_SHUTDOWN &&
|
||||
@ -2639,7 +2640,7 @@ nsresult MediaDecoderStateMachine::ScheduleStateMachine(int64_t aUsecs) {
|
||||
if (mState == DECODER_STATE_SHUTDOWN) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
aUsecs = NS_MAX<int64_t>(aUsecs, 0);
|
||||
aUsecs = std::max<int64_t>(aUsecs, 0);
|
||||
|
||||
TimeStamp timeout = TimeStamp::Now() + UsecsToDuration(aUsecs);
|
||||
if (!mTimeout.IsNull()) {
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "nsIAsyncVerifyRedirectCallback.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsHostObjectProtocolHandler.h"
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
PRLogModuleInfo* gMediaResourceLog;
|
||||
@ -1308,7 +1309,7 @@ public:
|
||||
MutexAutoLock lock(mLock);
|
||||
|
||||
EnsureSizeInitialized();
|
||||
return NS_MAX(aOffset, mSize);
|
||||
return std::max(aOffset, mSize);
|
||||
}
|
||||
virtual bool IsDataCachedToEndOfResource(int64_t aOffset) { return true; }
|
||||
virtual bool IsSuspendedByCache(MediaResource** aActiveResource)
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define MOZILLA_MEDIASEGMENT_H_
|
||||
|
||||
#include "nsTArray.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -156,7 +157,7 @@ public:
|
||||
return;
|
||||
}
|
||||
if (mChunks[0].IsNull()) {
|
||||
TrackTicks extraToForget = NS_MIN(aDuration, mDuration) - mChunks[0].GetDuration();
|
||||
TrackTicks extraToForget = std::min(aDuration, mDuration) - mChunks[0].GetDuration();
|
||||
if (extraToForget > 0) {
|
||||
RemoveLeading(extraToForget, 1);
|
||||
mChunks[0].mDuration += extraToForget;
|
||||
@ -237,9 +238,9 @@ protected:
|
||||
TrackTicks offset = 0;
|
||||
for (uint32_t i = 0; i < aSource.mChunks.Length() && offset < aEnd; ++i) {
|
||||
const Chunk& c = aSource.mChunks[i];
|
||||
TrackTicks start = NS_MAX(aStart, offset);
|
||||
TrackTicks start = std::max(aStart, offset);
|
||||
TrackTicks nextOffset = offset + c.GetDuration();
|
||||
TrackTicks end = NS_MIN(aEnd, nextOffset);
|
||||
TrackTicks end = std::min(aEnd, nextOffset);
|
||||
if (start < end) {
|
||||
mChunks.AppendElement(c)->SliceTo(start - offset, end - offset);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "TrackUnionStream.h"
|
||||
#include "ImageContainer.h"
|
||||
#include "AudioChannelCommon.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla::layers;
|
||||
using namespace mozilla::dom;
|
||||
@ -519,7 +520,7 @@ MediaStreamGraphImpl::GetDesiredBufferEnd(MediaStream* aStream)
|
||||
{
|
||||
StreamTime current = mCurrentTime - aStream->mBufferStartTime;
|
||||
return current +
|
||||
MillisecondsToMediaTime(NS_MAX(AUDIO_TARGET_MS, VIDEO_TARGET_MS));
|
||||
MillisecondsToMediaTime(std::max(AUDIO_TARGET_MS, VIDEO_TARGET_MS));
|
||||
}
|
||||
|
||||
void
|
||||
@ -691,18 +692,18 @@ MediaStreamGraphImpl::GraphTimeToStreamTime(MediaStream* aStream,
|
||||
NS_ASSERTION(aTime <= mStateComputedTime,
|
||||
"Don't ask about times where we haven't made blocking decisions yet");
|
||||
if (aTime <= mCurrentTime) {
|
||||
return NS_MAX<StreamTime>(0, aTime - aStream->mBufferStartTime);
|
||||
return std::max<StreamTime>(0, aTime - aStream->mBufferStartTime);
|
||||
}
|
||||
GraphTime t = mCurrentTime;
|
||||
StreamTime s = t - aStream->mBufferStartTime;
|
||||
while (t < aTime) {
|
||||
GraphTime end;
|
||||
if (!aStream->mBlocked.GetAt(t, &end)) {
|
||||
s += NS_MIN(aTime, end) - t;
|
||||
s += std::min(aTime, end) - t;
|
||||
}
|
||||
t = end;
|
||||
}
|
||||
return NS_MAX<StreamTime>(0, s);
|
||||
return std::max<StreamTime>(0, s);
|
||||
}
|
||||
|
||||
GraphTime
|
||||
@ -727,7 +728,7 @@ MediaStreamGraphImpl::StreamTimeToGraphTime(MediaStream* aStream,
|
||||
GraphTime end;
|
||||
if (t < mStateComputedTime) {
|
||||
blocked = aStream->mBlocked.GetAt(t, &end);
|
||||
end = NS_MIN(end, mStateComputedTime);
|
||||
end = std::min(end, mStateComputedTime);
|
||||
} else {
|
||||
blocked = false;
|
||||
end = GRAPH_TIME_MAX;
|
||||
@ -739,7 +740,7 @@ MediaStreamGraphImpl::StreamTimeToGraphTime(MediaStream* aStream,
|
||||
// No more stream time to consume at time t, so we're done.
|
||||
break;
|
||||
}
|
||||
MediaTime consume = NS_MIN(end - t, streamAmount);
|
||||
MediaTime consume = std::min(end - t, streamAmount);
|
||||
streamAmount -= consume;
|
||||
t += consume;
|
||||
}
|
||||
@ -806,7 +807,7 @@ MediaStreamGraphImpl::UpdateCurrentTime()
|
||||
GraphTime end;
|
||||
bool blocked = stream->mBlocked.GetAt(t, &end);
|
||||
if (blocked) {
|
||||
blockedTime += NS_MIN(end, nextCurrentTime) - t;
|
||||
blockedTime += std::min(end, nextCurrentTime) - t;
|
||||
}
|
||||
if (blocked != stream->mNotifiedBlocked) {
|
||||
for (uint32_t j = 0; j < stream->mListeners.Length(); ++j) {
|
||||
@ -882,7 +883,7 @@ MediaStreamGraphImpl::WillUnderrun(MediaStream* aStream, GraphTime aTime,
|
||||
return true;
|
||||
}
|
||||
// Reconsider decisions at bufferEnd
|
||||
*aEnd = NS_MIN(*aEnd, bufferEnd);
|
||||
*aEnd = std::min(*aEnd, bufferEnd);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1083,13 +1084,13 @@ MediaStreamGraphImpl::RecomputeBlockingAt(const nsTArray<MediaStream*>& aStreams
|
||||
LOG(PR_LOG_DEBUG, ("MediaStream %p is finished, but not blocked yet (end at %f, with blocking at %f)",
|
||||
stream, MediaTimeToSeconds(stream->GetBufferEnd()),
|
||||
MediaTimeToSeconds(endTime)));
|
||||
*aEnd = NS_MIN(*aEnd, endTime);
|
||||
*aEnd = std::min(*aEnd, endTime);
|
||||
}
|
||||
}
|
||||
|
||||
GraphTime end;
|
||||
bool explicitBlock = stream->mExplicitBlockerCount.GetAt(aTime, &end) > 0;
|
||||
*aEnd = NS_MIN(*aEnd, end);
|
||||
*aEnd = std::min(*aEnd, end);
|
||||
if (explicitBlock) {
|
||||
LOG(PR_LOG_DEBUG, ("MediaStream %p is blocked due to explicit blocker", stream));
|
||||
MarkStreamBlocking(stream);
|
||||
@ -1207,7 +1208,7 @@ MediaStreamGraphImpl::PlayAudio(MediaStream* aStream,
|
||||
while (t < aTo) {
|
||||
GraphTime end;
|
||||
bool blocked = aStream->mBlocked.GetAt(t, &end);
|
||||
end = NS_MIN(end, aTo);
|
||||
end = std::min(end, aTo);
|
||||
|
||||
AudioSegment output;
|
||||
output.InitFrom(*audio);
|
||||
@ -1234,7 +1235,7 @@ MediaStreamGraphImpl::PlayAudio(MediaStream* aStream,
|
||||
// will just be silence, which is fine here. But if endTicks is after
|
||||
// the track end, then 'audio' won't be long enough, so we'll need
|
||||
// to explicitly play silence.
|
||||
TrackTicks sliceEnd = NS_MIN(endTicks, audio->GetDuration());
|
||||
TrackTicks sliceEnd = std::min(endTicks, audio->GetDuration());
|
||||
if (sliceEnd > startTicks) {
|
||||
output.AppendSlice(*audio, startTicks, sliceEnd);
|
||||
}
|
||||
@ -1458,7 +1459,7 @@ MediaStreamGraphImpl::RunThread()
|
||||
int64_t((now - mCurrentTimeStamp).ToMilliseconds());
|
||||
// Make sure timeoutMS doesn't overflow 32 bits by waking up at
|
||||
// least once a minute, if we need to wake up at all
|
||||
timeoutMS = NS_MAX<int64_t>(0, NS_MIN<int64_t>(timeoutMS, 60*1000));
|
||||
timeoutMS = std::max<int64_t>(0, std::min<int64_t>(timeoutMS, 60*1000));
|
||||
timeout = PR_MillisecondsToInterval(uint32_t(timeoutMS));
|
||||
LOG(PR_LOG_DEBUG, ("Waiting for next iteration; at %f, timeout=%f",
|
||||
(now - mInitialTimeStamp).ToSeconds(), timeoutMS/1000.0));
|
||||
@ -2175,7 +2176,7 @@ MediaInputPort::GetNextInputInterval(GraphTime aTime)
|
||||
result.mStart = t;
|
||||
GraphTime sourceEnd;
|
||||
result.mInputIsBlocked = mSource->mBlocked.GetAt(t, &sourceEnd);
|
||||
result.mEnd = NS_MIN(end, sourceEnd);
|
||||
result.mEnd = std::min(end, sourceEnd);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "StreamBuffer.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -14,7 +15,7 @@ StreamBuffer::GetEnd() const
|
||||
for (uint32_t i = 0; i < mTracks.Length(); ++i) {
|
||||
Track* track = mTracks[i];
|
||||
if (!track->IsEnded()) {
|
||||
t = NS_MIN(t, track->GetEndTimeRoundDown());
|
||||
t = std::min(t, track->GetEndTimeRoundDown());
|
||||
}
|
||||
}
|
||||
return t;
|
||||
@ -52,7 +53,7 @@ StreamBuffer::ForgetUpTo(StreamTime aTime)
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
TrackTicks forgetTo = NS_MIN(track->GetEnd() - 1, track->TimeToTicksRoundDown(forget));
|
||||
TrackTicks forgetTo = std::min(track->GetEnd() - 1, track->TimeToTicksRoundDown(forget));
|
||||
track->ForgetUpTo(forgetTo);
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "MediaSegment.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -164,7 +165,7 @@ public:
|
||||
{
|
||||
mSegment->ForgetUpTo(aTime);
|
||||
#ifdef DEBUG
|
||||
mForgottenUpTo = NS_MAX<TrackTicks>(mForgottenUpTo, aTime);
|
||||
mForgottenUpTo = std::max<TrackTicks>(mForgottenUpTo, aTime);
|
||||
#endif
|
||||
}
|
||||
#ifdef DEBUG
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define MOZILLA_TRACKUNIONSTREAM_H_
|
||||
|
||||
#include "MediaStreamGraph.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -117,7 +118,7 @@ protected:
|
||||
{
|
||||
// Use the ID of the source track if we can, otherwise allocate a new
|
||||
// unique ID
|
||||
TrackID id = NS_MAX(mMaxTrackID + 1, aTrack->GetID());
|
||||
TrackID id = std::max(mMaxTrackID + 1, aTrack->GetID());
|
||||
mMaxTrackID = id;
|
||||
|
||||
TrackRate rate = aTrack->GetRate();
|
||||
@ -181,7 +182,7 @@ protected:
|
||||
*aOutputTrackFinished = false;
|
||||
for (GraphTime t = aFrom; t < aTo; t = next) {
|
||||
MediaInputPort::InputInterval interval = map->mInputPort->GetNextInputInterval(t);
|
||||
interval.mEnd = NS_MIN(interval.mEnd, aTo);
|
||||
interval.mEnd = std::min(interval.mEnd, aTo);
|
||||
if (interval.mStart >= interval.mEnd)
|
||||
break;
|
||||
next = interval.mEnd;
|
||||
@ -224,10 +225,10 @@ protected:
|
||||
TrackTicks inputEndTicks = TimeToTicksRoundUp(rate, inputEnd);
|
||||
TrackTicks inputStartTicks = inputEndTicks - ticks;
|
||||
segment->AppendSlice(*aInputTrack->GetSegment(),
|
||||
NS_MIN(inputTrackEndPoint, inputStartTicks),
|
||||
NS_MIN(inputTrackEndPoint, inputEndTicks));
|
||||
std::min(inputTrackEndPoint, inputStartTicks),
|
||||
std::min(inputTrackEndPoint, inputEndTicks));
|
||||
LOG(PR_LOG_DEBUG, ("TrackUnionStream %p appending %lld ticks of input data to track %d",
|
||||
this, (long long)(NS_MIN(inputTrackEndPoint, inputEndTicks) - NS_MIN(inputTrackEndPoint, inputStartTicks)),
|
||||
this, (long long)(std::min(inputTrackEndPoint, inputEndTicks) - std::min(inputTrackEndPoint, inputStartTicks)),
|
||||
outputTrack->GetID()));
|
||||
}
|
||||
for (uint32_t j = 0; j < mListeners.Length(); ++j) {
|
||||
|
@ -127,6 +127,7 @@
|
||||
#include "nsDASHMPDParser.h"
|
||||
#include "DASHRepDecoder.h"
|
||||
#include "DASHDecoder.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -939,7 +940,7 @@ DASHDecoder::PossiblySwitchDecoder(DASHRepDecoder* aRepDecoder)
|
||||
// increase in quality.
|
||||
uint32_t toDecoderIdx = mVideoRepDecoderIdx;
|
||||
if (bestRepIdx > toDecoderIdx) {
|
||||
toDecoderIdx = NS_MIN(toDecoderIdx+1, mVideoRepDecoders.Length()-1);
|
||||
toDecoderIdx = std::min(toDecoderIdx+1, mVideoRepDecoders.Length()-1);
|
||||
} else if (toDecoderIdx < bestRepIdx) {
|
||||
// If the bitrate is too much for the current bandwidth, just use that
|
||||
// stream directly.
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "AbstractMediaDecoder.h"
|
||||
#include "DASHReader.h"
|
||||
#include "DASHDecoder.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -421,7 +422,7 @@ DASHReader::FindStartTime(int64_t& aOutStartTime)
|
||||
}
|
||||
}
|
||||
|
||||
int64_t startTime = NS_MIN(videoStartTime, audioStartTime);
|
||||
int64_t startTime = std::min(videoStartTime, audioStartTime);
|
||||
if (startTime != INT64_MAX) {
|
||||
aOutStartTime = startTime;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "MediaResource.h"
|
||||
#include "DASHRepDecoder.h"
|
||||
#include "WebMReader.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -101,12 +102,12 @@ DASHRepDecoder::Load(MediaResource* aResource,
|
||||
// delta between it and the INIT byte ranges is less than
|
||||
// |SEEK_VS_READ_THRESHOLD|. To get around this, request all metadata bytes
|
||||
// now so |MediaCache| can assume the bytes are en route.
|
||||
int64_t delta = NS_MAX(mIndexByteRange.mStart, mInitByteRange.mStart)
|
||||
- NS_MIN(mIndexByteRange.mEnd, mInitByteRange.mEnd);
|
||||
int64_t delta = std::max(mIndexByteRange.mStart, mInitByteRange.mStart)
|
||||
- std::min(mIndexByteRange.mEnd, mInitByteRange.mEnd);
|
||||
MediaByteRange byteRange;
|
||||
if (delta <= SEEK_VS_READ_THRESHOLD) {
|
||||
byteRange.mStart = NS_MIN(mIndexByteRange.mStart, mInitByteRange.mStart);
|
||||
byteRange.mEnd = NS_MAX(mIndexByteRange.mEnd, mInitByteRange.mEnd);
|
||||
byteRange.mStart = std::min(mIndexByteRange.mStart, mInitByteRange.mStart);
|
||||
byteRange.mEnd = std::max(mIndexByteRange.mEnd, mInitByteRange.mEnd);
|
||||
// Loading everything in one chunk .
|
||||
mMetadataChunkCount = 1;
|
||||
} else {
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "nsTraceRefcnt.h"
|
||||
#include "VideoUtils.h"
|
||||
#include "MediaDecoderReader.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -501,7 +502,7 @@ void TheoraState::ReconstructTheoraGranulepos()
|
||||
// (frame - keyframeno) will overflow the "offset" segment of the
|
||||
// granulepos, so we take "keyframe" to be the max possible offset
|
||||
// frame instead.
|
||||
ogg_int64_t k = NS_MAX(frame - (((ogg_int64_t)1 << shift) - 1), version_3_2_1);
|
||||
ogg_int64_t k = std::max(frame - (((ogg_int64_t)1 << shift) - 1), version_3_2_1);
|
||||
granulepos = (k << shift) + (frame - k);
|
||||
}
|
||||
// Theora 3.2.1+ granulepos store frame number [1..N], so granulepos
|
||||
@ -805,7 +806,7 @@ nsresult VorbisState::ReconstructVorbisGranulepos()
|
||||
}
|
||||
|
||||
mPrevVorbisBlockSize = vorbis_packet_blocksize(&mInfo, last);
|
||||
mPrevVorbisBlockSize = NS_MAX(static_cast<long>(0), mPrevVorbisBlockSize);
|
||||
mPrevVorbisBlockSize = std::max(static_cast<long>(0), mPrevVorbisBlockSize);
|
||||
mGranulepos = last->granulepos;
|
||||
|
||||
return NS_OK;
|
||||
@ -934,7 +935,7 @@ bool OpusState::DecodeHeader(ogg_packet* aPacket)
|
||||
#ifdef MOZ_SAMPLE_TYPE_FLOAT32
|
||||
mGain = static_cast<float>(pow(10,0.05*gain_dB));
|
||||
#else
|
||||
mGain_Q16 = static_cast<int32_t>(NS_MIN(65536*pow(10,0.05*gain_dB)+0.5,
|
||||
mGain_Q16 = static_cast<int32_t>(std::min(65536*pow(10,0.05*gain_dB)+0.5,
|
||||
static_cast<double>(INT32_MAX)));
|
||||
#endif
|
||||
mChannelMapping = aPacket->packet[18];
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "OggReader.h"
|
||||
#include "VideoUtils.h"
|
||||
#include "theora/theoradec.h"
|
||||
#include <algorithm>
|
||||
#ifdef MOZ_OPUS
|
||||
#include "opus/opus.h"
|
||||
extern "C" {
|
||||
@ -455,8 +456,8 @@ nsresult OggReader::DecodeOpus(ogg_packet* aPacket) {
|
||||
// If this is the last packet, perform end trimming.
|
||||
if (aPacket->e_o_s && mOpusState->mPrevPacketGranulepos != -1) {
|
||||
startFrame = mOpusState->mPrevPacketGranulepos;
|
||||
frames = static_cast<int32_t>(NS_MAX(static_cast<int64_t>(0),
|
||||
NS_MIN(endFrame - startFrame,
|
||||
frames = static_cast<int32_t>(std::max(static_cast<int64_t>(0),
|
||||
std::min(endFrame - startFrame,
|
||||
static_cast<int64_t>(frames))));
|
||||
} else {
|
||||
startFrame = endFrame - frames;
|
||||
@ -464,7 +465,7 @@ nsresult OggReader::DecodeOpus(ogg_packet* aPacket) {
|
||||
|
||||
// Trim the initial frames while the decoder is settling.
|
||||
if (mOpusState->mSkip > 0) {
|
||||
int32_t skipFrames = NS_MIN(mOpusState->mSkip, frames);
|
||||
int32_t skipFrames = std::min(mOpusState->mSkip, frames);
|
||||
if (skipFrames == frames) {
|
||||
// discard the whole packet
|
||||
mOpusState->mSkip -= frames;
|
||||
@ -989,20 +990,20 @@ int64_t OggReader::RangeEndTime(int64_t aStartOffset,
|
||||
prevChecksumAfterSeek = checksumAfterSeek;
|
||||
checksumAfterSeek = 0;
|
||||
ogg_sync_reset(&sync.mState);
|
||||
readStartOffset = NS_MAX(static_cast<int64_t>(0), readStartOffset - step);
|
||||
readStartOffset = std::max(static_cast<int64_t>(0), readStartOffset - step);
|
||||
// There's no point reading more than the maximum size of
|
||||
// an Ogg page into data we've previously scanned. Any data
|
||||
// between readLimitOffset and aEndOffset must be garbage
|
||||
// and we can ignore it thereafter.
|
||||
readLimitOffset = NS_MIN(readLimitOffset,
|
||||
readLimitOffset = std::min(readLimitOffset,
|
||||
readStartOffset + maxOggPageSize);
|
||||
readHead = NS_MAX(aStartOffset, readStartOffset);
|
||||
readHead = std::max(aStartOffset, readStartOffset);
|
||||
}
|
||||
|
||||
int64_t limit = NS_MIN(static_cast<int64_t>(UINT32_MAX),
|
||||
int64_t limit = std::min(static_cast<int64_t>(UINT32_MAX),
|
||||
aEndOffset - readHead);
|
||||
limit = NS_MAX(static_cast<int64_t>(0), limit);
|
||||
limit = NS_MIN(limit, static_cast<int64_t>(step));
|
||||
limit = std::max(static_cast<int64_t>(0), limit);
|
||||
limit = std::min(limit, static_cast<int64_t>(step));
|
||||
uint32_t bytesToRead = static_cast<uint32_t>(limit);
|
||||
uint32_t bytesRead = 0;
|
||||
char* buffer = ogg_sync_buffer(&sync.mState, bytesToRead);
|
||||
@ -1278,7 +1279,7 @@ nsresult OggReader::SeekInBufferedRange(int64_t aTarget,
|
||||
int64_t keyframeTime = mTheoraState->StartTime(keyframeGranulepos);
|
||||
SEEK_LOG(PR_LOG_DEBUG, ("Keyframe for %lld is at %lld, seeking back to it",
|
||||
video->mTime, keyframeTime));
|
||||
aAdjustedTarget = NS_MIN(aAdjustedTarget, keyframeTime);
|
||||
aAdjustedTarget = std::min(aAdjustedTarget, keyframeTime);
|
||||
}
|
||||
}
|
||||
if (aAdjustedTarget < aTarget) {
|
||||
@ -1317,9 +1318,9 @@ nsresult OggReader::SeekInUnbuffered(int64_t aTarget,
|
||||
}
|
||||
// Add in the Opus pre-roll if necessary, as well.
|
||||
if (HasAudio() && mOpusState) {
|
||||
keyframeOffsetMs = NS_MAX(keyframeOffsetMs, SEEK_OPUS_PREROLL);
|
||||
keyframeOffsetMs = std::max(keyframeOffsetMs, SEEK_OPUS_PREROLL);
|
||||
}
|
||||
int64_t seekTarget = NS_MAX(aStartTime, aTarget - keyframeOffsetMs);
|
||||
int64_t seekTarget = std::max(aStartTime, aTarget - keyframeOffsetMs);
|
||||
// Minimize the bisection search space using the known timestamps from the
|
||||
// buffered ranges.
|
||||
SeekRange k = SelectSeekRange(aRanges, seekTarget, aStartTime, aEndTime, false);
|
||||
@ -1340,7 +1341,7 @@ nsresult OggReader::Seek(int64_t aTarget,
|
||||
NS_ENSURE_TRUE(resource != nullptr, NS_ERROR_FAILURE);
|
||||
int64_t adjustedTarget = aTarget;
|
||||
if (HasAudio() && mOpusState){
|
||||
adjustedTarget = NS_MAX(aStartTime, aTarget - SEEK_OPUS_PREROLL);
|
||||
adjustedTarget = std::max(aStartTime, aTarget - SEEK_OPUS_PREROLL);
|
||||
}
|
||||
|
||||
if (adjustedTarget == aStartTime) {
|
||||
@ -1418,7 +1419,7 @@ PageSync(MediaResource* aResource,
|
||||
NS_ASSERTION(buffer, "Must have a buffer");
|
||||
|
||||
// Read from the file into the buffer
|
||||
int64_t bytesToRead = NS_MIN(static_cast<int64_t>(PAGE_STEP),
|
||||
int64_t bytesToRead = std::min(static_cast<int64_t>(PAGE_STEP),
|
||||
aEndOffset - readHead);
|
||||
NS_ASSERTION(bytesToRead <= UINT32_MAX, "bytesToRead range check");
|
||||
if (bytesToRead <= 0) {
|
||||
@ -1489,7 +1490,7 @@ nsresult OggReader::SeekBisection(int64_t aTarget,
|
||||
ogg_int64_t endTime = aRange.mTimeEnd;
|
||||
|
||||
ogg_int64_t seekTarget = aTarget;
|
||||
int64_t seekLowerBound = NS_MAX(static_cast<int64_t>(0), aTarget - aFuzz);
|
||||
int64_t seekLowerBound = std::max(static_cast<int64_t>(0), aTarget - aFuzz);
|
||||
int hops = 0;
|
||||
DebugOnly<ogg_int64_t> previousGuess = -1;
|
||||
int backsteps = 0;
|
||||
@ -1536,7 +1537,7 @@ nsresult OggReader::SeekBisection(int64_t aTarget,
|
||||
target = (double)(seekTarget - startTime) / (double)duration;
|
||||
guess = startOffset + startLength +
|
||||
static_cast<ogg_int64_t>((double)interval * target);
|
||||
guess = NS_MIN(guess, endOffset - PAGE_STEP);
|
||||
guess = std::min(guess, endOffset - PAGE_STEP);
|
||||
if (mustBackoff) {
|
||||
// We previously failed to determine the time at the guess offset,
|
||||
// probably because we ran out of data to decode. This usually happens
|
||||
@ -1556,14 +1557,14 @@ nsresult OggReader::SeekBisection(int64_t aTarget,
|
||||
break;
|
||||
}
|
||||
|
||||
backsteps = NS_MIN(backsteps + 1, maxBackStep);
|
||||
backsteps = std::min(backsteps + 1, maxBackStep);
|
||||
// We reset mustBackoff. If we still need to backoff further, it will
|
||||
// be set to true again.
|
||||
mustBackoff = false;
|
||||
} else {
|
||||
backsteps = 0;
|
||||
}
|
||||
guess = NS_MAX(guess, startOffset + startLength);
|
||||
guess = std::max(guess, startOffset + startLength);
|
||||
|
||||
SEEK_LOG(PR_LOG_DEBUG, ("Seek loop start[o=%lld..%lld t=%lld] "
|
||||
"end[o=%lld t=%lld] "
|
||||
@ -1674,7 +1675,7 @@ nsresult OggReader::SeekBisection(int64_t aTarget,
|
||||
|
||||
// We've found appropriate time stamps here. Proceed to bisect
|
||||
// the search space.
|
||||
granuleTime = NS_MAX(audioTime, videoTime);
|
||||
granuleTime = std::max(audioTime, videoTime);
|
||||
NS_ASSERTION(granuleTime > 0, "Must get a granuletime");
|
||||
break;
|
||||
} // End of "until we determine time at guess offset" loop.
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "mozilla/StandardInteger.h"
|
||||
#include "mozilla/Util.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -198,7 +199,7 @@ bool WaveReader::DecodeAudioData()
|
||||
NS_ASSERTION(remaining >= 0, "Current wave position is greater than wave file length");
|
||||
|
||||
static const int64_t BLOCK_SIZE = 4096;
|
||||
int64_t readSize = NS_MIN(BLOCK_SIZE, remaining);
|
||||
int64_t readSize = std::min(BLOCK_SIZE, remaining);
|
||||
int64_t frames = readSize / mFrameSize;
|
||||
|
||||
PR_STATIC_ASSERT(uint64_t(BLOCK_SIZE) < UINT_MAX / sizeof(AudioDataValue) / MAX_CHANNELS);
|
||||
@ -262,7 +263,7 @@ nsresult WaveReader::Seek(int64_t aTarget, int64_t aStartTime, int64_t aEndTime,
|
||||
double d = BytesToTime(GetDataLength());
|
||||
NS_ASSERTION(d < INT64_MAX / USECS_PER_S, "Duration overflow");
|
||||
int64_t duration = static_cast<int64_t>(d * USECS_PER_S);
|
||||
double seekTime = NS_MIN(aTarget, duration) / static_cast<double>(USECS_PER_S);
|
||||
double seekTime = std::min(aTarget, duration) / static_cast<double>(USECS_PER_S);
|
||||
int64_t position = RoundDownToFrame(static_cast<int64_t>(TimeToBytes(seekTime)));
|
||||
NS_ASSERTION(INT64_MAX - mWavePCMOffset > position, "Integer overflow during wave seek");
|
||||
position += mWavePCMOffset;
|
||||
@ -494,8 +495,8 @@ WaveReader::GetDataLength()
|
||||
// the content length rather than the expected PCM data length.
|
||||
int64_t streamLength = mDecoder->GetResource()->GetLength();
|
||||
if (streamLength >= 0) {
|
||||
int64_t dataLength = NS_MAX<int64_t>(0, streamLength - mWavePCMOffset);
|
||||
length = NS_MIN(dataLength, length);
|
||||
int64_t dataLength = std::max<int64_t>(0, streamLength - mWavePCMOffset);
|
||||
length = std::min(dataLength, length);
|
||||
}
|
||||
return length;
|
||||
}
|
||||
@ -664,7 +665,7 @@ WaveReader::LoadAllChunks(nsAutoPtr<nsHTMLMediaElement::MetadataTags> &aTags)
|
||||
PR_STATIC_ASSERT(uint64_t(MAX_CHUNK_SIZE) < UINT_MAX / sizeof(char));
|
||||
nsAutoArrayPtr<char> chunk(new char[MAX_CHUNK_SIZE]);
|
||||
while (forward.value() > 0) {
|
||||
int64_t size = NS_MIN(forward.value(), MAX_CHUNK_SIZE);
|
||||
int64_t size = std::min(forward.value(), MAX_CHUNK_SIZE);
|
||||
if (!ReadAll(chunk.get(), size)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "WebMBufferedParser.h"
|
||||
#include "nsTimeRanges.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -158,7 +159,7 @@ void WebMBufferedParser::Append(const unsigned char* aBuffer, uint32_t aLength,
|
||||
case SKIP_DATA:
|
||||
if (mSkipBytes) {
|
||||
uint32_t left = aLength - (p - aBuffer);
|
||||
left = NS_MIN(left, mSkipBytes);
|
||||
left = std::min(left, mSkipBytes);
|
||||
p += left;
|
||||
mSkipBytes -= left;
|
||||
} else {
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "nsISMILAnimationElement.h"
|
||||
#include "nsIDOMSVGAnimationElement.h"
|
||||
#include "nsSMILTimedElement.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -118,7 +119,7 @@ nsSMILAnimationController::WillRefresh(mozilla::TimeStamp aTime)
|
||||
// doing so we get sampled by a refresh driver whose most recent refresh time
|
||||
// predates when we were initialised, so to be safe we make sure to take the
|
||||
// most recent time here.
|
||||
aTime = NS_MAX(mCurrentSampleTime, aTime);
|
||||
aTime = std::max(mCurrentSampleTime, aTime);
|
||||
|
||||
// Sleep detection: If the time between samples is a whole lot greater than we
|
||||
// were expecting then we assume the computer went to sleep or someone's
|
||||
@ -562,7 +563,7 @@ nsSMILAnimationController::DoMilestoneSamples()
|
||||
// Because we're only performing this clamping at the last moment, the
|
||||
// animations will still all get sampled in the correct order and
|
||||
// dependencies will be appropriately resolved.
|
||||
sampleTime = NS_MAX(nextMilestone.mTime, sampleTime);
|
||||
sampleTime = std::max(nextMilestone.mTime, sampleTime);
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
nsISMILAnimationElement* elem = params.mElements[i].get();
|
||||
@ -579,7 +580,7 @@ nsSMILAnimationController::DoMilestoneSamples()
|
||||
continue;
|
||||
|
||||
// Clamp the converted container time to non-negative values.
|
||||
nsSMILTime containerTime = NS_MAX<nsSMILTime>(0, containerTimeValue.GetMillis());
|
||||
nsSMILTime containerTime = std::max<nsSMILTime>(0, containerTimeValue.GetMillis());
|
||||
|
||||
if (nextMilestone.mIsEnd) {
|
||||
elem->TimedElement().SampleEndAt(containerTime);
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsString.h"
|
||||
#include <math.h>
|
||||
#include <algorithm>
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Static members
|
||||
@ -554,7 +555,7 @@ nsSMILAnimationFunction::ComputePacedPosition(const nsSMILValueArray& aValues,
|
||||
|
||||
NS_ASSERTION(curIntervalDist >= 0, "distance values must be non-negative");
|
||||
// Clamp distance value at 0, just in case ComputeDistance is evil.
|
||||
curIntervalDist = NS_MAX(curIntervalDist, 0.0);
|
||||
curIntervalDist = std::max(curIntervalDist, 0.0);
|
||||
|
||||
if (remainingDist >= curIntervalDist) {
|
||||
remainingDist -= curIntervalDist;
|
||||
@ -605,7 +606,7 @@ nsSMILAnimationFunction::ComputePacedTotalDistance(
|
||||
// Clamp distance value to 0, just in case we have an evil ComputeDistance
|
||||
// implementation somewhere
|
||||
NS_ABORT_IF_FALSE(tmpDist >= 0.0f, "distance values must be non-negative");
|
||||
tmpDist = NS_MAX(tmpDist, 0.0);
|
||||
tmpDist = std::max(tmpDist, 0.0);
|
||||
|
||||
totalDistance += tmpDist;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "nsSMILTimeContainer.h"
|
||||
#include "nsSMILTimeValue.h"
|
||||
#include "nsSMILTimedElement.h"
|
||||
#include <algorithm>
|
||||
|
||||
nsSMILTimeContainer::nsSMILTimeContainer()
|
||||
:
|
||||
@ -117,7 +118,7 @@ nsSMILTimeContainer::SetCurrentTime(nsSMILTime aSeekTo)
|
||||
{
|
||||
// SVG 1.1 doesn't specify what to do for negative times so we adopt SVGT1.2's
|
||||
// behaviour of clamping negative times to 0.
|
||||
aSeekTo = NS_MAX<nsSMILTime>(0, aSeekTo);
|
||||
aSeekTo = std::max<nsSMILTime>(0, aSeekTo);
|
||||
|
||||
// The following behaviour is consistent with:
|
||||
// http://www.w3.org/2003/01/REC-SVG11-20030114-errata
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "nsString.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -1822,7 +1823,7 @@ nsSMILTimedElement::CalcActiveEnd(const nsSMILTimeValue& aBegin,
|
||||
nsSMILTime activeDur = aEnd.GetMillis() - aBegin.GetMillis();
|
||||
|
||||
if (result.IsDefinite()) {
|
||||
result.SetMillis(NS_MIN(result.GetMillis(), activeDur));
|
||||
result.SetMillis(std::min(result.GetMillis(), activeDur));
|
||||
} else {
|
||||
result.SetMillis(activeDur);
|
||||
}
|
||||
@ -1847,7 +1848,7 @@ nsSMILTimedElement::GetRepeatDuration() const
|
||||
if (mSimpleDur.IsDefinite()) {
|
||||
nsSMILTime activeDur =
|
||||
nsSMILTime(mRepeatCount * double(mSimpleDur.GetMillis()));
|
||||
result.SetMillis(NS_MIN(activeDur, mRepeatDur.GetMillis()));
|
||||
result.SetMillis(std::min(activeDur, mRepeatDur.GetMillis()));
|
||||
} else {
|
||||
result = mRepeatDur;
|
||||
}
|
||||
@ -2186,7 +2187,7 @@ nsSMILTimedElement::GetNextMilestone(nsSMILMilestone& aNextMilestone) const
|
||||
(mCurrentRepeatIteration + 1) * mSimpleDur.GetMillis());
|
||||
}
|
||||
nsSMILTimeValue nextMilestone =
|
||||
NS_MIN(mCurrentInterval->End()->Time(), nextRepeat);
|
||||
std::min(mCurrentInterval->End()->Time(), nextRepeat);
|
||||
|
||||
// Check for an early end before that time
|
||||
nsSMILInstanceTime* earlyEnd = CheckForEarlyEnd(nextMilestone);
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/dom/SVGLengthListBinding.h"
|
||||
#include <algorithm>
|
||||
|
||||
// See the comment in this file's header.
|
||||
|
||||
@ -200,7 +201,7 @@ DOMSVGLengthList::InsertItemBefore(nsIDOMSVGLength *newItem,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
index = NS_MIN(index, LengthNoFlush());
|
||||
index = std::min(index, LengthNoFlush());
|
||||
if (index >= DOMSVGLength::MaxListIndex()) {
|
||||
error.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
return nullptr;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/dom/SVGNumberListBinding.h"
|
||||
#include <algorithm>
|
||||
|
||||
// See the comment in this file's header.
|
||||
|
||||
@ -198,7 +199,7 @@ DOMSVGNumberList::InsertItemBefore(nsIDOMSVGNumber *newItem,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
index = NS_MIN(index, LengthNoFlush());
|
||||
index = std::min(index, LengthNoFlush());
|
||||
if (index >= DOMSVGNumber::MaxListIndex()) {
|
||||
error.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
return nullptr;
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "nsSVGAttrTearoffTable.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/dom/SVGPointListBinding.h"
|
||||
#include <algorithm>
|
||||
|
||||
// See the comment in this file's header.
|
||||
|
||||
@ -253,7 +254,7 @@ DOMSVGPointList::InsertItemBefore(nsISVGPoint& aNewItem, uint32_t aIndex,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
aIndex = NS_MIN(aIndex, LengthNoFlush());
|
||||
aIndex = std::min(aIndex, LengthNoFlush());
|
||||
if (aIndex >= DOMSVGPoint::MaxListIndex()) {
|
||||
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
return nullptr;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "nsError.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsSVGAttrTearoffTable.h"
|
||||
#include <algorithm>
|
||||
|
||||
// See the architecture comment in this file's header.
|
||||
|
||||
@ -114,7 +115,7 @@ DOMSVGStringList::InsertItemBefore(const nsAString & newItem,
|
||||
if (newItem.IsEmpty()) { // takes care of DOMStringIsNull too
|
||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
}
|
||||
index = NS_MIN(index, InternalList().Length());
|
||||
index = std::min(index, InternalList().Length());
|
||||
|
||||
// Ensure we have enough memory so we can avoid complex error handling below:
|
||||
if (!InternalList().SetCapacity(InternalList().Length() + 1)) {
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/dom/SVGTransformListBinding.h"
|
||||
#include "nsError.h"
|
||||
#include <algorithm>
|
||||
|
||||
// local helper functions
|
||||
namespace {
|
||||
@ -197,7 +198,7 @@ DOMSVGTransformList::InsertItemBefore(DOMSVGTransform& newItem,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
index = NS_MIN(index, LengthNoFlush());
|
||||
index = std::min(index, LengthNoFlush());
|
||||
if (index >= DOMSVGTransform::MaxListIndex()) {
|
||||
error.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
return nullptr;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "nsMathUtils.h"
|
||||
#include "SVGContentUtils.h"
|
||||
#include <limits>
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -193,7 +194,7 @@ SVGLength::GetUserUnitsPerPercent(const nsSVGElement *aElement, uint8_t aAxis)
|
||||
if (aElement) {
|
||||
dom::SVGSVGElement *viewportElement = aElement->GetCtx();
|
||||
if (viewportElement) {
|
||||
return NS_MAX(viewportElement->GetLength(aAxis) / 100.0f, 0.0f);
|
||||
return std::max(viewportElement->GetLength(aAxis) / 100.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
return std::numeric_limits<float>::quiet_NaN();
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "SVGLengthList.h"
|
||||
#include "nsMathUtils.h"
|
||||
#include <math.h>
|
||||
#include <algorithm>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -267,7 +268,7 @@ SVGLengthListSMILType::Interpolate(const nsSMILValue& aStartVal,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!result.SetLength(NS_MAX(start.Length(), end.Length()))) {
|
||||
if (!result.SetLength(std::max(start.Length(), end.Length()))) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <stdarg.h>
|
||||
#include "SVGContentUtils.h"
|
||||
#include "SVGPathSegUtils.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -199,7 +200,7 @@ SVGPathData::GetPathSegAtLength(float aDistance) const
|
||||
|
||||
NS_ABORT_IF_FALSE(i == mData.Length(), "Very, very bad - mData corrupt");
|
||||
|
||||
return NS_MAX(0U, segIndex - 1); // -1 because while loop takes us 1 too far
|
||||
return std::max(0U, segIndex - 1); // -1 because while loop takes us 1 too far
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "mozilla/dom/SVGPathElement.h"
|
||||
#include "DOMSVGPoint.h"
|
||||
#include "gfxContext.h"
|
||||
#include <algorithm>
|
||||
|
||||
DOMCI_NODE_DATA(SVGPathElement, mozilla::dom::SVGPathElement)
|
||||
|
||||
@ -94,8 +95,8 @@ SVGPathElement::GetPointAtLength(float distance, nsISupports **_retval)
|
||||
}
|
||||
distance *= totalLength / pathLength;
|
||||
}
|
||||
distance = NS_MAX(0.f, distance);
|
||||
distance = NS_MIN(totalLength, distance);
|
||||
distance = std::max(0.f, distance);
|
||||
distance = std::min(totalLength, distance);
|
||||
|
||||
NS_ADDREF(*_retval = new DOMSVGPoint(flat->FindPoint(gfxPoint(distance, 0))));
|
||||
return NS_OK;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "nsGkAtoms.h"
|
||||
#include "gfxContext.h"
|
||||
#include "mozilla/dom/SVGRectElementBinding.h"
|
||||
#include <algorithm>
|
||||
|
||||
DOMCI_NODE_DATA(SVGRectElement, mozilla::dom::SVGRectElement)
|
||||
|
||||
@ -173,8 +174,8 @@ SVGRectElement::ConstructPath(gfxContext *aCtx)
|
||||
if (width <= 0 || height <= 0)
|
||||
return;
|
||||
|
||||
rx = NS_MAX(rx, 0.0f);
|
||||
ry = NS_MAX(ry, 0.0f);
|
||||
rx = std::max(rx, 0.0f);
|
||||
ry = std::max(ry, 0.0f);
|
||||
|
||||
/* optimize the no rounded corners case */
|
||||
if (rx == 0 && ry == 0) {
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "nsSMILTypes.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "SVGAngle.h"
|
||||
#include <algorithm>
|
||||
|
||||
DOMCI_NODE_DATA(SVGSVGElement, mozilla::dom::SVGSVGElement)
|
||||
|
||||
@ -1212,8 +1213,8 @@ SVGSVGElement::GetLength(uint8_t aCtxType)
|
||||
h = mViewportHeight;
|
||||
}
|
||||
|
||||
w = NS_MAX(w, 0.0f);
|
||||
h = NS_MAX(h, 0.0f);
|
||||
w = std::max(w, 0.0f);
|
||||
h = std::max(h, 0.0f);
|
||||
|
||||
switch (aCtxType) {
|
||||
case SVGContentUtils::X:
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "nsSVGEffects.h"
|
||||
#include "gfxUtils.h"
|
||||
#include "SVGContentUtils.h"
|
||||
#include <algorithm>
|
||||
|
||||
#if defined(XP_WIN)
|
||||
// Prevent Windows redefining LoadImage
|
||||
@ -500,8 +501,8 @@ BoxBlur(const uint8_t *aInput, uint8_t *aOutput,
|
||||
|
||||
for (int32_t i=0; i < boxSize; i++) {
|
||||
int32_t pos = aStartMinor - aLeftLobe + i;
|
||||
pos = NS_MAX(pos, aStartMinor);
|
||||
pos = NS_MIN(pos, aEndMinor - 1);
|
||||
pos = std::max(pos, aStartMinor);
|
||||
pos = std::min(pos, aEndMinor - 1);
|
||||
#define SUM(j) sums[j] += aInput[aStrideMinor*pos + j];
|
||||
SUM(0); SUM(1); SUM(2); SUM(3);
|
||||
#undef SUM
|
||||
@ -556,8 +557,8 @@ BoxBlur(const uint8_t *aInput, uint8_t *aOutput,
|
||||
} else {
|
||||
for (int32_t minor = aStartMinor; minor < aEndMinor; minor++) {
|
||||
int32_t tmp = minor - aLeftLobe;
|
||||
int32_t last = NS_MAX(tmp, aStartMinor);
|
||||
int32_t next = NS_MIN(tmp + int32_t(boxSize), aEndMinor - 1);
|
||||
int32_t last = std::max(tmp, aStartMinor);
|
||||
int32_t next = std::min(tmp + int32_t(boxSize), aEndMinor - 1);
|
||||
|
||||
OUTPUT_PIXEL();
|
||||
#define SUM(j) sums[j] += aInput[aStrideMinor*next + j] - \
|
||||
@ -945,8 +946,8 @@ nsSVGFEBlendElement::Filter(nsSVGFilterInstance* aInstance,
|
||||
uint32_t targIndex = y * stride + 4 * x;
|
||||
uint32_t qa = targetData[targIndex + GFX_ARGB32_OFFSET_A];
|
||||
uint32_t qb = sourceData[targIndex + GFX_ARGB32_OFFSET_A];
|
||||
for (int32_t i = NS_MIN(GFX_ARGB32_OFFSET_B, GFX_ARGB32_OFFSET_R);
|
||||
i <= NS_MAX(GFX_ARGB32_OFFSET_B, GFX_ARGB32_OFFSET_R); i++) {
|
||||
for (int32_t i = std::min(GFX_ARGB32_OFFSET_B, GFX_ARGB32_OFFSET_R);
|
||||
i <= std::max(GFX_ARGB32_OFFSET_B, GFX_ARGB32_OFFSET_R); i++) {
|
||||
uint32_t ca = targetData[targIndex + i];
|
||||
uint32_t cb = sourceData[targIndex + i];
|
||||
uint32_t val;
|
||||
@ -961,18 +962,18 @@ nsSVGFEBlendElement::Filter(nsSVGFilterInstance* aInstance,
|
||||
val = 255 * (cb + ca) - ca * cb;
|
||||
break;
|
||||
case nsSVGFEBlendElement::SVG_MODE_DARKEN:
|
||||
val = NS_MIN((255 - qa) * cb + 255 * ca,
|
||||
val = std::min((255 - qa) * cb + 255 * ca,
|
||||
(255 - qb) * ca + 255 * cb);
|
||||
break;
|
||||
case nsSVGFEBlendElement::SVG_MODE_LIGHTEN:
|
||||
val = NS_MAX((255 - qa) * cb + 255 * ca,
|
||||
val = std::max((255 - qa) * cb + 255 * ca,
|
||||
(255 - qb) * ca + 255 * cb);
|
||||
break;
|
||||
default:
|
||||
return NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
val = NS_MIN(val / 255, 255U);
|
||||
val = std::min(val / 255, 255U);
|
||||
targetData[targIndex + i] = static_cast<uint8_t>(val);
|
||||
}
|
||||
uint32_t alpha = 255 * 255 - (255 - qa) * (255 - qb);
|
||||
@ -1997,11 +1998,11 @@ nsSVGComponentTransferFunctionElement::GenerateLookupTable(uint8_t *aTable)
|
||||
for (i = 0; i < 256; i++) {
|
||||
uint32_t k = (i * (tvLength - 1)) / 255;
|
||||
float v1 = tableValues[k];
|
||||
float v2 = tableValues[NS_MIN(k + 1, tvLength - 1)];
|
||||
float v2 = tableValues[std::min(k + 1, tvLength - 1)];
|
||||
int32_t val =
|
||||
int32_t(255 * (v1 + (i/255.0f - k/float(tvLength-1))*(tvLength - 1)*(v2 - v1)));
|
||||
val = NS_MIN(255, val);
|
||||
val = NS_MAX(0, val);
|
||||
val = std::min(255, val);
|
||||
val = std::max(0, val);
|
||||
aTable[i] = val;
|
||||
}
|
||||
break;
|
||||
@ -2014,11 +2015,11 @@ nsSVGComponentTransferFunctionElement::GenerateLookupTable(uint8_t *aTable)
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
uint32_t k = (i * tvLength) / 255;
|
||||
k = NS_MIN(k, tvLength - 1);
|
||||
k = std::min(k, tvLength - 1);
|
||||
float v = tableValues[k];
|
||||
int32_t val = int32_t(255 * v);
|
||||
val = NS_MIN(255, val);
|
||||
val = NS_MAX(0, val);
|
||||
val = std::min(255, val);
|
||||
val = std::max(0, val);
|
||||
aTable[i] = val;
|
||||
}
|
||||
break;
|
||||
@ -2028,8 +2029,8 @@ nsSVGComponentTransferFunctionElement::GenerateLookupTable(uint8_t *aTable)
|
||||
{
|
||||
for (i = 0; i < 256; i++) {
|
||||
int32_t val = int32_t(slope * i + 255 * intercept);
|
||||
val = NS_MIN(255, val);
|
||||
val = NS_MAX(0, val);
|
||||
val = std::min(255, val);
|
||||
val = std::max(0, val);
|
||||
aTable[i] = val;
|
||||
}
|
||||
break;
|
||||
@ -2039,8 +2040,8 @@ nsSVGComponentTransferFunctionElement::GenerateLookupTable(uint8_t *aTable)
|
||||
{
|
||||
for (i = 0; i < 256; i++) {
|
||||
int32_t val = int32_t(255 * (amplitude * pow(i / 255.0f, exponent) + offset));
|
||||
val = NS_MIN(255, val);
|
||||
val = NS_MAX(0, val);
|
||||
val = std::min(255, val);
|
||||
val = std::max(0, val);
|
||||
aTable[i] = val;
|
||||
}
|
||||
break;
|
||||
@ -3356,8 +3357,8 @@ nsSVGFETurbulenceElement::Filter(nsSVGFilterInstance *instance,
|
||||
doStitch, filterX, filterY, filterWidth, filterHeight) * 255 + 255) / 2;
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
col[i] = NS_MIN(col[i], 255.f);
|
||||
col[i] = NS_MAX(col[i], 0.f);
|
||||
col[i] = std::min(col[i], 255.f);
|
||||
col[i] = std::max(col[i], 0.f);
|
||||
}
|
||||
|
||||
uint8_t r, g, b, a;
|
||||
@ -3757,7 +3758,7 @@ nsSVGFEMorphologyElement::InflateRect(const nsIntRect& aRect,
|
||||
int32_t rx, ry;
|
||||
GetRXY(&rx, &ry, aInstance);
|
||||
nsIntRect result = aRect;
|
||||
result.Inflate(NS_MAX(0, rx), NS_MAX(0, ry));
|
||||
result.Inflate(std::max(0, rx), std::max(0, ry));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -3820,8 +3821,8 @@ nsSVGFEMorphologyElement::Filter(nsSVGFilterInstance *instance,
|
||||
}
|
||||
|
||||
// Clamp radii to prevent completely insane values:
|
||||
rx = NS_MIN(rx, 100000);
|
||||
ry = NS_MIN(ry, 100000);
|
||||
rx = std::min(rx, 100000);
|
||||
ry = std::min(ry, 100000);
|
||||
|
||||
uint8_t* sourceData = aSources[0]->mImage->Data();
|
||||
uint8_t* targetData = aTarget->mImage->Data();
|
||||
@ -3831,14 +3832,14 @@ nsSVGFEMorphologyElement::Filter(nsSVGFilterInstance *instance,
|
||||
|
||||
// Scan the kernel for each pixel to determine max/min RGBA values.
|
||||
for (int32_t y = rect.y; y < rect.YMost(); y++) {
|
||||
int32_t startY = NS_MAX(0, y - ry);
|
||||
int32_t startY = std::max(0, y - ry);
|
||||
// We need to read pixels not just in 'rect', which is limited to
|
||||
// the dirty part of our filter primitive subregion, but all pixels in
|
||||
// the given radii from the source surface, so use the surface size here.
|
||||
int32_t endY = NS_MIN(y + ry, instance->GetSurfaceHeight() - 1);
|
||||
int32_t endY = std::min(y + ry, instance->GetSurfaceHeight() - 1);
|
||||
for (int32_t x = rect.x; x < rect.XMost(); x++) {
|
||||
int32_t startX = NS_MAX(0, x - rx);
|
||||
int32_t endX = NS_MIN(x + rx, instance->GetSurfaceWidth() - 1);
|
||||
int32_t startX = std::max(0, x - rx);
|
||||
int32_t endX = std::min(x + rx, instance->GetSurfaceWidth() - 1);
|
||||
int32_t targIndex = y * stride + 4 * x;
|
||||
|
||||
for (int32_t i = 0; i < 4; i++) {
|
||||
@ -4183,8 +4184,8 @@ nsSVGFEConvolveMatrixElement::ComputeChangeBBox(const nsTArray<nsIntRect>& aSour
|
||||
|
||||
static int32_t BoundInterval(int32_t aVal, int32_t aMax)
|
||||
{
|
||||
aVal = NS_MAX(aVal, 0);
|
||||
return NS_MIN(aVal, aMax - 1);
|
||||
aVal = std::max(aVal, 0);
|
||||
return std::min(aVal, aMax - 1);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -5083,7 +5084,7 @@ nsSVGFELightingElement::Filter(nsSVGFilterInstance *instance,
|
||||
|
||||
if (spot->mNumberAttributes[nsSVGFESpotLightElement::LIMITING_CONE_ANGLE].
|
||||
IsExplicitlySet()) {
|
||||
cosConeAngle = NS_MAX<double>(cos(limitingConeAngle * radPerDeg), 0.0);
|
||||
cosConeAngle = std::max<double>(cos(limitingConeAngle * radPerDeg), 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5301,11 +5302,11 @@ nsSVGFEDiffuseLightingElement::LightPixel(const float *N, const float *L,
|
||||
if (diffuseNL < 0) diffuseNL = 0;
|
||||
|
||||
targetData[GFX_ARGB32_OFFSET_B] =
|
||||
NS_MIN(uint32_t(diffuseNL * NS_GET_B(color)), 255U);
|
||||
std::min(uint32_t(diffuseNL * NS_GET_B(color)), 255U);
|
||||
targetData[GFX_ARGB32_OFFSET_G] =
|
||||
NS_MIN(uint32_t(diffuseNL * NS_GET_G(color)), 255U);
|
||||
std::min(uint32_t(diffuseNL * NS_GET_G(color)), 255U);
|
||||
targetData[GFX_ARGB32_OFFSET_R] =
|
||||
NS_MIN(uint32_t(diffuseNL * NS_GET_R(color)), 255U);
|
||||
std::min(uint32_t(diffuseNL * NS_GET_R(color)), 255U);
|
||||
targetData[GFX_ARGB32_OFFSET_A] = 255;
|
||||
}
|
||||
|
||||
@ -5470,15 +5471,15 @@ nsSVGFESpecularLightingElement::LightPixel(const float *N, const float *L,
|
||||
kS * pow(dotNH, mNumberAttributes[SPECULAR_EXPONENT].GetAnimValue());
|
||||
|
||||
targetData[GFX_ARGB32_OFFSET_B] =
|
||||
NS_MIN(uint32_t(specularNH * NS_GET_B(color)), 255U);
|
||||
std::min(uint32_t(specularNH * NS_GET_B(color)), 255U);
|
||||
targetData[GFX_ARGB32_OFFSET_G] =
|
||||
NS_MIN(uint32_t(specularNH * NS_GET_G(color)), 255U);
|
||||
std::min(uint32_t(specularNH * NS_GET_G(color)), 255U);
|
||||
targetData[GFX_ARGB32_OFFSET_R] =
|
||||
NS_MIN(uint32_t(specularNH * NS_GET_R(color)), 255U);
|
||||
std::min(uint32_t(specularNH * NS_GET_R(color)), 255U);
|
||||
|
||||
targetData[GFX_ARGB32_OFFSET_A] =
|
||||
NS_MAX(minAlpha, NS_MAX(targetData[GFX_ARGB32_OFFSET_B],
|
||||
NS_MAX(targetData[GFX_ARGB32_OFFSET_G],
|
||||
std::max(minAlpha, std::max(targetData[GFX_ARGB32_OFFSET_B],
|
||||
std::max(targetData[GFX_ARGB32_OFFSET_G],
|
||||
targetData[GFX_ARGB32_OFFSET_R])));
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "txXMLUtils.h"
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <algorithm>
|
||||
#ifdef WIN32
|
||||
#include <float.h>
|
||||
#endif
|
||||
@ -195,7 +196,7 @@ void txDouble::toString(double aValue, nsAString& aDest)
|
||||
}
|
||||
}
|
||||
// mantissa
|
||||
int firstlen = NS_MIN<size_t>(intDigits, endp - buf);
|
||||
int firstlen = std::min<size_t>(intDigits, endp - buf);
|
||||
for (i = 0; i < firstlen; i++) {
|
||||
*dest = buf[i]; ++dest;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsTArray.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/StandardInteger.h"
|
||||
#include <algorithm>
|
||||
|
||||
const uint32_t kUnknownIndex = uint32_t(-1);
|
||||
|
||||
@ -647,7 +648,7 @@ txXPathNodeUtils::comparePosition(const txXPathNode& aNode,
|
||||
int32_t otherTotal = otherParents.Length() - 1;
|
||||
NS_ASSERTION(total != otherTotal, "Can't have same number of parents");
|
||||
|
||||
int32_t lastIndex = NS_MIN(total, otherTotal);
|
||||
int32_t lastIndex = std::min(total, otherTotal);
|
||||
int32_t i;
|
||||
parent = nullptr;
|
||||
for (i = 0; i <= lastIndex; ++i) {
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "txLog.h"
|
||||
#include "nsMemory.h"
|
||||
#include "txXPathTreeWalker.h"
|
||||
#include <algorithm>
|
||||
|
||||
/**
|
||||
* Implementation of an XPath nodeset
|
||||
@ -519,7 +520,7 @@ bool txNodeSet::ensureGrowSize(int32_t aSize)
|
||||
|
||||
// This isn't 100% safe. But until someone manages to make a 1gig nodeset
|
||||
// it should be ok.
|
||||
int32_t newLength = NS_MAX(oldLength, kTxNodeSetMinSize);
|
||||
int32_t newLength = std::max(oldLength, kTxNodeSetMinSize);
|
||||
|
||||
while (newLength < ensureSize) {
|
||||
newLength *= kTxNodeSetGrowFactor;
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIFrame.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
@ -656,7 +657,7 @@ txMozillaXMLOutput::createTxWrapper()
|
||||
// The new documentElement should go after the document type.
|
||||
// This is needed for cases when there is no existing
|
||||
// documentElement in the document.
|
||||
rootLocation = NS_MAX(rootLocation, j + 1);
|
||||
rootLocation = std::max(rootLocation, j + 1);
|
||||
#endif
|
||||
++j;
|
||||
}
|
||||
|
@ -89,6 +89,7 @@
|
||||
#include "nsAttrValueOrString.h"
|
||||
#include "nsAttrValueInlines.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include <algorithm>
|
||||
|
||||
// The XUL doc interface
|
||||
#include "nsIDOMXULDocument.h"
|
||||
@ -821,7 +822,7 @@ nsXULElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
|
||||
int32_t treeRows;
|
||||
listBox->GetRowCount(&treeRows);
|
||||
if (treeRows > 0) {
|
||||
newCurrentIndex = NS_MIN((treeRows - 1), newCurrentIndex);
|
||||
newCurrentIndex = std::min((treeRows - 1), newCurrentIndex);
|
||||
nsCOMPtr<nsIDOMElement> newCurrentItem;
|
||||
listBox->GetItemAtIndex(newCurrentIndex, getter_AddRefs(newCurrentItem));
|
||||
nsCOMPtr<nsIDOMXULSelectControlItemElement> xulCurItem = do_QueryInterface(newCurrentItem);
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsTreeRows.h"
|
||||
#include <algorithm>
|
||||
|
||||
nsTreeRows::Subtree*
|
||||
nsTreeRows::EnsureSubtreeFor(Subtree* aParent,
|
||||
@ -231,7 +232,7 @@ nsTreeRows::iterator
|
||||
nsTreeRows::Subtree::InsertRowAt(nsTemplateMatch* aMatch, int32_t aIndex)
|
||||
{
|
||||
if (mCount >= mCapacity || aIndex >= mCapacity) {
|
||||
int32_t newCapacity = NS_MAX(mCapacity * 2, aIndex + 1);
|
||||
int32_t newCapacity = std::max(mCapacity * 2, aIndex + 1);
|
||||
Row* newRows = new Row[newCapacity];
|
||||
if (! newRows)
|
||||
return iterator();
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "nsIPlatformCharset.h"
|
||||
#include "nsIFile.h"
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef MOZ_TOOLKIT_SEARCH
|
||||
#include "nsIBrowserSearchService.h"
|
||||
@ -811,7 +812,7 @@ nsresult nsDefaultURIFixup::KeywordURIFixup(const nsACString & aURIString,
|
||||
spaceLoc = uint32_t(kNotFound);
|
||||
}
|
||||
uint32_t qMarkLoc = uint32_t(aURIString.FindChar('?'));
|
||||
uint32_t quoteLoc = NS_MIN(uint32_t(aURIString.FindChar('"')),
|
||||
uint32_t quoteLoc = std::min(uint32_t(aURIString.FindChar('"')),
|
||||
uint32_t(aURIString.FindChar('\'')));
|
||||
|
||||
if (((spaceLoc < dotLoc || quoteLoc < dotLoc) &&
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/TabChild.h"
|
||||
#include "mozilla/Util.h"
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef MOZ_LOGGING
|
||||
// so we can get logging even in release builds (but only for some things)
|
||||
@ -2421,8 +2422,8 @@ nsDocShell::HistoryPurged(int32_t aNumEntries)
|
||||
// eviction. We need to adjust by the number of entries that we
|
||||
// just purged from history, so that we look at the right session history
|
||||
// entries during eviction.
|
||||
mPreviousTransIndex = NS_MAX(-1, mPreviousTransIndex - aNumEntries);
|
||||
mLoadedTransIndex = NS_MAX(0, mLoadedTransIndex - aNumEntries);
|
||||
mPreviousTransIndex = std::max(-1, mPreviousTransIndex - aNumEntries);
|
||||
mLoadedTransIndex = std::max(0, mLoadedTransIndex - aNumEntries);
|
||||
|
||||
int32_t count = mChildList.Count();
|
||||
for (int32_t i = 0; i < count; ++i) {
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIStructuredCloneContainer.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace dom = mozilla::dom;
|
||||
|
||||
@ -561,7 +562,7 @@ nsSHEntry::AddChild(nsISHEntry * aChild, int32_t aOffset)
|
||||
// If there are dynamically added children before that, those must be
|
||||
// moved to be after aOffset.
|
||||
if (mChildren.Count() > 0) {
|
||||
int32_t start = NS_MIN(mChildren.Count() - 1, aOffset);
|
||||
int32_t start = std::min(mChildren.Count() - 1, aOffset);
|
||||
int32_t dynEntryIndex = -1;
|
||||
nsISHEntry* dynEntry = nullptr;
|
||||
for (int32_t i = start; i >= 0; --i) {
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
// Local Includes
|
||||
#include "nsSHistory.h"
|
||||
#include <algorithm>
|
||||
|
||||
// Helper Classes
|
||||
#include "nsXPIDLString.h"
|
||||
@ -664,7 +665,7 @@ nsSHistory::PurgeHistory(int32_t aEntries)
|
||||
if (mLength <= 0 || aEntries <= 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
aEntries = NS_MIN(aEntries, mLength);
|
||||
aEntries = std::min(aEntries, mLength);
|
||||
|
||||
bool purgeHistory = true;
|
||||
NOTIFY_LISTENERS_CANCELABLE(OnHistoryPurge, purgeHistory,
|
||||
@ -955,8 +956,8 @@ nsSHistory::EvictOutOfRangeWindowContentViewers(int32_t aIndex)
|
||||
}
|
||||
|
||||
// Calculate the range that's safe from eviction.
|
||||
int32_t startSafeIndex = NS_MAX(0, aIndex - gHistoryMaxViewers);
|
||||
int32_t endSafeIndex = NS_MIN(mLength, aIndex + gHistoryMaxViewers);
|
||||
int32_t startSafeIndex = std::max(0, aIndex - gHistoryMaxViewers);
|
||||
int32_t endSafeIndex = std::min(mLength, aIndex + gHistoryMaxViewers);
|
||||
|
||||
LOG(("EvictOutOfRangeWindowContentViewers(index=%d), "
|
||||
"mLength=%d. Safe range [%d, %d]",
|
||||
@ -1070,8 +1071,8 @@ nsSHistory::GloballyEvictContentViewers()
|
||||
// SHistory object in question, we'll do a full search of its history
|
||||
// and evict the out-of-range content viewers, so we don't bother here.
|
||||
//
|
||||
int32_t startIndex = NS_MAX(0, shist->mIndex - gHistoryMaxViewers);
|
||||
int32_t endIndex = NS_MIN(shist->mLength - 1,
|
||||
int32_t startIndex = std::max(0, shist->mIndex - gHistoryMaxViewers);
|
||||
int32_t endIndex = std::min(shist->mLength - 1,
|
||||
shist->mIndex + gHistoryMaxViewers);
|
||||
nsCOMPtr<nsISHTransaction> trans;
|
||||
shist->GetTransactionAtIndex(startIndex, getter_AddRefs(trans));
|
||||
@ -1088,7 +1089,7 @@ nsSHistory::GloballyEvictContentViewers()
|
||||
for (uint32_t j = 0; j < shTransactions.Length(); j++) {
|
||||
TransactionAndDistance &container = shTransactions[j];
|
||||
if (container.mViewer == contentViewer) {
|
||||
container.mDistance = NS_MIN(container.mDistance,
|
||||
container.mDistance = std::min(container.mDistance,
|
||||
std::abs(i - shist->mIndex));
|
||||
found = true;
|
||||
break;
|
||||
@ -1136,8 +1137,8 @@ nsSHistory::GloballyEvictContentViewers()
|
||||
nsresult
|
||||
nsSHistory::EvictExpiredContentViewerForEntry(nsIBFCacheEntry *aEntry)
|
||||
{
|
||||
int32_t startIndex = NS_MAX(0, mIndex - gHistoryMaxViewers);
|
||||
int32_t endIndex = NS_MIN(mLength - 1,
|
||||
int32_t startIndex = std::max(0, mIndex - gHistoryMaxViewers);
|
||||
int32_t endIndex = std::min(mLength - 1,
|
||||
mIndex + gHistoryMaxViewers);
|
||||
nsCOMPtr<nsISHTransaction> trans;
|
||||
GetTransactionAtIndex(startIndex, getter_AddRefs(trans));
|
||||
@ -1275,7 +1276,7 @@ bool IsSameTree(nsISHEntry* aEntry1, nsISHEntry* aEntry2)
|
||||
container1->GetChildCount(&count1);
|
||||
container2->GetChildCount(&count2);
|
||||
// We allow null entries in the end of the child list.
|
||||
int32_t count = NS_MAX(count1, count2);
|
||||
int32_t count = std::max(count1, count2);
|
||||
for (int32_t i = 0; i < count; ++i) {
|
||||
nsCOMPtr<nsISHEntry> child1, child2;
|
||||
container1->GetChildAt(i, getter_AddRefs(child1));
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIMarkupDocumentViewer.h"
|
||||
#include "nsClientRect.h"
|
||||
#include <algorithm>
|
||||
|
||||
#if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK)
|
||||
#include <gdk/gdk.h>
|
||||
@ -1311,10 +1312,10 @@ nsDOMWindowUtils::CompareCanvases(nsIDOMHTMLCanvasElement *aCanvas1,
|
||||
|
||||
different++;
|
||||
|
||||
dc = NS_MAX((uint32_t)abs(p1[0] - p2[0]), dc);
|
||||
dc = NS_MAX((uint32_t)abs(p1[1] - p2[1]), dc);
|
||||
dc = NS_MAX((uint32_t)abs(p1[2] - p2[2]), dc);
|
||||
dc = NS_MAX((uint32_t)abs(p1[3] - p2[3]), dc);
|
||||
dc = std::max((uint32_t)abs(p1[0] - p2[0]), dc);
|
||||
dc = std::max((uint32_t)abs(p1[1] - p2[1]), dc);
|
||||
dc = std::max((uint32_t)abs(p1[2] - p2[2]), dc);
|
||||
dc = std::max((uint32_t)abs(p1[3] - p2[3]), dc);
|
||||
}
|
||||
|
||||
p1 += 4;
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsIDOMXULTextboxElement.h"
|
||||
@ -1323,7 +1324,7 @@ nsFocusManager::GetCommonAncestor(nsPIDOMWindow* aWindow1,
|
||||
uint32_t pos2 = parents2.Length();
|
||||
nsIDocShellTreeItem* parent = nullptr;
|
||||
uint32_t len;
|
||||
for (len = NS_MIN(pos1, pos2); len > 0; --len) {
|
||||
for (len = std::min(pos1, pos2); len > 0; --len) {
|
||||
nsIDocShellTreeItem* child1 = parents1.ElementAt(--pos1);
|
||||
nsIDocShellTreeItem* child2 = parents2.ElementAt(--pos2);
|
||||
if (child1 != child2) {
|
||||
|
@ -5,6 +5,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include <algorithm>
|
||||
|
||||
/* This must occur *after* base/basictypes.h to avoid typedefs conflicts. */
|
||||
#include "mozilla/Util.h"
|
||||
@ -291,7 +292,7 @@ inline int32_t
|
||||
nsGlobalWindow::DOMMinTimeoutValue() const {
|
||||
bool isBackground = !mOuterWindow || mOuterWindow->IsBackground();
|
||||
return
|
||||
NS_MAX(isBackground ? gMinBackgroundTimeoutValue : gMinTimeoutValue, 0);
|
||||
std::max(isBackground ? gMinBackgroundTimeoutValue : gMinTimeoutValue, 0);
|
||||
}
|
||||
|
||||
// The number of nested timeouts before we start clamping. HTML5 says 1, WebKit
|
||||
@ -4301,10 +4302,10 @@ nsGlobalWindow::GetScrollMaxXY(int32_t* aScrollMaxX, int32_t* aScrollMaxY)
|
||||
nsRect scrollRange = sf->GetScrollRange();
|
||||
|
||||
if (aScrollMaxX)
|
||||
*aScrollMaxX = NS_MAX(0,
|
||||
*aScrollMaxX = std::max(0,
|
||||
(int32_t)floor(nsPresContext::AppUnitsToFloatCSSPixels(scrollRange.XMost())));
|
||||
if (aScrollMaxY)
|
||||
*aScrollMaxY = NS_MAX(0,
|
||||
*aScrollMaxY = std::max(0,
|
||||
(int32_t)floor(nsPresContext::AppUnitsToFloatCSSPixels(scrollRange.YMost())));
|
||||
|
||||
return NS_OK;
|
||||
@ -9536,7 +9537,7 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
|
||||
|
||||
// Disallow negative intervals. If aIsInterval also disallow 0,
|
||||
// because we use that as a "don't repeat" flag.
|
||||
interval = NS_MAX(aIsInterval ? 1 : 0, interval);
|
||||
interval = std::max(aIsInterval ? 1 : 0, interval);
|
||||
|
||||
// Make sure we don't proceed with an interval larger than our timer
|
||||
// code can handle. (Note: we already forced |interval| to be non-negative,
|
||||
@ -9557,7 +9558,7 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
|
||||
if (aIsInterval || nestingLevel >= DOM_CLAMP_TIMEOUT_NESTING_LEVEL) {
|
||||
// Don't allow timeouts less than DOMMinTimeoutValue() from
|
||||
// now...
|
||||
realInterval = NS_MAX(realInterval, uint32_t(DOMMinTimeoutValue()));
|
||||
realInterval = std::max(realInterval, uint32_t(DOMMinTimeoutValue()));
|
||||
}
|
||||
|
||||
// Get principal of currently executing code, save for execution of timeout.
|
||||
@ -9799,7 +9800,7 @@ nsGlobalWindow::RescheduleTimeout(nsTimeout* aTimeout, const TimeStamp& now,
|
||||
// Compute time to next timeout for interval timer.
|
||||
// Make sure nextInterval is at least DOMMinTimeoutValue().
|
||||
TimeDuration nextInterval =
|
||||
TimeDuration::FromMilliseconds(NS_MAX(aTimeout->mInterval,
|
||||
TimeDuration::FromMilliseconds(std::max(aTimeout->mInterval,
|
||||
uint32_t(DOMMinTimeoutValue())));
|
||||
|
||||
// If we're running pending timeouts, set the next interval to be
|
||||
@ -10118,7 +10119,7 @@ nsresult nsGlobalWindow::ResetTimersForNonBackgroundWindow()
|
||||
mTimeoutInsertionPoint->getNext() : mTimeouts.getFirst();
|
||||
timeout; ) {
|
||||
// It's important that this check be <= so that we guarantee that
|
||||
// taking NS_MAX with |now| won't make a quantity equal to
|
||||
// taking std::max with |now| won't make a quantity equal to
|
||||
// timeout->mWhen below.
|
||||
if (timeout->mWhen <= now) {
|
||||
timeout = timeout->getNext();
|
||||
@ -10137,7 +10138,7 @@ nsresult nsGlobalWindow::ResetTimersForNonBackgroundWindow()
|
||||
// Compute the interval the timer should have had if it had not been set in a
|
||||
// background window
|
||||
TimeDuration interval =
|
||||
TimeDuration::FromMilliseconds(NS_MAX(timeout->mInterval,
|
||||
TimeDuration::FromMilliseconds(std::max(timeout->mInterval,
|
||||
uint32_t(DOMMinTimeoutValue())));
|
||||
uint32_t oldIntervalMillisecs = 0;
|
||||
timeout->mTimer->GetDelay(&oldIntervalMillisecs);
|
||||
@ -10145,7 +10146,7 @@ nsresult nsGlobalWindow::ResetTimersForNonBackgroundWindow()
|
||||
if (oldInterval > interval) {
|
||||
// unclamp
|
||||
TimeStamp firingTime =
|
||||
NS_MAX(timeout->mWhen - oldInterval + interval, now);
|
||||
std::max(timeout->mWhen - oldInterval + interval, now);
|
||||
|
||||
NS_ASSERTION(firingTime < timeout->mWhen,
|
||||
"Our firing time should strictly decrease!");
|
||||
@ -10647,7 +10648,7 @@ nsGlobalWindow::ResumeTimeouts(bool aThawChildren)
|
||||
// makes no sense. Are we trying to impose that min timeout value or
|
||||
// not???
|
||||
uint32_t delay =
|
||||
NS_MAX(int32_t(t->mTimeRemaining.ToMilliseconds()),
|
||||
std::max(int32_t(t->mTimeRemaining.ToMilliseconds()),
|
||||
DOMMinTimeoutValue());
|
||||
|
||||
// Set mWhen back to the time when the timer is supposed to
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "nsAlgorithm.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include <algorithm>
|
||||
|
||||
static const char kSetIntervalStr[] = "setInterval";
|
||||
static const char kSetTimeoutStr[] = "setTimeout";
|
||||
@ -279,8 +280,8 @@ nsJSScriptTimeoutHandler::Init(nsGlobalWindow *aWindow, bool *aIsInterval,
|
||||
// and the delay, so only arguments after that need to go in our
|
||||
// array.
|
||||
nsCOMPtr<nsIJSArgArray> array;
|
||||
// NS_MAX(argc - 2, 0) wouldn't work right because argc is unsigned.
|
||||
rv = NS_CreateJSArgv(cx, NS_MAX(argc, 2u) - 2, nullptr,
|
||||
// std::max(argc - 2, 0) wouldn't work right because argc is unsigned.
|
||||
rv = NS_CreateJSArgv(cx, std::max(argc, 2u) - 2, nullptr,
|
||||
getter_AddRefs(array));
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -837,7 +837,7 @@ class CGDeferredFinalize(CGAbstractStaticMethod):
|
||||
return """ MOZ_ASSERT(slice > 0, "nonsensical/useless call with slice == 0");
|
||||
nsTArray<%(smartPtr)s >* pointers = static_cast<nsTArray<%(smartPtr)s >*>(data);
|
||||
uint32_t oldLen = pointers->Length();
|
||||
slice = NS_MIN(oldLen, slice);
|
||||
slice = std::min(oldLen, slice);
|
||||
uint32_t newLen = oldLen - slice;
|
||||
pointers->RemoveElementsAt(newLen, slice);
|
||||
if (newLen == 0) {
|
||||
@ -4117,7 +4117,7 @@ class CGMethodCall(CGThing):
|
||||
|
||||
overloadCGThings = []
|
||||
overloadCGThings.append(
|
||||
CGGeneric("unsigned argcount = NS_MIN(argc, %du);" %
|
||||
CGGeneric("unsigned argcount = std::min(argc, %du);" %
|
||||
maxArgCount))
|
||||
overloadCGThings.append(
|
||||
CGSwitch("argcount",
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "nsCExternalHandlerService.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include <algorithm>
|
||||
|
||||
// Microsoft's API Name hackery sucks
|
||||
#undef CreateEvent
|
||||
@ -441,7 +442,7 @@ DeviceStorageFile::Write(nsIInputStream* aInputStream)
|
||||
while (bufSize) {
|
||||
uint32_t wrote;
|
||||
rv = bufferedOutputStream->WriteFrom(aInputStream,
|
||||
static_cast<uint32_t>(NS_MIN<uint64_t>(bufSize, UINT32_MAX)),
|
||||
static_cast<uint32_t>(std::min<uint64_t>(bufSize, UINT32_MAX)),
|
||||
&wrote);
|
||||
if (NS_FAILED(rv)) {
|
||||
break;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "OpenDatabaseHelper.h"
|
||||
|
||||
#include "IndexedDatabaseInlines.h"
|
||||
#include <algorithm>
|
||||
|
||||
#define JOURNAL_DIRECTORY_NAME "journals"
|
||||
|
||||
@ -129,7 +130,7 @@ FileManager::Init(nsIFile* aDirectory,
|
||||
|
||||
mFileInfos.Put(id, fileInfo);
|
||||
|
||||
mLastFileId = NS_MAX(id, mLastFileId);
|
||||
mLastFileId = std::max(id, mLastFileId);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "Key.h"
|
||||
|
||||
#include "ipc/IndexedDBChild.h"
|
||||
#include <algorithm>
|
||||
|
||||
USING_INDEXEDDB_NAMESPACE
|
||||
|
||||
@ -445,7 +446,7 @@ IDBFactory::LoadDatabaseInformation(mozIStorageConnection* aConnection,
|
||||
int64_t version = 0;
|
||||
rv = stmt->GetInt64(0, &version);
|
||||
|
||||
*aVersion = NS_MAX<int64_t>(version, 0);
|
||||
*aVersion = std::max<int64_t>(version, 0);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "TransactionThreadPool.h"
|
||||
|
||||
#include "IndexedDatabaseInlines.h"
|
||||
#include <algorithm>
|
||||
|
||||
// The amount of time, in milliseconds, that our IO thread will stay alive
|
||||
// after the last event it processes.
|
||||
@ -901,7 +902,7 @@ IndexedDatabaseManager::OnDatabaseClosed(IDBDatabase* aDatabase)
|
||||
uint32_t
|
||||
IndexedDatabaseManager::GetIndexedDBQuotaMB()
|
||||
{
|
||||
return uint32_t(NS_MAX(gIndexedDBQuotaMB, 0));
|
||||
return uint32_t(std::max(gIndexedDBQuotaMB, 0));
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "nsAlgorithm.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "xpcpublic.h"
|
||||
#include <algorithm>
|
||||
|
||||
USING_INDEXEDDB_NAMESPACE
|
||||
|
||||
@ -409,7 +410,7 @@ Key::DecodeNumber(const unsigned char*& aPos, const unsigned char* aEnd)
|
||||
++aPos;
|
||||
|
||||
uint64_t number = 0;
|
||||
memcpy(&number, aPos, NS_MIN<size_t>(sizeof(number), aEnd - aPos));
|
||||
memcpy(&number, aPos, std::min<size_t>(sizeof(number), aEnd - aPos));
|
||||
number = NS_SWAP64(number);
|
||||
|
||||
aPos += sizeof(number);
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "IDBEvents.h"
|
||||
#include "IDBFactory.h"
|
||||
#include "IndexedDatabaseManager.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla;
|
||||
USING_INDEXEDDB_NAMESPACE
|
||||
@ -1679,9 +1680,9 @@ OpenDatabaseHelper::DoDatabaseWork()
|
||||
nsRefPtr<ObjectStoreInfo>& objectStoreInfo = mObjectStores[i];
|
||||
for (uint32_t j = 0; j < objectStoreInfo->indexes.Length(); j++) {
|
||||
IndexInfo& indexInfo = objectStoreInfo->indexes[j];
|
||||
mLastIndexId = NS_MAX(indexInfo.id, mLastIndexId);
|
||||
mLastIndexId = std::max(indexInfo.id, mLastIndexId);
|
||||
}
|
||||
mLastObjectStoreId = NS_MAX(objectStoreInfo->id, mLastObjectStoreId);
|
||||
mLastObjectStoreId = std::max(objectStoreInfo->id, mLastObjectStoreId);
|
||||
}
|
||||
|
||||
// See if we need to do a VERSION_CHANGE transaction
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsEmbedCID.h"
|
||||
#include "nsEventListenerManager.h"
|
||||
#include <algorithm>
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
#include "nsExceptionHandler.h"
|
||||
#endif
|
||||
@ -443,8 +444,8 @@ TabChild::HandlePossibleViewportChange()
|
||||
|
||||
float pageWidth, pageHeight;
|
||||
if (htmlDOMElement || bodyDOMElement) {
|
||||
pageWidth = NS_MAX(htmlWidth, bodyWidth);
|
||||
pageHeight = NS_MAX(htmlHeight, bodyHeight);
|
||||
pageWidth = std::max(htmlWidth, bodyWidth);
|
||||
pageHeight = std::max(htmlHeight, bodyHeight);
|
||||
} else {
|
||||
// For non-HTML content (e.g. SVG), just assume page size == viewport size.
|
||||
pageWidth = viewportW;
|
||||
@ -457,7 +458,7 @@ TabChild::HandlePossibleViewportChange()
|
||||
viewportInfo.GetMaxZoom());
|
||||
NS_ENSURE_TRUE_VOID(minScale); // (return early rather than divide by 0)
|
||||
|
||||
viewportH = NS_MAX(viewportH, screenH / minScale);
|
||||
viewportH = std::max(viewportH, screenH / minScale);
|
||||
SetCSSViewport(viewportW, viewportH);
|
||||
|
||||
// This change to the zoom accounts for all types of changes I can conceive:
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include "nsThreadUtils.h"
|
||||
#include "StructuredCloneUtils.h"
|
||||
#include "TabChild.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::ipc;
|
||||
@ -660,7 +661,7 @@ TabParent::HandleQueryContentEvent(nsQueryContentEvent& aEvent)
|
||||
{
|
||||
case NS_QUERY_SELECTED_TEXT:
|
||||
{
|
||||
aEvent.mReply.mOffset = NS_MIN(mIMESelectionAnchor, mIMESelectionFocus);
|
||||
aEvent.mReply.mOffset = std::min(mIMESelectionAnchor, mIMESelectionFocus);
|
||||
if (mIMESelectionAnchor == mIMESelectionFocus) {
|
||||
aEvent.mReply.mString.Truncate(0);
|
||||
} else {
|
||||
@ -709,7 +710,7 @@ TabParent::SendCompositionEvent(nsCompositionEvent& event)
|
||||
return false;
|
||||
}
|
||||
mIMEComposing = event.message != NS_COMPOSITION_END;
|
||||
mIMECompositionStart = NS_MIN(mIMESelectionAnchor, mIMESelectionFocus);
|
||||
mIMECompositionStart = std::min(mIMESelectionAnchor, mIMESelectionFocus);
|
||||
if (mIMECompositionEnding)
|
||||
return true;
|
||||
event.seqno = ++mIMESeqno;
|
||||
@ -737,7 +738,7 @@ TabParent::SendTextEvent(nsTextEvent& event)
|
||||
// We must be able to simulate the selection because
|
||||
// we might not receive selection updates in time
|
||||
if (!mIMEComposing) {
|
||||
mIMECompositionStart = NS_MIN(mIMESelectionAnchor, mIMESelectionFocus);
|
||||
mIMECompositionStart = std::min(mIMESelectionAnchor, mIMESelectionFocus);
|
||||
}
|
||||
mIMESelectionAnchor = mIMESelectionFocus =
|
||||
mIMECompositionStart + event.theText.Length();
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "nsPluginStreamListenerPeer.h"
|
||||
|
||||
#include "mozilla/StandardInteger.h"
|
||||
#include <algorithm>
|
||||
|
||||
nsNPAPIStreamWrapper::nsNPAPIStreamWrapper(nsIOutputStream *outputStream,
|
||||
nsNPAPIPluginStreamListener *streamListener)
|
||||
@ -461,12 +462,12 @@ nsNPAPIPluginStreamListener::OnDataAvailable(nsPluginStreamListenerPeer* streamP
|
||||
uint32_t contentLength;
|
||||
streamPeer->GetLength(&contentLength);
|
||||
|
||||
mStreamBufferSize = NS_MAX(length, contentLength);
|
||||
mStreamBufferSize = std::max(length, contentLength);
|
||||
|
||||
// Limit the size of the initial buffer to MAX_PLUGIN_NECKO_BUFFER
|
||||
// (16k). This buffer will grow if needed, as in the case where
|
||||
// we're getting data faster than the plugin can process it.
|
||||
mStreamBufferSize = NS_MIN(mStreamBufferSize,
|
||||
mStreamBufferSize = std::min(mStreamBufferSize,
|
||||
uint32_t(MAX_PLUGIN_NECKO_BUFFER));
|
||||
|
||||
mStreamBuffer = (char*) PR_Malloc(mStreamBufferSize);
|
||||
@ -522,7 +523,7 @@ nsNPAPIPluginStreamListener::OnDataAvailable(nsPluginStreamListenerPeer* streamP
|
||||
}
|
||||
|
||||
uint32_t bytesToRead =
|
||||
NS_MIN(length, mStreamBufferSize - mStreamBufferByteCount);
|
||||
std::min(length, mStreamBufferSize - mStreamBufferByteCount);
|
||||
|
||||
uint32_t amountRead = 0;
|
||||
rv = input->Read(mStreamBuffer + mStreamBufferByteCount, bytesToRead,
|
||||
@ -601,7 +602,7 @@ nsNPAPIPluginStreamListener::OnDataAvailable(nsPluginStreamListenerPeer* streamP
|
||||
break;
|
||||
}
|
||||
|
||||
numtowrite = NS_MIN(numtowrite, mStreamBufferByteCount);
|
||||
numtowrite = std::min(numtowrite, mStreamBufferByteCount);
|
||||
} else {
|
||||
// if WriteReady is not supported by the plugin, just write
|
||||
// the whole buffer
|
||||
@ -629,7 +630,7 @@ nsNPAPIPluginStreamListener::OnDataAvailable(nsPluginStreamListenerPeer* streamP
|
||||
NS_ASSERTION(writeCount <= mStreamBufferByteCount,
|
||||
"Plugin read past the end of the available data!");
|
||||
|
||||
writeCount = NS_MIN(writeCount, mStreamBufferByteCount);
|
||||
writeCount = std::min(writeCount, mStreamBufferByteCount);
|
||||
mStreamBufferByteCount -= writeCount;
|
||||
|
||||
streamPosition += writeCount;
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "nptest_platform.h"
|
||||
#include "nsAlgorithm.h"
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -175,8 +176,8 @@ pluginDraw(InstanceData* instanceData, NPCocoaEvent* event)
|
||||
|
||||
// Initialize a rectangular path.
|
||||
CGMutablePathRef path = CGPathCreateMutable();
|
||||
CGRect bounds = CGRectMake(10.0, 10.0, NS_MAX(0.0, windowWidth - 20.0),
|
||||
NS_MAX(0.0, windowHeight - 20.0));
|
||||
CGRect bounds = CGRectMake(10.0, 10.0, std::max(0.0, windowWidth - 20.0),
|
||||
std::max(0.0, windowHeight - 20.0));
|
||||
CGPathAddRect(path, NULL, bounds);
|
||||
|
||||
// Initialize an attributed string.
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef MOZ_MAEMO_LIBLOCATION
|
||||
#include "MaemoLocationProvider.h"
|
||||
@ -941,7 +942,7 @@ nsGeolocationService::IsBetterPosition(nsIDOMGeoPosition *aSomewhere)
|
||||
// The threshold is when the distance between the two
|
||||
// positions exceeds the worse (larger value) of the two
|
||||
// accuracies.
|
||||
double max_accuracy = NS_MAX(oldAccuracy, newAccuracy);
|
||||
double max_accuracy = std::max(oldAccuracy, newAccuracy);
|
||||
if (delta > max_accuracy)
|
||||
return true;
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "nsCRTGlue.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include <algorithm>
|
||||
|
||||
static const char kXPConnectServiceCID[] = "@mozilla.org/js/xpc/XPConnect;1";
|
||||
|
||||
@ -606,7 +607,7 @@ nsJSONListener::OnDataAvailable(nsIRequest *aRequest, nsISupports *aContext,
|
||||
while (bytesRemaining) {
|
||||
unsigned int bytesRead;
|
||||
rv = aStream->Read(buffer,
|
||||
NS_MIN((unsigned long)sizeof(buffer), bytesRemaining),
|
||||
std::min((unsigned long)sizeof(buffer), bytesRemaining),
|
||||
&bytesRead);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = ProcessBytes(buffer, bytesRead);
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "WorkerPrivate.h"
|
||||
|
||||
#include "OSFileConstants.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -1090,7 +1091,7 @@ RuntimeService::Init()
|
||||
|
||||
int32_t maxPerDomain = Preferences::GetInt(PREF_WORKERS_MAX_PER_DOMAIN,
|
||||
MAX_WORKERS_PER_DOMAIN);
|
||||
gMaxWorkersPerDomain = NS_MAX(0, maxPerDomain);
|
||||
gMaxWorkersPerDomain = std::max(0, maxPerDomain);
|
||||
|
||||
mDetectorName = Preferences::GetLocalizedCString("intl.charset.detector");
|
||||
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "xpcpublic.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
@ -3887,7 +3888,7 @@ WorkerPrivate::RunExpiredTimeouts(JSContext* aCx)
|
||||
|
||||
// We want to make sure to run *something*, even if the timer fired a little
|
||||
// early. Fudge the value of now to at least include the first timeout.
|
||||
const TimeStamp now = NS_MAX(TimeStamp::Now(), mTimeouts[0]->mTargetTime);
|
||||
const TimeStamp now = std::max(TimeStamp::Now(), mTimeouts[0]->mTargetTime);
|
||||
|
||||
nsAutoTArray<TimeoutInfo*, 10> expiredTimeouts;
|
||||
for (uint32_t index = 0; index < mTimeouts.Length(); index++) {
|
||||
@ -4005,7 +4006,7 @@ WorkerPrivate::RescheduleTimeoutTimer(JSContext* aCx)
|
||||
|
||||
double delta =
|
||||
(mTimeouts[0]->mTargetTime - TimeStamp::Now()).ToMilliseconds();
|
||||
uint32_t delay = delta > 0 ? NS_MIN(delta, double(UINT32_MAX)) : 0;
|
||||
uint32_t delay = delta > 0 ? std::min(delta, double(UINT32_MAX)) : 0;
|
||||
|
||||
nsresult rv = mTimer->InitWithFuncCallback(DummyCallback, nullptr, delay,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "nsStringFwd.h"
|
||||
#include "nsString.h"
|
||||
#include "nsAString.h"
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef DEBUG
|
||||
static bool gNoisy = false;
|
||||
@ -108,7 +109,7 @@ NS_IMETHODIMP CreateElementTxn::DoTransaction(void)
|
||||
}
|
||||
|
||||
|
||||
mOffsetInParent = NS_MIN(mOffsetInParent, mParent->GetChildCount());
|
||||
mOffsetInParent = std::min(mOffsetInParent, mParent->GetChildCount());
|
||||
|
||||
// note, it's ok for mRefNode to be null. that means append
|
||||
mRefNode = mParent->GetChildAt(mOffsetInParent);
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "nsTextEditRules.h"
|
||||
#include "nsTextEditUtils.h"
|
||||
#include "nscore.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -144,7 +145,7 @@ nsHTMLEditor::RelativeChangeElementZIndex(nsIDOMElement * aElement,
|
||||
nsresult res = GetElementZIndex(aElement, &zIndex);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
zIndex = NS_MAX(zIndex + aChange, 0);
|
||||
zIndex = std::max(zIndex + aChange, 0);
|
||||
SetElementZIndex(aElement, zIndex);
|
||||
*aReturn = zIndex;
|
||||
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "nsWSRunObject.h"
|
||||
#include <cstdlib> // for std::abs(int/long)
|
||||
#include <cmath> // for std::abs(float/double)
|
||||
#include <algorithm>
|
||||
|
||||
class nsISupports;
|
||||
class nsRulesInfo;
|
||||
@ -1931,7 +1932,7 @@ nsHTMLEditRules::WillDeleteSelection(Selection* aSelection,
|
||||
res = nsWSRunObject::PrepareToDeleteRange(mHTMLEditor, address_of(visNode), &so, address_of(visNode), &eo);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsCOMPtr<nsIDOMCharacterData> nodeAsText(do_QueryInterface(visNode));
|
||||
res = mHTMLEditor->DeleteText(nodeAsText, NS_MIN(so, eo), std::abs(eo - so));
|
||||
res = mHTMLEditor->DeleteText(nodeAsText, std::min(so, eo), std::abs(eo - so));
|
||||
*aHandled = true;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = InsertBRIfNeeded(aSelection);
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "nscore.h"
|
||||
#include <cstdlib> // for std::abs(int/long)
|
||||
#include <cmath> // for std::abs(float/double)
|
||||
#include <algorithm>
|
||||
|
||||
class nsISelection;
|
||||
|
||||
@ -798,7 +799,7 @@ nsHTMLEditor::GetNewResizingX(int32_t aX, int32_t aY)
|
||||
int32_t resized = mResizedObjectX +
|
||||
GetNewResizingIncrement(aX, aY, kX) * mXIncrementFactor;
|
||||
int32_t max = mResizedObjectX + mResizedObjectWidth;
|
||||
return NS_MIN(resized, max);
|
||||
return std::min(resized, max);
|
||||
}
|
||||
|
||||
int32_t
|
||||
@ -807,7 +808,7 @@ nsHTMLEditor::GetNewResizingY(int32_t aX, int32_t aY)
|
||||
int32_t resized = mResizedObjectY +
|
||||
GetNewResizingIncrement(aX, aY, kY) * mYIncrementFactor;
|
||||
int32_t max = mResizedObjectY + mResizedObjectHeight;
|
||||
return NS_MIN(resized, max);
|
||||
return std::min(resized, max);
|
||||
}
|
||||
|
||||
int32_t
|
||||
@ -816,7 +817,7 @@ nsHTMLEditor::GetNewResizingWidth(int32_t aX, int32_t aY)
|
||||
int32_t resized = mResizedObjectWidth +
|
||||
GetNewResizingIncrement(aX, aY, kWidth) *
|
||||
mWidthIncrementFactor;
|
||||
return NS_MAX(resized, 1);
|
||||
return std::max(resized, 1);
|
||||
}
|
||||
|
||||
int32_t
|
||||
@ -825,7 +826,7 @@ nsHTMLEditor::GetNewResizingHeight(int32_t aX, int32_t aY)
|
||||
int32_t resized = mResizedObjectHeight +
|
||||
GetNewResizingIncrement(aX, aY, kHeight) *
|
||||
mHeightIncrementFactor;
|
||||
return NS_MAX(resized, 1);
|
||||
return std::max(resized, 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "nsTableCellFrame.h"
|
||||
#include "nsTableOuterFrame.h"
|
||||
#include "nscore.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -1034,7 +1035,7 @@ nsHTMLEditor::DeleteTableColumn(int32_t aNumber)
|
||||
return DeleteTable2(table, selection);
|
||||
|
||||
// Check for counts too high
|
||||
aNumber = NS_MIN(aNumber,(colCount-startColIndex));
|
||||
aNumber = std::min(aNumber,(colCount-startColIndex));
|
||||
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
// Prevent rules testing until we're done
|
||||
@ -1268,7 +1269,7 @@ nsHTMLEditor::DeleteTableRow(int32_t aNumber)
|
||||
else
|
||||
{
|
||||
// Check for counts too high
|
||||
aNumber = NS_MIN(aNumber,(rowCount-startRowIndex));
|
||||
aNumber = std::min(aNumber,(rowCount-startRowIndex));
|
||||
|
||||
for (int32_t i = 0; i < aNumber; i++)
|
||||
{
|
||||
@ -1334,7 +1335,7 @@ nsHTMLEditor::DeleteRow(nsIDOMElement *aTable, int32_t aRowIndex)
|
||||
// We can't do it now since it upsets cell map,
|
||||
// so we will do it after deleting the row
|
||||
spanCellList.AppendElement(cell);
|
||||
newSpanList.AppendElement(NS_MAX((aRowIndex - startRowIndex), actualRowSpan-1));
|
||||
newSpanList.AppendElement(std::max((aRowIndex - startRowIndex), actualRowSpan-1));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1457,10 +1458,10 @@ nsHTMLEditor::SelectBlockOfCells(nsIDOMElement *aStartCell, nsIDOMElement *aEndC
|
||||
|
||||
// Examine all cell nodes in current selection and
|
||||
// remove those outside the new block cell region
|
||||
int32_t minColumn = NS_MIN(startColIndex, endColIndex);
|
||||
int32_t minRow = NS_MIN(startRowIndex, endRowIndex);
|
||||
int32_t maxColumn = NS_MAX(startColIndex, endColIndex);
|
||||
int32_t maxRow = NS_MAX(startRowIndex, endRowIndex);
|
||||
int32_t minColumn = std::min(startColIndex, endColIndex);
|
||||
int32_t minRow = std::min(startRowIndex, endRowIndex);
|
||||
int32_t maxColumn = std::max(startColIndex, endColIndex);
|
||||
int32_t maxRow = std::max(startRowIndex, endRowIndex);
|
||||
|
||||
nsCOMPtr<nsIDOMElement> cell;
|
||||
int32_t currentRowIndex, currentColIndex;
|
||||
@ -1489,7 +1490,7 @@ nsHTMLEditor::SelectBlockOfCells(nsIDOMElement *aStartCell, nsIDOMElement *aEndC
|
||||
bool isSelected;
|
||||
for (int32_t row = minRow; row <= maxRow; row++)
|
||||
{
|
||||
for(int32_t col = minColumn; col <= maxColumn; col += NS_MAX(actualColSpan, 1))
|
||||
for(int32_t col = minColumn; col <= maxColumn; col += std::max(actualColSpan, 1))
|
||||
{
|
||||
res = GetCellDataAt(table, row, col, getter_AddRefs(cell),
|
||||
¤tRowIndex, ¤tColIndex,
|
||||
@ -1548,7 +1549,7 @@ nsHTMLEditor::SelectAllTableCells()
|
||||
bool isSelected;
|
||||
for(int32_t row = 0; row < rowCount; row++)
|
||||
{
|
||||
for(int32_t col = 0; col < colCount; col += NS_MAX(actualColSpan, 1))
|
||||
for(int32_t col = 0; col < colCount; col += std::max(actualColSpan, 1))
|
||||
{
|
||||
res = GetCellDataAt(table, row, col, getter_AddRefs(cell),
|
||||
¤tRowIndex, ¤tColIndex,
|
||||
@ -1616,7 +1617,7 @@ nsHTMLEditor::SelectTableRow()
|
||||
bool cellSelected = false;
|
||||
int32_t rowSpan, colSpan, actualRowSpan, actualColSpan, currentRowIndex, currentColIndex;
|
||||
bool isSelected;
|
||||
for(int32_t col = 0; col < colCount; col += NS_MAX(actualColSpan, 1))
|
||||
for(int32_t col = 0; col < colCount; col += std::max(actualColSpan, 1))
|
||||
{
|
||||
res = GetCellDataAt(table, startRowIndex, col, getter_AddRefs(cell),
|
||||
¤tRowIndex, ¤tColIndex, &rowSpan, &colSpan,
|
||||
@ -1679,7 +1680,7 @@ nsHTMLEditor::SelectTableColumn()
|
||||
bool cellSelected = false;
|
||||
int32_t rowSpan, colSpan, actualRowSpan, actualColSpan, currentRowIndex, currentColIndex;
|
||||
bool isSelected;
|
||||
for(int32_t row = 0; row < rowCount; row += NS_MAX(actualRowSpan, 1))
|
||||
for(int32_t row = 0; row < rowCount; row += std::max(actualRowSpan, 1))
|
||||
{
|
||||
res = GetCellDataAt(table, row, startColIndex, getter_AddRefs(cell),
|
||||
¤tRowIndex, ¤tColIndex, &rowSpan, &colSpan,
|
||||
@ -1897,7 +1898,7 @@ nsHTMLEditor::SplitCellIntoRows(nsIDOMElement *aTable, int32_t aRowIndex, int32_
|
||||
lastCellFound = cell2;
|
||||
}
|
||||
// Skip to next available cellmap location
|
||||
colIndex += NS_MAX(actualColSpan2, 1);
|
||||
colIndex += std::max(actualColSpan2, 1);
|
||||
|
||||
// Done when past end of total number of columns
|
||||
if (colIndex > colCount)
|
||||
@ -2060,7 +2061,7 @@ nsHTMLEditor::JoinTableCells(bool aMergeNonContiguousContents)
|
||||
bool lastRowIsSet = false;
|
||||
int32_t lastColInRow = 0;
|
||||
int32_t firstColInRow = firstColIndex;
|
||||
for (colIndex = firstColIndex; colIndex < colCount; colIndex += NS_MAX(actualColSpan2, 1))
|
||||
for (colIndex = firstColIndex; colIndex < colCount; colIndex += std::max(actualColSpan2, 1))
|
||||
{
|
||||
res = GetCellDataAt(table, rowIndex, colIndex, getter_AddRefs(cell2),
|
||||
&startRowIndex2, &startColIndex2,
|
||||
@ -2082,7 +2083,7 @@ nsHTMLEditor::JoinTableCells(bool aMergeNonContiguousContents)
|
||||
// and keep previous lastColIndex
|
||||
//TODO: We could try to find the Maximum firstColInRow
|
||||
// so our block can still extend down more rows?
|
||||
lastRowIndex = NS_MAX(0,rowIndex - 1);
|
||||
lastRowIndex = std::max(0,rowIndex - 1);
|
||||
lastRowIsSet = true;
|
||||
break;
|
||||
}
|
||||
@ -2098,7 +2099,7 @@ nsHTMLEditor::JoinTableCells(bool aMergeNonContiguousContents)
|
||||
{
|
||||
// Cell is in a column less than current right border in
|
||||
// the third or higher selected row, so stop block at the previous row
|
||||
lastRowIndex = NS_MAX(0,rowIndex - 1);
|
||||
lastRowIndex = std::max(0,rowIndex - 1);
|
||||
lastRowIsSet = true;
|
||||
}
|
||||
// We're done with this row
|
||||
@ -2123,7 +2124,7 @@ nsHTMLEditor::JoinTableCells(bool aMergeNonContiguousContents)
|
||||
// (don't think we ever get here?)
|
||||
// Cell is in a column less than current right boundary,
|
||||
// so stop block at the previous row
|
||||
lastRowIndex = NS_MAX(0,rowIndex - 1);
|
||||
lastRowIndex = std::max(0,rowIndex - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2132,13 +2133,13 @@ nsHTMLEditor::JoinTableCells(bool aMergeNonContiguousContents)
|
||||
}
|
||||
}
|
||||
// Use the minimum col we found so far for right boundary
|
||||
lastColIndex = NS_MIN(lastColIndex, lastColInRow);
|
||||
lastColIndex = std::min(lastColIndex, lastColInRow);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No selected cells in this row -- stop at row above
|
||||
// and leave last column at its previous value
|
||||
lastRowIndex = NS_MAX(0,rowIndex - 1);
|
||||
lastRowIndex = std::max(0,rowIndex - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2148,7 +2149,7 @@ nsHTMLEditor::JoinTableCells(bool aMergeNonContiguousContents)
|
||||
// 2nd pass: Do the joining and merging
|
||||
for (rowIndex = 0; rowIndex < rowCount; rowIndex++)
|
||||
{
|
||||
for (colIndex = 0; colIndex < colCount; colIndex += NS_MAX(actualColSpan2, 1))
|
||||
for (colIndex = 0; colIndex < colCount; colIndex += std::max(actualColSpan2, 1))
|
||||
{
|
||||
res = GetCellDataAt(table, rowIndex, colIndex, getter_AddRefs(cell2),
|
||||
&startRowIndex2, &startColIndex2,
|
||||
@ -2385,7 +2386,7 @@ nsHTMLEditor::FixBadRowSpan(nsIDOMElement *aTable, int32_t aRowIndex, int32_t& a
|
||||
int32_t minRowSpan = -1;
|
||||
int32_t colIndex;
|
||||
|
||||
for( colIndex = 0; colIndex < colCount; colIndex += NS_MAX(actualColSpan, 1))
|
||||
for( colIndex = 0; colIndex < colCount; colIndex += std::max(actualColSpan, 1))
|
||||
{
|
||||
res = GetCellDataAt(aTable, aRowIndex, colIndex, getter_AddRefs(cell),
|
||||
&startRowIndex, &startColIndex, &rowSpan, &colSpan,
|
||||
@ -2407,7 +2408,7 @@ nsHTMLEditor::FixBadRowSpan(nsIDOMElement *aTable, int32_t aRowIndex, int32_t& a
|
||||
// The amount to reduce everyone's rowspan
|
||||
// so at least one cell has rowspan = 1
|
||||
int32_t rowsReduced = minRowSpan - 1;
|
||||
for(colIndex = 0; colIndex < colCount; colIndex += NS_MAX(actualColSpan, 1))
|
||||
for(colIndex = 0; colIndex < colCount; colIndex += std::max(actualColSpan, 1))
|
||||
{
|
||||
res = GetCellDataAt(aTable, aRowIndex, colIndex, getter_AddRefs(cell),
|
||||
&startRowIndex, &startColIndex, &rowSpan, &colSpan,
|
||||
@ -2443,7 +2444,7 @@ nsHTMLEditor::FixBadColSpan(nsIDOMElement *aTable, int32_t aColIndex, int32_t& a
|
||||
int32_t minColSpan = -1;
|
||||
int32_t rowIndex;
|
||||
|
||||
for( rowIndex = 0; rowIndex < rowCount; rowIndex += NS_MAX(actualRowSpan, 1))
|
||||
for( rowIndex = 0; rowIndex < rowCount; rowIndex += std::max(actualRowSpan, 1))
|
||||
{
|
||||
res = GetCellDataAt(aTable, rowIndex, aColIndex, getter_AddRefs(cell),
|
||||
&startRowIndex, &startColIndex, &rowSpan, &colSpan,
|
||||
@ -2465,7 +2466,7 @@ nsHTMLEditor::FixBadColSpan(nsIDOMElement *aTable, int32_t aColIndex, int32_t& a
|
||||
// The amount to reduce everyone's colspan
|
||||
// so at least one cell has colspan = 1
|
||||
int32_t colsReduced = minColSpan - 1;
|
||||
for(rowIndex = 0; rowIndex < rowCount; rowIndex += NS_MAX(actualRowSpan, 1))
|
||||
for(rowIndex = 0; rowIndex < rowCount; rowIndex += std::max(actualRowSpan, 1))
|
||||
{
|
||||
res = GetCellDataAt(aTable, rowIndex, aColIndex, getter_AddRefs(cell),
|
||||
&startRowIndex, &startColIndex, &rowSpan, &colSpan,
|
||||
@ -3341,7 +3342,7 @@ nsHTMLEditor::AllCellsInRowSelected(nsIDOMElement *aTable, int32_t aRowIndex, in
|
||||
int32_t curStartRowIndex, curStartColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
|
||||
bool isSelected;
|
||||
|
||||
for( int32_t col = 0; col < aNumberOfColumns; col += NS_MAX(actualColSpan, 1))
|
||||
for( int32_t col = 0; col < aNumberOfColumns; col += std::max(actualColSpan, 1))
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> cell;
|
||||
nsresult res = GetCellDataAt(aTable, aRowIndex, col, getter_AddRefs(cell),
|
||||
@ -3370,7 +3371,7 @@ nsHTMLEditor::AllCellsInColumnSelected(nsIDOMElement *aTable, int32_t aColIndex,
|
||||
int32_t curStartRowIndex, curStartColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
|
||||
bool isSelected;
|
||||
|
||||
for( int32_t row = 0; row < aNumberOfRows; row += NS_MAX(actualRowSpan, 1))
|
||||
for( int32_t row = 0; row < aNumberOfRows; row += std::max(actualRowSpan, 1))
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> cell;
|
||||
nsresult res = GetCellDataAt(aTable, row, aColIndex, getter_AddRefs(cell),
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user