gecko-dev/layout/generic
Markus Stange ebb461c874 Bug 1012752 - Snap scrolled area to layer pixels. r=tnikkel
We want the maximum scroll position to be aligned with layer pixels. That way
we don't have to re-rasterize the scrolled contents once scrolling hits the
edge of the scrollable area.

Here's how we determine the maximum scroll position: We get the scroll port
rect, snapped to layer pixels. Then we get the scrolled rect and also snap
that to layer pixels. The maximum scroll position is set to the difference
between right/bottom edges of these rectangles.
Now the scrollable area is computed by adding this maximum scroll position
to the unsnapped scroll port size.
The underlying idea here is: Pretend we have overflow:visible so that the
scrolled contents start at (0, 0) relative to the scroll port and spill over
the scroll port edges. When these contents are rendered, their rendering is
snapped to layer pixels. We want those exact pixels to be accessible by
scrolling.

This way of computing the snapped scrollable area ensures that, if you scroll
to the maximum scroll position, the right/bottom edges of the rendered
scrolled contents line up exactly with the right/bottom edges of the scroll
port. The scrolled contents are neither cut off nor are they moved too far.
(This is something that no other browser engine gets completely right, see the
testcase in bug 1012752.)

There are also a few disadvantages to this solution. We snap to layer pixels,
and the size of a layer pixel can depend on the zoom level, the document
resolution, the current screen's scale factor, and CSS transforms. The snap
origin is the position of the reference frame. So a change to any of these
things can influence the scrollable area and the maximum scroll position.
This patch does not make us adjust the current scroll position in the event
that the maximum scroll position changes such that the current scroll position
would be out of range, unless there's a reflow of the scrolled contents. This
means that we can sometimes render a slightly inconsistent state where the
current scroll position exceeds the maximum scroll position. We can fix this
once it turns out to be a problem; I doubt that it will be a problem because
none of the other browsers seems to prevent this problem either.

The size of the scrollable area is exposed through the DOM properties
scrollWidth and scrollHeight. At the moment, these are integer properties, so
their value is rounded to the nearest CSS pixel. Before this patch, the
returned value would always be within 0.5 CSS pixels of the value that layout
computed for the content's scrollable overflow based on the CSS styles of the
contents.
Now that scrollWidth and scrollHeight also depend on pixel snapping, their
values can deviate by up to one layer pixel from what the page might expect
based on the styles of the contents. This change requires a few changes to
existing tests.
The fact that scrollWidth and scrollHeight can change based on the position of
the scrollable element and the zoom level / resolution may surprise some web
pages. However, this also seems to happen in Edge. Edge seems to always round
scrollWidth and scrollHeight upwards, possibly to their equivalent of layout
device pixels.

MozReview-Commit-ID: 3LFV7Lio4tG

