Package org.mozilla.geckoview
Class PanZoomController
Object
org.mozilla.geckoview.PanZoomController
Manages panning, zooming, and input event handling for a GeckoSession.
This controller processes touch, mouse, and scroll events to update the web content viewport, supports fling and smooth scrolling behaviors, and reports input handling results.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceInput result type definitions for input event handling.static classRepresents how aMotionEventwas handled in Gecko.static @interfaceRepresents which directions can be over-scrolled in the scroll container where an input event was handled.static @interfaceRepresents which directions can be scrolled in the scroll container where an input event was handled.static @interfaceScroll behavior type definitions for scrolling animation. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSpecifies that an input event was handled by the PanZoomController for a panning or zooming operation, but likely not by any touch event listeners in Web content.static final intSpecifies that an input event was handled by the PanZoomController and passed on to touch event listeners in Web content.static final intSpecifies that an input event was consumed by a PanZoomController internally and browsers should do nothing in response to the event.static final intSpecifies that an input event was not handled by the PanZoomController for a panning or zooming operation.static final intthe container can be over-scrolled horizontally.static final intthe container cannot be over-scrolled.static final intthe container can be over-scrolled vertically.static final intSpecifies auto scrolling which jumps content to the desired scroll position.static final intSpecifies smooth scrolling which animates content to the desired scroll position.static final intThe container cannot be scrolled to bottomstatic final intThe container cannot be scrolled to leftstatic final intThe container cannot be scrolled.static final intThe container cannot be scrolled to rightstatic final intThe container cannot be scrolled to top -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPanZoomController(GeckoSession session) Constructs a PanZoomController for the specified GeckoSession and initializes the event queue. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidfinalize()floatGet the current scroll factor.booleanonDragEvent(DragEvent event) Process a drag event.voidonMotionEvent(MotionEvent event) Process a non-touch motion event through the pan-zoom controller.voidonMouseEvent(MotionEvent event) Process a touch event through the pan-zoom controller.voidonTouchEvent(MotionEvent event) Process a touch event through the pan-zoom controller.Process a touch event through the pan-zoom controller.voidscrollBy(ScreenLength width, ScreenLength height) Scroll the document body by an offset from the current scroll position.voidscrollBy(ScreenLength width, ScreenLength height, int behavior) Scroll the document body by an offset from the current scroll position.voidscrollTo(ScreenLength width, ScreenLength height) Scroll the document body to an absolute position.voidscrollTo(ScreenLength width, ScreenLength height, int behavior) Scroll the document body to an absolute position.voidScroll to the bottom left corner of the screen.voidScroll to the top left corner of the screen.voidsetIsLongpressEnabled(boolean isLongpressEnabled) Set whether Gecko should generate long-press events.voidsetScrollFactor(float factor) Set the current scroll factor.
-
Field Details
-
SCROLL_BEHAVIOR_SMOOTH
public static final int SCROLL_BEHAVIOR_SMOOTHSpecifies smooth scrolling which animates content to the desired scroll position.- See Also:
-
SCROLL_BEHAVIOR_AUTO
public static final int SCROLL_BEHAVIOR_AUTOSpecifies auto scrolling which jumps content to the desired scroll position.- See Also:
-
INPUT_RESULT_UNHANDLED
public static final int INPUT_RESULT_UNHANDLEDSpecifies that an input event was not handled by the PanZoomController for a panning or zooming operation. The event may have been handled by Web content or internally (e.g. text selection).- See Also:
-
INPUT_RESULT_HANDLED
public static final int INPUT_RESULT_HANDLEDSpecifies that an input event was handled by the PanZoomController for a panning or zooming operation, but likely not by any touch event listeners in Web content.- See Also:
-
INPUT_RESULT_HANDLED_CONTENT
public static final int INPUT_RESULT_HANDLED_CONTENTSpecifies that an input event was handled by the PanZoomController and passed on to touch event listeners in Web content.- See Also:
-
INPUT_RESULT_IGNORED
public static final int INPUT_RESULT_IGNOREDSpecifies that an input event was consumed by a PanZoomController internally and browsers should do nothing in response to the event.- See Also:
-
SCROLLABLE_FLAG_NONE
public static final int SCROLLABLE_FLAG_NONEThe container cannot be scrolled.- See Also:
-
SCROLLABLE_FLAG_TOP
public static final int SCROLLABLE_FLAG_TOPThe container cannot be scrolled to top- See Also:
-
SCROLLABLE_FLAG_RIGHT
public static final int SCROLLABLE_FLAG_RIGHTThe container cannot be scrolled to right- See Also:
-
SCROLLABLE_FLAG_BOTTOM
public static final int SCROLLABLE_FLAG_BOTTOMThe container cannot be scrolled to bottom- See Also:
-
SCROLLABLE_FLAG_LEFT
public static final int SCROLLABLE_FLAG_LEFTThe container cannot be scrolled to left- See Also:
-
OVERSCROLL_FLAG_NONE
public static final int OVERSCROLL_FLAG_NONEthe container cannot be over-scrolled.- See Also:
-
OVERSCROLL_FLAG_HORIZONTAL
public static final int OVERSCROLL_FLAG_HORIZONTALthe container can be over-scrolled horizontally.- See Also:
-
OVERSCROLL_FLAG_VERTICAL
public static final int OVERSCROLL_FLAG_VERTICALthe container can be over-scrolled vertically.- See Also:
-
-
Constructor Details
-
PanZoomController
Constructs a PanZoomController for the specified GeckoSession and initializes the event queue.- Parameters:
session- the GeckoSession to control panning and zooming for
-
-
Method Details
-
setScrollFactor
public void setScrollFactor(float factor) Set the current scroll factor. The scroll factor is the maximum scroll amount that one scroll event may generate, in device pixels.- Parameters:
factor- Scroll factor.
-
getScrollFactor
public float getScrollFactor()Get the current scroll factor.- Returns:
- Scroll factor.
-
onTouchEvent
Process a touch event through the pan-zoom controller. Treat any mouse events as "touch" rather than as "mouse". Pointer coordinates should be relative to the display surface.- Parameters:
event- MotionEvent to process.
-
onTouchEventForDetailResult
@NonNull public GeckoResult<PanZoomController.InputResultDetail> onTouchEventForDetailResult(@NonNull MotionEvent event) Process a touch event through the pan-zoom controller. Treat any mouse events as "touch" rather than as "mouse". Pointer coordinates should be relative to the display surface.NOTE: It is highly recommended to only call this with ACTION_DOWN or in otherwise limited capacity. Returning a GeckoResult for every touch event will generate a lot of allocations and unnecessary GC pressure. Instead, prefer to call
onTouchEvent(MotionEvent).- Parameters:
event- MotionEvent to process.- Returns:
- A GeckoResult resolving to
PanZoomController.InputResultDetail).
-
onMouseEvent
Process a touch event through the pan-zoom controller. Treat any mouse events as "mouse" rather than as "touch". Pointer coordinates should be relative to the display surface.- Parameters:
event- MotionEvent to process.
-
finalize
-
onMotionEvent
Process a non-touch motion event through the pan-zoom controller. Currently, hover and scroll events are supported. Pointer coordinates should be relative to the display surface.- Parameters:
event- MotionEvent to process.
-
onDragEvent
Process a drag event.- Parameters:
event- DragEvent to process.- Returns:
- true if this event is accepted.
-
setIsLongpressEnabled
public void setIsLongpressEnabled(boolean isLongpressEnabled) Set whether Gecko should generate long-press events.- Parameters:
isLongpressEnabled- True if Gecko should generate long-press events.
-
scrollBy
Scroll the document body by an offset from the current scroll position. UsesSCROLL_BEHAVIOR_SMOOTH.- Parameters:
width-ScreenLengthoffset to scroll along X axis.height-ScreenLengthoffset to scroll along Y axis.
-
scrollBy
@UiThread public void scrollBy(@NonNull ScreenLength width, @NonNull ScreenLength height, int behavior) Scroll the document body by an offset from the current scroll position.- Parameters:
width-ScreenLengthoffset to scroll along X axis.height-ScreenLengthoffset to scroll along Y axis.behavior- ScrollBehaviorType One ofSCROLL_BEHAVIOR_SMOOTH,SCROLL_BEHAVIOR_AUTO, that specifies how to scroll the content.
-
scrollTo
Scroll the document body to an absolute position. UsesSCROLL_BEHAVIOR_SMOOTH.- Parameters:
width-ScreenLengthposition to scroll along X axis.height-ScreenLengthposition to scroll along Y axis.
-
scrollTo
@UiThread public void scrollTo(@NonNull ScreenLength width, @NonNull ScreenLength height, int behavior) Scroll the document body to an absolute position.- Parameters:
width-ScreenLengthposition to scroll along X axis.height-ScreenLengthposition to scroll along Y axis.behavior- ScrollBehaviorType One ofSCROLL_BEHAVIOR_SMOOTH,SCROLL_BEHAVIOR_AUTO, that specifies how to scroll the content.
-
scrollToTop
@UiThread public void scrollToTop()Scroll to the top left corner of the screen. UsesSCROLL_BEHAVIOR_SMOOTH. -
scrollToBottom
@UiThread public void scrollToBottom()Scroll to the bottom left corner of the screen. UsesSCROLL_BEHAVIOR_SMOOTH.
-