Changeset 145195 in webkit


Ignore:
Timestamp:
Mar 8, 2013 1:58:28 AM (11 years ago)
Author:
sergio@webkit.org
Message:

Improve drag&drop of list items in contentEditable divs
https://bugs.webkit.org/show_bug.cgi?id=111556

Reviewed by Ryosuke Niwa.

Source/WebCore:

A single fully selected <li> should generate the same markup as if
we were selecting some of them, i.e., we should preserve the list
structure and appearance.

Test: editing/selection/drag-list-item.html

  • editing/htmlediting.cpp:

(WebCore::isListItem): modified constness.

  • editing/htmlediting.h:

(WebCore): ditto.

  • editing/markup.cpp:

(WebCore::highestAncestorToWrapMarkup):

LayoutTests:

Added a new test case. The test performs 2 drag&drops, first of
all a selection of a single list item, and secondly a selection of
two list items. It checks that both behave the same way, i.e, the
whole <li> is moved and not only the text.

  • editing/selection/drag-list-item-expected.txt: Added.
  • editing/selection/drag-list-item.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r145192 r145195  
     12013-03-08  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        Improve drag&drop of list items in contentEditable divs
     4        https://bugs.webkit.org/show_bug.cgi?id=111556
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Added a new test case. The test performs 2 drag&drops, first of
     9        all a selection of a single list item, and secondly a selection of
     10        two list items. It checks that both behave the same way, i.e, the
     11        whole <li> is moved and not only the text.
     12
     13        * editing/selection/drag-list-item-expected.txt: Added.
     14        * editing/selection/drag-list-item.html: Added.
     15
    1162013-03-08  Zoltan Arvai  <zarvai@inf.u-szeged.hu>
    217
  • trunk/Source/WebCore/ChangeLog

    r145193 r145195  
     12013-03-08  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        Improve drag&drop of list items in contentEditable divs
     4        https://bugs.webkit.org/show_bug.cgi?id=111556
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        A single fully selected <li> should generate the same markup as if
     9        we were selecting some of them, i.e., we should preserve the list
     10        structure and appearance.
     11
     12        Test: editing/selection/drag-list-item.html
     13
     14        * editing/htmlediting.cpp:
     15        (WebCore::isListItem): modified constness.
     16        * editing/htmlediting.h:
     17        (WebCore): ditto.
     18        * editing/markup.cpp:
     19        (WebCore::highestAncestorToWrapMarkup):
     20
    1212013-03-08  Alberto Garcia  <agarcia@igalia.com>
    222
  • trunk/Source/WebCore/editing/htmlediting.cpp

    r144911 r145195  
    581581}
    582582
    583 bool isListItem(Node *n)
     583bool isListItem(const Node *n)
    584584{
    585585    return n && n->renderer() && n->renderer()->isListItem();
  • trunk/Source/WebCore/editing/htmlediting.h

    r143893 r145195  
    108108bool isTableStructureNode(const Node*);
    109109bool isListElement(Node*);
    110 bool isListItem(Node*);
     110bool isListItem(const Node*);
    111111bool isNodeRendered(const Node*);
    112112bool isNodeVisiblyContainedWithin(Node*, const Range*);
  • trunk/Source/WebCore/editing/markup.cpp

    r144995 r145195  
    517517        specialCommonAncestor = ancestorToRetainStructureAndAppearance(commonAncestor);
    518518
     519        if (Node* parentListNode = enclosingNodeOfType(firstPositionInOrBeforeNode(range->firstNode()), isListItem)) {
     520            if (WebCore::areRangesEqual(VisibleSelection::selectionFromContentsOfNode(parentListNode).toNormalizedRange().get(), range)) {
     521                specialCommonAncestor = parentListNode->parentNode();
     522                while (specialCommonAncestor && !isListElement(specialCommonAncestor))
     523                    specialCommonAncestor = specialCommonAncestor->parentNode();
     524            }
     525        }
     526
    519527        // Retain the Mail quote level by including all ancestor mail block quotes.
    520528        if (Node* highestMailBlockquote = highestEnclosingNodeOfType(firstPositionInOrBeforeNode(range->firstNode()), isMailBlockquote, CanCrossEditingBoundary))
Note: See TracChangeset for help on using the changeset viewer.