Files
palemoon27/layout/base/UnitTransforms.h
T
roytam1 9319035337 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1153978 - Part 1: Separate buildIdOp from AsmJSCacheOps. r=jandem,bz (3e2b2c2754)
- Bug 1190032 - Sandbox failure in nsPluginHost::GetPluginTempDir. r=areinald (5698ee5709)
- Bug 1190032 - Sandbox failure in nsPluginHost::GetPluginTempDir, tighten earlier patch. r=areinald (81fad0767b)
- Bug 1201935 - Allow reading from TmpD in OS X content processes. r=smichaud (d67de1d8da)
- Bug 1237847 - [e10s] Null deref crash when running test_pluginstream_newstream.html; r=bobowen (c61e5fa268)
- Add a helper function for iterating indirect layer trees. (bug 1245765 part 1, r=mattwoodrow) (9fcc19e731)
- Propagate D3D9 device resets to remote layers. (bug 1245765 part 2, r=mattwoodrow) (15ab24ebd6)
- Don't propagate simulated device resets to child processes. (bug 1245765 part 3, r=mattwoodrow) (fe0986532c)
- Fix async drawing when we lose the D3D11 device. (bug 1245765 part 4, r=mattwoodrow) (fcf9e1a009)
- Factor compositor initialization out of LayerManagerComposite. (bug 1245765 part 6, r=mattwoodrow) (7af570b6fc)
- Bug 1232042: Execute an additional present for D3D11 on the compositor thread when a WM_PAINT event has returned. r=jrmuizel (ac14c78377)
- Handle device resets by recreating the compositor, rather than the compositor IPDL stack. (bug 1245765 part 7, r=mattwoodrow) (87292d6e2b)
- Ensure that content processes recreate rendering devices. (bug 1245765 part 8, r=mattwoodrow) (8c4e712c6e)
- Invalidate layers when starting a transaction on a stale device. (bug 1245765 part 9, r=mattwoodrow) (330efa7199)
- Bug 1041599 - Maintain a single volume control session between browser, content, and plugins on Windows. r=aklotz (bdab2a3b35)
- Bug 1250897 - Add build number data in Telemetry pings r=gfritzsche (06cdbada89)
- align more tests (c6445e1646)
- Bug 1241646 - remove unused token arguments from nsIX509CertDB r=keeler (13e50d449c)
- Bug 1064402 - Part 1: Remove Import button in Servers tab of the Certificate Manager. r=keeler (181a5a0be2)
- Bug 1064402 - Part 2: Remove nsIX509CertDB.importServerCertificate() and nsIX509Cert::SERVER_CERT support in importCertsFromFile(). r=keeler (a4ee6e83f4)
- Bug 1130418 - Remove broken e-mail cert trust editing UI. r=emk (d8dca873c1)
- Bug 1243182 - Enable eslint "space-infix-ops" rule for PSM. r=keeler (9f5110213f)
- Bug 1244245 - Enable eslint "curly" rule for PSM. r=keeler (09b4d913ab)
- Bug 1246365 - Enable eslint "comma-spacing" and "semi" rules for PSM. r=keeler (e85d033547)
- bug 1246765 - remove unnecessary resource://app/ registration from getHSTSPreloadList.js r=Cykesiopka DONTBUILD NPOTB (e4eb6d1a1e)
- Bug 1249595 - Enable 11 more ESLint rules for PSM. r=keeler (7daa42685a)
- Bug 1224968 - Support public key input to unbreak periodic HPKP updates. r=keeler (a14415f3c3)
- Bug 1229284 - Remove support for SHA-1 hashes in genHPKPStaticPins.js. r=keeler (2e54ef3566)
- No bug, Automated HPKP preload list update from host bld-linux64-spot-049 - a=hpkp-update (08eb34de92)
- No bug, Automated HPKP preload list update from host bld-linux64-spot-1077 - a=hpkp-update (2eca8a772a)
- No bug, Automated HPKP preload list update from host bld-linux64-spot-573 - a=hpkp-update (aa140271a8)
- No bug, Automated HPKP preload list update from host bld-linux64-spot-593 - a=hpkp-update (6acc29f100)
- No bug, Automated HPKP preload list update from host bld-linux64-spot-389 - a=hpkp-update (54189edc5f)
- No bug, Automated HPKP preload list update from host bld-linux64-spot-506 - a=hpkp-update (38d3927a54)
- Bug 1197607, Automated hsts & hpkp updates are failing on mozilla-central, mozilla-aurora, mozilla-esr38, r=cykesiopka (8754cce3ba)
- Bug 1224481 - Comment out CA certs removed in NSS 3.21 in PreloadedHPKPins.json to keep periodic Static HPKP updates working. r=dkeeler (6680c85a1b)
- bug 1232766 - update the preloaded pinset for Google domains r=rbarnes (83697d274b)
- Bug 1250254 - Enable ESLint "no-throw-literal" rule for PSM. r=dkeeler (300ef6f5b8)
- Bug 1224531 - Provide a mechanism for the updater to drive kinto collection sync r=rnewman,mossop (c1ef71581f)
- Bug 1256088 - Merge mock app-info implementation into AppInfo.jsm. r=gps (e38ae85b3d)
- Bug 1153978 - Part 0: Separate nsIPlatformInfo from nsIXULAppInfo. r=jst,gps (2f4eef64c1)
- Bug 1153978 - Part 2: Clear pending exception thrown from XDR related APIs when ignoring ReadCachedScript failure. r=bz (09f06d4c74)
- Bug 1153978 - Part 3: Use the build id instead of the XDR_BYTECODE_VERSION constant. r=jandem (2e8e01f534)
- bug 1241317 - gather telemetry on prevalence of FIPS r=jcj r=vladan (905485c911)
- Bug 1220237 - Remove uses of nsIEnumerator from PSM. r=keeler (6b17abd967)
- bug 1239455 - rework telemetry for SHA-1 certificates to reflect possible policy states r=Cykesiopka,mgoodwin,rbarnes (95fb0f63ab)
- Bug 1247847 - Use smart pointers in nsNSSCertHelper.cpp to manage NSS resources. r=keeler (56140f95c4)
- Bug 1248874 - Replace Scoped.h templates used only by PSM in ScopedNSSTypes.h with UniquePtr equivalents. r=dkeeler (1cedc01ab9)
- Bug 1016555 - Disable OCSP checking for certificates covered by OneCRL r=keeler (3dc16a87d6)
- Bug 1227970 - Perform preference checks to allow OCSP Bypass for OneCRL via Kinto r=keeler (58136eb9e5)
- Bug 1219482: Replace PRLogModuleInfo with LazyLogModule in security subdirectory.r=nfroyd (896838cc5d)
- Bug 1226928 - remove Wshadow warning in ScopedNSSTypes, r=keeler (52ccbac1bc)
- Bug 1226928 - signature verification for content-signing, r=keeler,mayhemer (5f589bf0e0)
- Bug 1250256 - Partially clean up nsSDR.cpp. r=keeler (665c582a90)
- bug 1241650 - remove nsIX509CertDB.findCertNicknames r=mgoodwin (bf0c26772b)
- Bug 1250258 - Partially clean up nsNSSCertificateDB.cpp import methods. r=keeler (693e213484)
- Bug 1239437 - xpcshell tests for responsive.html. r=pbrosset (d908a0e873)
- Bug 1219554 - Remove the unused waitUntilSnapshotState test utility; r=jsantell (9e89ccec3e)
- Bug 1249453 - Add arrows from parent to children in census trees; r=jsantell (b36c077be5)
- Bug 1204202 - Package Universal CRT DLLs for VS2015. r=glandium,ehsan (9b9e1e4057)
- bug 496234 - add test vectors from RFC 1320 for md4 implementation r=mayhemer (6526e81ec7)
- bug 1228175 - fix IsCertBuiltInRoot r=Cykesiopka,mgoodwin (13bdaf7bb3)
- bug 1240118 - add functionality to treat a test certificate as a built-in root r=mgoodwin (bf31c4365b)
- Bug 1245649: Turn on valid-typeof, no-invalid-regexp, no-empty-pattern and no-empty-character-class. r=felipe (f637f26dc7)
- Bug 1245916: Add additional default globals. r=felipe (229e39bbbe)
- Bug 1251011 - Enable ESLint "no-undef" rule for PSM. r=keeler r=mossop (a6e17d09aa)
- Bug 1243636. Switch to gfx::CriticalSection (a4d6172870)
- Bug 1137561 part.1 Implement WinTextEventDispatcherListener as a singleton class for using TextEventDispatcher at handling native keyboard and IME events r=m_kato (f4582070b0)
- Bug 1255475 - Properly distinguish 'moving' from 'resizing' state when a maximized window is dragged, resulting in a WM_SIZING message followed by WM_MOVING; this allows us to handle DPI rescaling during the move if necessary. r=emk (009527a407)
- Bug 1137572 part.1 TextEventDispatcher should manage its input transaction type r=smaug (ccafc27024)
- Bug 1137572 part.2 Add nsIWidget::GetNativeTextEventDispatcherListener() for TextEventDispatcher::NotifyIME() r=smaug, sr=smaug (21571501e8)
- Bug 1137572 part.3 Use pseudo IME context when TextEventDispatcher has input transaction which is not for native event handler r=smaug (40be7193b1)
- Bug 1137572 part.4 TextEventDispatcher::DispatchInputEvent() should decide if dispatches events with nsIWidget::DispatchInputEvent() with input transaction type r=smaug (ae71f47af2)
- Bug 1137572 part.5 Implement TextEventDispatcher::SetPendingComposition() for some platforms whose clause information may overlap each other or the order may not be from start to the end r=smaug (fd046de0fc)
- Bug 1137572 part.6 TextEventDispatcher::DispatchKeyboardEventInternal() should copy mNativeKeyEvent when it's in native text input transaction r=smaug (eb17ab1738)
- Bug 1137572 part.7 Add TextEventDispatcherListener::WillDispatchKeyboardEvent() for easier to maintain r=smaug (e66759a731)
- Bug 1137572 part.8 Callers of methods to dispatch composition events of TextEventDispatcher should be able to specify specific time/timeStamp r=smaug (2cdfd2f3d4)
- Bug 1137572 part.9 TextEventDispatcher should not allow WillDispatchKeyboardEvent() modifies unexpected members of WidgetKeyboardEvent r=smaug (94f97ff72d)
- Bug 1137561 part.2 Make TSFTextStore use TextEventDispatcher r=m_kato (5b0d92117d)
- Bug 1137561 part.3 Make IMMHandler use TextEventDispatcher r=m_kato (2b5ef42de7)
- Bug 1137561 part.4 Make NativeKey use TextEventDispatcher r=m_kato (e98eb8b72f)
- Bug 1137561 part.5 TextEventDispatcher should decide if keypress events should be fired for specific keys r=m_kato (b5ad4d702c)
- Bug 1248505 - Remove nsDocument::IsFullScreenDoc and its uses. r=smaug (05927c0bec)
2024-01-31 12:02:57 +08:00

