| Index: Source/core/editing/htmlediting.cpp
|
| diff --git a/Source/core/editing/htmlediting.cpp b/Source/core/editing/htmlediting.cpp
|
| index 5a399f1995e3ab490c54ef29cf072a99243474bf..678872771bcd47ee2d7b86fb2031d8dd00ea6307 100644
|
| --- a/Source/core/editing/htmlediting.cpp
|
| +++ b/Source/core/editing/htmlediting.cpp
|
| @@ -50,6 +50,7 @@
|
| #include "core/html/HTMLUListElement.h"
|
| #include "core/page/Frame.h"
|
| #include "core/rendering/RenderObject.h"
|
| +#include "core/rendering/RenderText.h"
|
| #include "wtf/Assertions.h"
|
| #include "wtf/StdLibExtras.h"
|
| #include "wtf/text/StringBuilder.h"
|
| @@ -483,7 +484,7 @@ Position positionAfterContainingSpecialElement(const Position& pos, Node **conta
|
| Node* isFirstPositionAfterTable(const VisiblePosition& visiblePosition)
|
| {
|
| Position upstream(visiblePosition.deepEquivalent().upstream());
|
| - if (upstream.deprecatedNode() && upstream.deprecatedNode()->renderer() && upstream.deprecatedNode()->renderer()->isTable() && upstream.atLastEditingPositionForNode())
|
| + if (upstream.deprecatedNode() && upstream.renderer() && upstream.renderer()->isTable() && upstream.atLastEditingPositionForNode())
|
| return upstream.deprecatedNode();
|
|
|
| return 0;
|
| @@ -492,7 +493,7 @@ Node* isFirstPositionAfterTable(const VisiblePosition& visiblePosition)
|
| Node* isLastPositionBeforeTable(const VisiblePosition& visiblePosition)
|
| {
|
| Position downstream(visiblePosition.deepEquivalent().downstream());
|
| - if (downstream.deprecatedNode() && downstream.deprecatedNode()->renderer() && downstream.deprecatedNode()->renderer()->isTable() && downstream.atFirstEditingPositionForNode())
|
| + if (downstream.deprecatedNode() && downstream.renderer() && downstream.renderer()->isTable() && downstream.atFirstEditingPositionForNode())
|
| return downstream.deprecatedNode();
|
|
|
| return 0;
|
| @@ -975,7 +976,11 @@ int caretMinOffset(const Node* n)
|
| {
|
| RenderObject* r = n->renderer();
|
| ASSERT(!n->isCharacterDataNode() || !r || r->isText()); // FIXME: This was a runtime check that seemingly couldn't fail; changed it to an assertion for now.
|
| - return r ? r->caretMinOffset() : 0;
|
| + if (!r)
|
| + return 0;
|
| + if (r->isText())
|
| + return r->caretMinOffset() + toRenderText(r)->textStartOffset();
|
| + return r->caretMinOffset();
|
| }
|
|
|
| // If a node can contain candidates for VisiblePositions, return the offset of the last candidate, otherwise
|
| @@ -983,8 +988,9 @@ int caretMinOffset(const Node* n)
|
| int caretMaxOffset(const Node* n)
|
| {
|
| // For rendered text nodes, return the last position that a caret could occupy.
|
| - if (n->isTextNode() && n->renderer())
|
| - return n->renderer()->caretMaxOffset();
|
| + RenderObject* renderer = n->renderer();
|
| + if (renderer && renderer->isText())
|
| + return renderer->caretMaxOffset() + toRenderText(renderer)->textStartOffset();
|
| // For containers return the number of children. For others do the same as above.
|
| return lastOffsetForEditing(n);
|
| }
|
| @@ -1002,10 +1008,10 @@ bool lineBreakExistsAtPosition(const Position& position)
|
| if (position.anchorNode()->hasTagName(brTag) && position.atFirstEditingPositionForNode())
|
| return true;
|
|
|
| - if (!position.anchorNode()->renderer())
|
| + if (!position.renderer())
|
| return false;
|
|
|
| - if (!position.anchorNode()->isTextNode() || !position.anchorNode()->renderer()->style()->preserveNewline())
|
| + if (!position.anchorNode()->isTextNode() || !position.renderer()->style()->preserveNewline())
|
| return false;
|
|
|
| Text* textNode = toText(position.anchorNode());
|
|
|