Changeset 200972 in webkit


Ignore:
Timestamp:
May 16, 2016, 3:20:16 PM (9 years ago)
Author:
enrica@apple.com
Message:

Text selection is basically impossible on plain text pages.
https://bugs.webkit.org/show_bug.cgi?id=157681
rdar://problem/26065660

Reviewed by Darin Adler.

When dealing with a plain text file, the rules for deciding whether
a position is selectable should be different and we should never
switch to block selection.

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::shouldSwitchToBlockModeForHandle):
(WebKit::rectIsTooBigForSelection): Added helper function.
(WebKit::WebPage::selectTextWithGranularityAtPoint):
(WebKit::WebPage::getPositionInformation):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r200966 r200972  
     12016-05-13  Enrica Casucci  <enrica@apple.com>
     2
     3        Text selection is basically impossible on plain text pages.
     4        https://bugs.webkit.org/show_bug.cgi?id=157681
     5        rdar://problem/26065660
     6
     7        Reviewed by Darin Adler.
     8
     9        When dealing with a plain text file, the rules for deciding whether
     10        a position is selectable should be different and we should never
     11        switch to block selection.
     12
     13        * WebProcess/WebPage/ios/WebPageIOS.mm:
     14        (WebKit::WebPage::shouldSwitchToBlockModeForHandle):
     15        (WebKit::rectIsTooBigForSelection): Added helper function.
     16        (WebKit::WebPage::selectTextWithGranularityAtPoint):
     17        (WebKit::WebPage::getPositionInformation):
     18
    1192016-05-16  Chelsea Pugh  <cpugh@apple.com>
    220
  • trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

    r200858 r200972  
    16591659bool WebPage::shouldSwitchToBlockModeForHandle(const IntPoint& handlePoint, SelectionHandlePosition handlePosition)
    16601660{
     1661    if (!m_blockRectForTextSelection.height())
     1662        return false;
    16611663    switch (handlePosition) {
    16621664    case SelectionHandlePosition::Top:
     
    18601862}
    18611863
     1864static inline bool rectIsTooBigForSelection(const IntRect& blockRect, const Frame& frame)
     1865{
     1866    const float factor = 0.97;
     1867    return blockRect.height() > frame.view()->unobscuredContentRect().height() * factor;
     1868}
     1869
    18621870void WebPage::selectTextWithGranularityAtPoint(const WebCore::IntPoint& point, uint32_t granularity, bool isInteractingWithAssistedNode, uint64_t callbackID)
    18631871{
     
    18681876        m_blockSelectionDesiredSize.setHeight(blockSelectionStartHeight);
    18691877        m_currentBlockSelection = nullptr;
    1870         RefPtr<Range> paragraphRange = enclosingTextUnitOfGranularity(visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithAssistedNode), ParagraphGranularity, DirectionForward);
    1871         if (paragraphRange && !paragraphRange->collapsed())
    1872             m_blockRectForTextSelection = selectionBoxForRange(paragraphRange.get());
     1878        auto* renderer = range->startContainer().renderer();
     1879        if (renderer->style().preserveNewline())
     1880            m_blockRectForTextSelection = renderer->absoluteBoundingBoxRect(true);
     1881        else {
     1882            auto* paragraphRange = enclosingTextUnitOfGranularity(visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithAssistedNode), ParagraphGranularity, DirectionForward).get();
     1883            if (paragraphRange && !paragraphRange->collapsed())
     1884                m_blockRectForTextSelection = selectionBoxForRange(paragraphRange);
     1885        }
     1886       
     1887        if (rectIsTooBigForSelection(m_blockRectForTextSelection, frame))
     1888            m_blockRectForTextSelection.setHeight(0);
    18731889    }
    18741890
     
    23892405                    info.url = downcast<HTMLAttachmentElement>(*hitNode).file()->path();
    23902406            } else {
    2391                 const static CGFloat factor = 0.97;
    2392                 info.isSelectable = renderer->style().userSelect() != SELECT_NONE && info.bounds.height() < result.innerNodeFrame()->view()->unobscuredContentRect().height() * factor;
     2407                info.isSelectable = renderer->style().userSelect() != SELECT_NONE;
     2408                if (info.isSelectable && !hitNode->isTextNode())
     2409                    info.isSelectable = !rectIsTooBigForSelection(info.bounds, *result.innerNodeFrame());
    23932410            }
    23942411        }
Note: See TracChangeset for help on using the changeset viewer.