Improve bug 206438 to also work on OSX and Linux

RESOLVED FIXED in Firefox 13

Status

()

Core
Layout
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: avih, Assigned: avih)

Tracking

(Blocks: 1 bug)

Trunk
mozilla14
x86
All
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox13 verified, firefox14 fixed)

Details

(Whiteboard: [snappy])

Attachments

(3 attachments, 3 obsolete attachments)

(Assignee)

Description

5 years ago
Bug 206438 (smooth scrolling should be similar to SmoothWheel) distinguishes mouse wheel events from the rest by identifying "pixels" unit at the scroll request. This only works on windows, because on Linux/OSX normal mouse wheel scroll generate "lines" unit scroll requests. This bug aims to fix it for those platforms.
Assignee: nobody → chuku_regs
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Status: REOPENED → ASSIGNED

Updated

5 years ago
Blocks: 206438, 710372
Component: Document Navigation → Layout
QA Contact: docshell → layout
(Assignee)

Comment 1

5 years ago
Summary of some IRC discussions from today:
[ESM = Events state manager]

tn: On Linux, ESM only receives "lines" scroll [for normal mouse wheel].
tn: On OSX, ESM receives "lines" scrolls for normal external mice, and "pixels" scrolls for proper "pixel devices" (trackpad, magic mouse, etc). (*)

