gfx/layers/FrameMetrics.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef GFX_FRAMEMETRICS_H
michael@0 7 #define GFX_FRAMEMETRICS_H
michael@0 8
michael@0 9 #include <stdint.h> // for uint32_t, uint64_t
michael@0 10 #include <string> // for std::string
michael@0 11 #include "Units.h" // for CSSRect, CSSPixel, etc
michael@0 12 #include "mozilla/gfx/BasePoint.h" // for BasePoint
michael@0 13 #include "mozilla/gfx/Rect.h" // for RoundedIn
michael@0 14 #include "mozilla/gfx/ScaleFactor.h" // for ScaleFactor
michael@0 15 #include "mozilla/gfx/Logging.h" // for Log
michael@0 16
michael@0 17 namespace IPC {
michael@0 18 template <typename T> struct ParamTraits;
michael@0 19 } // namespace IPC
michael@0 20
michael@0 21 namespace mozilla {
michael@0 22
michael@0 23 // The layer coordinates of the parent layer.
michael@0 24 // This can be arrived at in two ways:
michael@0 25 // - Start with the CSS coordinates of the parent layer (note: NOT the
michael@0 26 // CSS coordinates of the current layer, that will give you the wrong
michael@0 27 // answer), multiply by the device scale and the resolutions of all
michael@0 28 // layers from the root down to and including the parent.
michael@0 29 // - Start with global screen coordinates and unapply all CSS and async
michael@0 30 // transforms from the root down to and including the parent.
michael@0 31 // It's helpful to look at https://wiki.mozilla.org/Platform/GFX/APZ#Coordinate_systems
michael@0 32 // to get a picture of how the various coordinate systems relate to each other.
michael@0 33 struct ParentLayerPixel {};
michael@0 34
michael@0 35 typedef gfx::PointTyped<ParentLayerPixel> ParentLayerPoint;
michael@0 36 typedef gfx::RectTyped<ParentLayerPixel> ParentLayerRect;
michael@0 37 typedef gfx::SizeTyped<ParentLayerPixel> ParentLayerSize;
michael@0 38
michael@0 39 typedef gfx::IntMarginTyped<ParentLayerPixel> ParentLayerIntMargin;
michael@0 40 typedef gfx::IntPointTyped<ParentLayerPixel> ParentLayerIntPoint;
michael@0 41 typedef gfx::IntRectTyped<ParentLayerPixel> ParentLayerIntRect;
michael@0 42 typedef gfx::IntSizeTyped<ParentLayerPixel> ParentLayerIntSize;
michael@0 43
michael@0 44 typedef gfx::ScaleFactor<CSSPixel, ParentLayerPixel> CSSToParentLayerScale;
michael@0 45 typedef gfx::ScaleFactor<LayoutDevicePixel, ParentLayerPixel> LayoutDeviceToParentLayerScale;
michael@0 46 typedef gfx::ScaleFactor<ScreenPixel, ParentLayerPixel> ScreenToParentLayerScale;
michael@0 47
michael@0 48 typedef gfx::ScaleFactor<ParentLayerPixel, LayerPixel> ParentLayerToLayerScale;
michael@0 49 typedef gfx::ScaleFactor<ParentLayerPixel, ScreenPixel> ParentLayerToScreenScale;
michael@0 50
michael@0 51
michael@0 52 namespace layers {
michael@0 53
michael@0 54 /**
michael@0 55 * The viewport and displayport metrics for the painted frame at the
michael@0 56 * time of a layer-tree transaction. These metrics are especially
michael@0 57 * useful for shadow layers, because the metrics values are updated
michael@0 58 * atomically with new pixels.
michael@0 59 */
michael@0 60 struct FrameMetrics {
michael@0 61 friend struct IPC::ParamTraits<mozilla::layers::FrameMetrics>;
michael@0 62 public:
michael@0 63 // We use IDs to identify frames across processes.
michael@0 64 typedef uint64_t ViewID;
michael@0 65 static const ViewID NULL_SCROLL_ID; // This container layer does not scroll.
michael@0 66 static const ViewID START_SCROLL_ID = 2; // This is the ID that scrolling subframes
michael@0 67 // will begin at.
michael@0 68
michael@0 69 FrameMetrics()
michael@0 70 : mCompositionBounds(0, 0, 0, 0)
michael@0 71 , mDisplayPort(0, 0, 0, 0)
michael@0 72 , mCriticalDisplayPort(0, 0, 0, 0)
michael@0 73 , mViewport(0, 0, 0, 0)
michael@0 74 , mScrollableRect(0, 0, 0, 0)
michael@0 75 , mResolution(1)
michael@0 76 , mCumulativeResolution(1)
michael@0 77 , mTransformScale(1)
michael@0 78 , mDevPixelsPerCSSPixel(1)
michael@0 79 , mPresShellId(-1)
michael@0 80 , mMayHaveTouchListeners(false)
michael@0 81 , mIsRoot(false)
michael@0 82 , mHasScrollgrab(false)
michael@0 83 , mScrollId(NULL_SCROLL_ID)
michael@0 84 , mScrollOffset(0, 0)
michael@0 85 , mZoom(1)
michael@0 86 , mUpdateScrollOffset(false)
michael@0 87 , mScrollGeneration(0)
michael@0 88 , mRootCompositionSize(0, 0)
michael@0 89 , mDisplayPortMargins(0, 0, 0, 0)
michael@0 90 , mUseDisplayPortMargins(false)
michael@0 91 {}
michael@0 92
michael@0 93 // Default copy ctor and operator= are fine
michael@0 94
michael@0 95 bool operator==(const FrameMetrics& aOther) const
michael@0 96 {
michael@0 97 // mContentDescription is not compared on purpose as it's only used
michael@0 98 // for debugging.
michael@0 99 return mCompositionBounds.IsEqualEdges(aOther.mCompositionBounds) &&
michael@0 100 mRootCompositionSize == aOther.mRootCompositionSize &&
michael@0 101 mDisplayPort.IsEqualEdges(aOther.mDisplayPort) &&
michael@0 102 mDisplayPortMargins == aOther.mDisplayPortMargins &&
michael@0 103 mUseDisplayPortMargins == aOther.mUseDisplayPortMargins &&
michael@0 104 mCriticalDisplayPort.IsEqualEdges(aOther.mCriticalDisplayPort) &&
michael@0 105 mViewport.IsEqualEdges(aOther.mViewport) &&
michael@0 106 mScrollableRect.IsEqualEdges(aOther.mScrollableRect) &&
michael@0 107 mResolution == aOther.mResolution &&
michael@0 108 mCumulativeResolution == aOther.mCumulativeResolution &&
michael@0 109 mDevPixelsPerCSSPixel == aOther.mDevPixelsPerCSSPixel &&
michael@0 110 mMayHaveTouchListeners == aOther.mMayHaveTouchListeners &&
michael@0 111 mPresShellId == aOther.mPresShellId &&
michael@0 112 mIsRoot == aOther.mIsRoot &&
michael@0 113 mScrollId == aOther.mScrollId &&
michael@0 114 mScrollOffset == aOther.mScrollOffset &&
michael@0 115 mHasScrollgrab == aOther.mHasScrollgrab &&
michael@0 116 mUpdateScrollOffset == aOther.mUpdateScrollOffset;
michael@0 117 }
michael@0 118 bool operator!=(const FrameMetrics& aOther) const
michael@0 119 {
michael@0 120 return !operator==(aOther);
michael@0 121 }
michael@0 122
michael@0 123 bool IsDefault() const
michael@0 124 {
michael@0 125 FrameMetrics def;
michael@0 126
michael@0 127 def.mPresShellId = mPresShellId;
michael@0 128 return (def == *this);
michael@0 129 }
michael@0 130
michael@0 131 bool IsRootScrollable() const
michael@0 132 {
michael@0 133 return mIsRoot;
michael@0 134 }
michael@0 135
michael@0 136 bool IsScrollable() const
michael@0 137 {
michael@0 138 return mScrollId != NULL_SCROLL_ID;
michael@0 139 }
michael@0 140
michael@0 141 CSSToLayerScale LayersPixelsPerCSSPixel() const
michael@0 142 {
michael@0 143 return mCumulativeResolution * mDevPixelsPerCSSPixel;
michael@0 144 }
michael@0 145
michael@0 146 LayerPoint GetScrollOffsetInLayerPixels() const
michael@0 147 {
michael@0 148 return GetScrollOffset() * LayersPixelsPerCSSPixel();
michael@0 149 }
michael@0 150
michael@0 151 LayoutDeviceToParentLayerScale GetParentResolution() const
michael@0 152 {
michael@0 153 return mCumulativeResolution / mResolution;
michael@0 154 }
michael@0 155
michael@0 156 // Ensure the scrollableRect is at least as big as the compositionBounds
michael@0 157 // because the scrollableRect can be smaller if the content is not large
michael@0 158 // and the scrollableRect hasn't been updated yet.
michael@0 159 // We move the scrollableRect up because we don't know if we can move it
michael@0 160 // down. i.e. we know that scrollableRect can go back as far as zero.
michael@0 161 // but we don't know how much further ahead it can go.
michael@0 162 CSSRect GetExpandedScrollableRect() const
michael@0 163 {
michael@0 164 CSSRect scrollableRect = mScrollableRect;
michael@0 165 CSSSize compSize = CalculateCompositedSizeInCssPixels();
michael@0 166 if (scrollableRect.width < compSize.width) {
michael@0 167 scrollableRect.x = std::max(0.f,
michael@0 168 scrollableRect.x - (compSize.width - scrollableRect.width));
michael@0 169 scrollableRect.width = compSize.width;
michael@0 170 }
michael@0 171
michael@0 172 if (scrollableRect.height < compSize.height) {
michael@0 173 scrollableRect.y = std::max(0.f,
michael@0 174 scrollableRect.y - (compSize.height - scrollableRect.height));
michael@0 175 scrollableRect.height = compSize.height;
michael@0 176 }
michael@0 177
michael@0 178 return scrollableRect;
michael@0 179 }
michael@0 180
michael@0 181 // Return the scale factor needed to fit the viewport
michael@0 182 // into its composition bounds.
michael@0 183 CSSToScreenScale CalculateIntrinsicScale() const
michael@0 184 {
michael@0 185 return CSSToScreenScale(float(mCompositionBounds.width) / float(mViewport.width));
michael@0 186 }
michael@0 187
michael@0 188 // Return the scale factor for converting from CSS pixels (for this layer)
michael@0 189 // to layer pixels of our parent layer. Much as mZoom is used to interface
michael@0 190 // between inputs we get in screen pixels and quantities in CSS pixels,
michael@0 191 // this is used to interface between mCompositionBounds and quantities
michael@0 192 // in CSS pixels.
michael@0 193 CSSToParentLayerScale GetZoomToParent() const
michael@0 194 {
michael@0 195 return mZoom * mTransformScale;
michael@0 196 }
michael@0 197
michael@0 198 CSSSize CalculateCompositedSizeInCssPixels() const
michael@0 199 {
michael@0 200 return mCompositionBounds.Size() / GetZoomToParent();
michael@0 201 }
michael@0 202
michael@0 203 CSSRect CalculateCompositedRectInCssPixels() const
michael@0 204 {
michael@0 205 return mCompositionBounds / GetZoomToParent();
michael@0 206 }
michael@0 207
michael@0 208 void ScrollBy(const CSSPoint& aPoint)
michael@0 209 {
michael@0 210 mScrollOffset += aPoint;
michael@0 211 }
michael@0 212
michael@0 213 void ZoomBy(float aFactor)
michael@0 214 {
michael@0 215 mZoom.scale *= aFactor;
michael@0 216 }
michael@0 217
michael@0 218 void CopyScrollInfoFrom(const FrameMetrics& aOther)
michael@0 219 {
michael@0 220 mScrollOffset = aOther.mScrollOffset;
michael@0 221 mScrollGeneration = aOther.mScrollGeneration;
michael@0 222 }
michael@0 223
michael@0 224 // ---------------------------------------------------------------------------
michael@0 225 // The following metrics are all in widget space/device pixels.
michael@0 226 //
michael@0 227
michael@0 228 // This is the area within the widget that we're compositing to. It is relative
michael@0 229 // to the layer tree origin.
michael@0 230 //
michael@0 231 // This is useful because, on mobile, the viewport and composition dimensions
michael@0 232 // are not always the same. In this case, we calculate the displayport using
michael@0 233 // an area bigger than the region we're compositing to. If we used the
michael@0 234 // viewport dimensions to calculate the displayport, we'd run into situations
michael@0 235 // where we're prerendering the wrong regions and the content may be clipped,
michael@0 236 // or too much of it prerendered. If the composition dimensions are the same as the
michael@0 237 // viewport dimensions, there is no need for this and we can just use the viewport
michael@0 238 // instead.
michael@0 239 //
michael@0 240 // This value is valid for nested scrollable layers as well, and is still
michael@0 241 // relative to the layer tree origin. This value is provided by Gecko at
michael@0 242 // layout/paint time.
michael@0 243 ParentLayerIntRect mCompositionBounds;
michael@0 244
michael@0 245 // ---------------------------------------------------------------------------
michael@0 246 // The following metrics are all in CSS pixels. They are not in any uniform
michael@0 247 // space, so each is explained separately.
michael@0 248 //
michael@0 249
michael@0 250 // The area of a frame's contents that has been painted, relative to the
michael@0 251 // viewport. It is in the same coordinate space as |mViewport|. For example,
michael@0 252 // if it is at 0,0, then it's at the same place at the viewport, which is at
michael@0 253 // the top-left in the layer, and at the same place as the scroll offset of
michael@0 254 // the document.
michael@0 255 //
michael@0 256 // Note that this is structured in such a way that it doesn't depend on the
michael@0 257 // method layout uses to scroll content.
michael@0 258 //
michael@0 259 // May be larger or smaller than |mScrollableRect|.
michael@0 260 //
michael@0 261 // To pre-render a margin of 100 CSS pixels around the window,
michael@0 262 // { x = -100, y = - 100,
michael@0 263 // width = window.innerWidth + 200, height = window.innerHeight + 200 }
michael@0 264 CSSRect mDisplayPort;
michael@0 265
michael@0 266 // If non-empty, the area of a frame's contents that is considered critical
michael@0 267 // to paint. Area outside of this area (i.e. area inside mDisplayPort, but
michael@0 268 // outside of mCriticalDisplayPort) is considered low-priority, and may be
michael@0 269 // painted with lower precision, or not painted at all.
michael@0 270 //
michael@0 271 // The same restrictions for mDisplayPort apply here.
michael@0 272 CSSRect mCriticalDisplayPort;
michael@0 273
michael@0 274 // The CSS viewport, which is the dimensions we're using to constrain the
michael@0 275 // <html> element of this frame, relative to the top-left of the layer. Note
michael@0 276 // that its offset is structured in such a way that it doesn't depend on the
michael@0 277 // method layout uses to scroll content.
michael@0 278 //
michael@0 279 // This is mainly useful on the root layer, however nested iframes can have
michael@0 280 // their own viewport, which will just be the size of the window of the
michael@0 281 // iframe. For layers that don't correspond to a document, this metric is
michael@0 282 // meaningless and invalid.
michael@0 283 CSSRect mViewport;
michael@0 284
michael@0 285 // The scrollable bounds of a frame. This is determined by reflow.
michael@0 286 // Ordinarily the x and y will be 0 and the width and height will be the
michael@0 287 // size of the element being scrolled. However for RTL pages or elements
michael@0 288 // the x value may be negative.
michael@0 289 //
michael@0 290 // This is relative to the document. It is in the same coordinate space as
michael@0 291 // |mScrollOffset|, but a different coordinate space than |mViewport| and
michael@0 292 // |mDisplayPort|. Note also that this coordinate system is understood by
michael@0 293 // window.scrollTo().
michael@0 294 //
michael@0 295 // This is valid on any layer unless it has no content.
michael@0 296 CSSRect mScrollableRect;
michael@0 297
michael@0 298 // ---------------------------------------------------------------------------
michael@0 299 // The following metrics are dimensionless.
michael@0 300 //
michael@0 301
michael@0 302 // The incremental resolution that the current frame has been painted at
michael@0 303 // relative to the parent frame's resolution. This information is provided
michael@0 304 // by Gecko at layout/paint time.
michael@0 305 ParentLayerToLayerScale mResolution;
michael@0 306
michael@0 307 // The cumulative resolution that the current frame has been painted at.
michael@0 308 // This is the product of our mResolution and the mResolutions of our parent frames.
michael@0 309 // This information is provided by Gecko at layout/paint time.
michael@0 310 LayoutDeviceToLayerScale mCumulativeResolution;
michael@0 311
michael@0 312 // The conversion factor between local screen pixels (the coordinate
michael@0 313 // system in which APZCs receive input events) and our parent layer's
michael@0 314 // layer pixels (the coordinate system of mCompositionBounds).
michael@0 315 // This consists of the scale of the local CSS transform and the
michael@0 316 // nontransient async transform.
michael@0 317 // TODO: APZ does not currently work well if there is a CSS transform
michael@0 318 // on the layer being scrolled that's not just a scale that's
michael@0 319 // the same in both directions. When we fix this, mTransformScale
michael@0 320 // will probably need to turn into a matrix.
michael@0 321 ScreenToParentLayerScale mTransformScale;
michael@0 322
michael@0 323 // The conversion factor between CSS pixels and device pixels for this frame.
michael@0 324 // This can vary based on a variety of things, such as reflowing-zoom. The
michael@0 325 // conversion factor for device pixels to layers pixels is just the
michael@0 326 // resolution.
michael@0 327 CSSToLayoutDeviceScale mDevPixelsPerCSSPixel;
michael@0 328
michael@0 329 uint32_t mPresShellId;
michael@0 330
michael@0 331 // Whether or not this frame may have touch listeners.
michael@0 332 bool mMayHaveTouchListeners;
michael@0 333
michael@0 334 // Whether or not this is the root scroll frame for the root content document.
michael@0 335 bool mIsRoot;
michael@0 336
michael@0 337 // Whether or not this frame is for an element marked 'scrollgrab'.
michael@0 338 bool mHasScrollgrab;
michael@0 339
michael@0 340 public:
michael@0 341 void SetScrollOffset(const CSSPoint& aScrollOffset)
michael@0 342 {
michael@0 343 mScrollOffset = aScrollOffset;
michael@0 344 }
michael@0 345
michael@0 346 const CSSPoint& GetScrollOffset() const
michael@0 347 {
michael@0 348 return mScrollOffset;
michael@0 349 }
michael@0 350
michael@0 351 void SetZoom(const CSSToScreenScale& aZoom)
michael@0 352 {
michael@0 353 mZoom = aZoom;
michael@0 354 }
michael@0 355
michael@0 356 CSSToScreenScale GetZoom() const
michael@0 357 {
michael@0 358 return mZoom;
michael@0 359 }
michael@0 360
michael@0 361 void SetScrollOffsetUpdated(uint32_t aScrollGeneration)
michael@0 362 {
michael@0 363 mUpdateScrollOffset = true;
michael@0 364 mScrollGeneration = aScrollGeneration;
michael@0 365 }
michael@0 366
michael@0 367 bool GetScrollOffsetUpdated() const
michael@0 368 {
michael@0 369 return mUpdateScrollOffset;
michael@0 370 }
michael@0 371
michael@0 372 uint32_t GetScrollGeneration() const
michael@0 373 {
michael@0 374 return mScrollGeneration;
michael@0 375 }
michael@0 376
michael@0 377 const std::string& GetContentDescription() const
michael@0 378 {
michael@0 379 return mContentDescription;
michael@0 380 }
michael@0 381
michael@0 382 void SetContentDescription(const std::string& aContentDescription)
michael@0 383 {
michael@0 384 mContentDescription = aContentDescription;
michael@0 385 }
michael@0 386
michael@0 387 ViewID GetScrollId() const
michael@0 388 {
michael@0 389 return mScrollId;
michael@0 390 }
michael@0 391
michael@0 392 void SetScrollId(ViewID scrollId)
michael@0 393 {
michael@0 394 mScrollId = scrollId;
michael@0 395 }
michael@0 396
michael@0 397 void SetRootCompositionSize(const CSSSize& aRootCompositionSize)
michael@0 398 {
michael@0 399 mRootCompositionSize = aRootCompositionSize;
michael@0 400 }
michael@0 401
michael@0 402 const CSSSize& GetRootCompositionSize() const
michael@0 403 {
michael@0 404 return mRootCompositionSize;
michael@0 405 }
michael@0 406
michael@0 407 void SetDisplayPortMargins(const LayerMargin& aDisplayPortMargins)
michael@0 408 {
michael@0 409 mDisplayPortMargins = aDisplayPortMargins;
michael@0 410 }
michael@0 411
michael@0 412 const LayerMargin& GetDisplayPortMargins() const
michael@0 413 {
michael@0 414 return mDisplayPortMargins;
michael@0 415 }
michael@0 416
michael@0 417 void SetUseDisplayPortMargins()
michael@0 418 {
michael@0 419 mUseDisplayPortMargins = true;
michael@0 420 }
michael@0 421
michael@0 422 bool GetUseDisplayPortMargins() const
michael@0 423 {
michael@0 424 return mUseDisplayPortMargins;
michael@0 425 }
michael@0 426
michael@0 427 private:
michael@0 428 // New fields from now on should be made private and old fields should
michael@0 429 // be refactored to be private.
michael@0 430
michael@0 431 // A unique ID assigned to each scrollable frame.
michael@0 432 ViewID mScrollId;
michael@0 433
michael@0 434 // The position of the top-left of the CSS viewport, relative to the document
michael@0 435 // (or the document relative to the viewport, if that helps understand it).
michael@0 436 //
michael@0 437 // Thus it is relative to the document. It is in the same coordinate space as
michael@0 438 // |mScrollableRect|, but a different coordinate space than |mViewport| and
michael@0 439 // |mDisplayPort|.
michael@0 440 //
michael@0 441 // It is required that the rect:
michael@0 442 // { x = mScrollOffset.x, y = mScrollOffset.y,
michael@0 443 // width = mCompositionBounds.x / mResolution.scale,
michael@0 444 // height = mCompositionBounds.y / mResolution.scale }
michael@0 445 // Be within |mScrollableRect|.
michael@0 446 //
michael@0 447 // This is valid for any layer, but is always relative to this frame and
michael@0 448 // not any parents, regardless of parent transforms.
michael@0 449 CSSPoint mScrollOffset;
michael@0 450
michael@0 451 // The "user zoom". Content is painted by gecko at mResolution * mDevPixelsPerCSSPixel,
michael@0 452 // but will be drawn to the screen at mZoom. In the steady state, the
michael@0 453 // two will be the same, but during an async zoom action the two may
michael@0 454 // diverge. This information is initialized in Gecko but updated in the APZC.
michael@0 455 CSSToScreenScale mZoom;
michael@0 456
michael@0 457 // Whether mScrollOffset was updated by something other than the APZ code, and
michael@0 458 // if the APZC receiving this metrics should update its local copy.
michael@0 459 bool mUpdateScrollOffset;
michael@0 460 // The scroll generation counter used to acknowledge the scroll offset update.
michael@0 461 uint32_t mScrollGeneration;
michael@0 462
michael@0 463 // A description of the content element corresponding to this frame.
michael@0 464 // This is empty unless the apz.printtree pref is turned on.
michael@0 465 std::string mContentDescription;
michael@0 466
michael@0 467 // The size of the root scrollable's composition bounds, but in local CSS pixels.
michael@0 468 CSSSize mRootCompositionSize;
michael@0 469
michael@0 470 // A display port expressed as layer margins that apply to the rect of what
michael@0 471 // is drawn of the scrollable element.
michael@0 472 LayerMargin mDisplayPortMargins;
michael@0 473
michael@0 474 // If this is true then we use the display port margins on this metrics,
michael@0 475 // otherwise use the display port rect.
michael@0 476 bool mUseDisplayPortMargins;
michael@0 477 };
michael@0 478
michael@0 479 /**
michael@0 480 * This class allows us to uniquely identify a scrollable layer. The
michael@0 481 * mLayersId identifies the layer tree (corresponding to a child process
michael@0 482 * and/or tab) that the scrollable layer belongs to. The mPresShellId
michael@0 483 * is a temporal identifier (corresponding to the document loaded that
michael@0 484 * contains the scrollable layer, which may change over time). The
michael@0 485 * mScrollId corresponds to the actual frame that is scrollable.
michael@0 486 */
michael@0 487 struct ScrollableLayerGuid {
michael@0 488 uint64_t mLayersId;
michael@0 489 uint32_t mPresShellId;
michael@0 490 FrameMetrics::ViewID mScrollId;
michael@0 491
michael@0 492 ScrollableLayerGuid()
michael@0 493 : mLayersId(0)
michael@0 494 , mPresShellId(0)
michael@0 495 , mScrollId(0)
michael@0 496 {
michael@0 497 MOZ_COUNT_CTOR(ScrollableLayerGuid);
michael@0 498 }
michael@0 499
michael@0 500 ScrollableLayerGuid(uint64_t aLayersId, uint32_t aPresShellId,
michael@0 501 FrameMetrics::ViewID aScrollId)
michael@0 502 : mLayersId(aLayersId)
michael@0 503 , mPresShellId(aPresShellId)
michael@0 504 , mScrollId(aScrollId)
michael@0 505 {
michael@0 506 MOZ_COUNT_CTOR(ScrollableLayerGuid);
michael@0 507 }
michael@0 508
michael@0 509 ScrollableLayerGuid(uint64_t aLayersId, const FrameMetrics& aMetrics)
michael@0 510 : mLayersId(aLayersId)
michael@0 511 , mPresShellId(aMetrics.mPresShellId)
michael@0 512 , mScrollId(aMetrics.GetScrollId())
michael@0 513 {
michael@0 514 MOZ_COUNT_CTOR(ScrollableLayerGuid);
michael@0 515 }
michael@0 516
michael@0 517 ~ScrollableLayerGuid()
michael@0 518 {
michael@0 519 MOZ_COUNT_DTOR(ScrollableLayerGuid);
michael@0 520 }
michael@0 521
michael@0 522 bool operator==(const ScrollableLayerGuid& other) const
michael@0 523 {
michael@0 524 return mLayersId == other.mLayersId
michael@0 525 && mPresShellId == other.mPresShellId
michael@0 526 && mScrollId == other.mScrollId;
michael@0 527 }
michael@0 528
michael@0 529 bool operator!=(const ScrollableLayerGuid& other) const
michael@0 530 {
michael@0 531 return !(*this == other);
michael@0 532 }
michael@0 533 };
michael@0 534
michael@0 535 template <int LogLevel>
michael@0 536 gfx::Log<LogLevel>& operator<<(gfx::Log<LogLevel>& log, const ScrollableLayerGuid& aGuid) {
michael@0 537 return log << '(' << aGuid.mLayersId << ',' << aGuid.mPresShellId << ',' << aGuid.mScrollId << ')';
michael@0 538 }
michael@0 539
michael@0 540 struct ZoomConstraints {
michael@0 541 bool mAllowZoom;
michael@0 542 bool mAllowDoubleTapZoom;
michael@0 543 CSSToScreenScale mMinZoom;
michael@0 544 CSSToScreenScale mMaxZoom;
michael@0 545
michael@0 546 ZoomConstraints()
michael@0 547 : mAllowZoom(true)
michael@0 548 , mAllowDoubleTapZoom(true)
michael@0 549 {
michael@0 550 MOZ_COUNT_CTOR(ZoomConstraints);
michael@0 551 }
michael@0 552
michael@0 553 ZoomConstraints(bool aAllowZoom,
michael@0 554 bool aAllowDoubleTapZoom,
michael@0 555 const CSSToScreenScale& aMinZoom,
michael@0 556 const CSSToScreenScale& aMaxZoom)
michael@0 557 : mAllowZoom(aAllowZoom)
michael@0 558 , mAllowDoubleTapZoom(aAllowDoubleTapZoom)
michael@0 559 , mMinZoom(aMinZoom)
michael@0 560 , mMaxZoom(aMaxZoom)
michael@0 561 {
michael@0 562 MOZ_COUNT_CTOR(ZoomConstraints);
michael@0 563 }
michael@0 564
michael@0 565 ~ZoomConstraints()
michael@0 566 {
michael@0 567 MOZ_COUNT_DTOR(ZoomConstraints);
michael@0 568 }
michael@0 569
michael@0 570 bool operator==(const ZoomConstraints& other) const
michael@0 571 {
michael@0 572 return mAllowZoom == other.mAllowZoom
michael@0 573 && mAllowDoubleTapZoom == other.mAllowDoubleTapZoom
michael@0 574 && mMinZoom == other.mMinZoom
michael@0 575 && mMaxZoom == other.mMaxZoom;
michael@0 576 }
michael@0 577
michael@0 578 bool operator!=(const ZoomConstraints& other) const
michael@0 579 {
michael@0 580 return !(*this == other);
michael@0 581 }
michael@0 582 };
michael@0 583
michael@0 584 }
michael@0 585 }
michael@0 586
michael@0 587 #endif /* GFX_FRAMEMETRICS_H */

mercurial