本文整理汇总了C++中PlatformWheelEvent::granularity方法的典型用法代码示例。如果您正苦于以下问题:C++ PlatformWheelEvent::granularity方法的具体用法?C++ PlatformWheelEvent::granularity怎么用?C++ PlatformWheelEvent::granularity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlatformWheelEvent
的用法示例。
在下文中一共展示了PlatformWheelEvent::granularity方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleWheelEvent
bool ScrollAnimator::handleWheelEvent(const PlatformWheelEvent& e)
{
#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
if (!m_scrollController.processWheelEventForScrollSnap(e))
return false;
#endif
#if PLATFORM(COCOA)
// Events in the PlatformWheelEventPhaseMayBegin phase have no deltas, and therefore never passes through the scroll handling logic below.
// This causes us to return with an 'unhandled' return state, even though this event was successfully processed.
//
// We receive at least one PlatformWheelEventPhaseMayBegin when starting main-thread scrolling (see FrameView::wheelEvent), which can
// fool the scrolling thread into attempting to handle the scroll, unless we treat the event as handled here.
if (e.phase() == PlatformWheelEventPhaseMayBegin)
return true;
#endif
Scrollbar* horizontalScrollbar = m_scrollableArea.horizontalScrollbar();
Scrollbar* verticalScrollbar = m_scrollableArea.verticalScrollbar();
// Accept the event if we have a scrollbar in that direction and can still
// scroll any further.
float deltaX = horizontalScrollbar ? e.deltaX() : 0;
float deltaY = verticalScrollbar ? e.deltaY() : 0;
bool handled = false;
ScrollGranularity granularity = ScrollByPixel;
IntSize maxForwardScrollDelta = m_scrollableArea.maximumScrollPosition() - m_scrollableArea.scrollPosition();
IntSize maxBackwardScrollDelta = m_scrollableArea.scrollPosition() - m_scrollableArea.minimumScrollPosition();
if ((deltaX < 0 && maxForwardScrollDelta.width() > 0)
|| (deltaX > 0 && maxBackwardScrollDelta.width() > 0)
|| (deltaY < 0 && maxForwardScrollDelta.height() > 0)
|| (deltaY > 0 && maxBackwardScrollDelta.height() > 0)) {
handled = true;
if (deltaY) {
if (e.granularity() == ScrollByPageWheelEvent) {
bool negative = deltaY < 0;
deltaY = Scrollbar::pageStepDelta(m_scrollableArea.visibleHeight());
if (negative)
deltaY = -deltaY;
}
scroll(VerticalScrollbar, granularity, verticalScrollbar->pixelStep(), -deltaY);
}
if (deltaX) {
if (e.granularity() == ScrollByPageWheelEvent) {
bool negative = deltaX < 0;
deltaX = Scrollbar::pageStepDelta(m_scrollableArea.visibleWidth());
if (negative)
deltaX = -deltaX;
}
scroll(HorizontalScrollbar, granularity, horizontalScrollbar->pixelStep(), -deltaX);
}
}
return handled;
}
示例2: handleWheelEvent
bool ScrollAnimator::handleWheelEvent(const PlatformWheelEvent& e)
{
bool canScrollX = m_scrollableArea->userInputScrollable(HorizontalScrollbar);
bool canScrollY = m_scrollableArea->userInputScrollable(VerticalScrollbar);
// Accept the event if we are scrollable in that direction and can still
// scroll any further.
float deltaX = canScrollX ? e.deltaX() : 0;
float deltaY = canScrollY ? e.deltaY() : 0;
bool handled = false;
#if !OS(MACOSX)
ScrollGranularity granularity = e.hasPreciseScrollingDeltas() ? ScrollByPrecisePixel : ScrollByPixel;
#else
ScrollGranularity granularity = ScrollByPixel;
#endif
IntSize maxForwardScrollDelta = m_scrollableArea->maximumScrollPosition() - m_scrollableArea->scrollPosition();
IntSize maxBackwardScrollDelta = m_scrollableArea->scrollPosition() - m_scrollableArea->minimumScrollPosition();
if ((deltaX < 0 && maxForwardScrollDelta.width() > 0)
|| (deltaX > 0 && maxBackwardScrollDelta.width() > 0)
|| (deltaY < 0 && maxForwardScrollDelta.height() > 0)
|| (deltaY > 0 && maxBackwardScrollDelta.height() > 0)) {
handled = true;
if (deltaY) {
if (e.granularity() == ScrollByPageWheelEvent) {
bool negative = deltaY < 0;
deltaY = m_scrollableArea->pageStep(VerticalScrollbar);
if (negative)
deltaY = -deltaY;
}
scroll(VerticalScrollbar, granularity, m_scrollableArea->pixelStep(VerticalScrollbar), -deltaY);
}
if (deltaX) {
if (e.granularity() == ScrollByPageWheelEvent) {
bool negative = deltaX < 0;
deltaX = m_scrollableArea->pageStep(HorizontalScrollbar);
if (negative)
deltaX = -deltaX;
}
scroll(HorizontalScrollbar, granularity, m_scrollableArea->pixelStep(HorizontalScrollbar), -deltaX);
}
}
return handled;
}
示例3: handleWheelEvent
void ScrollAnimator::handleWheelEvent(PlatformWheelEvent& e)
{
Scrollbar* horizontalScrollbar = m_scrollableArea->horizontalScrollbar();
Scrollbar* verticalScrollbar = m_scrollableArea->verticalScrollbar();
// Accept the event if we have a scrollbar in that direction and can still
// scroll any further.
float deltaX = horizontalScrollbar ? e.deltaX() : 0;
float deltaY = verticalScrollbar ? e.deltaY() : 0;
IntSize maxForwardScrollDelta = m_scrollableArea->maximumScrollPosition() - m_scrollableArea->scrollPosition();
IntSize maxBackwardScrollDelta = m_scrollableArea->scrollPosition() - m_scrollableArea->minimumScrollPosition();
if ((deltaX < 0 && maxForwardScrollDelta.width() > 0)
|| (deltaX > 0 && maxBackwardScrollDelta.width() > 0)
|| (deltaY < 0 && maxForwardScrollDelta.height() > 0)
|| (deltaY > 0 && maxBackwardScrollDelta.height() > 0)) {
e.accept();
if (e.granularity() == ScrollByPageWheelEvent) {
ASSERT(!e.deltaX());
bool negative = deltaY < 0;
deltaY = max(max(static_cast<float>(m_scrollableArea->visibleHeight()) * Scrollbar::minFractionToStepWhenPaging(), static_cast<float>(m_scrollableArea->visibleHeight() - Scrollbar::maxOverlapBetweenPages())), 1.0f);
if (negative)
deltaY = -deltaY;
}
if (deltaY)
scroll(VerticalScrollbar, ScrollByPixel, verticalScrollbar->pixelStep(), -deltaY);
if (deltaX)
scroll(HorizontalScrollbar, ScrollByPixel, horizontalScrollbar->pixelStep(), -deltaX);
}
}
示例4: dispatchWheelEvent
void EventTargetNode::dispatchWheelEvent(PlatformWheelEvent& e)
{
ASSERT(!eventDispatchForbidden());
if (e.deltaX() == 0 && e.deltaY() == 0)
return;
FrameView* view = document()->view();
if (!view)
return;
IntPoint pos = view->windowToContents(e.pos());
// Convert the deltas from pixels to lines if we have a pixel scroll event.
float deltaX = e.deltaX();
float deltaY = e.deltaY();
// FIXME: Should we do anything with a ScrollByPageWheelEvent here?
// It will be treated like a line scroll of 1 right now.
if (e.granularity() == ScrollByPixelWheelEvent) {
deltaX /= cMouseWheelPixelsPerLineStep;
deltaY /= cMouseWheelPixelsPerLineStep;
}
RefPtr<WheelEvent> we = WheelEvent::create(e.deltaX(), e.deltaY(),
document()->defaultView(), e.globalX(), e.globalY(), pos.x(), pos.y(),
e.ctrlKey(), e.altKey(), e.shiftKey(), e.metaKey());
ExceptionCode ec = 0;
if (!dispatchEvent(we.release(), ec))
e.accept();
}
示例5: wheelEvent
void ScrollView::wheelEvent(PlatformWheelEvent& e)
{
// We don't allow mouse wheeling to happen in a ScrollView that has had its scrollbars explicitly disabled.
#if PLATFORM(WX)
if (!canHaveScrollbars()) {
#else
if (!canHaveScrollbars() || platformWidget()) {
#endif
return;
}
// Accept the event if we have a scrollbar in that direction and can still
// scroll any further.
float deltaX = m_horizontalScrollbar ? e.deltaX() : 0;
float deltaY = m_verticalScrollbar ? e.deltaY() : 0;
IntSize maxForwardScrollDelta = maximumScrollPosition() - scrollPosition();
IntSize maxBackwardScrollDelta = scrollPosition() - minimumScrollPosition();
if ((deltaX < 0 && maxForwardScrollDelta.width() > 0)
|| (deltaX > 0 && maxBackwardScrollDelta.width() >0)
|| (deltaY < 0 && maxForwardScrollDelta.height() > 0)
|| (deltaY > 0 && maxBackwardScrollDelta.height() > 0)) {
e.accept();
if (e.granularity() == ScrollByPageWheelEvent) {
ASSERT(!e.deltaX());
bool negative = deltaY < 0;
deltaY = max(max(static_cast<float>(visibleHeight()) * Scrollbar::minFractionToStepWhenPaging(), static_cast<float>(visibleHeight() - Scrollbar::maxOverlapBetweenPages())), 1.0f);
if (negative)
deltaY = -deltaY;
}
if (deltaY)
m_verticalScrollbar->scroll(ScrollUp, ScrollByPixel, deltaY);
if (deltaX)
m_horizontalScrollbar->scroll(ScrollLeft, ScrollByPixel, deltaX);
}
}
void ScrollView::setFrameRect(const IntRect& newRect)
{
IntRect oldRect = frameRect();
if (newRect == oldRect)
return;
Widget::setFrameRect(newRect);
if (platformWidget())
return;
if (newRect.width() != oldRect.width() || newRect.height() != oldRect.height()) {
updateScrollbars(m_scrollOffset);
if (!m_useFixedLayout)
contentsResized();
}
frameRectsChanged();
}
示例6: wheelEvent
void ScrollView::wheelEvent(PlatformWheelEvent& e)
{
// We don't allow mouse wheeling to happen in a ScrollView that has had its scrollbars explicitly disabled.
#if PLATFORM(WX)
if (!canHaveScrollbars()) {
#else
if (!canHaveScrollbars() || platformWidget()) {
#endif
return;
}
// Determine how much we want to scroll. If we can move at all, we will accept the event.
IntSize maxScrollDelta = maximumScrollPosition() - scrollPosition();
if ((e.deltaX() < 0 && maxScrollDelta.width() > 0) ||
(e.deltaX() > 0 && scrollOffset().width() > 0) ||
(e.deltaY() < 0 && maxScrollDelta.height() > 0) ||
(e.deltaY() > 0 && scrollOffset().height() > 0)) {
e.accept();
float deltaX = e.deltaX();
float deltaY = e.deltaY();
if (e.granularity() == ScrollByPageWheelEvent) {
ASSERT(deltaX == 0);
bool negative = deltaY < 0;
deltaY = max(max(static_cast<float>(visibleHeight()) * Scrollbar::minFractionToStepWhenPaging(), static_cast<float>(visibleHeight() - Scrollbar::maxOverlapBetweenPages())), 1.0f);
if (negative)
deltaY = -deltaY;
}
// Should we fall back on scrollBy() if there is no scrollbar for a non-zero delta?
if (deltaY && m_verticalScrollbar)
m_verticalScrollbar->scroll(ScrollUp, ScrollByPixel, deltaY);
if (deltaX && m_horizontalScrollbar)
m_horizontalScrollbar->scroll(ScrollLeft, ScrollByPixel, deltaX);
}
}
void ScrollView::setFrameRect(const IntRect& newRect)
{
IntRect oldRect = frameRect();
if (newRect == oldRect)
return;
Widget::setFrameRect(newRect);
if (platformWidget())
return;
if (newRect.width() != oldRect.width() || newRect.height() != oldRect.height()) {
updateScrollbars(m_scrollOffset);
if (!m_useFixedLayout)
contentsResized();
}
frameRectsChanged();
}
示例7: wheelEvent
void ScrollView::wheelEvent(PlatformWheelEvent& e)
{
// We don't allow mouse wheeling to happen in a ScrollView that has had its scrollbars explicitly disabled.
#if PLATFORM(WX)
if (!canHaveScrollbars()) {
#else
if (!canHaveScrollbars() || platformWidget()) {
#endif
return;
}
// Determine how much we want to scroll. If we can move at all, we will accept the event.
IntSize maxScrollDelta = maximumScrollPosition() - scrollPosition();
if ((e.deltaX() < 0 && maxScrollDelta.width() > 0) ||
(e.deltaX() > 0 && scrollOffset().width() > 0) ||
(e.deltaY() < 0 && maxScrollDelta.height() > 0) ||
(e.deltaY() > 0 && scrollOffset().height() > 0)) {
e.accept();
float deltaX = e.deltaX();
float deltaY = e.deltaY();
if (e.granularity() == ScrollByPageWheelEvent) {
ASSERT(deltaX == 0);
bool negative = deltaY < 0;
deltaY = max(max<int>(visibleHeight() * Scrollbar::minFractionToStepWhenPaging(), visibleHeight() - Scrollbar::maxOverlapBetweenPages()), 1);
if (negative)
deltaY = -deltaY;
}
scrollBy(IntSize(-deltaX, -deltaY));
}
}
void ScrollView::setFrameRect(const IntRect& newRect)
{
IntRect oldRect = frameRect();
if (newRect == oldRect)
return;
Widget::setFrameRect(newRect);
if (platformWidget())
return;
if (newRect.width() != oldRect.width() || newRect.height() != oldRect.height()) {
updateScrollbars(m_scrollOffset);
contentsResized();
}
frameRectsChanged();
}
示例8: handleWheel
ScrollResult RootFrameViewport::handleWheel(const PlatformWheelEvent& event)
{
updateScrollAnimator();
ScrollableArea& primary = !m_invertScrollOrder ? layoutViewport() : visualViewport();
ScrollableArea& secondary = !m_invertScrollOrder ? visualViewport() : layoutViewport();
ScrollResult viewScrollResult = primary.handleWheel(event);
// The visual viewport will only accept pixel scrolls.
if (!event.canScroll() || event.granularity() == ScrollByPageWheelEvent)
return viewScrollResult;
// TODO(sataya.m) : The delta in PlatformWheelEvent is negative when scrolling the
// wheel towards the user, so negate it to get the scroll delta that should be applied
// to the page. unusedScrollDelta computed in the ScrollResult is also negative. Say
// there is WheelEvent({0, -10} and page scroll by 2px and unusedScrollDelta computed
// is {0, -8}. Due to which we have to negate the unusedScrollDelta to obtain the expected
// animation.Please address http://crbug.com/504389.
DoublePoint oldOffset = secondary.scrollPositionDouble();
DoublePoint locationDelta;
if (viewScrollResult.didScroll()) {
locationDelta = -DoublePoint(viewScrollResult.unusedScrollDeltaX, viewScrollResult.unusedScrollDeltaY);
} else {
if (event.railsMode() != PlatformEvent::RailsModeVertical)
locationDelta.setX(-event.deltaX());
if (event.railsMode() != PlatformEvent::RailsModeHorizontal)
locationDelta.setY(-event.deltaY());
}
DoublePoint targetPosition = secondary.clampScrollPosition(
secondary.scrollPositionDouble() + toDoubleSize(locationDelta));
secondary.setScrollPosition(targetPosition, UserScroll);
DoublePoint usedLocationDelta(secondary.scrollPositionDouble() - oldOffset);
bool didScrollX = viewScrollResult.didScrollX || usedLocationDelta.x();
bool didScrollY = viewScrollResult.didScrollY || usedLocationDelta.y();
return ScrollResult(didScrollX, didScrollY, -viewScrollResult.unusedScrollDeltaX - usedLocationDelta.x(), -viewScrollResult.unusedScrollDeltaY - usedLocationDelta.y());
}
示例9: deltaMode
inline static unsigned deltaMode(const PlatformWheelEvent& event)
{
return event.granularity() == ScrollByPageWheelEvent ? WheelEvent::DOM_DELTA_PAGE : WheelEvent::DOM_DELTA_PIXEL;
}
示例10: granularity
inline static WheelEvent::Granularity granularity(const PlatformWheelEvent& event)
{
return event.granularity() == ScrollByPageWheelEvent ? WheelEvent::Page : WheelEvent::Pixel;
}