288 lines
13 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MOZ_UNIT_TRANSFORMS_H_
#define MOZ_UNIT_TRANSFORMS_H_
#include "Units.h"
#include "mozilla/gfx/Matrix.h"
#include "mozilla/Maybe.h"
#include "nsRegion.h"
namespace mozilla {
// Convenience functions for converting an entity from one strongly-typed
// coordinate system to another without changing the values it stores (this
// can be thought of as a cast).
// To use these functions, you must provide a justification for each use!
// Feel free to add more justifications to PixelCastJustification, along with
// a comment that explains under what circumstances it is appropriate to use.
enum class PixelCastJustification : uint8_t {
// For the root layer, Screen Pixel = Parent Layer Pixel.
ScreenIsParentLayerForRoot,
// On the layout side, Screen Pixel = LayoutDevice at the outer-window level.
LayoutDeviceIsScreenForBounds,
// For the root layer, Render Target Pixel = Parent Layer Pixel.
RenderTargetIsParentLayerForRoot,
// For the root composition size we want to view it as layer pixels in any layer
ParentLayerToLayerForRootComposition,
// The Layer coordinate space for one layer is the ParentLayer coordinate
// space for its children
MovingDownToChildren,
// The transform that is usually used to convert between two coordinate
// systems is not available (for example, because the object that stores it
// is being destroyed), so fall back to the identity.
TransformNotAvailable,
// When an OS event is initially constructed, its reference point is
// technically in screen pixels, as it has not yet accounted for any
// asynchronous transforms. This justification is for viewing the initial
// reference point as a screen point. The reverse is useful when synthetically
// created WidgetEvents need to be converted back to InputData.
LayoutDeviceIsScreenForUntransformedEvent,
// Similar to LayoutDeviceIsScreenForUntransformedEvent, PBrowser handles
// some widget/tab dimension information as the OS does -- in screen units.
LayoutDeviceIsScreenForTabDims,
// A combination of LayoutDeviceIsScreenForBounds and
// ScreenIsParentLayerForRoot, which is how we're using it.
LayoutDeviceIsParentLayerForRCDRSF,
// Used to treat the product of AsyncTransformComponentMatrix objects
// as an AsyncTransformMatrix. See the definitions of these matrices in
// LayersTypes.h for details.
MultipleAsyncTransforms
};
template <class TargetUnits, class SourceUnits>
gfx::SizeTyped<TargetUnits> ViewAs(const gfx::SizeTyped<SourceUnits>& aSize, PixelCastJustification) {
return gfx::SizeTyped<TargetUnits>(aSize.width, aSize.height);
}
template <class TargetUnits, class SourceUnits>
gfx::IntSizeTyped<TargetUnits> ViewAs(const gfx::IntSizeTyped<SourceUnits>& aSize, PixelCastJustification) {
return gfx::IntSizeTyped<TargetUnits>(aSize.width, aSize.height);
}
template <class TargetUnits, class SourceUnits>
gfx::PointTyped<TargetUnits> ViewAs(const gfx::PointTyped<SourceUnits>& aPoint, PixelCastJustification) {
return gfx::PointTyped<TargetUnits>(aPoint.x, aPoint.y);
}
template <class TargetUnits, class SourceUnits>
gfx::IntPointTyped<TargetUnits> ViewAs(const gfx::IntPointTyped<SourceUnits>& aPoint, PixelCastJustification) {
return gfx::IntPointTyped<TargetUnits>(aPoint.x, aPoint.y);
}
template <class TargetUnits, class SourceUnits>
gfx::RectTyped<TargetUnits> ViewAs(const gfx::RectTyped<SourceUnits>& aRect, PixelCastJustification) {
return gfx::RectTyped<TargetUnits>(aRect.x, aRect.y, aRect.width, aRect.height);
}
template <class TargetUnits, class SourceUnits>
gfx::IntRectTyped<TargetUnits> ViewAs(const gfx::IntRectTyped<SourceUnits>& aRect, PixelCastJustification) {
return gfx::IntRectTyped<TargetUnits>(aRect.x, aRect.y, aRect.width, aRect.height);
}
template <class TargetUnits, class SourceUnits>
gfx::MarginTyped<TargetUnits> ViewAs(const gfx::MarginTyped<SourceUnits>& aMargin, PixelCastJustification) {
return gfx::MarginTyped<TargetUnits>(aMargin.top, aMargin.right, aMargin.bottom, aMargin.left);
}
template <class TargetUnits, class SourceUnits>
gfx::IntMarginTyped<TargetUnits> ViewAs(const gfx::IntMarginTyped<SourceUnits>& aMargin, PixelCastJustification) {
return gfx::IntMarginTyped<TargetUnits>(aMargin.top, aMargin.right, aMargin.bottom, aMargin.left);
}
template <class TargetUnits, class SourceUnits>
gfx::IntRegionTyped<TargetUnits> ViewAs(const gfx::IntRegionTyped<SourceUnits>& aRegion, PixelCastJustification) {
return gfx::IntRegionTyped<TargetUnits>::FromUnknownRegion(aRegion.ToUnknownRegion());
}
template <class NewTargetUnits, class OldTargetUnits, class SourceUnits>
gfx::ScaleFactor<SourceUnits, NewTargetUnits> ViewTargetAs(
const gfx::ScaleFactor<SourceUnits, OldTargetUnits>& aScaleFactor,
PixelCastJustification) {
return gfx::ScaleFactor<SourceUnits, NewTargetUnits>(aScaleFactor.scale);
}
// Unlike the other functions in this category, this function takes the
// target matrix type, rather than its source and target unit types, as
// the explicit template argument, so an example invocation is:
// ViewAs<ScreenToLayerMatrix4x4>(otherTypedMatrix, justification)
// The reason is that if it took the source and target unit types as two
// template arguments, there may be some confusion as to which is the
// source and which is the target.
template <class TargetMatrix, class SourceMatrixSourceUnits, class SourceMatrixTargetUnits>
TargetMatrix ViewAs(
const gfx::Matrix4x4Typed<SourceMatrixSourceUnits, SourceMatrixTargetUnits>& aMatrix,
PixelCastJustification) {
return TargetMatrix::FromUnknownMatrix(aMatrix.ToUnknownMatrix());
}
// Convenience functions for casting untyped entities to typed entities.
// Using these functions does not require a justification, but once we convert
// all code to use strongly typed units they should not be needed any longer.
template <class TargetUnits>
gfx::PointTyped<TargetUnits> ViewAs(const gfxPoint& aPoint) {
return gfx::PointTyped<TargetUnits>(aPoint.x, aPoint.y);
}
template <class TargetUnits>
gfx::PointTyped<TargetUnits> ViewAs(const gfx::Point& aPoint) {
return gfx::PointTyped<TargetUnits>(aPoint.x, aPoint.y);
}
template <class TargetUnits>
gfx::RectTyped<TargetUnits> ViewAs(const gfx::Rect& aRect) {
return gfx::RectTyped<TargetUnits>(aRect.x, aRect.y, aRect.width, aRect.height);
}
template <class TargetUnits>
gfx::IntSizeTyped<TargetUnits> ViewAs(const nsIntSize& aSize) {
return gfx::IntSizeTyped<TargetUnits>(aSize.width, aSize.height);
}
template <class TargetUnits>
gfx::IntPointTyped<TargetUnits> ViewAs(const nsIntPoint& aPoint) {
return gfx::IntPointTyped<TargetUnits>(aPoint.x, aPoint.y);
}
template <class TargetUnits>
gfx::IntRectTyped<TargetUnits> ViewAs(const nsIntRect& aRect) {
return gfx::IntRectTyped<TargetUnits>(aRect.x, aRect.y, aRect.width, aRect.height);
}
template <class TargetUnits>
gfx::IntRegionTyped<TargetUnits> ViewAs(const nsIntRegion& aRegion) {
return gfx::IntRegionTyped<TargetUnits>::FromUnknownRegion(aRegion);
}
// Unlike the other functions in this category, this function takes the
// target matrix type, rather than its source and target unit types, as
// the template argument, so an example invocation is:
// ViewAs<ScreenToLayerMatrix4x4>(untypedMatrix)
// The reason is that if it took the source and target unit types as two
// template arguments, there may be some confusion as to which is the
// source and which is the target.
template <class TypedMatrix>
TypedMatrix ViewAs(const gfx::Matrix4x4& aMatrix) {
return TypedMatrix::FromUnknownMatrix(aMatrix);
}
// Convenience functions for transforming an entity from one strongly-typed
// coordinate system to another using the provided transformation matrix.
template <typename TargetUnits, typename SourceUnits>
static gfx::PointTyped<TargetUnits>
TransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::PointTyped<SourceUnits>& aPoint)
{
return aTransform * aPoint;
}
template <typename TargetUnits, typename SourceUnits>
static gfx::IntPointTyped<TargetUnits>
TransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::IntPointTyped<SourceUnits>& aPoint)
{
return RoundedToInt(TransformBy(aTransform, gfx::PointTyped<SourceUnits>(aPoint)));
}
template <typename TargetUnits, typename SourceUnits>
static gfx::RectTyped<TargetUnits>
TransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::RectTyped<SourceUnits>& aRect)
{
return aTransform.TransformBounds(aRect);
}
template <typename TargetUnits, typename SourceUnits>
static gfx::IntRectTyped<TargetUnits>
TransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::IntRectTyped<SourceUnits>& aRect)
{
return RoundedToInt(TransformBy(aTransform, gfx::RectTyped<SourceUnits>(aRect)));
}
template <typename TargetUnits, typename SourceUnits>
static gfx::IntRegionTyped<TargetUnits>
TransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::IntRegionTyped<SourceUnits>& aRegion)
{
return ViewAs<TargetUnits>(aRegion.ToUnknownRegion().Transform(
aTransform.ToUnknownMatrix()));
}
// Transform |aVector|, which is anchored at |aAnchor|, by the given transform
// matrix, yielding a point in |TargetUnits|.
// The anchor is necessary because with 3D tranforms, the location of the
// vector can affect the result of the transform.
template <typename TargetUnits, typename SourceUnits>
static gfx::PointTyped<TargetUnits>
TransformVector(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::PointTyped<SourceUnits>& aVector,
const gfx::PointTyped<SourceUnits>& aAnchor)
{
gfx::PointTyped<TargetUnits> transformedStart = TransformBy(aTransform, aAnchor);
gfx::PointTyped<TargetUnits> transformedEnd = TransformBy(aTransform, aAnchor + aVector);
return transformedEnd - transformedStart;
}
// UntransformBy() and UntransformVector() are like TransformBy() and
// TransformVector(), respectively, but are intended for cases where
// the transformation matrix is the inverse of a 3D projection. When
// using such transforms, the resulting Point4D is only meaningful
// if it has a positive w-coordinate. To handle this, these functions
// return a Maybe object which contains a value if and only if the
// result is meaningful
template <typename TargetUnits, typename SourceUnits>
static Maybe<gfx::PointTyped<TargetUnits>>
UntransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::PointTyped<SourceUnits>& aPoint)
{
gfx::Point4DTyped<TargetUnits> point = aTransform.ProjectPoint(aPoint);
if (!point.HasPositiveWCoord()) {
return Nothing();
}
return Some(point.As2DPoint());
}
template <typename TargetUnits, typename SourceUnits>
static Maybe<gfx::IntPointTyped<TargetUnits>>
UntransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::IntPointTyped<SourceUnits>& aPoint)
{
gfx::PointTyped<SourceUnits> p = aPoint;
gfx::Point4DTyped<TargetUnits> point = aTransform.ProjectPoint(p);
if (!point.HasPositiveWCoord()) {
return Nothing();
}
return Some(RoundedToInt(point.As2DPoint()));
}
// The versions of UntransformBy() that take a rectangle also take a clip,
// which represents the bounds within which the target must fall. The
// result of the transform is intersected with this clip, and is considered
// meaningful if the intersection is not empty.
template <typename TargetUnits, typename SourceUnits>
static Maybe<gfx::RectTyped<TargetUnits>>
UntransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::RectTyped<SourceUnits>& aRect,
const gfx::RectTyped<TargetUnits>& aClip)
{
gfx::RectTyped<TargetUnits> rect = aTransform.ProjectRectBounds(aRect, aClip);
if (rect.IsEmpty()) {
return Nothing();
}
return Some(rect);
}
template <typename TargetUnits, typename SourceUnits>
static Maybe<gfx::IntRectTyped<TargetUnits>>
UntransformBy(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::IntRectTyped<SourceUnits>& aRect,
const gfx::IntRectTyped<TargetUnits>& aClip)
{
gfx::RectTyped<TargetUnits> rect = aTransform.ProjectRectBounds(aRect, aClip);
if (rect.IsEmpty()) {
return Nothing();
}
return Some(RoundedToInt(rect));
}
template <typename TargetUnits, typename SourceUnits>
static Maybe<gfx::PointTyped<TargetUnits>>
UntransformVector(const gfx::Matrix4x4Typed<SourceUnits, TargetUnits>& aTransform,
const gfx::PointTyped<SourceUnits>& aVector,
const gfx::PointTyped<SourceUnits>& aAnchor)
{
gfx::Point4DTyped<TargetUnits> projectedAnchor = aTransform.ProjectPoint(aAnchor);
gfx::Point4DTyped<TargetUnits> projectedTarget = aTransform.ProjectPoint(aAnchor + aVector);
if (!projectedAnchor.HasPositiveWCoord() || !projectedTarget.HasPositiveWCoord()){
return Nothing();
}
return Some(projectedTarget.As2DPoint() - projectedAnchor.As2DPoint());
}
} // namespace mozilla
#endif