зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1587973 - Part 1: Use CSS pixels or device pixels in ResizeObserverSize. r=emilio
We will introduce device-pixel-content-box, which is in device-pixel domain. Therefore, we convert the app units into CSS/device pixel when creating ResizeObserverSize. Differential Revision: https://phabricator.services.mozilla.com/D121016
This commit is contained in:
Родитель
1321fa97c4
Коммит
a2b8e058de
|
@ -370,7 +370,8 @@ void ResizeObserverEntry::GetContentBoxSize(
|
|||
void ResizeObserverEntry::SetBorderBoxSize(const nsSize& aSize) {
|
||||
nsIFrame* frame = mTarget->GetPrimaryFrame();
|
||||
const WritingMode wm = frame ? frame->GetWritingMode() : WritingMode();
|
||||
mBorderBoxSize = new ResizeObserverSize(this, aSize, wm);
|
||||
mBorderBoxSize = new ResizeObserverSize(
|
||||
this, CSSSize::FromAppUnits(aSize).ToUnknownSize(), wm);
|
||||
}
|
||||
|
||||
void ResizeObserverEntry::SetContentRectAndSize(const nsSize& aSize) {
|
||||
|
@ -387,7 +388,8 @@ void ResizeObserverEntry::SetContentRectAndSize(const nsSize& aSize) {
|
|||
|
||||
// 2. Update mContentBoxSize.
|
||||
const WritingMode wm = frame ? frame->GetWritingMode() : WritingMode();
|
||||
mContentBoxSize = new ResizeObserverSize(this, aSize, wm);
|
||||
mContentBoxSize = new ResizeObserverSize(
|
||||
this, CSSSize::FromAppUnits(aSize).ToUnknownSize(), wm);
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ResizeObserverSize, mOwner)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef mozilla_dom_ResizeObserver_h
|
||||
#define mozilla_dom_ResizeObserver_h
|
||||
|
||||
#include "gfxPoint.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "mozilla/AppUnits.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
@ -231,11 +232,9 @@ class ResizeObserverSize final : public nsISupports, public nsWrapperCache {
|
|||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ResizeObserverSize)
|
||||
|
||||
// Note: the unit of |aSize| is app unit, and we convert it into css pixel in
|
||||
// the public JS APIs.
|
||||
ResizeObserverSize(nsISupports* aOwner, const nsSize& aSize,
|
||||
ResizeObserverSize(nsISupports* aOwner, const gfx::Size& aSize,
|
||||
const WritingMode aWM)
|
||||
: mOwner(aOwner), mSize(aWM, aSize), mWM(aWM) {
|
||||
: mOwner(aOwner), mSize(aSize), mWM(aWM) {
|
||||
MOZ_ASSERT(mOwner, "Need a non-null owner");
|
||||
}
|
||||
|
||||
|
@ -247,18 +246,22 @@ class ResizeObserverSize final : public nsISupports, public nsWrapperCache {
|
|||
}
|
||||
|
||||
double InlineSize() const {
|
||||
return NSAppUnitsToDoublePixels(mSize.ISize(mWM), AppUnitsPerCSSPixel());
|
||||
return mWM.IsVertical() ? mSize.Height() : mSize.Width();
|
||||
}
|
||||
|
||||
double BlockSize() const {
|
||||
return NSAppUnitsToDoublePixels(mSize.BSize(mWM), AppUnitsPerCSSPixel());
|
||||
return mWM.IsVertical() ? mSize.Width() : mSize.Height();
|
||||
}
|
||||
|
||||
protected:
|
||||
~ResizeObserverSize() = default;
|
||||
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
const LogicalSize mSize;
|
||||
// The physical size value:
|
||||
// 1. content-box/border-box: in CSS pixels.
|
||||
// 2. device-pixel-content-box: in device pixels.
|
||||
const gfx::Size mSize;
|
||||
// The writing mode of |mSize|.
|
||||
const WritingMode mWM;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче