This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch geckoview-99.0.1-11.0-1 in repository tor-browser.
commit a52a423779f78ce3be6965f21588e82309e6746c Author: Emilio Cobos Álvarez emilio@crisal.io AuthorDate: Fri Mar 18 02:20:01 2022 +0000
Bug 1757443 - Correctly account for padding in ResizeObserver content-box size for scrollable frames. r=boris,layout-reviewers a=dmeehan
See test.
Differential Revision: https://phabricator.services.mozilla.com/D141398 --- dom/base/ResizeObserver.cpp | 10 +++++- .../tests/resize-observer/scrollbars-2.html | 36 ++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/dom/base/ResizeObserver.cpp b/dom/base/ResizeObserver.cpp index 0b7bf9afe5cd0..8b0b84e706dec 100644 --- a/dom/base/ResizeObserver.cpp +++ b/dom/base/ResizeObserver.cpp @@ -49,7 +49,15 @@ static uint32_t GetNodeDepth(nsINode* aNode) { 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(); + // But the scrollPort includes padding (but not border!), so remove it. + nsRect scrollPort = f->GetScrollPortRect(); + nsMargin padding = + aFrame.GetUsedPadding().ApplySkipSides(aFrame.GetSkipSides()); + scrollPort.Deflate(padding); + MOZ_ASSERT(!aFrame.PresContext()->UseOverlayScrollbars() || + scrollPort.Size() == + aFrame.GetContentRectRelativeToSelf().Size()); + return scrollPort.Size(); } return aFrame.GetContentRectRelativeToSelf().Size(); } diff --git a/testing/web-platform/tests/resize-observer/scrollbars-2.html b/testing/web-platform/tests/resize-observer/scrollbars-2.html new file mode 100644 index 0000000000000..51b470c8a2d61 --- /dev/null +++ b/testing/web-platform/tests/resize-observer/scrollbars-2.html @@ -0,0 +1,36 @@ +<!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> + #scrollContainer { + width: 100px; + height: 100px; + /* Should be bigger than any reasonable scrollbar */ + padding: 30px; + border: 10px solid blue; + overflow: scroll; + background: #818182; + } + +</style> +<div id="scrollContainer"></div> +<script> + promise_test(async function() { + let count = 0; + + const scrollContainer = document.getElementById('scrollContainer'); + // 20 to account for the border. + const scrollbarSize = scrollContainer.offsetWidth - scrollContainer.clientWidth - 20; + let size = await new Promise(resolve => { + const observer = new ResizeObserver(entries => { + resolve(entries[0].contentBoxSize[0]); + }); + observer.observe(scrollContainer); + }); + + assert_equals(size.inlineSize, 100 - scrollbarSize); + assert_equals(size.blockSize, 100 - scrollbarSize); + }); +</script>