Backed out changeset 623c4391875a (bug 1733042) for causing wpt failures at scrollbars.html. CLOSED TREE

This commit is contained in:
Butkovits Atila 2022-02-24 09:07:26 +02:00
Родитель 1a7d472966
Коммит f669c536bb
2 изменённых файлов: 38 добавлений и 98 удалений

Просмотреть файл

@ -11,7 +11,6 @@
#include "mozilla/SVGUtils.h"
#include "nsIContent.h"
#include "nsIContentInlines.h"
#include "nsIScrollableFrame.h"
#include <limits>
namespace mozilla::dom {
@ -46,14 +45,6 @@ static uint32_t GetNodeDepth(nsINode* aNode) {
return depth;
}
static nsSize GetContentRectSize(const nsIFrame& aFrame) {
if (const nsIScrollableFrame* f = do_QueryFrame(&aFrame)) {
// We return the scrollport rect for compat with other UAs, see bug 1733042.
return f->GetScrollPortRect().Size();
}
return aFrame.GetContentRectRelativeToSelf().Size();
}
/**
* Returns |aTarget|'s size in the form of gfx::Size (in pixels).
* If the target is SVG, width and height are determined from bounding box.
@ -84,42 +75,47 @@ static gfx::Size CalculateBoxSize(Element* aTarget,
const LayoutDeviceIntSize snappedSize =
RoundedToInt(CSSSize::FromUnknownSize(size) *
frame->PresContext()->CSSToDevPixelScale());
return gfx::Size(snappedSize.ToUnknownSize());
size = gfx::Size(snappedSize.ToUnknownSize());
}
} else {
// Per the spec, non-replaced inline Elements will always have an empty
// content rect. Therefore, we always use the same trivially-empty size
// for non-replaced inline elements here, and their IsActive() will
// always return false. (So its observation won't be fired.)
if (!frame->IsFrameOfType(nsIFrame::eReplaced) &&
frame->IsFrameOfType(nsIFrame::eLineParticipant)) {
return size;
}
switch (aBox) {
case ResizeObserverBoxOptions::Border_box:
// GetSize() includes the content area, borders, and padding.
size = CSSPixel::FromAppUnits(frame->GetSize()).ToUnknownSize();
break;
case ResizeObserverBoxOptions::Device_pixel_content_box: {
// This is a implementation-dependent for subpixel snapping algorithm.
// Gecko relys on LayoutDevicePixel to convert (and snap) the app units
// into device pixels in painting and gfx code, so here we simply
// convert it into dev pixels and round it.
//
// Note: This size must contain integer values.
// https://drafts.csswg.org/resize-observer/#dom-resizeobserverboxoptions-device-pixel-content-box
const LayoutDeviceIntSize snappedSize =
LayoutDevicePixel::FromAppUnitsRounded(
frame->GetContentRectRelativeToSelf().Size(),
frame->PresContext()->AppUnitsPerDevPixel());
size = gfx::Size(snappedSize.ToUnknownSize());
break;
}
case ResizeObserverBoxOptions::Content_box:
default:
size =
CSSPixel::FromAppUnits(frame->GetContentRectRelativeToSelf().Size())
.ToUnknownSize();
}
return size;
}
// Per the spec, non-replaced inline Elements will always have an empty
// content rect. Therefore, we always use the same trivially-empty size
// for non-replaced inline elements here, and their IsActive() will
// always return false. (So its observation won't be fired.)
if (!frame->IsFrameOfType(nsIFrame::eReplaced) &&
frame->IsFrameOfType(nsIFrame::eLineParticipant)) {
return size;
}
switch (aBox) {
case ResizeObserverBoxOptions::Border_box:
return CSSPixel::FromAppUnits(frame->GetSize()).ToUnknownSize();
case ResizeObserverBoxOptions::Device_pixel_content_box: {
// This is a implementation-dependent for subpixel snapping algorithm.
// Gecko relies on LayoutDevicePixel to convert (and snap) the app units
// into device pixels in painting and gfx code, so here we simply
// convert it into dev pixels and round it.
//
// Note: This size must contain integer values.
// https://drafts.csswg.org/resize-observer/#dom-resizeobserverboxoptions-device-pixel-content-box
const LayoutDeviceIntSize snappedSize =
LayoutDevicePixel::FromAppUnitsRounded(
GetContentRectSize(*frame),
frame->PresContext()->AppUnitsPerDevPixel());
return gfx::Size(snappedSize.ToUnknownSize());
}
case ResizeObserverBoxOptions::Content_box:
default:
break;
}
return CSSPixel::FromAppUnits(GetContentRectSize(*frame)).ToUnknownSize();
return size;
}
NS_IMPL_CYCLE_COLLECTION_CLASS(ResizeObservation)

Просмотреть файл

@ -1,56 +0,0 @@
<!DOCTYPE html>
<title>ResizeObserver content-box size and scrollbars</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1733042">
<style>
#outer {
position: relative;
width: 100px;
height: 200px;
overflow: auto;
background: #818182;
}
#inner {
position: absolute;
top: 0;
left: 0;
width: 10px;
height: 10px;
background: #0a6fc0;
}
</style>
<div id="outer">
<div id="inner"></div>
</div>
<script>
async function animationFrame() {
return new Promise(r => requestAnimationFrame(r));
}
// This test is expected to fail with overlay scrollbars.
promise_test(async function() {
let count = 0;
const outer = document.getElementById('outer');
const inner = document.getElementById('inner');
const observer = new ResizeObserver(entries => {
count++;
});
observer.observe(outer);
inner.style.top = '1000px';
await animationFrame();
await animationFrame();
inner.style.top = 0;
await animationFrame();
await animationFrame();
assert_equals(count, 2, "ResizeObserver should subtract scrollbar sizes from content-box rect");
});
</script>