diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 41bb61daecb68c486a6c890652af438e718ee034..803367f237d7e15de0d35dccc3e41424e0367fe3 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,13 @@ +2011-01-07 Justin Garcia + + Reviewed by Dan Bernstein. + + https://bugs.webkit.org/show_bug.cgi?id=51851 + Implement RenderSVGInlineText::localCaretRect() + + * svg/text/caret-in-svg-text-expected.txt: Added. + * svg/text/caret-in-svg-text.xhtml: Added. + 2011-01-06 Ryosuke Niwa Reviewed by Adam Barth. diff --git a/LayoutTests/svg/text/caret-in-svg-text-expected.txt b/LayoutTests/svg/text/caret-in-svg-text-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..ec7fd3d522f4023c3ebb886aef01acfac00935fb --- /dev/null +++ b/LayoutTests/svg/text/caret-in-svg-text-expected.txt @@ -0,0 +1,7 @@ +Sheriff Woody +שדגש + +Success +Success +Failure. Was: 20,546,0,18, expected: 58,546,0,18 +Failure. Was: 58,546,0,18, expected: 20,546,0,18 diff --git a/LayoutTests/svg/text/caret-in-svg-text.xhtml b/LayoutTests/svg/text/caret-in-svg-text.xhtml new file mode 100644 index 0000000000000000000000000000000000000000..c7b4c4f48f4fc70f78ae86f4ca998601c883d242 --- /dev/null +++ b/LayoutTests/svg/text/caret-in-svg-text.xhtml @@ -0,0 +1,35 @@ + + +
+ + Sheriff Woody + שדגש + +
+
+ + + diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 0385faaabf39c46236ae719f5184305de9b38222..279565172393e0c7940b3b4081355728f3a34048 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,13 @@ +2011-01-07 Justin Garcia + + Reviewed by Dan Bernstein. + + https://bugs.webkit.org/show_bug.cgi?id=51851 + Implement RenderSVGInlineText::localCaretRect() + + * rendering/svg/RenderSVGInlineText.cpp: + (WebCore::RenderSVGInlineText::localCaretRect): Implemented. + 2011-01-07 Ryosuke Niwa Unreviewed; Added the missing null pointer check for r75293. diff --git a/WebCore/rendering/svg/RenderSVGInlineText.cpp b/WebCore/rendering/svg/RenderSVGInlineText.cpp index 49727ee372f92f4ca1b804e8201b3a7e1f93e49d..b791f3e3ed48d2b5adbe44f7745d5533fb39fe63 100644 --- a/WebCore/rendering/svg/RenderSVGInlineText.cpp +++ b/WebCore/rendering/svg/RenderSVGInlineText.cpp @@ -92,9 +92,25 @@ InlineTextBox* RenderSVGInlineText::createTextBox() return box; } -IntRect RenderSVGInlineText::localCaretRect(InlineBox*, int, int*) +IntRect RenderSVGInlineText::localCaretRect(InlineBox* box, int caretOffset, int*) { - return IntRect(); + if (!box->isInlineTextBox()) + return IntRect(); + + InlineTextBox* textBox = static_cast(box); + if (static_cast(caretOffset) < textBox->start() || static_cast(caretOffset) > textBox->start() + textBox->len()) + return IntRect(); + + // Use the edge of the selection rect to determine the caret rect. + if (static_cast(caretOffset) < textBox->start() + textBox->len()) { + IntRect rect = textBox->selectionRect(0, 0, caretOffset, caretOffset + 1); + int x = box->isLeftToRightDirection() ? rect.x() : rect.right(); + return IntRect(x, rect.y(), caretWidth, rect.height()); + } + + IntRect rect = textBox->selectionRect(0, 0, caretOffset - 1, caretOffset); + int x = box->isLeftToRightDirection() ? rect.right() : rect.x(); + return IntRect(x, rect.y(), caretWidth, rect.height()); } IntRect RenderSVGInlineText::linesBoundingBox() const