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

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

Issue 421293004: Move Node::enclosingBlockFlowElement() to htmlediting.h (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix nits Created 6 years, 5 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') | no next file » | 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 8b5e040f7fb0d12d1e820f6ee2dadde554a62a8c..5cc0cece6dd5ce46a654b73850d16eaf6b72506c 100644
--- a/Source/core/editing/htmlediting.cpp
+++ b/Source/core/editing/htmlediting.cpp
@@ -334,6 +334,23 @@ Element* enclosingBlock(Node* node, EditingBoundaryCrossingRule rule)
return enclosingNode && enclosingNode->isElementNode() ? toElement(enclosingNode) : 0;
}
+Element* enclosingBlockFlowElement(Node& node)
+{
+ if (node.isBlockFlowElement())
+ return &toElement(node);
+
+ for (Node* n = node.parentNode(); n; n = n->parentNode()) {
+ if (n->isBlockFlowElement() || isHTMLBodyElement(*n))
+ return toElement(n);
+ }
+ return 0;
+}
+
+bool inSameContainingBlockFlowElement(Node* a, Node* b)
+{
+ return a && b && enclosingBlockFlowElement(*a) == enclosingBlockFlowElement(*b);
+}
+
TextDirection directionOfEnclosingBlock(const Position& position)
{
Element* enclosingBlockElement = enclosingBlock(position.containerNode());
@@ -933,7 +950,7 @@ Position leadingWhitespacePosition(const Position& position, EAffinity affinity,
return Position();
Position prev = previousCharacterPosition(position, affinity);
- if (prev != position && prev.anchorNode()->inSameContainingBlockFlowElement(position.anchorNode()) && prev.anchorNode()->isTextNode()) {
+ if (prev != position && inSameContainingBlockFlowElement(prev.anchorNode(), position.anchorNode()) && prev.anchorNode()->isTextNode()) {
String string = toText(prev.anchorNode())->data();
UChar previousCharacter = string[prev.deprecatedEditingOffset()];
bool isSpace = option == ConsiderNonCollapsibleWhitespace ? (isSpaceOrNewline(previousCharacter) || previousCharacter == noBreakSpace) : isCollapsibleWhitespace(previousCharacter);
« no previous file with comments | « Source/core/editing/htmlediting.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698