--HG--
extra : rebase_source : 3e4e0b60493397e61283aa1d7fd93d7c197dec29
extra : source : d43c2d5e87f31ff47d7f3ada66c3f5f27cef84a9
2016-08-04 23:51:58 -04:00
..
crashtests Merge autoland into mozilla-central; a=merge 2016-07-04 09:01:56 -07:00
test Bug 1012752 - Snap scrolled area to layer pixels. r=tnikkel 2016-08-04 23:51:58 -04:00
AsyncScrollBase.cpp
AsyncScrollBase.h
BlockReflowInput.cpp Bug 1288383 - Replace NS_STYLE_FLOAT_EDGE_* with an enum class; r=heycam 2016-07-25 11:56:05 +05:30
BlockReflowInput.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
broken-image.png
DetailsFrame.cpp Bug 1258657 Part 2 - Remove SummaryFrame. r=bz 2016-04-13 13:34:14 +08:00
DetailsFrame.h
folder.png
frame-graph.py
FrameChildList.cpp
FrameChildList.h
jar.mn
JustificationUtils.h Bug 1277775 - Replace MOZ_CONSTEXPR{_VAR,_TMPL} with constexpr. r=froydnj 2016-07-08 14:39:53 -07:00
loading-image.png
MathMLTextRunFactory.cpp Bug 1266391 - Introduce an enum class mozilla::unicode::Script, and use this instead of bare integers to specify script codes for better type checking. r=masayuki 2016-04-21 18:58:59 +01:00
MathMLTextRunFactory.h Bug 1283273 - Change nsAutoPtr to UniquePtr in classes within layout/generic. r=dholbert 2016-07-08 08:08:00 +02:00
moz.build Bug 1286877 - do not set c-basic-offset for python-mode; r=gps 2016-07-14 10:16:42 -06:00
nsAbsoluteContainingBlock.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsAbsoluteContainingBlock.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsAtomicContainerFrame.h
nsAutoCopyListener.h
nsBackdropFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsBackdropFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsBlockDebugFlags.h Bug 1275831 - part6: remove unused block layout debug flag. r=dholbert 2016-05-27 16:06:27 +08:00
nsBlockFrame.cpp Bug 1197324 - Fix new warnings. r=froydnj 2016-08-03 14:37:31 +02:00
nsBlockFrame.h Bug 1290813 - Correctly number indirect descendants of <ol reversed>; r=xidorn 2016-08-01 15:54:25 +05:30
nsBlockReflowContext.cpp Bug 1277129 Part 7c - Rename various RS variables to RI. r=dbaron 2016-07-21 18:36:39 +08:00
nsBlockReflowContext.h Bug 1277129 Part 7c - Rename various RS variables to RI. r=dbaron 2016-07-21 18:36:39 +08:00
nsBRFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsBulletFrame.cpp Bug 1288992 Part 3 - Rename local variables named metrics to reflowOutput. r=dholbert 2016-07-26 17:10:52 +08:00
nsBulletFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsCanvasFrame.cpp Bug 1284837 - Disallow implicit conversions from float to integer when creating IntPoint and IntSize objects. r=botond 2016-07-26 16:48:30 +02:00
nsCanvasFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsColumnSetFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsColumnSetFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsContainerFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsContainerFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsDirection.h
nsFirstLetterFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsFirstLetterFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsFlexContainerFrame.cpp Bug 1277129 Part 7c - Rename various RS variables to RI. r=dbaron 2016-07-21 18:36:39 +08:00
nsFlexContainerFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsFloatManager.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsFloatManager.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsFontInflationData.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsFontInflationData.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsFrame.cpp Bug 1287122 - Make sure we build nsDisplayOpacity if we need it, since useOpacity already takes svg effects into account. r=dbaron 2016-08-05 10:37:46 +12:00
nsFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsFrameIdList.h Bug 1277131 : Part 2 - rename nsMathMLmtableOuterFrame to nsMathMLmtableWrapperFrame. r=heycam 2016-06-16 13:14:50 +01:00
nsFrameList.cpp
nsFrameList.h
nsFrameSelection.h Bug 1278014 part.3 Define 2 constants for number of SelectionType and number of SelectionType except "none" r=smaug 2016-06-11 11:12:26 +09:00
nsFrameSetFrame.cpp Bug 1288992 Part 3 - Rename local variables named metrics to reflowOutput. r=dholbert 2016-07-26 17:10:52 +08:00
nsFrameSetFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsFrameState.cpp Bug 1144096 part 5 - [css-grid] Create a couple of Grid container frame bits. r=dholbert 2016-03-11 17:39:26 +01:00
nsFrameState.h Bug 1265624 - Remove unnecessary compiler version check for MSVS 2010 in nsFrameState.h. r=heycam 2016-04-17 17:09:32 -07:00
nsFrameStateBits.h Bug 1277129 Part 2c - Rename nsBlockReflowState to BlockReflowInput. r=dbaron 2016-07-21 18:36:36 +08:00
nsFrameUtil.cpp
nsGfxScrollFrame.cpp Bug 1012752 - Snap scrolled area to layer pixels. r=tnikkel 2016-08-04 23:51:58 -04:00
nsGfxScrollFrame.h Bug 1012752 - Snap scrolled area to layer pixels. r=tnikkel 2016-08-04 23:51:58 -04:00
nsGridContainerFrame.cpp Bug 1289509 - Supply a default value for mGenerateComputedGridInfo. r=bz 2016-07-26 10:03:26 -07:00
nsGridContainerFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsHTMLCanvasFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsHTMLCanvasFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsHTMLParts.h Bug 1277131 : Part 1 - rename nsTableOuterFrame to nsTableWrapperFrame. r=heycam 2016-06-16 13:14:08 +01:00
nsIAnonymousContentCreator.h
nsIFrame.h Bug 1288992 Part 2 - Rename ReflowMetrics variables to ReflowOutput. r=dholbert 2016-07-26 16:33:52 +08:00
nsIFrameInlines.h Bug 1277131 : Part 3 - rename nsGkAtoms::tableOuterFrame and nsCSSAnonBoxes::tableOuter. r=heycam 2016-06-16 13:35:43 +01:00
nsIFrameUtil.h
nsILineIterator.h
nsImageFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsImageFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsImageMap.cpp Bug 1263782 - Kill off the deprecated nsINode::IsInDoc(). r=baku 2016-03-31 11:58:25 +01:00
nsImageMap.h
nsInlineFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsInlineFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsIntervalSet.cpp
nsIntervalSet.h
nsIObjectFrame.h
nsIPageSequenceFrame.h
nsIScrollableFrame.h Bug 1284586 - Disable paint-skipping for scrollframes that we detect as having a CSS-clipped descendant. r=mstange 2016-07-13 16:05:53 -04:00
nsIScrollPositionListener.h
nsIStatefulFrame.h Bug 1249664 - Make stateful frames responsible for their own keys r=dbaron 2016-03-10 10:14:37 -05:00
nsLeafFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsLeafFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsLineBox.cpp
nsLineBox.h
nsLineLayout.cpp Bug 1288992 Part 3 - Rename local variables named metrics to reflowOutput. r=dholbert 2016-07-26 17:10:52 +08:00
nsLineLayout.h Bug 1277129 Part 7c - Rename various RS variables to RI. r=dbaron 2016-07-21 18:36:39 +08:00
nsPageContentFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsPageContentFrame.h Bug 1277129 Part 5c - Rename nsHTMLReflowMetrics to ReflowOutput. r=dbaron 2016-07-21 18:36:38 +08:00
nsPageFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsPageFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsPlaceholderFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsPlaceholderFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsPluginFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsPluginFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsQueryFrame.h
nsRubyBaseContainerFrame.cpp Bug 1277129 Part 7c - Rename various RS variables to RI. r=dbaron 2016-07-21 18:36:39 +08:00
nsRubyBaseContainerFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsRubyBaseFrame.cpp Bug 1264837 Part 9 - Remove nsRubyBaseFrameSuper. r=dholbert 2016-04-18 14:04:03 +08:00
nsRubyBaseFrame.h Bug 1264837 Part 9 - Remove nsRubyBaseFrameSuper. r=dholbert 2016-04-18 14:04:03 +08:00
nsRubyContentFrame.cpp Bug 1264837 Part 10 - Remove nsRubyContentFrameSuper. r=dholbert 2016-04-18 14:06:23 +08:00
nsRubyContentFrame.h Bug 1264837 Part 10 - Remove nsRubyContentFrameSuper. r=dholbert 2016-04-18 14:06:23 +08:00
nsRubyFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsRubyFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsRubyTextContainerFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsRubyTextContainerFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsRubyTextFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsRubyTextFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsSelection.cpp Bug 1260651 part.56 Rename nsHTMLEditor to mozilla::HTMLEditor and related stuff r=mccr8 2016-07-09 11:42:33 +09:00
nsSimplePageSequenceFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsSimplePageSequenceFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsSplittableFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsSplittableFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsSubDocumentFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsSubDocumentFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsTextFrame.cpp Bug 1288938: Allow passing different reasons to dirty a non display SVG text frame. r=heycam 2016-08-03 10:53:37 -07:00
nsTextFrame.h Bug 1058040, part 2 - Rename gfxTextContextPaint to SVGContextPaint and add some code comments. r=dholbert 2016-07-22 14:56:09 +01:00
nsTextFrameUtils.cpp
nsTextFrameUtils.h Bug 1288938: layout: Move the GlyphObserver to the text run instead of the frame. r=jfkthame 2016-08-03 10:53:37 -07:00
nsTextRunTransformations.cpp Bug 1282248 - Declare a bunch of gfxTextRun measurement/drawing methods and related helpers as const. r=m_kato 2016-06-27 17:41:55 +01:00
nsTextRunTransformations.h Bug 1283273 - Change nsAutoPtr to UniquePtr in classes within layout/generic. r=dholbert 2016-07-08 08:08:00 +02:00
nsVideoFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsVideoFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsViewportFrame.cpp Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
nsViewportFrame.h Bug 1277129 Part 7b - Rename various ReflowState variables to ReflowInput. r=dbaron 2016-07-21 18:36:39 +08:00
ReflowInput.cpp Bug 1288992 Part 2 - Rename ReflowMetrics variables to ReflowOutput. r=dholbert 2016-07-26 16:33:52 +08:00
ReflowInput.h Bug 1277129 Part 7c - Rename various RS variables to RI. r=dbaron 2016-07-21 18:36:39 +08:00
ReflowOutput.cpp Bug 1277129 Part 5c - Rename nsHTMLReflowMetrics to ReflowOutput. r=dbaron 2016-07-21 18:36:38 +08:00
ReflowOutput.h Bug 1277129 Part 5c - Rename nsHTMLReflowMetrics to ReflowOutput. r=dbaron 2016-07-21 18:36:38 +08:00
RubyUtils.cpp
RubyUtils.h Bug 1263773 - Mark a bunch of classes in layout as MOZ_RAII. r=dholbert 2016-03-28 13:34:26 +01:00
ScrollbarActivity.cpp Bug 824592 part 3. Get rid of nsIDOMElementCSSInlineStyle. r=peterv 2016-08-02 11:05:38 -07:00
ScrollbarActivity.h
ScrollSnap.cpp Bug 1219296 - Move the layout.css.scroll-snap.proximity-threshold pref to gfxPrefs, so it can be queried on the compositor thread. r=kats 2016-03-18 21:15:45 -04:00
ScrollSnap.h Bug 1219296 - Scroll snap directly in APZ instead of going through the main thread. r=kats 2016-03-28 18:36:02 -04:00
ScrollVelocityQueue.cpp
ScrollVelocityQueue.h
Selection.h Bug 1185307 part.1 Add nsISelection::AsSelection() r=smaug 2016-06-17 16:16:10 +09:00
SelectionChangeListener.h
StickyScrollContainer.cpp Bug 1280344 - Use first continuation's normal position in computing sticky scroll ranges for APZ. r=dholbert 2016-07-12 12:36:31 -04:00
StickyScrollContainer.h
TextOverflow.cpp Bug 1261578 - Part 4. Correct text overflow color; r=jfkthame 2016-04-19 17:10:17 +08:00
TextOverflow.h Bug 1279451 - Remove a lot of unnecessary includes of nsAutoPtr.h. rs=sparky 2016-06-07 21:10:18 +01:00
Visibility.h Bug 1261554 (Part 3) - Visualize Visibility::IN_DISPLAYPORT regions in the APZ minimap visibility debugger. r=botond 2016-04-21 01:22:10 -07:00
VisibilityIPC.h Bug 1262671 - void** -> PickleIterator (r=froydnj) 2016-05-27 09:57:38 -07:00
WritingModes.h Bug 1280647 - Rename nsStyleDisplay member mFloats to mFloat. r=dholbert 2016-06-18 22:16:20 +01:00