avih: On Windows, even for normal mouse wheel events, the platform-specific code sends ESM a pixels scroll event ("faked", because it didn't originate in a true pixels scroll request).
(*) avih: Pixels scrolls on both OSX and Windows (faked or not) are preceded with a lines scroll event which has the kHasPixels flag on.

masayuki: The windows behavior will change with bug 719320 and bug 672175 [this will probably fix the Windows abnormality in this context].

@mstange, tn is not 100% sure of his OSX info, could you please confirm?
Component: Layout → Document Navigation
Yes, I'm pretty sure this is all correct.

Updated

5 years ago
Component: Document Navigation → Layout
Masayuki, so we never got pixel scrolling hooked up to what some hardware was sending? What is the plan for pixel scrolling on Windows?
Also, why do we want to always send pixel scroll events even if we didn't get pixel level scroll messages from the OS?
So that a consumer could choose to handle only pixel scroll events without missing any events. The same works for line scroll events: Existing web contents expected only line scrolls from DOMMouseScroll events, so handling only those needed to work, too.
Also, the kHasPixels flag isn't published on the scroll DOM events, so web content can't conditionally handle either line scrolls or pixel scroll because it doesn't know the original source unit.
Looks like smaug and I made that decision on IRC, see bug 350471 comment 51.
In any case, the new DOM wheel events (bug 719320) probably have a much better API.
Oh sorry, I specifically meant how the Windows handles it where it always send both types of events even if it doesn't have any pixel data. On OS X we only send pixel events if we get pixel data, no?
Oh, right. What I was thinking of were the DOM events. You're right about OS X, and I don't know the reasons for the Windows behavior.
(In reply to Markus Stange from comment #5)
> In any case, the new DOM wheel events (bug 719320) probably have a much
> better API.

I'm thinking that:

1. D3E wheel event is fired.
2. If D3E wheel event isn't consumed by preventDefault(), DOMMouseScroll is fired.
3. If DOMMouseScroll event isn't consumed by preventDefault(), MozMousePixelScroll is fired.
4. If MozMousePixelScroll event isn't consumed by preventDefault(), ESM does its default action.
Sounds good.
(Assignee)

Comment 10

5 years ago
Created attachment 608658 [details] [diff] [review]
Part 1: Propagate mouse wheel event origin from ESM

This _should_ fix OSX+Linux (not tested), but will break Windows, because on Windows it'll ens at the MOUSE_SCROLL_PIXELS case.
Attachment #608658 - Flags: review?
(Assignee)

Comment 11

5 years ago
Created attachment 608659 [details] [diff] [review]
Part 2: Address Windows abnormality (detect "faked" pixel scrolls)
Attachment #608659 - Flags: review?
(Assignee)

Comment 12

5 years ago
Created attachment 608660 [details] [diff] [review]
Part 3: Cleanups and consistency
Attachment #608660 - Flags: review?
Attachment #608659 - Flags: review? → review?(jmathies)
Comment on attachment 608658 [details] [diff] [review]
Part 1: Propagate mouse wheel event origin from ESM

roc: Can you review the /layout and /modules/libpref changes?
smaug: Can you review the /content changes?
Attachment #608658 - Flags: review?(roc)
Attachment #608658 - Flags: review?(bugs)
Attachment #608658 - Flags: review?
Attachment #608660 - Flags: review? → review?(roc)
(Assignee)

Comment 14

5 years ago
FWIW, even after landing bug 672175, part 2 here (address windows abnormality) is still required, and in general, this patch doesn't create hg conflicts with latest m-c, and the parts of this patch are as valid as before.
Comment on attachment 608658 [details] [diff] [review]
Part 1: Propagate mouse wheel event origin from ESM


> nsresult
> nsEventStateManager::DoScrollText(nsIFrame* aTargetFrame,
>                                   nsMouseScrollEvent* aMouseEvent,
>                                   nsIScrollableFrame::ScrollUnit aScrollQuantity,
>                                   bool aAllowScrollSpeedOverride,
>-                                  nsQueryContentEvent* aQueryEvent)
>+                                  nsQueryContentEvent* aQueryEvent,
>+                                  nsIAtom *aOrigin)
I would use an enum for aOrigin.
Attachment #608658 - Flags: review?(bugs) → review-
(Assignee)

Comment 16

5 years ago
(In reply to Olli Pettay [:smaug] from comment #15)
>...
> I would use an enum for aOrigin.

Me too, but roc really wanted atoms instead. The main reason, as far as I understand, is to later on compose a preference name on the fly from this string, instead of using a big case statement for each origin. If you wish to follow this discussion, see bug 206438 comment 52 onwards.
Comment on attachment 608658 [details] [diff] [review]
Part 1: Propagate mouse wheel event origin from ESM

Ok, I see. A bit ugly but should work.
Attachment #608658 - Flags: review- → review+
Comment on attachment 608658 [details] [diff] [review]
Part 1: Propagate mouse wheel event origin from ESM

Review of attachment 608658 [details] [diff] [review]:
-----------------------------------------------------------------

::: content/events/src/nsEventStateManager.cpp
@@ +3218,5 @@
>            break;
>  
>          case MOUSE_SCROLL_PAGE:
>            DoScrollText(aTargetFrame, msEvent, nsIScrollableFrame::PAGES,
>                         false);

Why not pass an origin for all calls to DoScrollText?

::: content/events/src/nsEventStateManager.h
@@ +353,5 @@
>                          nsMouseScrollEvent* aMouseEvent,
>                          nsIScrollableFrame::ScrollUnit aScrollQuantity,
>                          bool aAllowScrollSpeedOverride,
> +                        nsQueryContentEvent* aQueryEvent = nsnull,
> +                        nsIAtom *aOrigin = nsnull);

I don't think this parameter should be optional.
Comment on attachment 608660 [details] [diff] [review]
Part 3: Cleanups and consistency

Review of attachment 608660 [details] [diff] [review]:
-----------------------------------------------------------------

::: layout/generic/nsGfxScrollFrame.cpp
@@ +1407,5 @@
>   */
>  void
> +nsGfxScrollFrameInner::AsyncScroll::InitDuration(nsIAtom *aOrigin) {
> +  if (!aOrigin)
> +    aOrigin = nsGkAtoms::other;

Who's passing a null origin? Let's make everything pass an explicit origin.
(In reply to Avi Halachmi (:avih) from comment #16)
> Me too, but roc really wanted atoms instead. The main reason, as far as I
> understand, is to later on compose a preference name on the fly from this
> string, instead of using a big case statement for each origin. If you wish
> to follow this discussion, see bug 206438 comment 52 onwards.

The main reason is modularity. This way you can add new scroll origins without modifying nsGfxScrollFrame.
(Assignee)

Comment 21

5 years ago
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #18)
> Comment on attachment 608658 [details] [diff] [review]
> Part 1: Propagate mouse wheel event origin from ESM
> 
> Review of attachment 608658 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: content/events/src/nsEventStateManager.cpp
> @@ +3218,5 @@
> >            break;
> >  
> >          case MOUSE_SCROLL_PAGE:
> >            DoScrollText(aTargetFrame, msEvent, nsIScrollableFrame::PAGES,
> >                         false);
> 
> Why not pass an origin for all calls to DoScrollText?

My original (unsubmitted) patch actually did this, however, when I rewrote it, I changed it because:

1. We don't need other origins right now (and we can add them later if/when that changes). Bug 206438 comment 62 defines our current "requirement" as mouse wheel scroll only. I added other origins (lines/pages) because I think they're very useful, AND the code changes were very local and safe.

2. If we really want it complete, we should also use origin for all other scroll requests/propagations (e.g. usages of ScrollTo, ScrollBy, etc - a LOT of places around the code). Also, for some/many of these places, origin might not be as obvious as it is here, and also, most scroll calls don't even know if it might end in smooth scroll - which is where origin is used.

3. "Fragmentation" of scroll origins will, IMHO, make it less useful. Right now origin is mouseWheel/scrollbars/lines/pages(/pixels/other), which covers nicely all scroll triggers (and after minimal testing, smooth scroll currently always ends with one of first 4). If we use "high resolution" origin, we could end up with MANY different origins (e.g. VK_UP/VK_DOWN/VK_LEFT/...), which will overall make this system cumbersome, and therefore not as useful IMO.

So, taking into account the negatives stated above, compared to the other approach of minimal required code changes (even if generally "incomplete"), I chose the latter as I see it as less evil.


> 
> ::: content/events/src/nsEventStateManager.h
> @@ +353,5 @@
> >                          nsMouseScrollEvent* aMouseEvent,
> >                          nsIScrollableFrame::ScrollUnit aScrollQuantity,
> >                          bool aAllowScrollSpeedOverride,
> > +                        nsQueryContentEvent* aQueryEvent = nsnull,
> > +                        nsIAtom *aOrigin = nsnull);
> 
> I don't think this parameter should be optional.

See next reply.

(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #19)
> Comment on attachment 608660 [details] [diff] [review]
> Part 3: Cleanups and consistency
> 
> Review of attachment 608660 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: layout/generic/nsGfxScrollFrame.cpp
> @@ +1407,5 @@
> >   */
> >  void
> > +nsGfxScrollFrameInner::AsyncScroll::InitDuration(nsIAtom *aOrigin) {
> > +  if (!aOrigin)
> > +    aOrigin = nsGkAtoms::other;
> 
> Who's passing a null origin? Let's make everything pass an explicit origin.

Part 2 of this patch does. And I used null and not nsGkAtoms::other as default value because IMO it's easier and less error prone in usage.

Making all scroll calls use an explicit (and correct) origin is not easy, requires MANY code changes all over the place, cumbersome, and error prone (see answers 2,3 above).
Comment on attachment 608658 [details] [diff] [review]
Part 1: Propagate mouse wheel event origin from ESM

Review of attachment 608658 [details] [diff] [review]:
-----------------------------------------------------------------

::: layout/generic/nsGfxScrollFrame.cpp
@@ +2327,4 @@
>  {
>    nsSize deltaMultiplier;
> +  if (!aOrigin)
> +    aOrigin = nsGkAtoms::other;

{}

@@ +2334,5 @@
>      nscoord appUnitsPerDevPixel =
>        mOuter->PresContext()->AppUnitsPerDevPixel();
>      deltaMultiplier = nsSize(appUnitsPerDevPixel, appUnitsPerDevPixel);
> +    if (isGenericOrigin)
> +      aOrigin = nsGkAtoms::pixels;

{}

@@ +2340,5 @@
>    }
>    case nsIScrollableFrame::LINES: {
>      deltaMultiplier = GetLineScrollAmount();
> +    if (isGenericOrigin)
> +      aOrigin = nsGkAtoms::lines;

{}

@@ +2346,5 @@
>    }
>    case nsIScrollableFrame::PAGES: {
>      deltaMultiplier = GetPageScrollAmount();
> +    if (isGenericOrigin)
> +      aOrigin = nsGkAtoms::pages;

{}
Attachment #608658 - Flags: review?(roc) → review+
Comment on attachment 608660 [details] [diff] [review]
Part 3: Cleanups and consistency

Review of attachment 608660 [details] [diff] [review]:
-----------------------------------------------------------------

::: layout/generic/nsGfxScrollFrame.cpp
@@ +1407,5 @@
>   */
>  void
> +nsGfxScrollFrameInner::AsyncScroll::InitDuration(nsIAtom *aOrigin) {
> +  if (!aOrigin)
> +    aOrigin = nsGkAtoms::other;

{} around the if body
Attachment #608660 - Flags: review?(roc) → review+
(Assignee)

Comment 24

5 years ago
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #23)
> {} around the if body

OK, and what about your previous comments (and my replies)?
I agree with your response to my previous comments.
(Assignee)

Comment 26

5 years ago
Created attachment 609268 [details] [diff] [review]
Part 1 V2: Propagate mouse wheel event origin from ESM

Adds {} around if bodies.
Attachment #608658 - Attachment is obsolete: true
Attachment #609268 - Flags: review?(roc)
(Assignee)

Updated

5 years ago
Attachment #609268 - Attachment description: Part 1 V2: → Part 1 V2: Propagate mouse wheel event origin from ESM
(Assignee)

Comment 27

5 years ago
Created attachment 609269 [details] [diff] [review]
Part 3 V2: Cleanups and semantic consistency

{} around the if body.
Attachment #608660 - Attachment is obsolete: true
Attachment #609269 - Flags: review?(roc)
Attachment #609268 - Flags: review?(roc) → review+
Attachment #609269 - Flags: review?(roc) → review+

Comment 28

5 years ago
Comment on attachment 608659 [details] [diff] [review]
Part 2: Address Windows abnormality (detect "faked" pixel scrolls)

Review of attachment 608659 [details] [diff] [review]:
-----------------------------------------------------------------

::: content/events/src/nsEventStateManager.cpp
@@ +3226,5 @@
>            DoScrollText(aTargetFrame, msEvent, nsIScrollableFrame::DEVICE_PIXELS,
> +                       false, nsnull,
> +                       (msEvent->scrollFlags & nsMouseScrollEvent::kFromLines) ?
> +                          nsGkAtoms::mouseWheel : nsnull
> +                      );

nit - wrap the conditional statement in paren so you don't have to fold that ending ');' over.
Attachment #608659 - Flags: review?(jmathies) → review+
(Assignee)

Comment 29

5 years ago
Created attachment 609281 [details] [diff] [review]
Part 2 V2: Address Windows abnormality (identify _faked_ pixel scrolls)

Readability.
Attachment #608659 - Attachment is obsolete: true
Attachment #609281 - Flags: review?(jmathies)
Attachment #609281 - Flags: checkin?
(Assignee)

Updated

5 years ago
Attachment #609268 - Flags: checkin?
(Assignee)

Updated

5 years ago
Attachment #609269 - Flags: checkin?

Updated

5 years ago
Attachment #609281 - Flags: review?(jmathies) → review+
(Assignee)

Comment 30

5 years ago
I also suggest to land this for Aurora as well. Otherwise, bug 206438 (already in Aurora) is not fixed for OSX/Linux, and it will also not work for Windows if mousewheel.enable_pixel_scrolling == false (not sure when that's the case, but mouse wheel roll will NOT trigger longer animation duration when enable_pixel_scrolling == false).
Keywords: checkin-needed
Comment on attachment 609268 [details] [diff] [review]
Part 1 V2: Propagate mouse wheel event origin from ESM

I'm clearing the checkin flag on the attachments since all parts should land at the same time and it will be easier for the person landing this to only update one place stating that they have checked this in.
Attachment #609268 - Flags: checkin?
Attachment #609269 - Flags: checkin?
Attachment #609281 - Flags: checkin?
(Assignee)

Comment 32

5 years ago
Removing checkin-needed for now: Patch V2 might not work on all Linux systems.

jwir3 and dholbert compiled and tested this patch on Linux (jwir3 on Ubuntu 11.04, and dholbert on Ubuntu 12.04), and it only worked for dholbert.

For jwir3 it seems that the new pref: general.smoothScroll.mouseWheel(.*) doesn't affect mouse wheel smooth scrolling.

dholbert and jwir3 will try to figure out what happened, and post the conclusion here.
Keywords: checkin-needed
(In reply to Avi Halachmi (:avih) from comment #32)
> dholbert and jwir3 will try to figure out what happened, and post the
> conclusion here.

It was a build configuration issue on my part. Sorry for holding this up. I pushed to inbound now:

https://hg.mozilla.org/integration/mozilla-inbound/rev/5f10a8447a5b
https://hg.mozilla.org/integration/mozilla-inbound/rev/28ab6cd9175d
https://hg.mozilla.org/integration/mozilla-inbound/rev/6442d65f75f6

Thanks for the contribution, Avi!
Target Milestone: --- → mozilla14
(Assignee)

Comment 34

5 years ago
Comment on attachment 609268 [details] [diff] [review]
Part 1 V2: Propagate mouse wheel event origin from ESM

[Aurora Approval Request Comment]
Regression caused by (bug #): 736251 (the new behavior doesn't work on OSX/Linux).
User impact if declined: OSX/Linux users won't get the fix for bug 736251.
Testing completed (on m-c, etc.): Tested locally - Aurora compiled with the patch applied (cleanly) and behaves as expected: Ubuntu 11.10(32), Win7(64), XP-SP3(32).
Risk to taking this patch (and alternatives if risky): No concrete risks that I can think of. Worst theoretical risk is probably: slightly longer-than-expected smooth scroll animation for some input devices.
String changes made by this patch: None.

@roc, I'd appreciate if you could review the "Risks" part.
Attachment #609268 - Flags: approval-mozilla-aurora?
(Assignee)

Updated

5 years ago
Attachment #609281 - Flags: approval-mozilla-aurora?
(Assignee)

Updated

5 years ago
Attachment #609269 - Flags: approval-mozilla-aurora?
(Assignee)

Comment 35

5 years ago
Oops, Correction [Aurora Approval Request Comment]:
Regression caused by (bug#): 206438 (won't work on OSX/Linux)
Impact: OSX/Linux users won't see the fix for bug 206438.

Sorry.
https://hg.mozilla.org/mozilla-central/rev/5f10a8447a5b
https://hg.mozilla.org/mozilla-central/rev/28ab6cd9175d
https://hg.mozilla.org/mozilla-central/rev/6442d65f75f6
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago5 years ago
Resolution: --- → FIXED
Whiteboard: [snappy]
Comment on attachment 609268 [details] [diff] [review]
Part 1 V2: Propagate mouse wheel event origin from ESM

[Triage Comment]
Approving for Aurora 13 to complete the smooth scrolling feature for OS X and Linux, since we expect that any fallout will become quickly apparent through user feedback and our own testing. If that's the case, we may need to consider backing out this change later.
Attachment #609268 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+

Updated

5 years ago
Attachment #609281 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+

Updated

5 years ago
Attachment #609269 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
(Assignee)

Updated

5 years ago
Keywords: checkin-needed
Whiteboard: [snappy] → [snappy] [land in aurora]
https://hg.mozilla.org/releases/mozilla-aurora/rev/993e301d9bdb
https://hg.mozilla.org/releases/mozilla-aurora/rev/5096a64c4c39
https://hg.mozilla.org/releases/mozilla-aurora/rev/4e89e0ae8354
status-firefox13: --- → fixed
status-firefox14: --- → fixed
Keywords: checkin-needed
Whiteboard: [snappy] [land in aurora] → [snappy]
Changed target milestone to mozilla13 as this has been uplifted to Aurora.
Target Milestone: mozilla14 → mozilla13
Target milestone tracks trunk landing, the status-firefox* flags track "backports".
Target Milestone: mozilla13 → mozilla14
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:13.0) Gecko/20100101 Firefox/13.0
Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20100101 Firefox/13.0

Verified that smooth scroll is applied to KB arrows, mouse scroll, PgUp/PgDn, Space, scrollbar buttons/empty space and magic mouse scroll.
status-firefox13: fixed → verified
You need to log in before you can comment on or make changes to this bug.