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

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

Issue 59963002: Unable to delete the first and the last characters of a contenteditable div with display: table. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adding new method to preserve old behavior. Created 7 years, 1 month 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/htmlediting.cpp
diff --git a/Source/core/editing/htmlediting.cpp b/Source/core/editing/htmlediting.cpp
index ce132c1364d78d22c75c1e1b32a52123c745ff77..5d676c08aba1b9a0649bb5be70eee8ff18cc93d7 100644
--- a/Source/core/editing/htmlediting.cpp
+++ b/Source/core/editing/htmlediting.cpp
@@ -160,7 +160,7 @@ bool isEditablePosition(const Position& p, EditableType editableType, EUpdateSty
else
ASSERT(updateStyle == DoNotUpdateStyle);
- if (node->renderer() && node->renderer()->isTable())
+ if (isTableElement(node))
node = node->parentNode();
return node->rendererIsEditable(editableType);
@@ -179,7 +179,7 @@ bool isRichlyEditablePosition(const Position& p, EditableType editableType)
if (!node)
return false;
- if (node->renderer() && node->renderer()->isTable())
+ if (isTableElement(node))
node = node->parentNode();
return node->rendererIsRichlyEditable(editableType);
@@ -191,7 +191,7 @@ Element* editableRootForPosition(const Position& p, EditableType editableType)
if (!node)
return 0;
- if (node->renderer() && node->renderer()->isTable())
+ if (isTableElement(node))
node = node->parentNode();
return node->rootEditableElement(editableType);
@@ -434,7 +434,7 @@ static Node* firstInSpecialElement(const Position& pos)
if (isSpecialElement(n)) {
VisiblePosition vPos = VisiblePosition(pos, DOWNSTREAM);
VisiblePosition firstInElement = VisiblePosition(firstPositionInOrBeforeNode(n), DOWNSTREAM);
- if (isTableElement(n) && vPos == firstInElement.next())
+ if (isRenderedTable(n) && vPos == firstInElement.next())
return n;
if (vPos == firstInElement)
return n;
@@ -449,7 +449,7 @@ static Node* lastInSpecialElement(const Position& pos)
if (isSpecialElement(n)) {
VisiblePosition vPos = VisiblePosition(pos, DOWNSTREAM);
VisiblePosition lastInElement = VisiblePosition(lastPositionInOrAfterNode(n), DOWNSTREAM);
- if (isTableElement(n) && vPos == lastInElement.previous())
+ if (isRenderedTable(n) && vPos == lastInElement.previous())
return n;
if (vPos == lastInElement)
return n;
@@ -752,13 +752,20 @@ bool canMergeLists(Element* firstList, Element* secondList)
// Make sure there is no visible content between this li and the previous list
}
-// FIXME: do not require renderer, so that this can be used within fragments, or rename to isRenderedTable()
-bool isTableElement(Node* n)
+bool isTableElement(const Node* n)
{
if (!n || !n->isElementNode())
return false;
- RenderObject* renderer = n->renderer();
+ return n->hasTagName(tableTag);
+}
+
+bool isRenderedTable(const Node* node)
+{
+ if (!node || !node->isElementNode())
+ return false;
+
+ RenderObject* renderer = node->renderer();
return (renderer && (renderer->style()->display() == TABLE || renderer->style()->display() == INLINE_TABLE));
}

Powered by Google App Engine
This is Rietveld 408576698