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

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

Issue 434393003: Use tighter typing in editing: VisiblePosition & VisibleSelection (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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
« no previous file with comments | « Source/core/editing/htmlediting.h ('k') | Source/core/rendering/RenderBox.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/htmlediting.cpp
diff --git a/Source/core/editing/htmlediting.cpp b/Source/core/editing/htmlediting.cpp
index bd9eef7e1f8b471f9f8b92270ccbc05ac8cb231a..084e3d4eaee048680c627f28f0730cb65c45637a 100644
--- a/Source/core/editing/htmlediting.cpp
+++ b/Source/core/editing/htmlediting.cpp
@@ -161,7 +161,7 @@ bool isEditablePosition(const Position& p, EditableType editableType, EUpdateSty
else
ASSERT(updateStyle == DoNotUpdateStyle);
- if (isRenderedTableElement(node))
+ if (isRenderedHTMLTableElement(node))
node = node->parentNode();
return node->hasEditableStyle(editableType);
@@ -180,7 +180,7 @@ bool isRichlyEditablePosition(const Position& p, EditableType editableType)
if (!node)
return false;
- if (isRenderedTableElement(node))
+ if (isRenderedHTMLTableElement(node))
node = node->parentNode();
return node->rendererIsRichlyEditable(editableType);
@@ -192,7 +192,7 @@ Element* editableRootForPosition(const Position& p, EditableType editableType)
if (!node)
return 0;
- if (isRenderedTableElement(node))
+ if (isRenderedHTMLTableElement(node))
node = node->parentNode();
return node->rootEditableElement(editableType);
@@ -457,7 +457,7 @@ static HTMLElement* firstInSpecialElement(const Position& pos)
HTMLElement* specialElement = toHTMLElement(n);
VisiblePosition vPos = VisiblePosition(pos, DOWNSTREAM);
VisiblePosition firstInElement = VisiblePosition(firstPositionInOrBeforeNode(specialElement), DOWNSTREAM);
- if (isRenderedTable(specialElement) && vPos == firstInElement.next())
+ if (isRenderedTableElement(specialElement) && vPos == firstInElement.next())
return specialElement;
if (vPos == firstInElement)
return specialElement;
@@ -474,7 +474,7 @@ static HTMLElement* lastInSpecialElement(const Position& pos)
HTMLElement* specialElement = toHTMLElement(n);
VisiblePosition vPos = VisiblePosition(pos, DOWNSTREAM);
VisiblePosition lastInElement = VisiblePosition(lastPositionInOrAfterNode(specialElement), DOWNSTREAM);
- if (isRenderedTable(specialElement) && vPos == lastInElement.previous())
+ if (isRenderedTableElement(specialElement) && vPos == lastInElement.previous())
return specialElement;
if (vPos == lastInElement)
return specialElement;
@@ -509,20 +509,20 @@ Position positionAfterContainingSpecialElement(const Position& pos, HTMLElement*
return result;
}
-Node* isFirstPositionAfterTable(const VisiblePosition& visiblePosition)
+Element* isFirstPositionAfterTable(const VisiblePosition& visiblePosition)
{
Position upstream(visiblePosition.deepEquivalent().upstream());
- if (isRenderedTable(upstream.deprecatedNode()) && upstream.atLastEditingPositionForNode())
- return upstream.deprecatedNode();
+ if (isRenderedTableElement(upstream.deprecatedNode()) && upstream.atLastEditingPositionForNode())
+ return toElement(upstream.deprecatedNode());
return 0;
}
-Node* isLastPositionBeforeTable(const VisiblePosition& visiblePosition)
+Element* isLastPositionBeforeTable(const VisiblePosition& visiblePosition)
{
Position downstream(visiblePosition.deepEquivalent().downstream());
- if (isRenderedTable(downstream.deprecatedNode()) && downstream.atFirstEditingPositionForNode())
- return downstream.deprecatedNode();
+ if (isRenderedTableElement(downstream.deprecatedNode()) && downstream.atFirstEditingPositionForNode())
+ return toElement(downstream.deprecatedNode());
return 0;
}
@@ -750,12 +750,12 @@ bool canMergeLists(Element* firstList, Element* secondList)
// Make sure there is no visible content between this li and the previous list
}
-bool isRenderedTableElement(const Node* node)
+bool isRenderedHTMLTableElement(const Node* node)
{
return isHTMLTableElement(*node) && node->renderer();
}
-bool isRenderedTable(const Node* node)
+bool isRenderedTableElement(const Node* node)
{
if (!node || !node->isElementNode())
return false;
@@ -1081,7 +1081,7 @@ VisibleSelection selectionForParagraphIteration(const VisibleSelection& original
// if the start of the selection is inside that table, then the last paragraph
// that we'll want modify is the last one inside the table, not the table itself
// (a table is itself a paragraph).
- if (Node* table = isFirstPositionAfterTable(endOfSelection))
+ if (Element* table = isFirstPositionAfterTable(endOfSelection))
if (startOfSelection.deepEquivalent().deprecatedNode()->isDescendantOf(table))
newSelection = VisibleSelection(startOfSelection, endOfSelection.previous(CannotCrossEditingBoundary));
@@ -1089,7 +1089,7 @@ VisibleSelection selectionForParagraphIteration(const VisibleSelection& original
// and if the end of the selection is inside that table, then the first paragraph
// we'll want to modify is the first one inside the table, not the paragraph
// containing the table itself.
- if (Node* table = isLastPositionBeforeTable(startOfSelection))
+ if (Element* table = isLastPositionBeforeTable(startOfSelection))
if (endOfSelection.deepEquivalent().deprecatedNode()->isDescendantOf(table))
newSelection = VisibleSelection(startOfSelection.next(CannotCrossEditingBoundary), endOfSelection);
« no previous file with comments | « Source/core/editing/htmlediting.h ('k') | Source/core/rendering/RenderBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698