⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 243735 in webkit


Ignore:
Timestamp:
Apr 1, 2019, 8:16:48 PM (7 years ago)
Author:
Simon Fraser
Message:

Remove some unused iOS scrolling-related code in Frame
https://bugs.webkit.org/show_bug.cgi?id=196473

Reviewed by Zalan Bujtas.

This code has no callers.

  • page/Frame.cpp:

(WebCore::Frame::Frame):
(WebCore::Frame::scrollOverflowLayer): Deleted.
(WebCore::Frame::overflowAutoScrollTimerFired): Deleted.
(WebCore::Frame::startOverflowAutoScroll): Deleted.
(WebCore::Frame::checkOverflowScroll): Deleted.

  • page/Frame.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243734 r243735  
     12019-04-01  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Remove some unused iOS scrolling-related code in Frame
     4        https://bugs.webkit.org/show_bug.cgi?id=196473
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        This code has no callers.
     9
     10        * page/Frame.cpp:
     11        (WebCore::Frame::Frame):
     12        (WebCore::Frame::scrollOverflowLayer): Deleted.
     13        (WebCore::Frame::overflowAutoScrollTimerFired): Deleted.
     14        (WebCore::Frame::startOverflowAutoScroll): Deleted.
     15        (WebCore::Frame::checkOverflowScroll): Deleted.
     16        * page/Frame.h:
     17
    1182019-04-01  Chris Dumez  <cdumez@apple.com>
    219
  • trunk/Source/WebCore/page/Frame.cpp

    r243324 r243735  
    153153    , m_selection(makeUniqueRef<FrameSelection>(this))
    154154    , m_animationController(makeUniqueRef<CSSAnimationController>(*this))
    155 #if PLATFORM(IOS_FAMILY)
    156     , m_overflowAutoScrollTimer(*this, &Frame::overflowAutoScrollTimerFired)
    157     , m_selectionChangeCallbacksDisabled(false)
    158 #endif
    159155    , m_pageZoomFactor(parentPageZoomFactor(this))
    160156    , m_textZoomFactor(parentTextZoomFactor(this))
    161     , m_activeDOMObjectsAndAnimationsSuspendedCount(0)
    162157    , m_eventHandler(makeUniqueRef<EventHandler>(*this))
    163158{
     
    501496
    502497#if PLATFORM(IOS_FAMILY)
    503 void Frame::scrollOverflowLayer(RenderLayer* layer, const IntRect& visibleRect, const IntRect& exposeRect)
    504 {
    505     if (!layer)
    506         return;
    507 
    508     RenderBox* box = layer->renderBox();
    509     if (!box)
    510         return;
    511 
    512     if (visibleRect.intersects(exposeRect))
    513         return;
    514 
    515     // FIXME: Why isn't this just calling RenderLayer::scrollRectToVisible()?
    516     ScrollOffset scrollOffset = layer->scrollOffset();
    517     int exposeLeft = exposeRect.x();
    518     int exposeRight = exposeLeft + exposeRect.width();
    519     int clientWidth = roundToInt(box->clientWidth());
    520     if (exposeLeft <= 0)
    521         scrollOffset.setX(std::max(0, scrollOffset.x() + exposeLeft - clientWidth / 2));
    522     else if (exposeRight >= clientWidth)
    523         scrollOffset.setX(std::min(box->scrollWidth() - clientWidth, scrollOffset.x() + clientWidth / 2));
    524 
    525     int exposeTop = exposeRect.y();
    526     int exposeBottom = exposeTop + exposeRect.height();
    527     int clientHeight = roundToInt(box->clientHeight());
    528     if (exposeTop <= 0)
    529         scrollOffset.setY(std::max(0, scrollOffset.y() + exposeTop - clientHeight / 2));
    530     else if (exposeBottom >= clientHeight)
    531         scrollOffset.setY(std::min(box->scrollHeight() - clientHeight, scrollOffset.y() + clientHeight / 2));
    532 
    533     layer->scrollToOffset(scrollOffset, ScrollClamping::Unclamped);
    534     selection().setCaretRectNeedsUpdate();
    535     selection().updateAppearance();
    536 }
    537 
    538 void Frame::overflowAutoScrollTimerFired()
    539 {
    540     if (!eventHandler().mousePressed() || checkOverflowScroll(PerformOverflowScroll) == OverflowScrollNone) {
    541         if (m_overflowAutoScrollTimer.isActive())
    542             m_overflowAutoScrollTimer.stop();
    543     }
    544 }
    545 
    546 void Frame::startOverflowAutoScroll(const IntPoint& mousePosition)
    547 {
    548     m_overflowAutoScrollPos = mousePosition;
    549 
    550     if (m_overflowAutoScrollTimer.isActive())
    551         return;
    552 
    553     if (checkOverflowScroll(DoNotPerformOverflowScroll) == OverflowScrollNone)
    554         return;
    555 
    556     m_overflowAutoScrollTimer.startRepeating(scrollFrequency);
    557     m_overflowAutoScrollDelta = 3;
    558 }
    559 
    560 int Frame::checkOverflowScroll(OverflowScrollAction action)
    561 {
    562     Position extent = selection().selection().extent();
    563     if (extent.isNull())
    564         return OverflowScrollNone;
    565 
    566     RenderObject* renderer = extent.deprecatedNode()->renderer();
    567     if (!renderer)
    568         return OverflowScrollNone;
    569 
    570     FrameView* view = this->view();
    571     if (!view)
    572         return OverflowScrollNone;
    573 
    574     RenderBlock* containingBlock = renderer->containingBlock();
    575     if (!containingBlock || !containingBlock->hasOverflowClip())
    576         return OverflowScrollNone;
    577     RenderLayer* layer = containingBlock->layer();
    578     ASSERT(layer);
    579 
    580     IntRect visibleRect = IntRect(view->scrollX(), view->scrollY(), view->visibleWidth(), view->visibleHeight());
    581     IntPoint position = m_overflowAutoScrollPos;
    582     if (visibleRect.contains(position.x(), position.y()))
    583         return OverflowScrollNone;
    584 
    585     int scrollType = 0;
    586     int deltaX = 0;
    587     int deltaY = 0;
    588     IntPoint selectionPosition;
    589 
    590     // This constant will make the selection draw a little bit beyond the edge of the visible area.
    591     // This prevents a visual glitch, in that you can fail to select a portion of a character that
    592     // is being rendered right at the edge of the visible rectangle.
    593     // FIXME: This probably needs improvement, and may need to take the font size into account.
    594     static const int scrollBoundsAdjustment = 3;
    595 
    596     // FIXME: Make a small buffer at the end of a visible rectangle so that autoscrolling works
    597     // even if the visible extends to the limits of the screen.
    598     if (position.x() < visibleRect.x()) {
    599         scrollType |= OverflowScrollLeft;
    600         if (action == PerformOverflowScroll) {
    601             deltaX -= static_cast<int>(m_overflowAutoScrollDelta);
    602             selectionPosition.setX(view->scrollX() - scrollBoundsAdjustment);
    603         }
    604     } else if (position.x() > visibleRect.maxX()) {
    605         scrollType |= OverflowScrollRight;
    606         if (action == PerformOverflowScroll) {
    607             deltaX += static_cast<int>(m_overflowAutoScrollDelta);
    608             selectionPosition.setX(view->scrollX() + view->visibleWidth() + scrollBoundsAdjustment);
    609         }
    610     }
    611 
    612     if (position.y() < visibleRect.y()) {
    613         scrollType |= OverflowScrollUp;
    614         if (action == PerformOverflowScroll) {
    615             deltaY -= static_cast<int>(m_overflowAutoScrollDelta);
    616             selectionPosition.setY(view->scrollY() - scrollBoundsAdjustment);
    617         }
    618     } else if (position.y() > visibleRect.maxY()) {
    619         scrollType |= OverflowScrollDown;
    620         if (action == PerformOverflowScroll) {
    621             deltaY += static_cast<int>(m_overflowAutoScrollDelta);
    622             selectionPosition.setY(view->scrollY() + view->visibleHeight() + scrollBoundsAdjustment);
    623         }
    624     }
    625 
    626     Ref<Frame> protectedThis(*this);
    627 
    628     if (action == PerformOverflowScroll && (deltaX || deltaY)) {
    629         layer->scrollToOffset(layer->scrollOffset() + IntSize(deltaX, deltaY), ScrollClamping::Unclamped);
    630 
    631         // Handle making selection.
    632         VisiblePosition visiblePosition(renderer->positionForPoint(selectionPosition, nullptr));
    633         if (visiblePosition.isNotNull()) {
    634             VisibleSelection visibleSelection = selection().selection();
    635             visibleSelection.setExtent(visiblePosition);
    636             if (selection().granularity() != CharacterGranularity)
    637                 visibleSelection.expandUsingGranularity(selection().granularity());
    638             if (selection().shouldChangeSelection(visibleSelection))
    639                 selection().setSelection(visibleSelection);
    640         }
    641 
    642         m_overflowAutoScrollDelta *= 1.02f; // Accelerate the scroll
    643     }
    644     return scrollType;
    645 }
    646498
    647499void Frame::setSelectionChangeCallbacksDisabled(bool selectionChangeCallbacksDisabled)
  • trunk/Source/WebCore/page/Frame.h

    r243674 r243735  
    259259
    260260#if PLATFORM(IOS_FAMILY)
    261     // Scroll the selection in an overflow layer.
    262     void scrollOverflowLayer(RenderLayer*, const IntRect& visibleRect, const IntRect& exposeRect);
    263 
    264261    WEBCORE_EXPORT int preferredHeight() const;
    265262    WEBCORE_EXPORT void updateLayout() const;
     
    334331    Node* qualifyingNodeAtViewportLocation(const FloatPoint& viewportLocation, FloatPoint& adjustedViewportLocation, const NodeQualifier&, bool shouldApproximate);
    335332
    336     void overflowAutoScrollTimerFired();
    337     void startOverflowAutoScroll(const IntPoint&);
    338     int checkOverflowScroll(OverflowScrollAction);
    339 
    340333    void setTimersPausedInternal(bool);
    341334
    342     Timer m_overflowAutoScrollTimer;
    343     float m_overflowAutoScrollDelta;
    344     IntPoint m_overflowAutoScrollPos;
    345335    ViewportArguments m_viewportArguments;
    346     bool m_selectionChangeCallbacksDisabled;
     336    bool m_selectionChangeCallbacksDisabled { false };
    347337    VisibleSelection m_rangedSelectionBase;
    348338    VisibleSelection m_rangedSelectionInitialExtent;
     
    352342    float m_textZoomFactor;
    353343
    354     int m_activeDOMObjectsAndAnimationsSuspendedCount;
     344    int m_activeDOMObjectsAndAnimationsSuspendedCount { 0 };
    355345    bool m_documentIsBeingReplaced { false };
    356346    unsigned m_navigationDisableCount { 0 };
Note: See TracChangeset for help on using the changeset viewer.