Commit 53a7d963 authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Make IsEditablePosition() to use Position::ComputeContainerNode()

This patch changes |IsEditablePosition()| to use |Position::
ComputeContainerNode()| instead of |Position::ParentAnchoredEquivalent()| not to
incorporate |EditorIngoreContetns()|, e.g. <hr>, <img>, etc.

For "<hr contenteditable>", |IsEditablePosition(<hr>@0)| returns false before
this patch. After this patch, it returns true.

Bug: 873088
Change-Id: Id75bd2c857dbd85e59f7795d02f3583802347060
Reviewed-on: https://chromium-review.googlesource.com/1172273Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583457}
parent 960dfdf0
......@@ -458,7 +458,7 @@ ContainerNode* HighestEditableRoot(const PositionInFlatTree& position) {
}
bool IsEditablePosition(const Position& position) {
const Node* node = position.ParentAnchoredEquivalent().AnchorNode();
const Node* node = position.ComputeContainerNode();
if (!node)
return false;
DCHECK(node->GetDocument().IsActive());
......
......@@ -104,6 +104,22 @@ TEST_F(EditingUtilitiesTest, enclosingNodeOfType) {
EnclosingNodeOfType(PositionInFlatTree(one, 0), IsEnclosingBlock));
}
// http://crbug.com/873088
TEST_F(EditingUtilitiesTest, IsEditablePositionWithHr) {
SetBodyContent("<hr contenteditable id=target>");
Element& target = *GetDocument().getElementById("target");
EXPECT_FALSE(IsEditablePosition(Position::BeforeNode(target)));
EXPECT_TRUE(IsEditablePosition(Position(target, 0)));
}
// http://crbug.com/873088
TEST_F(EditingUtilitiesTest, IsEditablePositionWithSpan) {
SetBodyContent("<span contenteditable id=target>abc</span>");
Element& target = *GetDocument().getElementById("target");
EXPECT_FALSE(IsEditablePosition(Position::BeforeNode(target)));
EXPECT_TRUE(IsEditablePosition(Position(target, 0)));
}
TEST_F(EditingUtilitiesTest, isEditablePositionWithTable) {
// We would like to have below DOM tree without HTML, HEAD and BODY element.
// <table id=table><caption>foo</caption></table>
......
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