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

Side by Side Diff: Source/core/editing/htmlediting.cpp

Issue 16879016: Use toElement instead of static_cast<Element*> and static_cast<const Element*> (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 7 years, 6 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 unified diff | Download patch
« no previous file with comments | « Source/core/editing/ReplaceSelectionCommand.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 return HTMLElementFactory::createHTMLElement(name, document, 0, false); 888 return HTMLElementFactory::createHTMLElement(name, document, 0, false);
889 } 889 }
890 890
891 PassRefPtr<HTMLElement> createHTMLElement(Document* document, const AtomicString & tagName) 891 PassRefPtr<HTMLElement> createHTMLElement(Document* document, const AtomicString & tagName)
892 { 892 {
893 return createHTMLElement(document, QualifiedName(nullAtom, tagName, xhtmlNam espaceURI)); 893 return createHTMLElement(document, QualifiedName(nullAtom, tagName, xhtmlNam espaceURI));
894 } 894 }
895 895
896 bool isTabSpanNode(const Node *node) 896 bool isTabSpanNode(const Node *node)
897 { 897 {
898 return node && node->hasTagName(spanTag) && node->isElementNode() && static_ cast<const Element *>(node)->getAttribute(classAttr) == AppleTabSpanClass; 898 return node && node->hasTagName(spanTag) && node->isElementNode() && toEleme nt(node)->getAttribute(classAttr) == AppleTabSpanClass;
899 } 899 }
900 900
901 bool isTabSpanTextNode(const Node *node) 901 bool isTabSpanTextNode(const Node *node)
902 { 902 {
903 return node && node->isTextNode() && node->parentNode() && isTabSpanNode(nod e->parentNode()); 903 return node && node->isTextNode() && node->parentNode() && isTabSpanNode(nod e->parentNode());
904 } 904 }
905 905
906 Node* tabSpanNode(const Node *node) 906 Node* tabSpanNode(const Node *node)
907 { 907 {
908 return isTabSpanTextNode(node) ? node->parentNode() : 0; 908 return isTabSpanTextNode(node) ? node->parentNode() : 0;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 position = positionInParentBeforeNode(node); 1000 position = positionInParentBeforeNode(node);
1001 break; 1001 break;
1002 } 1002 }
1003 } 1003 }
1004 1004
1005 bool isMailBlockquote(const Node *node) 1005 bool isMailBlockquote(const Node *node)
1006 { 1006 {
1007 if (!node || !node->hasTagName(blockquoteTag)) 1007 if (!node || !node->hasTagName(blockquoteTag))
1008 return false; 1008 return false;
1009 1009
1010 return static_cast<const Element *>(node)->getAttribute("type") == "cite"; 1010 return toElement(node)->getAttribute("type") == "cite";
1011 } 1011 }
1012 1012
1013 int caretMinOffset(const Node* n) 1013 int caretMinOffset(const Node* n)
1014 { 1014 {
1015 RenderObject* r = n->renderer(); 1015 RenderObject* r = n->renderer();
1016 ASSERT(!n->isCharacterDataNode() || !r || r->isText()); // FIXME: This was a runtime check that seemingly couldn't fail; changed it to an assertion for now. 1016 ASSERT(!n->isCharacterDataNode() || !r || r->isText()); // FIXME: This was a runtime check that seemingly couldn't fail; changed it to an assertion for now.
1017 return r ? r->caretMinOffset() : 0; 1017 return r ? r->caretMinOffset() : 0;
1018 } 1018 }
1019 1019
1020 // If a node can contain candidates for VisiblePositions, return the offset of t he last candidate, otherwise 1020 // If a node can contain candidates for VisiblePositions, return the offset of t he last candidate, otherwise
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 // if the selection starts just before a paragraph break, skip over it 1198 // if the selection starts just before a paragraph break, skip over it
1199 if (isEndOfParagraph(visiblePosition)) 1199 if (isEndOfParagraph(visiblePosition))
1200 return visiblePosition.next().deepEquivalent().downstream(); 1200 return visiblePosition.next().deepEquivalent().downstream();
1201 1201
1202 // otherwise, make sure to be at the start of the first selected node, 1202 // otherwise, make sure to be at the start of the first selected node,
1203 // instead of possibly at the end of the last node before the selection 1203 // instead of possibly at the end of the last node before the selection
1204 return visiblePosition.deepEquivalent().downstream(); 1204 return visiblePosition.deepEquivalent().downstream();
1205 } 1205 }
1206 1206
1207 } // namespace WebCore 1207 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/editing/ReplaceSelectionCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698