mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
7ad90a7dc7
- Bug 1208829 - Use the effective visible region to calculate the intermediate surface size. r=mstange (c3f8290088) - Bug 1168263 - Annotate layers with a perspective transform. r=mattwoodrow (a79c34590c) - Bug 1199798 - Use more generic tree traversal algorithms in APZCTreeManager. r=botond (9fede80160) - Bug 1179287 - Skip TestTiledLayerBuffer due to Linux PGO bustage. CLOSED TREE (c8dc548010) - Bug 1199798 - Create tests for TreeTraversal.h r=botond Move queue and stack includes outside of mozilla namespace. (37ba7ca2fe) - Bug 1226920 - Allow calling ForEachNode() with an action returning void r=botond (8368fcecc6) - Bug 1208829 - static_assert that IntRegionTyped is instantiated with a proper unit type. r=mstange (6acc37e149) - Bug 1208829 - Add utilities for converting between typed and untyped regions. r=mstange (40402a2f11) - Bug 1208829 - Rename LayerManagerComposite::ApplyOcclusionCulling to PostProcessLayers, and clean it up a bit. r=mstange (34f0bfe970) - Bug 1208829 - Recompute visible regions during composition. r=mstange (21304a1854) - Bug 1220873 - Make Layer::mVisibleRegion a LayerIntRegion. r=botond (5b8c30825e) - Bug 1168263 - Introduce a helper function IntersectMaybeRects(). r=kats (71f5087b64) - Bug 1168263 - Propagate the scroll-clip of a descendant of a layer with a perspective transform up to the layer itself. r=kats,mstange (fea1d86d5b) - Bug 1221694 - Add a basic telemetry probe for checkerboarding. r=botond,vladan (5725e19e0d) - Bug 1168263 - Simplify GetResultingTransformMatrix calculations to avoid unnecessary origin changes. r=roc (80368ae14f) - Bug 1127170 - Add TYPE_RENDERS_NO_IMAGES for display item with transform type to bypass invalidation during image decode. r=mattwoodrow (f6a207ee9d) - Bug 1168263 - Add nsDisplayPerspective and build separate layers for perspective. r=roc (b2b23687fb) - Bug 1176453 - Do not increment the cluster counter for input elements with label. r=kats (5bc312ca59) - Bug 1165128 - Enable zoomedview by default. r=mcomella (544b50df8b) - Bug 1181763 - Allow the target fluffing code to fluff even when directly hitting something clickable. r=roc (6ca7dd6904) - Bug 1188185 - Zoomed View appears when the two links are the same link. r=kats (813fca7975) - Bug 1192075 - Change copy in Settings for Zoomed View/ magnifying glass preference. r=mcomella (8430d9a907) - Bug 1191041 - Increase the likelihood of zoomed view triggering for small elements but decreased the likelihood for large elements. r=kats (eedeb65931) - Bug 1208370 - Deactivate the size heuristic in cluster detection. r=mcomella (360bca3b20) - Bug 1171731 - Ignore elements with 0 font size in cluster detection. r=kats (16d602f9d7) - Bug 1172488 - Small clickable text nodes are wrongly detected in cluster detection process. r=kats (d87c933ae2) - Bug 1191277 - Ensure that we don't find clusters of clickable elements when there is no possible way for the heuristic to actually target those elements. r=domivinc (50608494f9) - Bug 1226872 - Remove unnecessary wrapper methods in nsLayoutUtils. r=roc (6fbe70a794) - Bug 1208023 - Remove unused function. r=botond (c4f79eff8e) - Bug 1208023 - Ensure the minimum scale is a sane value greater than zero and add a separate flag to track if the default zoom is valid. r=botond (523cd967e2) - Bug 1225508 - Add a displayport on non-scrollable frames which have a resolution. r=botond (106045f0c9) - Bug 1201272 - use a SkBlurImageFilter for Skia canvas shadows so we can better control composite operations. r=gwright (bca9f2a21a) - Bug 998042 - 4-byte align Skia surfaces to interoperate with Cairo r=jrmuizel (5311a66ba1) - Bug 1083101 - Use win32's CreateEventW instead of CreateEvent to avoid macro name collision (68f94fa48c) - Bug 1148131 - Enable DrawTargetTiled on Android r=Bas (23f7fbca56) - Bug 1131264 - Extend the workaround for drawing D2D circles. r=bas (67ce725cfe) - Bug 1174922 - NativeZip does not null-terminate zip entry comparisons correctly, r=nchen (308848c1ef) - Bug 1127464 - Assert when we unexpectedly unload libraries on Android r=glandium (d55cda6129) - Bug 497495 late-breaking followup: s/GetAllocatedSize/GetFrameId/ in documentation, to reflect the same change having happened in code. (no review, comment-only, DONTBUILD) (f3cb3cf27c) - Bug 1216332 - Remove framearena helpers from abstract frame classes and stop them from being instantiated. r=dbaron (5b30fe7cba) - Bug 1178382 - Ignore overflow: -moz-hidden-unscrollable on <select size=n> listboxes. r=roc (555b7490c5) - Bug 1197620 - Part 3: Terminate *all* animations if corresponding element style is changed to display:none. r=bbirtles (1614414c50)
243 lines
12 KiB
C++
243 lines
12 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 "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
|
|
};
|
|
|
|
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);
|
|
}
|
|
|
|
// 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);
|
|
}
|
|
|
|
// 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> TransformTo(const gfx::Matrix4x4& aTransform,
|
|
const gfx::PointTyped<SourceUnits>& aPoint)
|
|
{
|
|
return ViewAs<TargetUnits>(aTransform * aPoint.ToUnknownPoint());
|
|
}
|
|
template <typename TargetUnits, typename SourceUnits>
|
|
static gfx::IntPointTyped<TargetUnits> TransformTo(const gfx::Matrix4x4& aTransform,
|
|
const gfx::IntPointTyped<SourceUnits>& aPoint)
|
|
{
|
|
return RoundedToInt(TransformTo<TargetUnits>(aTransform, gfx::PointTyped<SourceUnits>(aPoint)));
|
|
}
|
|
template <typename TargetUnits, typename SourceUnits>
|
|
static gfx::RectTyped<TargetUnits> TransformTo(const gfx::Matrix4x4& aTransform,
|
|
const gfx::RectTyped<SourceUnits>& aRect)
|
|
{
|
|
return ViewAs<TargetUnits>(aTransform.TransformBounds(aRect.ToUnknownRect()));
|
|
}
|
|
template <typename TargetUnits, typename SourceUnits>
|
|
static gfx::IntRectTyped<TargetUnits> TransformTo(const gfx::Matrix4x4& aTransform,
|
|
const gfx::IntRectTyped<SourceUnits>& aRect)
|
|
{
|
|
gfx::Rect rect(aRect.ToUnknownRect());
|
|
return RoundedToInt(ViewAs<TargetUnits>(aTransform.TransformBounds(rect)));
|
|
}
|
|
template <typename TargetUnits, typename SourceUnits>
|
|
static gfx::IntRegionTyped<TargetUnits> TransformTo(const gfx::Matrix4x4& aTransform,
|
|
const gfx::IntRegionTyped<SourceUnits>& aRegion)
|
|
{
|
|
return ViewAs<TargetUnits>(aRegion.ToUnknownRegion().Transform(aTransform));
|
|
}
|
|
|
|
// 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::Matrix4x4& aTransform,
|
|
const gfx::PointTyped<SourceUnits>& aVector,
|
|
const gfx::PointTyped<SourceUnits>& aAnchor) {
|
|
gfx::PointTyped<TargetUnits> transformedStart = TransformTo<TargetUnits>(aTransform, aAnchor);
|
|
gfx::PointTyped<TargetUnits> transformedEnd = TransformTo<TargetUnits>(aTransform, aAnchor + aVector);
|
|
return transformedEnd - transformedStart;
|
|
}
|
|
|
|
// UntransformTo() and UntransformVector() are like TransformTo() 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>> UntransformTo(const gfx::Matrix4x4& aTransform,
|
|
const gfx::PointTyped<SourceUnits>& aPoint)
|
|
{
|
|
gfx::Point4D point = aTransform.ProjectPoint(aPoint.ToUnknownPoint());
|
|
if (!point.HasPositiveWCoord()) {
|
|
return Nothing();
|
|
}
|
|
return Some(ViewAs<TargetUnits>(point.As2DPoint()));
|
|
}
|
|
template <typename TargetUnits, typename SourceUnits>
|
|
static Maybe<gfx::IntPointTyped<TargetUnits>> UntransformTo(const gfx::Matrix4x4& aTransform,
|
|
const gfx::IntPointTyped<SourceUnits>& aPoint)
|
|
{
|
|
gfx::Point p = aPoint.ToUnknownPoint();
|
|
gfx::Point4D point = aTransform.ProjectPoint(p);
|
|
if (!point.HasPositiveWCoord()) {
|
|
return Nothing();
|
|
}
|
|
return Some(RoundedToInt(ViewAs<TargetUnits>(point.As2DPoint())));
|
|
}
|
|
|
|
// The versions of UntransformTo() 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>> UntransformTo(const gfx::Matrix4x4& aTransform,
|
|
const gfx::RectTyped<SourceUnits>& aRect,
|
|
const gfx::RectTyped<TargetUnits>& aClip)
|
|
{
|
|
gfx::Rect rect = aTransform.ProjectRectBounds(aRect.ToUnknownRect(), aClip.ToUnknownRect());
|
|
if (rect.IsEmpty()) {
|
|
return Nothing();
|
|
}
|
|
return Some(ViewAs<TargetUnits>(rect));
|
|
}
|
|
template <typename TargetUnits, typename SourceUnits>
|
|
static Maybe<gfx::IntRectTyped<TargetUnits>> UntransformTo(const gfx::Matrix4x4& aTransform,
|
|
const gfx::IntRectTyped<SourceUnits>& aRect,
|
|
const gfx::IntRectTyped<TargetUnits>& aClip)
|
|
{
|
|
gfx::Rect rect = aTransform.ProjectRectBounds(aRect.ToUnknownRect(), aClip.ToUnknownRect());
|
|
if (rect.IsEmpty()) {
|
|
return Nothing();
|
|
}
|
|
return Some(RoundedToInt(ViewAs<TargetUnits>(rect)));
|
|
}
|
|
|
|
template <typename TargetUnits, typename SourceUnits>
|
|
static Maybe<gfx::PointTyped<TargetUnits>> UntransformVector(const gfx::Matrix4x4& aTransform,
|
|
const gfx::PointTyped<SourceUnits>& aVector,
|
|
const gfx::PointTyped<SourceUnits>& aAnchor) {
|
|
gfx::Point4D projectedAnchor = aTransform.ProjectPoint(aAnchor.ToUnknownPoint());
|
|
gfx::Point4D projectedTarget = aTransform.ProjectPoint(aAnchor.ToUnknownPoint() + aVector.ToUnknownPoint());
|
|
if (!projectedAnchor.HasPositiveWCoord() || !projectedTarget.HasPositiveWCoord()){
|
|
return Nothing();
|
|
}
|
|
return Some(ViewAs<TargetUnits>(projectedAnchor.As2DPoint() - projectedTarget.As2DPoint()));
|
|
}
|
|
|
|
} // namespace mozilla
|
|
|
|
#endif
|