Changeset 153060 in webkit


Ignore:
Timestamp:
Jul 23, 2013 12:09:39 PM (11 years ago)
Author:
ap@apple.com
Message:

Dictionary hotkey does not work on vertical text
https://bugs.webkit.org/show_bug.cgi?id=118993
<rdar://problem/14478260>

Reviewed by Enrica Casucci.

Test: platform/mac/editing/input/firstrectforcharacterrange-vertical.html

  • editing/Editor.cpp: (WebCore::collapseCaretWidth): A helper function. (WebCore::Editor::firstRectForRange): Many changes:
  • use RenderObject::absoluteBoundingBoxRectForRange() in regular case, because that's more direct that getting caret rects and computing bounding rect from those.
  • handle collapsed ranges separately, because absoluteBoundingBoxRectForRange() doesn't provide the needed result, and because it can be done faster.
  • wherever we use carets to compute the result, account for vertical text (in a hackish way, as we don't have layout information at Editor level).
  • rendering/RenderBlock.cpp: (WebCore::RenderBlock::localCaretRect): Removed dead code.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r153058 r153060  
     12013-07-23  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Dictionary hotkey does not work on vertical text
     4        https://bugs.webkit.org/show_bug.cgi?id=118993
     5        <rdar://problem/14478260>
     6
     7        Reviewed by Enrica Casucci.
     8
     9        * platform/mac/editing/input/caret-primary-bidi-expected.txt: Old results had
     10        some collapsed positions have a rect of width 1. Now they are all consistently 0.
     11
     12        * platform/mac/editing/input/firstrectforcharacterrange-vertical-expected.txt: Added.
     13        * platform/mac/editing/input/firstrectforcharacterrange-vertical.html: Added.
     14        * platform/wk2/TestExpectations: Skipping the new test, as WKTR doesn't implement firstRectForCharacterRange.
     15
    1162013-07-23  Bem Jones-Bey  <bjonesbe@adobe.com>
    217
  • trunk/LayoutTests/platform/mac/editing/input/caret-primary-bidi-expected.txt

    r78910 r153060  
    221: 21,564,0,28
    332: 36,564,0,28
    4 3: 48,564,1,28
     43: 48,564,0,28
    554: 154,564,0,28
    665: 140,564,0,28
     
    111110: 73,564,0,28
    121211: 56,564,0,28
    13 12: 169,564,1,28
     1312: 170,564,0,28
    141413: 185,564,0,28
    151514: 198,564,0,28
     
    383837: 60,478,0,28
    393938: 75,478,0,28
    40 39: 87,478,1,28
     4039: 87,478,0,28
    414140: 112,478,0,28
    424241: 95,478,0,28
     
    616160: 776,422,0,28
    626261: 762,422,0,28
    63 62: 752,422,1,28
     6362: 753,422,0,28
    646463: 722,422,0,28
    656564: 737,422,0,28
     
    818180: 736,364,0,28
    828281: 722,364,0,28
    83 82: 711,364,1,28
     8382: 711,364,0,28
    848483: 689,364,0,28
    858584: 702,364,0,28
  • trunk/LayoutTests/platform/wk2/TestExpectations

    r150654 r153060  
    128128platform/mac/editing/input/firstrectforcharacterrange-plain.html
    129129platform/mac/editing/input/firstrectforcharacterrange-styled.html
     130platform/mac/editing/input/firstrectforcharacterrange-vertical.html
    130131platform/mac/editing/input/hangul-enter-confirms-and-sends-keypress.html
    131132platform/mac/editing/input/insert-delete-smp-symbol.html
  • trunk/Source/WebCore/ChangeLog

    r153058 r153060  
     12013-07-23  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Dictionary hotkey does not work on vertical text
     4        https://bugs.webkit.org/show_bug.cgi?id=118993
     5        <rdar://problem/14478260>
     6
     7        Reviewed by Enrica Casucci.
     8
     9        Test: platform/mac/editing/input/firstrectforcharacterrange-vertical.html
     10
     11        * editing/Editor.cpp:
     12        (WebCore::collapseCaretWidth): A helper function.
     13        (WebCore::Editor::firstRectForRange): Many changes:
     14        - use RenderObject::absoluteBoundingBoxRectForRange() in regular case, because
     15        that's more direct that getting caret rects and computing bounding rect from those.
     16        - handle collapsed ranges separately, because absoluteBoundingBoxRectForRange()
     17        doesn't provide the needed result, and because it can be done faster.
     18        - wherever we use carets to compute the result, account for vertical text (in a hackish
     19        way, as we don't have layout information at Editor level).
     20
     21        * rendering/RenderBlock.cpp: (WebCore::RenderBlock::localCaretRect): Removed
     22        dead code.
     23
    1242013-07-23  Bem Jones-Bey  <bjonesbe@adobe.com>
    225
  • trunk/Source/WebCore/editing/Editor.cpp

    r152668 r153060  
    26572657}
    26582658
     2659static inline void collapseCaretWidth(IntRect& rect)
     2660{
     2661    // FIXME: Width adjustment doesn't work for rotated text.
     2662    if (rect.width() == caretWidth)
     2663        rect.setWidth(0);
     2664    else if (rect.height() == caretWidth)
     2665        rect.setHeight(0);
     2666}
     2667
    26592668IntRect Editor::firstRectForRange(Range* range) const
    26602669{
    2661     LayoutUnit extraWidthToEndOfLine = 0;
    26622670    ASSERT(range->startContainer());
    26632671    ASSERT(range->endContainer());
    26642672
    2665     IntRect startCaretRect = RenderedPosition(VisiblePosition(range->startPosition()).deepEquivalent(), DOWNSTREAM).absoluteRect(&extraWidthToEndOfLine);
    2666     if (startCaretRect == LayoutRect())
     2673    VisiblePosition startVisiblePosition(range->startPosition(), DOWNSTREAM);
     2674
     2675    if (range->collapsed(ASSERT_NO_EXCEPTION)) {
     2676        // FIXME: Getting caret rect and removing caret width is a very roundabout way to get collapsed range location.
     2677        // In particular, width adjustment doesn't work for rotated text.
     2678        IntRect startCaretRect = RenderedPosition(startVisiblePosition).absoluteRect();
     2679        collapseCaretWidth(startCaretRect);
     2680        return startCaretRect;
     2681    }
     2682
     2683    VisiblePosition endVisiblePosition(range->endPosition(), UPSTREAM);
     2684
     2685    if (inSameLine(startVisiblePosition, endVisiblePosition))
     2686        return enclosingIntRect(RenderObject::absoluteBoundingBoxRectForRange(range));
     2687
     2688    LayoutUnit extraWidthToEndOfLine = 0;
     2689    IntRect startCaretRect = RenderedPosition(startVisiblePosition).absoluteRect(&extraWidthToEndOfLine);
     2690    if (startCaretRect == IntRect())
    26672691        return IntRect();
    26682692
    2669     IntRect endCaretRect = RenderedPosition(VisiblePosition(range->endPosition()).deepEquivalent(), UPSTREAM).absoluteRect();
    2670     if (endCaretRect == LayoutRect())
    2671         return IntRect();
    2672 
    2673     if (startCaretRect.y() == endCaretRect.y()) {
    2674         // start and end are on the same line
    2675         return IntRect(min(startCaretRect.x(), endCaretRect.x()),
     2693    // When start and end aren't on the same line, we want to go from start to the end of its line.
     2694    bool textIsHorizontal = startCaretRect.width() == caretWidth;
     2695    return textIsHorizontal ?
     2696        IntRect(startCaretRect.x(),
    26762697            startCaretRect.y(),
    2677             abs(endCaretRect.x() - startCaretRect.x()),
    2678             max(startCaretRect.height(), endCaretRect.height()));
    2679     }
    2680 
    2681     // start and end aren't on the same line, so go from start to the end of its line
    2682     return IntRect(startCaretRect.x(),
    2683         startCaretRect.y(),
    2684         startCaretRect.width() + extraWidthToEndOfLine,
    2685         startCaretRect.height());
     2698            startCaretRect.width() + extraWidthToEndOfLine,
     2699            startCaretRect.height()) :
     2700        IntRect(startCaretRect.x(),
     2701            startCaretRect.y(),
     2702            startCaretRect.width(),
     2703            startCaretRect.height() + extraWidthToEndOfLine);
    26862704}
    26872705
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r153058 r153060  
    73287328    LayoutRect caretRect = localCaretRectForEmptyElement(width(), textIndentOffset());
    73297329
    7330     if (extraWidthToEndOfLine) {
    7331         if (isRenderBlock()) {
    7332             *extraWidthToEndOfLine = width() - caretRect.maxX();
    7333         } else {
    7334             // FIXME: This code looks wrong.
    7335             // myRight and containerRight are set up, but then clobbered.
    7336             // So *extraWidthToEndOfLine will always be 0 here.
    7337 
    7338             LayoutUnit myRight = caretRect.maxX();
    7339             // FIXME: why call localToAbsoluteForContent() twice here, too?
    7340             FloatPoint absRightPoint = localToAbsolute(FloatPoint(myRight, 0));
    7341 
    7342             LayoutUnit containerRight = containingBlock()->x() + containingBlockLogicalWidthForContent();
    7343             FloatPoint absContainerPoint = localToAbsolute(FloatPoint(containerRight, 0));
    7344 
    7345             *extraWidthToEndOfLine = absContainerPoint.x() - absRightPoint.x();
    7346         }
    7347     }
     7330    // FIXME: Does this need to adjust for vertical orientation?
     7331    if (extraWidthToEndOfLine)
     7332        *extraWidthToEndOfLine = width() - caretRect.maxX();
    73487333
    73497334    return caretRect;
Note: See TracChangeset for help on using the changeset viewer.