Changeset 22037 in webkit


Ignore:
Timestamp:
Jun 6, 2007, 8:11:34 PM (18 years ago)
Author:
justing
Message:

LayoutTests:

Reviewed by Harrison.

<rdar://problem/4889598> Problems with moveDown: and moveUp: in Notes with ToDos

  • editing/selection/4889598-expected.checksum: Added.
  • editing/selection/4889598-expected.png: Added.
  • editing/selection/4889598-expected.txt: Added.
  • editing/selection/4889598.html: Added.

WebCore:

Reviewed by Harrison.

<rdar://problem/4889598> Problems with moveDown: and moveUp: in Notes with ToDos


The caret would disappear when moving from content above or below
a ToDo if that ToDo doesn't have any content in it with the same
x position as the caret. That's because closestLeafChildForXPos
would return non-editable leaves, and which turn into non-editable
VisiblePositions, which are invisible.

  • editing/visible_units.cpp: (WebCore::previousLinePosition): Ask closestLeafForXPos to only return editable leaves. (WebCore::nextLinePosition): Ditto.
  • rendering/RootInlineBox.cpp: (WebCore::isEditableLeaf): Added. (WebCore::RootInlineBox::closestLeafChildForXPos): If requested, return the closest editable leaf. Removed an early return if the position is before the first leaf, it's not really much of an optimization.
  • rendering/RootInlineBox.h:
Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r22035 r22037  
     12007-06-06  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by Harrison.
     4
     5        <rdar://problem/4889598> Problems with moveDown: and moveUp: in Notes with ToDos
     6
     7        * editing/selection/4889598-expected.checksum: Added.
     8        * editing/selection/4889598-expected.png: Added.
     9        * editing/selection/4889598-expected.txt: Added.
     10        * editing/selection/4889598.html: Added.
     11
    1122007-06-06  Sam Weinig  <sam@webkit.org>
    213
  • trunk/WebCore/ChangeLog

    r22036 r22037  
     12007-06-06  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by Harrison.
     4
     5        <rdar://problem/4889598> Problems with moveDown: and moveUp: in Notes with ToDos
     6       
     7        The caret would disappear when moving from content above or below
     8        a ToDo if that ToDo doesn't have any content in it with the same
     9        x position as the caret. That's because closestLeafChildForXPos
     10        would return non-editable leaves, and which turn into non-editable
     11        VisiblePositions, which are invisible.
     12
     13        * editing/visible_units.cpp:
     14        (WebCore::previousLinePosition): Ask closestLeafForXPos to only
     15        return editable leaves.
     16        (WebCore::nextLinePosition): Ditto.
     17        * rendering/RootInlineBox.cpp:
     18        (WebCore::isEditableLeaf): Added.
     19        (WebCore::RootInlineBox::closestLeafChildForXPos): If requested,
     20        return the closest editable leaf. Removed an early return if the
     21        position is before the first leaf, it's not really much of an
     22        optimization.
     23        * rendering/RootInlineBox.h:
     24
    1252007-06-06  Sam Weinig  <sam@webkit.org>
    226
  • trunk/WebCore/editing/visible_units.cpp

    r21904 r22037  
    433433        if (containingBlock->hasOverflowClip())
    434434            containingBlock->layer()->subtractScrollOffset(absx, absy);
    435         RenderObject *renderer = root->closestLeafChildForXPos(x - absx)->object();
     435        RenderObject *renderer = root->closestLeafChildForXPos(x - absx, isEditablePosition(p))->object();
    436436        Node* node = renderer->element();
    437437        if (editingIgnoresContent(node))
     
    503503        if (containingBlock->hasOverflowClip())
    504504            containingBlock->layer()->subtractScrollOffset(absx, absy);
    505         RenderObject *renderer = root->closestLeafChildForXPos(x - absx)->object();
     505        RenderObject *renderer = root->closestLeafChildForXPos(x - absx, isEditablePosition(p))->object();
    506506        Node* node = renderer->element();
    507507        if (editingIgnoresContent(node))
  • trunk/WebCore/rendering/RootInlineBox.cpp

    r21079 r22037  
    316316}
    317317
    318 InlineBox* RootInlineBox::closestLeafChildForXPos(int x)
     318bool isEditableLeaf(InlineBox* leaf)
     319{
     320    return leaf && leaf->object() && leaf->object()->element() && leaf->object()->element()->isContentEditable();
     321}
     322
     323InlineBox* RootInlineBox::closestLeafChildForXPos(int x, bool onlyEditableLeaves)
    319324{
    320325    InlineBox* firstLeaf = firstLeafChildAfterBox();
    321326    InlineBox* lastLeaf = lastLeafChildBeforeBox();
    322     if (firstLeaf == lastLeaf)
     327    if (firstLeaf == lastLeaf && (!onlyEditableLeaves || isEditableLeaf(firstLeaf)))
    323328        return firstLeaf;
    324329
    325330    // Avoid returning a list marker when possible.
    326     if (x <= firstLeaf->m_x && !firstLeaf->object()->isListMarker())
     331    if (x <= firstLeaf->m_x && !firstLeaf->object()->isListMarker() && (!onlyEditableLeaves || isEditableLeaf(firstLeaf)))
    327332        // The x coordinate is less or equal to left edge of the firstLeaf.
    328333        // Return it.
    329334        return firstLeaf;
    330335
    331     if (x >= lastLeaf->m_x + lastLeaf->m_width && !lastLeaf->object()->isListMarker())
     336    if (x >= lastLeaf->m_x + lastLeaf->m_width && !lastLeaf->object()->isListMarker() && (!onlyEditableLeaves || isEditableLeaf(lastLeaf)))
    332337        // The x coordinate is greater or equal to right edge of the lastLeaf.
    333338        // Return it.
    334339        return lastLeaf;
    335340
     341    InlineBox* closestLeaf = lastLeaf;
    336342    for (InlineBox* leaf = firstLeaf; leaf && leaf != lastLeaf; leaf = leaf->nextLeafChild()) {
    337         if (!leaf->object()->isListMarker()) {
     343        if (!leaf->object()->isListMarker() && (!onlyEditableLeaves || isEditableLeaf(leaf))) {
    338344            int leafX = leaf->m_x;
     345            closestLeaf = leaf;
    339346            if (x < leafX + leaf->m_width)
    340347                // The x coordinate is less than the right edge of the box.
     
    344351    }
    345352
    346     return lastLeaf;
     353    return closestLeaf;
    347354}
    348355
  • trunk/WebCore/rendering/RootInlineBox.h

    r21079 r22037  
    121121    int selectionHeight() { return max(0, selectionBottom() - selectionTop()); }
    122122
    123     InlineBox* closestLeafChildForXPos(int x);
     123    InlineBox* closestLeafChildForXPos(int x, bool onlyEditableLeaves = false);
    124124
    125125protected:
Note: See TracChangeset for help on using the changeset viewer.