Changeset 155058 in webkit


Ignore:
Timestamp:
Sep 4, 2013 12:52:25 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

<https://webkit.org/b/119622> [CSSRegions] Not possible to clear the selection when mixing content from different FlowThreads

Patch by Javier Fernandez <jfernandez@igalia.com> on 2013-09-04
Reviewed by David Hyatt.

Source/WebCore:

When using CSS Regions is usual that the RenderTree doesn't match
the DOM Tree in terms of relative position of the nodes. Besides,
usually the content of a certain node is split and spread across
multiple blocks, rendered in different positions.

Regarding the Selection, this problem is even more important; the
selection direction changes when crossing the FlowThread
boundaries. This weird behavior is also present in other layouts
using non-regular positioning mechanisms, like absolute,
static. However, for those layouts the RenderTree preserves the
order of the nodes, unlike the CSS Regions layout model.

Because of how the RenderTree is generated with CSS Regions, the
RenderView::setSelection algorithm is not able to repaint some of
the rectangles defined during the selection process. In order to
face this issue, the proposed fix determines whether it should
backwards traversing the RenderTree, from the "stop" node to the
RenderView node.

Test: fast/regions/selecting-text-through-different-region-flows-2.html

  • rendering/RenderView.cpp:

(WebCore::getNextOrPrevRenderObjectBasedOnDirection): Added.
(WebCore::RenderView::setSelection):

LayoutTests:

  • fast/regions/selecting-text-through-different-region-flows-2-expected.html: Added.
  • fast/regions/selecting-text-through-different-region-flows-2.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r155051 r155058  
     12013-09-04  Javier Fernandez  <jfernandez@igalia.com>
     2
     3        <https://webkit.org/b/119622> [CSSRegions] Not possible to clear the selection when mixing content from different FlowThreads
     4
     5        Reviewed by David Hyatt.
     6
     7        * fast/regions/selecting-text-through-different-region-flows-2-expected.html: Added.
     8        * fast/regions/selecting-text-through-different-region-flows-2.html: Added.
     9
    1102013-09-04  Oliver Hunt  <oliver@apple.com>
    211
  • trunk/Source/WebCore/ChangeLog

    r155057 r155058  
     12013-09-04  Javier Fernandez  <jfernandez@igalia.com>
     2
     3        <https://webkit.org/b/119622> [CSSRegions] Not possible to clear the selection when mixing content from different FlowThreads
     4
     5        Reviewed by David Hyatt.
     6
     7        When using CSS Regions is usual that the RenderTree doesn't match
     8        the DOM Tree in terms of relative position of the nodes. Besides,
     9        usually the content of a certain node is split and spread across
     10        multiple blocks, rendered in different positions.
     11
     12        Regarding the Selection, this problem is even more important; the
     13        selection direction changes when crossing the FlowThread
     14        boundaries. This weird behavior is also present in other layouts
     15        using non-regular positioning mechanisms, like absolute,
     16        static. However, for those layouts the RenderTree preserves the
     17        order of the nodes, unlike the CSS Regions layout model.
     18
     19        Because of how the RenderTree is generated with CSS Regions, the
     20        RenderView::setSelection algorithm is not able to repaint some of
     21        the rectangles defined during the selection process. In order to
     22        face this issue, the proposed fix determines whether it should
     23        backwards traversing the RenderTree, from the "stop" node to the
     24        RenderView node.
     25
     26        Test: fast/regions/selecting-text-through-different-region-flows-2.html
     27
     28        * rendering/RenderView.cpp:
     29        (WebCore::getNextOrPrevRenderObjectBasedOnDirection): Added.
     30        (WebCore::RenderView::setSelection):
     31
    1322013-09-04  Eric Carlson  <eric.carlson@apple.com>
    233
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r154877 r155058  
    737737#endif
    738738
     739// When exploring the RenderTree looking for the nodes involved in the Selection, sometimes it's
     740// required to change the traversing direction because the "start" position is below the "end" one.
     741static inline RenderObject* getNextOrPrevRenderObjectBasedOnDirection(const RenderObject* o, const RenderObject* stop, bool& continueExploring, bool& exploringBackwards)
     742{
     743    RenderObject* next;
     744    if (exploringBackwards) {
     745        next = o->previousInPreOrder();
     746        continueExploring = next && !(next)->isRenderView();
     747    } else {
     748        next = o->nextInPreOrder();
     749        continueExploring = next && next != stop;
     750        exploringBackwards = !next && (next != stop);
     751        if (exploringBackwards) {
     752            next = stop->previousInPreOrder();
     753            continueExploring = next && !next->isRenderView();
     754        }
     755    }
     756
     757    return next;
     758}
     759
    739760void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* end, int endPos, SelectionRepaintMode blockRepaintMode)
    740761{
     
    749770    if (m_selectionStart == start && m_selectionStartPos == startPos &&
    750771        m_selectionEnd == end && m_selectionEndPos == endPos && !caretChanged)
    751         return;
    752 
    753     if ((start && end) && (start->flowThreadContainingBlock() != end->flowThreadContainingBlock()))
    754772        return;
    755773
     
    773791    RenderObject* os = m_selectionStart;
    774792    RenderObject* stop = rendererAfterPosition(m_selectionEnd, m_selectionEndPos);
    775     while (os && os != stop) {
     793    bool exploringBackwards = false;
     794    bool continueExploring = os && (os != stop);
     795    while (continueExploring) {
    776796        if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selectionEnd) && os->selectionState() != SelectionNone) {
    777797            // Blocks are responsible for painting line gaps and margin gaps.  They must be examined as well.
     
    789809        }
    790810
    791         os = os->nextInPreOrder();
     811        os = getNextOrPrevRenderObjectBasedOnDirection(os, stop, continueExploring, exploringBackwards);
    792812    }
    793813
     
    828848    // put them in the new objects list.
    829849    o = start;
    830     while (o && o != stop) {
     850    exploringBackwards = false;
     851    continueExploring = o && (o != stop);
     852    while (continueExploring) {
    831853        if ((o->canBeSelectionLeaf() || o == start || o == end) && o->selectionState() != SelectionNone) {
    832854            newSelectedObjects.set(o, adoptPtr(new RenderSelectionInfo(o, true)));
     
    841863        }
    842864
    843         o = o->nextInPreOrder();
     865        o = getNextOrPrevRenderObjectBasedOnDirection(o, stop, continueExploring, exploringBackwards);
    844866    }
    845867
Note: See TracChangeset for help on using the changeset viewer.