mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1842072 - Prevent IntCoordTyped's constructor from accepting non-integral parameters. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D182936
This commit is contained in:
parent
8ece9e4f9c
commit
74639ffcbe
@ -833,10 +833,12 @@ void Element::Scroll(const ScrollToOptions& aOptions) {
|
||||
if (sf) {
|
||||
CSSIntPoint scrollPos = sf->GetScrollPositionCSSPixels();
|
||||
if (aOptions.mLeft.WasPassed()) {
|
||||
scrollPos.x = mozilla::ToZeroIfNonfinite(aOptions.mLeft.Value());
|
||||
scrollPos.x = static_cast<int32_t>(
|
||||
mozilla::ToZeroIfNonfinite(aOptions.mLeft.Value()));
|
||||
}
|
||||
if (aOptions.mTop.WasPassed()) {
|
||||
scrollPos.y = mozilla::ToZeroIfNonfinite(aOptions.mTop.Value());
|
||||
scrollPos.y = static_cast<int32_t>(
|
||||
mozilla::ToZeroIfNonfinite(aOptions.mTop.Value()));
|
||||
}
|
||||
Scroll(scrollPos, aOptions);
|
||||
}
|
||||
@ -863,10 +865,12 @@ void Element::ScrollBy(const ScrollToOptions& aOptions) {
|
||||
if (sf) {
|
||||
CSSIntPoint scrollDelta;
|
||||
if (aOptions.mLeft.WasPassed()) {
|
||||
scrollDelta.x = mozilla::ToZeroIfNonfinite(aOptions.mLeft.Value());
|
||||
scrollDelta.x = static_cast<int32_t>(
|
||||
mozilla::ToZeroIfNonfinite(aOptions.mLeft.Value()));
|
||||
}
|
||||
if (aOptions.mTop.WasPassed()) {
|
||||
scrollDelta.y = mozilla::ToZeroIfNonfinite(aOptions.mTop.Value());
|
||||
scrollDelta.y = static_cast<int32_t>(
|
||||
mozilla::ToZeroIfNonfinite(aOptions.mTop.Value()));
|
||||
}
|
||||
|
||||
ScrollMode scrollMode = sf->IsSmoothScroll(aOptions.mBehavior)
|
||||
|
@ -3829,10 +3829,12 @@ void nsGlobalWindowInner::ScrollTo(const ScrollToOptions& aOptions) {
|
||||
if (sf) {
|
||||
CSSIntPoint scrollPos = sf->GetScrollPositionCSSPixels();
|
||||
if (aOptions.mLeft.WasPassed()) {
|
||||
scrollPos.x = mozilla::ToZeroIfNonfinite(aOptions.mLeft.Value());
|
||||
scrollPos.x = static_cast<int32_t>(
|
||||
mozilla::ToZeroIfNonfinite(aOptions.mLeft.Value()));
|
||||
}
|
||||
if (aOptions.mTop.WasPassed()) {
|
||||
scrollPos.y = mozilla::ToZeroIfNonfinite(aOptions.mTop.Value());
|
||||
scrollPos.y = static_cast<int32_t>(
|
||||
mozilla::ToZeroIfNonfinite(aOptions.mTop.Value()));
|
||||
}
|
||||
|
||||
ScrollTo(scrollPos, aOptions);
|
||||
@ -3901,10 +3903,12 @@ void nsGlobalWindowInner::ScrollBy(const ScrollToOptions& aOptions) {
|
||||
if (sf) {
|
||||
CSSIntPoint scrollDelta;
|
||||
if (aOptions.mLeft.WasPassed()) {
|
||||
scrollDelta.x = mozilla::ToZeroIfNonfinite(aOptions.mLeft.Value());
|
||||
scrollDelta.x = static_cast<int32_t>(
|
||||
mozilla::ToZeroIfNonfinite(aOptions.mLeft.Value()));
|
||||
}
|
||||
if (aOptions.mTop.WasPassed()) {
|
||||
scrollDelta.y = mozilla::ToZeroIfNonfinite(aOptions.mTop.Value());
|
||||
scrollDelta.y = static_cast<int32_t>(
|
||||
mozilla::ToZeroIfNonfinite(aOptions.mTop.Value()));
|
||||
}
|
||||
|
||||
ScrollMode scrollMode = sf->IsSmoothScroll(aOptions.mBehavior)
|
||||
|
@ -82,7 +82,10 @@ struct BasePoint {
|
||||
return x.value * aPoint.x.value + y.value * aPoint.y.value;
|
||||
}
|
||||
|
||||
Coord Length() const { return hypot(x.value, y.value); }
|
||||
// FIXME: Maybe Length() should return a float Coord event for integer Points?
|
||||
Coord Length() const {
|
||||
return static_cast<decltype(x.value)>(hypot(x.value, y.value));
|
||||
}
|
||||
|
||||
T LengthSquare() const { return x.value * x.value + y.value * y.value; }
|
||||
|
||||
|
@ -103,7 +103,9 @@ struct MOZ_EMPTY_BASES IntCoordTyped
|
||||
static_assert(sizeof(IntCoordTyped) == sizeof(Rep),
|
||||
"Would be unfortunate otherwise!");
|
||||
}
|
||||
constexpr MOZ_IMPLICIT IntCoordTyped(Rep aValue) : Super(aValue) {
|
||||
template <class T, typename = typename std::enable_if<
|
||||
std::is_integral<T>::value>::type>
|
||||
constexpr MOZ_IMPLICIT IntCoordTyped(T aValue) : Super(aValue) {
|
||||
static_assert(sizeof(IntCoordTyped) == sizeof(Rep),
|
||||
"Would be unfortunate otherwise!");
|
||||
}
|
||||
|
@ -2542,12 +2542,12 @@ IntRect FilterNodeConvolveMatrixSoftware::InflatedSourceRect(
|
||||
}
|
||||
|
||||
IntMargin margin;
|
||||
margin.left = ceil(mTarget.x * mKernelUnitLength.width);
|
||||
margin.top = ceil(mTarget.y * mKernelUnitLength.height);
|
||||
margin.right =
|
||||
ceil((mKernelSize.width - mTarget.x - 1) * mKernelUnitLength.width);
|
||||
margin.bottom =
|
||||
ceil((mKernelSize.height - mTarget.y - 1) * mKernelUnitLength.height);
|
||||
margin.left = static_cast<int32_t>(ceil(mTarget.x * mKernelUnitLength.width));
|
||||
margin.top = static_cast<int32_t>(ceil(mTarget.y * mKernelUnitLength.height));
|
||||
margin.right = static_cast<int32_t>(
|
||||
ceil((mKernelSize.width - mTarget.x - 1) * mKernelUnitLength.width));
|
||||
margin.bottom = static_cast<int32_t>(
|
||||
ceil((mKernelSize.height - mTarget.y - 1) * mKernelUnitLength.height));
|
||||
|
||||
IntRect srcRect = aDestRect;
|
||||
srcRect.Inflate(margin);
|
||||
@ -2561,12 +2561,14 @@ IntRect FilterNodeConvolveMatrixSoftware::InflatedDestRect(
|
||||
}
|
||||
|
||||
IntMargin margin;
|
||||
margin.left =
|
||||
ceil((mKernelSize.width - mTarget.x - 1) * mKernelUnitLength.width);
|
||||
margin.top =
|
||||
ceil((mKernelSize.height - mTarget.y - 1) * mKernelUnitLength.height);
|
||||
margin.right = ceil(mTarget.x * mKernelUnitLength.width);
|
||||
margin.bottom = ceil(mTarget.y * mKernelUnitLength.height);
|
||||
margin.left = static_cast<int32_t>(
|
||||
ceil((mKernelSize.width - mTarget.x - 1) * mKernelUnitLength.width));
|
||||
margin.top = static_cast<int32_t>(
|
||||
ceil((mKernelSize.height - mTarget.y - 1) * mKernelUnitLength.height));
|
||||
margin.right =
|
||||
static_cast<int32_t>(ceil(mTarget.x * mKernelUnitLength.width));
|
||||
margin.bottom =
|
||||
static_cast<int32_t>(ceil(mTarget.y * mKernelUnitLength.height));
|
||||
|
||||
IntRect destRect = aSourceRect;
|
||||
destRect.Inflate(margin);
|
||||
|
@ -70,19 +70,20 @@ TEST_F(APZCGestureDetectorTester, Pan_After_Pinch) {
|
||||
|
||||
// Spread fingers out to enter the pinch state
|
||||
mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, 0, mcc->Time(), 0);
|
||||
mti.mTouches.AppendElement(
|
||||
CreateSingleTouchData(firstFingerId, focusX - pinchLength, focusY));
|
||||
mti.mTouches.AppendElement(
|
||||
CreateSingleTouchData(secondFingerId, focusX + pinchLength, focusY));
|
||||
mti.mTouches.AppendElement(CreateSingleTouchData(
|
||||
firstFingerId, static_cast<int32_t>(focusX - pinchLength), focusY));
|
||||
mti.mTouches.AppendElement(CreateSingleTouchData(
|
||||
secondFingerId, static_cast<int32_t>(focusX + pinchLength), focusY));
|
||||
apzc->ReceiveInputEvent(mti);
|
||||
mcc->AdvanceBy(TIME_BETWEEN_TOUCH_EVENT);
|
||||
|
||||
// Do the actual pinch of 1.25x
|
||||
mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, 0, mcc->Time(), 0);
|
||||
mti.mTouches.AppendElement(
|
||||
CreateSingleTouchData(firstFingerId, focusX - pinchLengthScaled, focusY));
|
||||
mti.mTouches.AppendElement(CreateSingleTouchData(
|
||||
secondFingerId, focusX + pinchLengthScaled, focusY));
|
||||
firstFingerId, static_cast<int32_t>(focusX - pinchLengthScaled), focusY));
|
||||
mti.mTouches.AppendElement(CreateSingleTouchData(
|
||||
secondFingerId, static_cast<int32_t>(focusX + pinchLengthScaled),
|
||||
focusY));
|
||||
apzc->ReceiveInputEvent(mti);
|
||||
mcc->AdvanceBy(TIME_BETWEEN_TOUCH_EVENT);
|
||||
|
||||
@ -95,7 +96,8 @@ TEST_F(APZCGestureDetectorTester, Pan_After_Pinch) {
|
||||
// Now we lift one finger...
|
||||
mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_END, 0, mcc->Time(), 0);
|
||||
mti.mTouches.AppendElement(CreateSingleTouchData(
|
||||
secondFingerId, focusX + pinchLengthScaled, focusY));
|
||||
secondFingerId, static_cast<int32_t>(focusX + pinchLengthScaled),
|
||||
focusY));
|
||||
apzc->ReceiveInputEvent(mti);
|
||||
mcc->AdvanceBy(TIME_BETWEEN_TOUCH_EVENT);
|
||||
|
||||
@ -103,23 +105,23 @@ TEST_F(APZCGestureDetectorTester, Pan_After_Pinch) {
|
||||
// distance threshold.
|
||||
focusY += StaticPrefs::apz_touch_start_tolerance() * tm->GetDPI();
|
||||
mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, 0, mcc->Time(), 0);
|
||||
mti.mTouches.AppendElement(
|
||||
CreateSingleTouchData(firstFingerId, focusX - pinchLengthScaled, focusY));
|
||||
mti.mTouches.AppendElement(CreateSingleTouchData(
|
||||
firstFingerId, static_cast<int32_t>(focusX - pinchLengthScaled), focusY));
|
||||
apzc->ReceiveInputEvent(mti);
|
||||
mcc->AdvanceBy(TIME_BETWEEN_TOUCH_EVENT);
|
||||
|
||||
// This one does an actual pan of 20 pixels
|
||||
focusY += panDistance;
|
||||
mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, 0, mcc->Time(), 0);
|
||||
mti.mTouches.AppendElement(
|
||||
CreateSingleTouchData(firstFingerId, focusX - pinchLengthScaled, focusY));
|
||||
mti.mTouches.AppendElement(CreateSingleTouchData(
|
||||
firstFingerId, static_cast<int32_t>(focusX - pinchLengthScaled), focusY));
|
||||
apzc->ReceiveInputEvent(mti);
|
||||
mcc->AdvanceBy(TIME_BETWEEN_TOUCH_EVENT);
|
||||
|
||||
// Lift the remaining finger
|
||||
mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_END, 0, mcc->Time(), 0);
|
||||
mti.mTouches.AppendElement(
|
||||
CreateSingleTouchData(firstFingerId, focusX - pinchLengthScaled, focusY));
|
||||
mti.mTouches.AppendElement(CreateSingleTouchData(
|
||||
firstFingerId, static_cast<int32_t>(focusX - pinchLengthScaled), focusY));
|
||||
apzc->ReceiveInputEvent(mti);
|
||||
mcc->AdvanceBy(TIME_BETWEEN_TOUCH_EVENT);
|
||||
|
||||
@ -241,8 +243,8 @@ TEST_F(APZCGestureDetectorTester, SecondTapIsFar_Bug1586496) {
|
||||
|
||||
mcc->AdvanceBy(brief);
|
||||
|
||||
point.x += apzc->GetSecondTapTolerance() * 2;
|
||||
point.y += apzc->GetSecondTapTolerance() * 2;
|
||||
point.x += static_cast<int32_t>(apzc->GetSecondTapTolerance() * 2);
|
||||
point.y += static_cast<int32_t>(apzc->GetSecondTapTolerance() * 2);
|
||||
|
||||
Tap(apzc, point, brief);
|
||||
}
|
||||
|
@ -1422,10 +1422,12 @@ static nsIntRegion ResultChangeRegionForPrimitive(
|
||||
IntSize kernelSize = aConvolveMatrix.mKernelSize;
|
||||
IntPoint target = aConvolveMatrix.mTarget;
|
||||
nsIntMargin m(
|
||||
ceil(kernelUnitLength.width * (target.x)),
|
||||
ceil(kernelUnitLength.height * (target.y)),
|
||||
ceil(kernelUnitLength.width * (kernelSize.width - target.x - 1)),
|
||||
ceil(kernelUnitLength.height * (kernelSize.height - target.y - 1)));
|
||||
static_cast<int32_t>(ceil(kernelUnitLength.width * (target.x))),
|
||||
static_cast<int32_t>(ceil(kernelUnitLength.height * (target.y))),
|
||||
static_cast<int32_t>(
|
||||
ceil(kernelUnitLength.width * (kernelSize.width - target.x - 1))),
|
||||
static_cast<int32_t>(ceil(kernelUnitLength.height *
|
||||
(kernelSize.height - target.y - 1))));
|
||||
return mInputChangeRegions[0].Inflated(m);
|
||||
}
|
||||
|
||||
@ -1798,10 +1800,12 @@ static nsIntRegion SourceNeededRegionForPrimitive(
|
||||
IntSize kernelSize = aConvolveMatrix.mKernelSize;
|
||||
IntPoint target = aConvolveMatrix.mTarget;
|
||||
nsIntMargin m(
|
||||
ceil(kernelUnitLength.width * (kernelSize.width - target.x - 1)),
|
||||
ceil(kernelUnitLength.height * (kernelSize.height - target.y - 1)),
|
||||
ceil(kernelUnitLength.width * (target.x)),
|
||||
ceil(kernelUnitLength.height * (target.y)));
|
||||
static_cast<int32_t>(
|
||||
ceil(kernelUnitLength.width * (kernelSize.width - target.x - 1))),
|
||||
static_cast<int32_t>(ceil(kernelUnitLength.height *
|
||||
(kernelSize.height - target.y - 1))),
|
||||
static_cast<int32_t>(ceil(kernelUnitLength.width * (target.x))),
|
||||
static_cast<int32_t>(ceil(kernelUnitLength.height * (target.y))));
|
||||
return mResultNeededRegion.Inflated(m);
|
||||
}
|
||||
|
||||
|
@ -1835,7 +1835,7 @@ void nsHTMLScrollFrame::ScrollByLine(nsScrollbarFrame* aScrollbar,
|
||||
if (isHorizontal) {
|
||||
const double kScrollMultiplier =
|
||||
StaticPrefs::toolkit_scrollbox_horizontalScrollDistance();
|
||||
delta.x = aDirection * kScrollMultiplier;
|
||||
delta.x = static_cast<int32_t>(aDirection * kScrollMultiplier);
|
||||
if (GetLineScrollAmount().width * delta.x > GetPageScrollAmount().width) {
|
||||
// The scroll frame is so small that the delta would be more
|
||||
// than an entire page. Scroll by one page instead to maintain
|
||||
@ -1846,7 +1846,7 @@ void nsHTMLScrollFrame::ScrollByLine(nsScrollbarFrame* aScrollbar,
|
||||
} else {
|
||||
const double kScrollMultiplier =
|
||||
StaticPrefs::toolkit_scrollbox_verticalScrollDistance();
|
||||
delta.y = aDirection * kScrollMultiplier;
|
||||
delta.y = static_cast<int32_t>(aDirection * kScrollMultiplier);
|
||||
if (GetLineScrollAmount().height * delta.y > GetPageScrollAmount().height) {
|
||||
// The scroll frame is so small that the delta would be more
|
||||
// than an entire page. Scroll by one page instead to maintain
|
||||
|
@ -2346,14 +2346,14 @@ static void SizeOpenedWindow(nsIDocShellTreeOwner* aTreeOwner,
|
||||
winHeight = height + extraHeight;
|
||||
}
|
||||
if (winHeight > screenCssSize.height) {
|
||||
height = screenCssSize.height - extraHeight;
|
||||
height = static_cast<int32_t>(screenCssSize.height - extraHeight);
|
||||
}
|
||||
if (width < 100) {
|
||||
width = 100;
|
||||
winWidth = width + extraWidth;
|
||||
}
|
||||
if (winWidth > screenCssSize.width) {
|
||||
width = screenCssSize.width - extraWidth;
|
||||
width = static_cast<int32_t>(screenCssSize.width - extraWidth);
|
||||
}
|
||||
} else {
|
||||
int32_t targetContentWidth = 0;
|
||||
|
@ -4297,9 +4297,9 @@ NSUInteger IMEInputHandler::CharacterIndexForPoint(NSPoint& aPoint) {
|
||||
NSPoint ptInWindow = nsCocoaUtils::ConvertPointFromScreen(mainWindow, aPoint);
|
||||
NSPoint ptInView = [mView convertPoint:ptInWindow fromView:nil];
|
||||
queryCharAtPointEvent.mRefPoint.x =
|
||||
static_cast<int32_t>(ptInView.x) * mWidget->BackingScaleFactor();
|
||||
static_cast<int32_t>(ptInView.x * mWidget->BackingScaleFactor());
|
||||
queryCharAtPointEvent.mRefPoint.y =
|
||||
static_cast<int32_t>(ptInView.y) * mWidget->BackingScaleFactor();
|
||||
static_cast<int32_t>(ptInView.y * mWidget->BackingScaleFactor());
|
||||
mWidget->DispatchWindowEvent(queryCharAtPointEvent);
|
||||
if (queryCharAtPointEvent.Failed() || queryCharAtPointEvent.DidNotFindChar() ||
|
||||
queryCharAtPointEvent.mReply->StartOffset() >= static_cast<uint32_t>(NSNotFound)) {
|
||||
|
@ -254,10 +254,10 @@ void nsPrintSettingsX::SetFromPrintInfo(NSPrintInfo* aPrintInfo, bool aAdoptPrin
|
||||
SetPaperHeight(PaperSizeFromCocoaPoints(paperSize.width));
|
||||
}
|
||||
|
||||
mUnwriteableMargin.top = [aPrintInfo topMargin];
|
||||
mUnwriteableMargin.right = [aPrintInfo rightMargin];
|
||||
mUnwriteableMargin.bottom = [aPrintInfo bottomMargin];
|
||||
mUnwriteableMargin.left = [aPrintInfo leftMargin];
|
||||
mUnwriteableMargin.top = static_cast<int32_t>([aPrintInfo topMargin]);
|
||||
mUnwriteableMargin.right = static_cast<int32_t>([aPrintInfo rightMargin]);
|
||||
mUnwriteableMargin.bottom = static_cast<int32_t>([aPrintInfo bottomMargin]);
|
||||
mUnwriteableMargin.left = static_cast<int32_t>([aPrintInfo leftMargin]);
|
||||
|
||||
if (aAdoptPrintInfo) {
|
||||
// Keep a reference to the printInfo; it may have settings that we don't know how to handle
|
||||
|
Loading…
Reference in New Issue
Block a user