mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
67e04cfead
- Bug 1236750 - Introduce a new unit type CSSTransformedLayerPixel. r=kats (4e9bba3d19) - Bug 1236750 - Add a ViewAs() overload for casting (with a justification) one typed matrix to another. r=kats (c48e143508) - Bug 1236750 - Add some specialized typedefs of Matrix4x4 to represent layer transform matrices. r=kats (cc50113c98) - Bug 1239300 - reject promise with null while creating imagebitmap from empty blob; r=smaug (bff7483bf1) - Bug 1233056 - Long tapping on a link will select a different link from the page r=tnikkel (3a727b33c1) - Bug 1245674. Null-check mGlobal before dereferencing it in one more place in Promise code. r=smaug (68cf5312dc) - Bug 1236750 - Use strongly-typed matrices to represent layer transforms in APZ code. r=kats (63931eb2a1) - Bug 1236750 - Add typed getters for layer transform matrices. r=kats (baef978fe1) - Bug 1147673 - Relax the ancestor transform assertion a little. r=kats (ec9ce47ba4) - Bug 1154161 Initialize WidgetQueryContentEvent::mReply r=smaug (6086291313) - Bug 1240921 - Use nsAutoTArray in nsStyleSet::RuleNodeWithReplacement. r=bz. (66f6823b46) - Bug 1229437 part 1 - Add a helper function to get the float containing block of a given frame. r=dbaron (72de452e5d) - Bug 1229437 part 2 - Reparent floats inside pulled ruby segment. r=dbaron (82cc44632d) - Bug 1229437 part 3 - Support iterating frames of RubyColumn. r=dholbert (5d43e7f6ff) - Bug 1229437 part 4 - Reparent floats inside pulled ruby column. r=dbaron (4c1a7ff20b) - Bug 1229437 part 5 - Add crashtests for this bug. r=dbaron (6afabe1604) - Bug 1229437 followup - Fix sign-compare error in RubyColumn::Iterator on CLOSED TREE. (e93453d00a) - Bug 1229437 followup 2 - Fix another sign-compare error in RubyColumn::Iterator on CLOSED TREE. (c0bf6a2a7b) - Bug 1229437 followup 3 - Fix a mistake in RubyColumn::Iterator::SkipUntilExistingFrame(). a=me (1ce408e194) - bits of Bug 1072150 - Use the opt-out for various sloppy consumers (29d97c59ca) - Make test_bug946632 compatible with asynchronous scrolling. (bug 1140293, r=mstange) (e975a8350c) - fix misspatch of 1072150 (a3e580fa4b) - Bug 686281 - Implement nsStyleImageLayers; r=dbaron (85bb33c8e6) - Bug 686281 - Rename *background* to *imagelayer*; r=dbaron. (36d90f112d) - Bug 1230034 part 4 - Make FramePropertyDescriptor to be a template. r=froydnj,dbaron (271cd19b6e) - Bug 1230034 part 5 - Convert all frame properties which use DeleteValue and ReleaseValue as destructor to be typesafe. r=dbaron (efc8d63c9d) - Bug 1230034 part 6 - Convert all frame properties which do not hold pointer to be typed. r=dbaron (b5541775f7) - Bug 1230034 part 7 - Convert nsIFrame::GenConProperty to be typed. r=dbaron (2b71527b2c) - Bug 1230034 part 8 - Convert frame properties which assert on destructor to be typed. r=dbaron (0f125a3414) - Bug 1230034 part 9 - Convert FrameLayerBuilder::LayerManagerDataProperty to be typed. r=dbaron (1147498c2f) - Bug 1230034 part 10 - Convert remaining frame properties to by typed and remove the unsafe declaring macro. r=dbaron (d59d94eac4) - Bug 1072501: Unmap file mapping on source surface destruction. r=jrmuizel (19fd63890a) - Bug 1235613 - Make gfxCriticalError/Note strings in gfx/ unique. r=jrmuizel (780c6ff862) - Bug 1247535 - Fix -Wunreachable-code warning in mfbt/Poison.cpp. r=froydnj (0e7cf60b6d) - Bug 1239479: Add comments to mfbt/XorShift128PlusRNG.h from the RNG's designer. DONTBUILD r=Waldo (bb674b07ce) - Add an assertion message to the assert-is-empty in LinkedList::~LinkedList, to indicate to users who hit it that it's the fault of the caller, not the fault of MFBT code. No bug, rs=froydnj (4cad80874c) - Bug 1221103 - Add a comment to nsIChannel::securityInfo noting that this info may appear on non-nsHttpChannels and how that may happen. r=bz IGNORE IDL (cd9cebc3f2) - Bug 1001765 - Make login credentials in Saved Passwords manager editable. r=MattN (09eec4f6f8) - Bug 1188478 - Add an Import button to the password manager to open the browser migrator. r=dolske (d1126a89fc) - Bug 1199382 - Rename some strings from "password" to "login" in preferences and the manager. r=markh (60638f5e2a) - Bug 1207733 - Update @disabled on the Remove Password button when selection changes. r=MattN (64ac9f22f6) - bits of 1124472 and 1166840 (26e2681183) - Bug 1219707 - fix argument passing to migration.js, r=jaws (55d332f5c6) - bug 1215657 - make AccessibleWrap::get_accSelection work with proxies=davidb (4e72111032) - fix missing telemetry entry (4fcfabb3e6) and follow-up API changes of TFF#493.
490 lines
13 KiB
C++
490 lines
13 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
* 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 GFX_LAYERMETRICSWRAPPER_H
|
|
#define GFX_LAYERMETRICSWRAPPER_H
|
|
|
|
#include "Layers.h"
|
|
#include "UnitTransforms.h"
|
|
|
|
namespace mozilla {
|
|
namespace layers {
|
|
|
|
/**
|
|
* A wrapper class around a target Layer with that allows user code to
|
|
* walk through the FrameMetrics objects on the layer the same way it
|
|
* would walk through a ContainerLayer hierarchy. Consider the following
|
|
* layer tree:
|
|
*
|
|
* +---+
|
|
* | A |
|
|
* +---+
|
|
* / | \
|
|
* / | \
|
|
* / | \
|
|
* +---+ +-----+ +---+
|
|
* | B | | C | | D |
|
|
* +---+ +-----+ +---+
|
|
* | FMn |
|
|
* | . |
|
|
* | . |
|
|
* | . |
|
|
* | FM1 |
|
|
* | FM0 |
|
|
* +-----+
|
|
* / \
|
|
* / \
|
|
* +---+ +---+
|
|
* | E | | F |
|
|
* +---+ +---+
|
|
*
|
|
* In this layer tree, there are six layers with A being the root and B,D,E,F
|
|
* being leaf nodes. Layer C is in the middle and has n+1 FrameMetrics, labelled
|
|
* FM0...FMn. FM0 is the FrameMetrics you get by calling c->GetFrameMetrics(0)
|
|
* and FMn is the FrameMetrics you can obtain by calling
|
|
* c->GetFrameMetrics(c->GetFrameMetricsCount() - 1). This layer tree is
|
|
* conceptually equivalent to this one below:
|
|
*
|
|
* +---+
|
|
* | A |
|
|
* +---+
|
|
* / | \
|
|
* / | \
|
|
* / | \
|
|
* +---+ +-----+ +---+
|
|
* | B | | Cn | | D |
|
|
* +---+ +-----+ +---+
|
|
* |
|
|
* .
|
|
* .
|
|
* .
|
|
* |
|
|
* +-----+
|
|
* | C1 |
|
|
* +-----+
|
|
* |
|
|
* +-----+
|
|
* | C0 |
|
|
* +-----+
|
|
* / \
|
|
* / \
|
|
* +---+ +---+
|
|
* | E | | F |
|
|
* +---+ +---+
|
|
*
|
|
* In this layer tree, the layer C has been expanded into a stack of container
|
|
* layers C1...Cn, where C1 has FrameMetrics FM1 and Cn has FrameMetrics Fn.
|
|
* Although in this example C (in the first layer tree) and C0 (in the second
|
|
* layer tree) are both ContainerLayers (because they have children), they
|
|
* do not have to be. They may just be PaintedLayers or ColorLayers, for example,
|
|
* which do not have any children. However, the type of C will always be the
|
|
* same as the type of C0.
|
|
*
|
|
* The LayerMetricsWrapper class allows client code to treat the first layer
|
|
* tree as though it were the second. That is, instead of client code having
|
|
* to iterate through the FrameMetrics objects directly, it can use a
|
|
* LayerMetricsWrapper to encapsulate that aspect of the layer tree and just
|
|
* walk the tree as if it were a stack of ContainerLayers.
|
|
*
|
|
* The functions on this class do different things depending on which
|
|
* simulated ContainerLayer is being wrapped. For example, if the
|
|
* LayerMetricsWrapper is pretending to be C0, the GetNextSibling() function
|
|
* will return null even though the underlying layer C does actually have
|
|
* a next sibling. The LayerMetricsWrapper pretending to be Cn will return
|
|
* D as the next sibling.
|
|
*
|
|
* Implementation notes:
|
|
*
|
|
* The AtTopLayer() and AtBottomLayer() functions in this class refer to
|
|
* Cn and C0 in the second layer tree above; that is, they are predicates
|
|
* to test if the LayerMetricsWrapper is simulating the topmost or bottommost
|
|
* layer, as those will have special behaviour.
|
|
*
|
|
* It is possible to wrap a nullptr in a LayerMetricsWrapper, in which case
|
|
* the IsValid() function will return false. This is required to allow
|
|
* LayerMetricsWrapper to be a MOZ_STACK_CLASS (desirable because it is used
|
|
* in loops and recursion).
|
|
*
|
|
* This class purposely does not expose the wrapped layer directly to avoid
|
|
* user code from accidentally calling functions directly on it. Instead
|
|
* any necessary functions should be wrapped in this class. It does expose
|
|
* the wrapped layer as a void* for printf purposes.
|
|
*
|
|
* The implementation may look like it special-cases mIndex == 0 and/or
|
|
* GetFrameMetricsCount() == 0. This is an artifact of the fact that both
|
|
* mIndex and GetFrameMetricsCount() are uint32_t and GetFrameMetricsCount()
|
|
* can return 0 but mIndex cannot store -1. This seems better than the
|
|
* alternative of making mIndex a int32_t that can store -1, but then having
|
|
* to cast to uint32_t all over the place.
|
|
*/
|
|
class MOZ_STACK_CLASS LayerMetricsWrapper {
|
|
public:
|
|
enum StartAt {
|
|
TOP,
|
|
BOTTOM,
|
|
};
|
|
|
|
LayerMetricsWrapper()
|
|
: mLayer(nullptr)
|
|
, mIndex(0)
|
|
{
|
|
}
|
|
|
|
explicit LayerMetricsWrapper(Layer* aRoot, StartAt aStart = StartAt::TOP)
|
|
: mLayer(aRoot)
|
|
, mIndex(0)
|
|
{
|
|
if (!mLayer) {
|
|
return;
|
|
}
|
|
|
|
switch (aStart) {
|
|
case StartAt::TOP:
|
|
mIndex = mLayer->GetFrameMetricsCount();
|
|
if (mIndex > 0) {
|
|
mIndex--;
|
|
}
|
|
break;
|
|
case StartAt::BOTTOM:
|
|
mIndex = 0;
|
|
break;
|
|
default:
|
|
MOZ_ASSERT_UNREACHABLE("Unknown startAt value");
|
|
break;
|
|
}
|
|
}
|
|
|
|
explicit LayerMetricsWrapper(Layer* aLayer, uint32_t aMetricsIndex)
|
|
: mLayer(aLayer)
|
|
, mIndex(aMetricsIndex)
|
|
{
|
|
MOZ_ASSERT(mLayer);
|
|
MOZ_ASSERT(mIndex == 0 || mIndex < mLayer->GetFrameMetricsCount());
|
|
}
|
|
|
|
bool IsValid() const
|
|
{
|
|
return mLayer != nullptr;
|
|
}
|
|
|
|
MOZ_EXPLICIT_CONVERSION operator bool() const
|
|
{
|
|
return IsValid();
|
|
}
|
|
|
|
bool IsScrollInfoLayer() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
// If we are not at the bottommost layer then it's
|
|
// a stack of container layers all the way down to
|
|
// mLayer, which we can ignore. We only care about
|
|
// non-container descendants.
|
|
return Metrics().IsScrollable()
|
|
&& mLayer->AsContainerLayer()
|
|
&& !mLayer->GetFirstChild();
|
|
}
|
|
|
|
LayerMetricsWrapper GetParent() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (!AtTopLayer()) {
|
|
return LayerMetricsWrapper(mLayer, mIndex + 1);
|
|
}
|
|
if (mLayer->GetParent()) {
|
|
return LayerMetricsWrapper(mLayer->GetParent(), StartAt::BOTTOM);
|
|
}
|
|
return LayerMetricsWrapper(nullptr);
|
|
}
|
|
|
|
LayerMetricsWrapper GetFirstChild() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (!AtBottomLayer()) {
|
|
return LayerMetricsWrapper(mLayer, mIndex - 1);
|
|
}
|
|
return LayerMetricsWrapper(mLayer->GetFirstChild());
|
|
}
|
|
|
|
LayerMetricsWrapper GetLastChild() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (!AtBottomLayer()) {
|
|
return LayerMetricsWrapper(mLayer, mIndex - 1);
|
|
}
|
|
return LayerMetricsWrapper(mLayer->GetLastChild());
|
|
}
|
|
|
|
LayerMetricsWrapper GetPrevSibling() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (AtTopLayer()) {
|
|
return LayerMetricsWrapper(mLayer->GetPrevSibling());
|
|
}
|
|
return LayerMetricsWrapper(nullptr);
|
|
}
|
|
|
|
LayerMetricsWrapper GetNextSibling() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (AtTopLayer()) {
|
|
return LayerMetricsWrapper(mLayer->GetNextSibling());
|
|
}
|
|
return LayerMetricsWrapper(nullptr);
|
|
}
|
|
|
|
const FrameMetrics& Metrics() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (mIndex >= mLayer->GetFrameMetricsCount()) {
|
|
return FrameMetrics::sNullMetrics;
|
|
}
|
|
return mLayer->GetFrameMetrics(mIndex);
|
|
}
|
|
|
|
AsyncPanZoomController* GetApzc() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (mIndex >= mLayer->GetFrameMetricsCount()) {
|
|
return nullptr;
|
|
}
|
|
return mLayer->GetAsyncPanZoomController(mIndex);
|
|
}
|
|
|
|
void SetApzc(AsyncPanZoomController* aApzc) const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (mLayer->GetFrameMetricsCount() == 0) {
|
|
MOZ_ASSERT(mIndex == 0);
|
|
MOZ_ASSERT(aApzc == nullptr);
|
|
return;
|
|
}
|
|
MOZ_ASSERT(mIndex < mLayer->GetFrameMetricsCount());
|
|
mLayer->SetAsyncPanZoomController(mIndex, aApzc);
|
|
}
|
|
|
|
const char* Name() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (AtBottomLayer()) {
|
|
return mLayer->Name();
|
|
}
|
|
return "DummyContainerLayer";
|
|
}
|
|
|
|
LayerManager* Manager() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
return mLayer->Manager();
|
|
}
|
|
|
|
gfx::Matrix4x4 GetTransform() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (AtBottomLayer()) {
|
|
return mLayer->GetTransform();
|
|
}
|
|
return gfx::Matrix4x4();
|
|
}
|
|
|
|
CSSTransformMatrix GetTransformTyped() const
|
|
{
|
|
return ViewAs<CSSTransformMatrix>(GetTransform());
|
|
}
|
|
|
|
bool TransformIsPerspective() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
// mLayer->GetTransformIsPerspective() tells us whether
|
|
// mLayer->GetTransform() is a perspective transform. Since
|
|
// mLayer->GetTransform() is only used at the bottom layer, we only
|
|
// need to check GetTransformIsPerspective() at the bottom layer too.
|
|
if (AtBottomLayer()) {
|
|
return mLayer->GetTransformIsPerspective();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
EventRegions GetEventRegions() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (AtBottomLayer()) {
|
|
return mLayer->GetEventRegions();
|
|
}
|
|
return EventRegions();
|
|
}
|
|
|
|
bool HasTransformAnimation() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (AtBottomLayer()) {
|
|
return mLayer->HasTransformAnimation();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
RefLayer* AsRefLayer() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (AtBottomLayer()) {
|
|
return mLayer->AsRefLayer();
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
LayerIntRegion GetVisibleRegion() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (AtBottomLayer()) {
|
|
return mLayer->GetVisibleRegion();
|
|
}
|
|
LayerIntRegion region = mLayer->GetVisibleRegion();
|
|
region.Transform(mLayer->GetTransform());
|
|
return region;
|
|
}
|
|
|
|
const Maybe<ParentLayerIntRect>& GetClipRect() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
static const Maybe<ParentLayerIntRect> sNoClipRect = Nothing();
|
|
|
|
if (AtBottomLayer()) {
|
|
return mLayer->GetClipRect();
|
|
}
|
|
|
|
return sNoClipRect;
|
|
}
|
|
|
|
float GetPresShellResolution() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (AtTopLayer() && mLayer->AsContainerLayer()) {
|
|
return mLayer->AsContainerLayer()->GetPresShellResolution();
|
|
}
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
EventRegionsOverride GetEventRegionsOverride() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (mLayer->AsContainerLayer()) {
|
|
return mLayer->AsContainerLayer()->GetEventRegionsOverride();
|
|
}
|
|
return EventRegionsOverride::NoOverride;
|
|
}
|
|
|
|
Layer::ScrollDirection GetScrollbarDirection() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
return mLayer->GetScrollbarDirection();
|
|
}
|
|
|
|
FrameMetrics::ViewID GetScrollbarTargetContainerId() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
return mLayer->GetScrollbarTargetContainerId();
|
|
}
|
|
|
|
int32_t GetScrollbarSize() const
|
|
{
|
|
if (GetScrollbarDirection() == Layer::VERTICAL) {
|
|
return mLayer->GetVisibleRegion().GetBounds().height;
|
|
} else {
|
|
return mLayer->GetVisibleRegion().GetBounds().width;
|
|
}
|
|
}
|
|
|
|
// Expose an opaque pointer to the layer. Mostly used for printf
|
|
// purposes. This is not intended to be a general-purpose accessor
|
|
// for the underlying layer.
|
|
const void* GetLayer() const
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
return (void*)mLayer;
|
|
}
|
|
|
|
bool operator==(const LayerMetricsWrapper& aOther) const
|
|
{
|
|
return mLayer == aOther.mLayer
|
|
&& mIndex == aOther.mIndex;
|
|
}
|
|
|
|
bool operator!=(const LayerMetricsWrapper& aOther) const
|
|
{
|
|
return !(*this == aOther);
|
|
}
|
|
|
|
static const FrameMetrics& TopmostScrollableMetrics(Layer* aLayer)
|
|
{
|
|
for (uint32_t i = aLayer->GetFrameMetricsCount(); i > 0; i--) {
|
|
if (aLayer->GetFrameMetrics(i - 1).IsScrollable()) {
|
|
return aLayer->GetFrameMetrics(i - 1);
|
|
}
|
|
}
|
|
return FrameMetrics::sNullMetrics;
|
|
}
|
|
|
|
static const FrameMetrics& BottommostScrollableMetrics(Layer* aLayer)
|
|
{
|
|
for (uint32_t i = 0; i < aLayer->GetFrameMetricsCount(); i++) {
|
|
if (aLayer->GetFrameMetrics(i).IsScrollable()) {
|
|
return aLayer->GetFrameMetrics(i);
|
|
}
|
|
}
|
|
return FrameMetrics::sNullMetrics;
|
|
}
|
|
|
|
static const FrameMetrics& BottommostMetrics(Layer* aLayer)
|
|
{
|
|
if (aLayer->GetFrameMetricsCount() > 0) {
|
|
return aLayer->GetFrameMetrics(0);
|
|
}
|
|
return FrameMetrics::sNullMetrics;
|
|
}
|
|
|
|
private:
|
|
bool AtBottomLayer() const
|
|
{
|
|
return mIndex == 0;
|
|
}
|
|
|
|
bool AtTopLayer() const
|
|
{
|
|
return mLayer->GetFrameMetricsCount() == 0 || mIndex == mLayer->GetFrameMetricsCount() - 1;
|
|
}
|
|
|
|
private:
|
|
Layer* mLayer;
|
|
uint32_t mIndex;
|
|
};
|
|
|
|
} // namespace layers
|
|
} // namespace mozilla
|
|
|
|
#endif /* GFX_LAYERMETRICSWRAPPER_H */
|