Bug 945584: Part 8 - Implement Scroll Snapping for Middle Mouse Button Scrolls (v2 Patch), r=roc, r=bz

- Implemented scroll snapping at the end of a middle-mouse-button scroll.
- As this scrolling occurs within chrome Javascript, chrome-only DOM methods
  had to be added: window.MozScrollSnap and element.MozScrollSnap
- Bug 1137937 tracks implementation of a replacement for these chome-only DOM methods,
  to be replaced with a web accessible API.

--HG--
extra : rebase_source : f511296dbdbfd97e3da391d2a0b67fd3f6edca6b
This commit is contained in:
Kearwood (Kip) Gilbert 2015-02-19 16:03:07 -08:00
parent 5e7a1dc4a2
commit b0c31cd0a6
7 changed files with 32 additions and 0 deletions

View File

@ -797,6 +797,15 @@ Element::ScrollByNoFlush(int32_t aDx, int32_t aDy)
return (before != after);
}
void
Element::MozScrollSnap()
{
nsIScrollableFrame* sf = GetScrollFrame(nullptr, false);
if (sf) {
sf->ScrollSnap();
}
}
static nsSize GetScrollRectSizeForOverflowVisibleFrame(nsIFrame* aFrame)
{
if (!aFrame) {

View File

@ -762,6 +762,7 @@ public:
void SetScrollLeft(int32_t aScrollLeft);
int32_t ScrollWidth();
int32_t ScrollHeight();
void MozScrollSnap();
int32_t ClientTop()
{
return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().y);

View File

@ -7355,6 +7355,16 @@ nsGlobalWindow::ScrollByPages(int32_t numPages,
}
}
void
nsGlobalWindow::MozScrollSnap()
{
FlushPendingNotifications(Flush_Layout);
nsIScrollableFrame *sf = GetScrollFrame();
if (sf) {
sf->ScrollSnap();
}
}
void
nsGlobalWindow::MozRequestOverfill(OverfillCallback& aCallback,
mozilla::ErrorResult& aError)

View File

@ -946,6 +946,7 @@ public:
const mozilla::dom::ScrollOptions& aOptions);
void ScrollByPages(int32_t numPages,
const mozilla::dom::ScrollOptions& aOptions);
void MozScrollSnap();
int32_t GetInnerWidth(mozilla::ErrorResult& aError);
void SetInnerWidth(int32_t aInnerWidth, mozilla::ErrorResult& aError);
int32_t GetInnerHeight(mozilla::ErrorResult& aError);

View File

@ -185,6 +185,11 @@ partial interface Element {
void scrollTo(optional ScrollToOptions options);
void scrollBy(unrestricted double x, unrestricted double y);
void scrollBy(optional ScrollToOptions options);
// mozScrollSnap is used by chrome to perform scroll snapping after the
// user performs actions that may affect scroll position
// mozScrollSnap is deprecated, to be replaced by a web accessible API, such
// as an extension to the ScrollOptions dictionary. See bug 1137937.
[ChromeOnly] void mozScrollSnap();
readonly attribute long clientTop;
readonly attribute long clientLeft;

View File

@ -190,6 +190,11 @@ partial interface Window {
void scrollTo(optional ScrollToOptions options);
void scrollBy(unrestricted double x, unrestricted double y);
void scrollBy(optional ScrollToOptions options);
// mozScrollSnap is used by chrome to perform scroll snapping after the
// user performs actions that may affect scroll position
// mozScrollSnap is deprecated, to be replaced by a web accessible API, such
// as an extension to the ScrollOptions dictionary. See bug 1137937.
[ChromeOnly] void mozScrollSnap();
[Replaceable, Throws] readonly attribute long scrollX;
[Throws] readonly attribute long pageXOffset;
[Replaceable, Throws] readonly attribute long scrollY;

View File

@ -146,6 +146,7 @@ let ClickEventHandler = {
stopScroll: function() {
if (this._scrollable) {
this._scrollable.mozScrollSnap();
this._scrollable = null;
Cc["@mozilla.org/eventlistenerservice;1"]