Changeset 214174 in webkit


Ignore:
Timestamp:
Mar 20, 2017 10:32:48 AM (7 years ago)
Author:
Wenson Hsieh
Message:

TextIndicator should support a mode where selection rects are used to size the snapshot
https://bugs.webkit.org/show_bug.cgi?id=169845
<rdar://problem/31127818>

Reviewed by Beth Dakin.

Source/WebCore:

Adds TextIndicator support in iOS for using the would-be selection rects of a given range to determine
snapshotting bounds. See below changes for more details.

  • dom/Range.cpp:

(WebCore::Range::collectSelectionRectsWithoutUnionInteriorLines):
(WebCore::Range::collectSelectionRects):

Mark these helper methods as const.

  • dom/Range.h:
  • page/TextIndicator.cpp:

(WebCore::getSelectionRectsForRange):
(WebCore::initializeIndicator):

If TextIndicatorOptionUseSelectionRectForSizing is enabled, then compute selection rects and set the text rects
to be the resulting selection rects. These are in document coordinates.

  • page/TextIndicator.h:

Source/WebKit2:

Adopt the new TextIndicatorOptionUseSelectionRectForSizing flag when generating an edit data interaction snapshot.

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::didConcludeEditDataInteraction):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r214173 r214174  
     12017-03-20  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        TextIndicator should support a mode where selection rects are used to size the snapshot
     4        https://bugs.webkit.org/show_bug.cgi?id=169845
     5        <rdar://problem/31127818>
     6
     7        Reviewed by Beth Dakin.
     8
     9        Adds TextIndicator support in iOS for using the would-be selection rects of a given range to determine
     10        snapshotting bounds. See below changes for more details.
     11
     12        * dom/Range.cpp:
     13        (WebCore::Range::collectSelectionRectsWithoutUnionInteriorLines):
     14        (WebCore::Range::collectSelectionRects):
     15
     16        Mark these helper methods as const.
     17
     18        * dom/Range.h:
     19        * page/TextIndicator.cpp:
     20        (WebCore::getSelectionRectsForRange):
     21        (WebCore::initializeIndicator):
     22
     23        If TextIndicatorOptionUseSelectionRectForSizing is enabled, then compute selection rects and set the text rects
     24        to be the resulting selection rects. These are in document coordinates.
     25
     26        * page/TextIndicator.h:
     27
    1282017-03-20  Simon Fraser  <simon.fraser@apple.com>
    229
  • trunk/Source/WebCore/dom/Range.cpp

    r213355 r214174  
    12671267// This function is similar in spirit to addLineBoxRects, but annotates the returned rectangles
    12681268// with additional state which helps iOS draw selections in its unique way.
    1269 int Range::collectSelectionRectsWithoutUnionInteriorLines(Vector<SelectionRect>& rects)
     1269int Range::collectSelectionRectsWithoutUnionInteriorLines(Vector<SelectionRect>& rects) const
    12701270{
    12711271    auto& startContainer = this->startContainer();
     
    14271427}
    14281428
    1429 void Range::collectSelectionRects(Vector<SelectionRect>& rects)
     1429void Range::collectSelectionRects(Vector<SelectionRect>& rects) const
    14301430{
    14311431    int maxLineNumber = collectSelectionRectsWithoutUnionInteriorLines(rects);
  • trunk/Source/WebCore/dom/Range.h

    r211356 r214174  
    125125    WEBCORE_EXPORT FloatRect absoluteBoundingRect() const;
    126126#if PLATFORM(IOS)
    127     WEBCORE_EXPORT void collectSelectionRects(Vector<SelectionRect>&);
    128     WEBCORE_EXPORT int collectSelectionRectsWithoutUnionInteriorLines(Vector<SelectionRect>&);
     127    WEBCORE_EXPORT void collectSelectionRects(Vector<SelectionRect>&) const;
     128    WEBCORE_EXPORT int collectSelectionRectsWithoutUnionInteriorLines(Vector<SelectionRect>&) const;
    129129#endif
    130130
  • trunk/Source/WebCore/page/TextIndicator.cpp

    r214111 r214174  
    4242#include "RenderObject.h"
    4343
     44#if PLATFORM(IOS)
     45#include "SelectionRect.h"
     46#endif
     47
    4448using namespace WebCore;
    4549
     
    184188}
    185189
     190#if PLATFORM(IOS)
     191
     192static void getSelectionRectsForRange(Vector<FloatRect>& resultingRects, const Range& range)
     193{
     194    Vector<SelectionRect> selectionRectsForRange;
     195    Vector<FloatRect> selectionRectsForRangeInBoundingRectCoordinates;
     196    range.collectSelectionRects(selectionRectsForRange);
     197    for (auto selectionRect : selectionRectsForRange)
     198        resultingRects.append(selectionRect.rect());
     199}
     200
     201#endif
     202
    186203static bool initializeIndicator(TextIndicatorData& data, Frame& frame, const Range& range, FloatSize margin, bool indicatesCurrentSelection)
    187204{
     
    198215    if ((data.options & TextIndicatorOptionUseBoundingRectAndPaintAllContentForComplexRanges) && hasNonInlineOrReplacedElements(range))
    199216        data.options |= TextIndicatorOptionPaintAllContent;
     217#if PLATFORM(IOS)
     218    else if (data.options & TextIndicatorOptionUseSelectionRectForSizing)
     219        getSelectionRectsForRange(textRects, range);
     220#endif
    200221    else {
    201222        if (data.options & TextIndicatorOptionDoNotClipToVisibleRect)
  • trunk/Source/WebCore/page/TextIndicator.h

    r213614 r214174  
    8484    // Include an additional snapshot of everything in view, with the exception of nodes within the currently selected range.
    8585    TextIndicatorOptionIncludeSnapshotOfAllVisibleContentWithoutSelection = 1 << 8,
     86
     87    // By default, TextIndicator uses text rects to size the snapshot. Enabling this flag causes it to use the bounds of the
     88    // selection rects that would enclose the given Range instead.
     89    // Currently, this is only supported on iOS.
     90    TextIndicatorOptionUseSelectionRectForSizing = 1 << 9,
    8691};
    8792typedef uint16_t TextIndicatorOptions;
  • trunk/Source/WebKit2/ChangeLog

    r214163 r214174  
     12017-03-20  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        TextIndicator should support a mode where selection rects are used to size the snapshot
     4        https://bugs.webkit.org/show_bug.cgi?id=169845
     5        <rdar://problem/31127818>
     6
     7        Reviewed by Beth Dakin.
     8
     9        Adopt the new TextIndicatorOptionUseSelectionRectForSizing flag when generating an edit data interaction snapshot.
     10
     11        * WebProcess/WebPage/ios/WebPageIOS.mm:
     12        (WebKit::WebPage::didConcludeEditDataInteraction):
     13
    1142017-03-20  Carlos Garcia Campos  <cgarcia@igalia.com>
    215
  • trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

    r214003 r214174  
    632632    std::optional<TextIndicatorData> textIndicatorData;
    633633
    634     static auto defaultEditDragTextIndicatorOptions = TextIndicatorOptionIncludeSnapshotOfAllVisibleContentWithoutSelection | TextIndicatorOptionDoNotClipToVisibleRect | TextIndicatorOptionPaintAllContent | TextIndicatorOptionIncludeMarginIfRangeMatchesSelection | TextIndicatorOptionPaintBackgrounds | TextIndicatorOptionIncludeSnapshotWithSelectionHighlight;
     634    static auto defaultEditDragTextIndicatorOptions = TextIndicatorOptionIncludeSnapshotOfAllVisibleContentWithoutSelection | TextIndicatorOptionDoNotClipToVisibleRect | TextIndicatorOptionPaintAllContent | TextIndicatorOptionIncludeMarginIfRangeMatchesSelection | TextIndicatorOptionPaintBackgrounds | TextIndicatorOptionUseSelectionRectForSizing | TextIndicatorOptionIncludeSnapshotWithSelectionHighlight;
    635635    auto& frame = m_page->focusController().focusedOrMainFrame();
    636636    if (auto range = frame.selection().selection().toNormalizedRange()) {
Note: See TracChangeset for help on using the changeset viewer.