Changeset 75308 in webkit


Ignore:
Timestamp:
Jan 7, 2011 6:59:58 PM (13 years ago)
Author:
justin.garcia@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=51851
Implement RenderSVGInlineText::localCaretRect()

Reviewed by Dan Bernstein.

WebCore:

  • rendering/svg/RenderSVGInlineText.cpp:

(WebCore::RenderSVGInlineText::localCaretRect): Implemented.

LayoutTests:

  • svg/text/caret-in-svg-text-expected.txt: Added.
  • svg/text/caret-in-svg-text.xhtml: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r75305 r75308  
     12011-01-07  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=51851
     6        Implement RenderSVGInlineText::localCaretRect()
     7
     8        * svg/text/caret-in-svg-text-expected.txt: Added.
     9        * svg/text/caret-in-svg-text.xhtml: Added.
     10
    1112011-01-06  Ryosuke Niwa  <rniwa@webkit.org>
    212
  • trunk/WebCore/ChangeLog

    r75307 r75308  
     12011-01-07  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=51851
     6        Implement RenderSVGInlineText::localCaretRect()
     7
     8        * rendering/svg/RenderSVGInlineText.cpp:
     9        (WebCore::RenderSVGInlineText::localCaretRect): Implemented.
     10
    1112011-01-07  Ryosuke Niwa  <rniwa@webkit.org>
    212
  • trunk/WebCore/rendering/svg/RenderSVGInlineText.cpp

    r69186 r75308  
    9393}
    9494
    95 IntRect RenderSVGInlineText::localCaretRect(InlineBox*, int, int*)
    96 {
    97     return IntRect();
     95IntRect RenderSVGInlineText::localCaretRect(InlineBox* box, int caretOffset, int*)
     96{
     97    if (!box->isInlineTextBox())
     98        return IntRect();
     99
     100    InlineTextBox* textBox = static_cast<InlineTextBox*>(box);
     101    if (static_cast<unsigned>(caretOffset) < textBox->start() || static_cast<unsigned>(caretOffset) > textBox->start() + textBox->len())
     102        return IntRect();
     103
     104    // Use the edge of the selection rect to determine the caret rect.
     105    if (static_cast<unsigned>(caretOffset) < textBox->start() + textBox->len()) {
     106        IntRect rect = textBox->selectionRect(0, 0, caretOffset, caretOffset + 1);
     107        int x = box->isLeftToRightDirection() ? rect.x() : rect.right();
     108        return IntRect(x, rect.y(), caretWidth, rect.height());
     109    }
     110
     111    IntRect rect = textBox->selectionRect(0, 0, caretOffset - 1, caretOffset);
     112    int x = box->isLeftToRightDirection() ? rect.right() : rect.x();
     113    return IntRect(x, rect.y(), caretWidth, rect.height());
    98114}
    99115
Note: See TracChangeset for help on using the changeset viewer.