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

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

Issue 482903002: Get rid of loops looking for the first Element ancestor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix nits 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Position.cpp ('k') | Source/core/rendering/TextAutosizer.cpp » ('j') | 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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 { 568 {
569 return n && n->renderer() && n->renderer()->isListItem(); 569 return n && n->renderer() && n->renderer()->isListItem();
570 } 570 }
571 571
572 Element* enclosingElementWithTag(const Position& p, const QualifiedName& tagName ) 572 Element* enclosingElementWithTag(const Position& p, const QualifiedName& tagName )
573 { 573 {
574 if (p.isNull()) 574 if (p.isNull())
575 return 0; 575 return 0;
576 576
577 ContainerNode* root = highestEditableRoot(p); 577 ContainerNode* root = highestEditableRoot(p);
578 for (Element* ancestor = ElementTraversal::firstAncestorOrSelf(*p.deprecated Node()); ancestor; ancestor = ElementTraversal::firstAncestor(*ancestor)) { 578 Element* ancestor = p.deprecatedNode()->isElementNode() ? toElement(p.deprec atedNode()) : p.deprecatedNode()->parentElement();
579 for (; ancestor; ancestor = ancestor->parentElement()) {
579 if (root && !ancestor->hasEditableStyle()) 580 if (root && !ancestor->hasEditableStyle())
580 continue; 581 continue;
581 if (ancestor->hasTagName(tagName)) 582 if (ancestor->hasTagName(tagName))
582 return ancestor; 583 return ancestor;
583 if (ancestor == root) 584 if (ancestor == root)
584 return 0; 585 return 0;
585 } 586 }
586 587
587 return 0; 588 return 0;
588 } 589 }
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 // if the selection starts just before a paragraph break, skip over it 1225 // if the selection starts just before a paragraph break, skip over it
1225 if (isEndOfParagraph(visiblePosition)) 1226 if (isEndOfParagraph(visiblePosition))
1226 return visiblePosition.next().deepEquivalent().downstream(); 1227 return visiblePosition.next().deepEquivalent().downstream();
1227 1228
1228 // otherwise, make sure to be at the start of the first selected node, 1229 // otherwise, make sure to be at the start of the first selected node,
1229 // instead of possibly at the end of the last node before the selection 1230 // instead of possibly at the end of the last node before the selection
1230 return visiblePosition.deepEquivalent().downstream(); 1231 return visiblePosition.deepEquivalent().downstream();
1231 } 1232 }
1232 1233
1233 } // namespace blink 1234 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/Position.cpp ('k') | Source/core/rendering/TextAutosizer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698