Changeset 77075 in webkit


Ignore:
Timestamp:
Jan 29, 2011 4:22:49 PM (13 years ago)
Author:
mjs@apple.com
Message:

2011-01-29 Maciej Stachowiak <mjs@apple.com>

Reviewed by Dan Bernstein.

Fix fat build for both 32-bit and 64-bit under llvm-gcc 4.2
https://bugs.webkit.org/show_bug.cgi?id=53386

  • platform/mac/ScrollAnimatorMac.mm: (WebCore::elasticDeltaForReboundDelta): (WebCore::scrollWheelMultiplier): (WebCore::ScrollAnimatorMac::smoothScrollWithEvent): (WebCore::ScrollAnimatorMac::beginScrollGesture): (WebCore::roundTowardZero): (WebCore::ScrollAnimatorMac::snapRubberBandTimerFired):
Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r77073 r77075  
     12011-01-29  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Fix fat build for both 32-bit and 64-bit under llvm-gcc 4.2
     6        https://bugs.webkit.org/show_bug.cgi?id=53386
     7
     8        * platform/mac/ScrollAnimatorMac.mm:
     9        (WebCore::elasticDeltaForReboundDelta):
     10        (WebCore::scrollWheelMultiplier):
     11        (WebCore::ScrollAnimatorMac::smoothScrollWithEvent):
     12        (WebCore::ScrollAnimatorMac::beginScrollGesture):
     13        (WebCore::roundTowardZero):
     14        (WebCore::ScrollAnimatorMac::snapRubberBandTimerFired):
     15
    1162011-01-29  Daniel Bates  <dbates@rim.com>
    217
  • trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm

    r77071 r77075  
    214214
    215215static const float scrollVelocityZeroingTimeout = 0.10f;
    216 static const float rubberbandStiffness = 20.0f;
    217 static const float rubberbandDirectionLockStretchRatio = 1.0f;
    218 static const float rubberbandMinimumRequiredDeltaBeforeStretch = 10.0f;
     216static const float rubberbandStiffness = 20;
     217static const float rubberbandDirectionLockStretchRatio = 1;
     218static const float rubberbandMinimumRequiredDeltaBeforeStretch = 10;
    219219static const float rubberbandAmplitude = 0.31f;
    220220static const float rubberbandPeriod = 1.6f;
     
    231231static float elasticDeltaForReboundDelta(float delta)
    232232{
    233     float stiffness = std::max(rubberbandStiffness, 1.0);
     233    float stiffness = std::max(rubberbandStiffness, 1.0f);
    234234    return delta / stiffness;
    235235}
     
    242242static float scrollWheelMultiplier()
    243243{
    244     static float multiplier = -1.0;
     244    static float multiplier = -1;
    245245    if (multiplier < 0) {
    246246        multiplier = [[NSUserDefaults standardUserDefaults] floatForKey:@"NSScrollWheelMultiplier"];
     
    340340    // Slightly prefer scrolling vertically by applying the = case to deltaY
    341341    if (fabsf(deltaY) >= fabsf(deltaX))
    342         deltaX = 0.0;
     342        deltaX = 0;
    343343    else
    344         deltaY = 0.0;
     344        deltaY = 0;
    345345   
    346346    bool isVerticallyStretched = false;
     
    350350    IntSize stretchAmount = m_scrollableArea->overhangAmount();
    351351
    352     isHorizontallyStretched = (stretchAmount.width() == 0.0) ? false : true;
    353     isVerticallyStretched = (stretchAmount.height() == 0.0) ? false : true;
     352    isHorizontallyStretched = stretchAmount.width();
     353    isVerticallyStretched = stretchAmount.height();
    354354
    355355    PlatformWheelEventPhase phase = wheelEvent.phase();
     
    361361    CFTimeInterval timeDelta = wheelEvent.timestamp() - m_lastMomemtumScrollTimestamp;
    362362    if (m_inScrollGesture || m_momentumScrollInProgress) {
    363         if (m_lastMomemtumScrollTimestamp && timeDelta > 0.0 && timeDelta < scrollVelocityZeroingTimeout) {
    364             m_momentumVelocity.setWidth(eventCoallescedDeltaX / timeDelta);
    365             m_momentumVelocity.setHeight(eventCoallescedDeltaY / timeDelta);
     363        if (m_lastMomemtumScrollTimestamp && timeDelta > 0 && timeDelta < scrollVelocityZeroingTimeout) {
     364            m_momentumVelocity.setWidth(eventCoallescedDeltaX / (float)timeDelta);
     365            m_momentumVelocity.setHeight(eventCoallescedDeltaY / (float)timeDelta);
    366366            m_lastMomemtumScrollTimestamp = wheelEvent.timestamp();
    367367        } else {
     
    373373            if (!isHorizontallyStretched && pinnedInDirection(deltaX, 0)) {               
    374374                // Stretching only in the vertical.
    375                 if (deltaY != 0.0 && (fabsf(deltaX / deltaY) < rubberbandDirectionLockStretchRatio))
    376                     deltaX = 0.0;
     375                if (deltaY != 0 && (fabsf(deltaX / deltaY) < rubberbandDirectionLockStretchRatio))
     376                    deltaX = 0;
    377377                else if (fabsf(deltaX) < rubberbandMinimumRequiredDeltaBeforeStretch) {
    378378                    m_overflowScrollDelta.setWidth(m_overflowScrollDelta.width() + deltaX);
    379                     deltaX = 0.0;
     379                    deltaX = 0;
    380380                } else
    381381                    m_overflowScrollDelta.setWidth(m_overflowScrollDelta.width() + deltaX);
     
    384384            // Stretching only in the horizontal.
    385385            if (pinnedInDirection(0, deltaY)) {
    386                 if (deltaX != 0.0 && (fabsf(deltaY / deltaX) < rubberbandDirectionLockStretchRatio))
    387                     deltaY = 0.0;
     386                if (deltaX != 0 && (fabsf(deltaY / deltaX) < rubberbandDirectionLockStretchRatio))
     387                    deltaY = 0;
    388388                else if (fabsf(deltaY) < rubberbandMinimumRequiredDeltaBeforeStretch) {
    389389                    m_overflowScrollDelta.setHeight(m_overflowScrollDelta.height() + deltaY);
    390                     deltaY = 0.0;
     390                    deltaY = 0;
    391391                } else
    392392                    m_overflowScrollDelta.setHeight(m_overflowScrollDelta.height() + deltaY);
     
    398398                    if (fabsf(deltaX) < rubberbandMinimumRequiredDeltaBeforeStretch) {
    399399                        m_overflowScrollDelta.setWidth(m_overflowScrollDelta.width() + deltaX);
    400                         deltaX = 0.0;
     400                        deltaX = 0;
    401401                    } else
    402402                        m_overflowScrollDelta.setWidth(m_overflowScrollDelta.width() + deltaX);
     
    407407    }
    408408
    409     if (deltaX != 0.0 || deltaY != 0.0) {
     409    if (deltaX != 0 || deltaY != 0) {
    410410        if (!(shouldStretch || isVerticallyStretched || isHorizontallyStretched)) {
    411411            if (deltaY != 0) {
     
    419419        } else {
    420420            if (!allowsHorizontalStretching()) {
    421                 deltaX = 0.0;
    422                 eventCoallescedDeltaX = 0.0;
     421                deltaX = 0;
     422                eventCoallescedDeltaX = 0;
    423423            } else if ((deltaX != 0) && !isHorizontallyStretched && !pinnedInDirection(deltaX, 0)) {
    424424                deltaX *= scrollWheelMultiplier();
     
    428428                m_scrollableArea->setConstrainsScrollingToContentEdge(true);
    429429
    430                 deltaX = 0.0;
     430                deltaX = 0;
    431431            }
    432432           
    433433            if (!allowsVerticalStretching()) {
    434                 deltaY = 0.0;
    435                 eventCoallescedDeltaY = 0.0;
     434                deltaY = 0;
     435                eventCoallescedDeltaY = 0;
    436436            } else if ((deltaY != 0) && !isVerticallyStretched && !pinnedInDirection(0, deltaY)) {
    437437                deltaY *= scrollWheelMultiplier();
     
    441441                m_scrollableArea->setConstrainsScrollingToContentEdge(true);
    442442
    443                 deltaY = 0.0;
     443                deltaY = 0;
    444444            }
    445445           
     
    472472        m_momentumScrollInProgress = false;
    473473        m_ignoreMomentumScrolls = false;
    474         m_lastMomemtumScrollTimestamp = 0.0;
     474        m_lastMomemtumScrollTimestamp = 0;
    475475    }
    476476}
     
    481481    m_momentumScrollInProgress = false;
    482482    m_ignoreMomentumScrolls = false;
    483     m_lastMomemtumScrollTimestamp = 0.0;
     483    m_lastMomemtumScrollTimestamp = 0;
    484484    m_momentumVelocity = FloatSize();
    485485
     
    520520static inline float roundTowardZero(float num)
    521521{
    522     return num > 0.0 ? ceilf(num - 0.5) : floorf(num + 0.5);
     522    return num > 0 ? ceilf(num - 0.5f) : floorf(num + 0.5f);
    523523}
    524524
     
    568568        }
    569569
    570         FloatPoint delta(roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_startStretch.width(), -m_origVelocity.width(), timeDelta)),
    571                          roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_startStretch.height(), -m_origVelocity.height(), timeDelta)));
    572 
    573         if (fabs(delta.x()) >= 1.0 || fabs(delta.y()) >= 1.0) {
     570        FloatPoint delta(roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_startStretch.width(), -m_origVelocity.width(), (float)timeDelta)),
     571                         roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_startStretch.height(), -m_origVelocity.height(), (float)timeDelta)));
     572
     573        if (fabs(delta.x()) >= 1 || fabs(delta.y()) >= 1) {
    574574            FloatPoint newOrigin = m_origOrigin + delta;
    575575
Note: See TracChangeset for help on using the changeset viewer.