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

Unified Diff: Source/core/dom/Position.cpp

Issue 192293002: Use new is*Element() helper functions in DOM code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add is*Element(PassRefPtr) helper Created 6 years, 9 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
Index: Source/core/dom/Position.cpp
diff --git a/Source/core/dom/Position.cpp b/Source/core/dom/Position.cpp
index c08a67c3559579812606ec813f61a4ce43794ea4..2bdca345bcd35b71212f7de66cb6dc3262769838 100644
--- a/Source/core/dom/Position.cpp
+++ b/Source/core/dom/Position.cpp
@@ -37,12 +37,13 @@
#include "core/editing/htmlediting.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
-#include "platform/Logging.h"
+#include "core/html/HTMLTableElement.h"
#include "core/rendering/InlineIterator.h"
#include "core/rendering/InlineTextBox.h"
#include "core/rendering/RenderBlock.h"
#include "core/rendering/RenderInline.h"
#include "core/rendering/RenderText.h"
+#include "platform/Logging.h"
#include "wtf/text/CString.h"
#include "wtf/unicode/CharacterNames.h"
@@ -544,12 +545,12 @@ static bool endsOfNodeAreVisuallyDistinctPositions(Node* node)
return true;
// Don't include inline tables.
- if (node->hasTagName(tableTag))
+ if (isHTMLTableElement(*node))
return false;
// A Marquee elements are moving so we should assume their ends are always
// visibily distinct.
- if (node->hasTagName(marqueeTag))
+ if (isHTMLMarqueeElement(*node))
return true;
// There is a VisiblePosition inside an empty inline-block container.
@@ -739,7 +740,7 @@ Position Position::downstream(EditingBoundaryCrossingRule rule) const
// stop before going above the body, up into the head
// return the last visible streamer position
- if (currentNode->hasTagName(bodyTag) && currentPos.atEndOfNode())
+ if (isHTMLBodyElement(*currentNode) && currentPos.atEndOfNode())
break;
// Do not move to a visually distinct position.
@@ -895,11 +896,11 @@ bool Position::isCandidate() const
if (isRenderedTableElement(deprecatedNode()) || editingIgnoresContent(deprecatedNode()))
return (atFirstEditingPositionForNode() || atLastEditingPositionForNode()) && !nodeIsUserSelectNone(deprecatedNode()->parentNode());
- if (m_anchorNode->hasTagName(htmlTag))
+ if (isHTMLHtmlElement(*m_anchorNode))
return false;
if (renderer->isRenderBlockFlow()) {
- if (toRenderBlock(renderer)->logicalHeight() || m_anchorNode->hasTagName(bodyTag)) {
+ if (toRenderBlock(renderer)->logicalHeight() || isHTMLBodyElement(*m_anchorNode)) {
if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer))
return atFirstEditingPositionForNode() && !Position::nodeIsUserSelectNone(deprecatedNode());
return m_anchorNode->rendererIsEditable() && !Position::nodeIsUserSelectNone(deprecatedNode()) && atEditingBoundary();
@@ -980,7 +981,7 @@ bool Position::rendersInDifferentPosition(const Position &pos) const
return false;
if (deprecatedNode() == pos.deprecatedNode()) {
- if (deprecatedNode()->hasTagName(brTag))
+ if (isHTMLBRElement(*deprecatedNode()))
return false;
if (m_offset == pos.deprecatedEditingOffset())
@@ -992,10 +993,10 @@ bool Position::rendersInDifferentPosition(const Position &pos) const
}
}
- if (deprecatedNode()->hasTagName(brTag) && pos.isCandidate())
+ if (isHTMLBRElement(*deprecatedNode()) && pos.isCandidate())
return true;
- if (pos.deprecatedNode()->hasTagName(brTag) && isCandidate())
+ if (isHTMLBRElement(*pos.deprecatedNode()) && isCandidate())
return true;
if (deprecatedNode()->enclosingBlockFlowElement() != pos.deprecatedNode()->enclosingBlockFlowElement())
@@ -1055,7 +1056,7 @@ Position Position::leadingWhitespacePosition(EAffinity affinity, bool considerNo
if (isNull())
return Position();
- if (upstream().deprecatedNode()->hasTagName(brTag))
+ if (isHTMLBRElement(*upstream().deprecatedNode()))
return Position();
Position prev = previousCharacterPosition(affinity);

Powered by Google App Engine
This is Rietveld 408576698