Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(874)

Unified Diff: Source/core/editing/VisibleUnits.cpp

Issue 20681004: Make first-letter style to work with editing Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-09-20T18:27:32 Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/editing/VisibleUnits.cpp
diff --git a/Source/core/editing/VisibleUnits.cpp b/Source/core/editing/VisibleUnits.cpp
index 92f8be86c7e01c6486f836bde5dd0dff359000a6..6b4e0fabe301218dd0a831a86c15c7f6cc5d9351 100644
--- a/Source/core/editing/VisibleUnits.cpp
+++ b/Source/core/editing/VisibleUnits.cpp
@@ -1134,16 +1134,16 @@ VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossi
if (r->isText() && toRenderText(r)->renderedTextLength()) {
ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode());
+ RenderText* text = toRenderText(r);
type = Position::PositionIsOffsetInAnchor;
if (style->preserveNewline()) {
- RenderText* text = toRenderText(r);
int i = text->textLength();
int o = offset;
if (n == startNode && o < i)
i = max(0, o);
while (--i >= 0) {
if ((*text)[i] == '\n')
- return VisiblePosition(Position(toText(n), i + 1), DOWNSTREAM);
+ return VisiblePosition(Position(toText(n), i + text->textStartOffset() + 1), DOWNSTREAM);
}
}
node = n;
@@ -1212,18 +1212,18 @@ VisiblePosition endOfParagraph(const VisiblePosition &c, EditingBoundaryCrossing
// FIXME: We avoid returning a position where the renderer can't accept the caret.
if (r->isText() && toRenderText(r)->renderedTextLength()) {
ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode());
- int length = toRenderText(r)->textLength();
+ RenderText* text = toRenderText(r);
+ int length = text->textLength();
type = Position::PositionIsOffsetInAnchor;
if (style->preserveNewline()) {
- RenderText* text = toRenderText(r);
int o = n == startNode ? offset : 0;
for (int i = o; i < length; ++i) {
if ((*text)[i] == '\n')
- return VisiblePosition(Position(toText(n), i), DOWNSTREAM);
+ return VisiblePosition(Position(toText(n), i + text->textStartOffset()), DOWNSTREAM);
}
}
node = n;
- offset = r->caretMaxOffset();
+ offset = r->caretMaxOffset() + text->textStartOffset();
n = NodeTraversal::next(n, stayInsideBlock);
} else if (editingIgnoresContent(n) || isTableElement(n)) {
node = n;

Powered by Google App Engine
This is Rietveld 408576698