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.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75308 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a80cad0e
2011-01-07 Justin Garcia <justin.garcia@apple.com>
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 <rniwa@webkit.org>
Reviewed by Adam Barth.
......
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
<html xmlns="http://www.w3.org/1999/xhtml">
<body style="margin: 0px; ">
<div style="width: 400px; height: 100px;">
<svg xmlns="http://www.w3.org/2000/svg">
<text x="20" y="30"><tspan>Sheriff Woody</tspan></text>
<text x="20" y="50"><tspan>שדגש</tspan></text>
</svg>
</div>
<div id="log"></div>
<script>
function log(message) {
document.getElementById("log").innerText = document.getElementById("log").innerText + "\n" + message;
}
function assert(found, expected) {
if (found == expected)
log("Success");
else
log("Failure. Was: " + found + ", expected: " + expected);
}
if (window.layoutTestController) {
window.layoutTestController.dumpAsText();
// First offset, left edge, LTR text
assert(textInputController.firstRectForCharacterRange(0, 0), "20,566,0,18");
// Last offset, right edge, RTL text
assert(textInputController.firstRectForCharacterRange(13, 0), "114,566,0,18");
// FIXME: These edges are incorrect (although carets in the middle of RTL runs are correct).
// First offset, right edge, RTL text
assert(textInputController.firstRectForCharacterRange(14, 0), "58,546,0,18");
// Last offset, left edge, RTL text
assert(textInputController.firstRectForCharacterRange(18, 0), "20,546,0,18");
}
</script>
</body>
</html>
2011-01-07 Justin Garcia <justin.garcia@apple.com>
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 <rniwa@webkit.org>
Unreviewed; Added the missing null pointer check for r75293.
......
......@@ -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<InlineTextBox*>(box);
if (static_cast<unsigned>(caretOffset) < textBox->start() || static_cast<unsigned>(caretOffset) > textBox->start() + textBox->len())
return IntRect();
// Use the edge of the selection rect to determine the caret rect.
if (static_cast<unsigned>(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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment