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

Side by Side Diff: Source/core/dom/TreeScope.cpp

Issue 407093010: Simplify compareDocumentPosition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « Source/core/dom/StyleEngine.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) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * Copyright (C) 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 if (chain1[index1 - 1] != chain2[index2 - 1]) 398 if (chain1[index1 - 1] != chain2[index2 - 1])
399 return Node::DOCUMENT_POSITION_DISCONNECTED | Node::DOCUMENT_POSITION_IM PLEMENTATION_SPECIFIC; 399 return Node::DOCUMENT_POSITION_DISCONNECTED | Node::DOCUMENT_POSITION_IM PLEMENTATION_SPECIFIC;
400 400
401 for (unsigned i = std::min(index1, index2); i; --i) { 401 for (unsigned i = std::min(index1, index2); i; --i) {
402 const TreeScope* child1 = chain1[--index1]; 402 const TreeScope* child1 = chain1[--index1];
403 const TreeScope* child2 = chain2[--index2]; 403 const TreeScope* child2 = chain2[--index2];
404 if (child1 != child2) { 404 if (child1 != child2) {
405 Node* shadowHost1 = child1->rootNode().parentOrShadowHostNode(); 405 Node* shadowHost1 = child1->rootNode().parentOrShadowHostNode();
406 Node* shadowHost2 = child2->rootNode().parentOrShadowHostNode(); 406 Node* shadowHost2 = child2->rootNode().parentOrShadowHostNode();
407 if (shadowHost1 != shadowHost2) 407 if (shadowHost1 != shadowHost2)
408 return shadowHost1->compareDocumentPositionInternal(shadowHost2, Node::TreatShadowTreesAsDisconnected); 408 return shadowHost1->compareDocumentPosition(shadowHost2, Node::T reatShadowTreesAsDisconnected);
409 409
410 for (const ShadowRoot* child = toShadowRoot(child2->rootNode()).olde rShadowRoot(); child; child = child->olderShadowRoot()) 410 for (const ShadowRoot* child = toShadowRoot(child2->rootNode()).olde rShadowRoot(); child; child = child->olderShadowRoot())
411 if (child == child1) 411 if (child == child1)
412 return Node::DOCUMENT_POSITION_FOLLOWING; 412 return Node::DOCUMENT_POSITION_FOLLOWING;
413 413
414 return Node::DOCUMENT_POSITION_PRECEDING; 414 return Node::DOCUMENT_POSITION_PRECEDING;
415 } 415 }
416 } 416 }
417 417
418 // There was no difference between the two parent chains, i.e., one was a su bset of the other. The shorter 418 // There was no difference between the two parent chains, i.e., one was a su bset of the other. The shorter
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 visitor->trace(m_document); 543 visitor->trace(m_document);
544 visitor->trace(m_parentTreeScope); 544 visitor->trace(m_parentTreeScope);
545 visitor->trace(m_idTargetObserverRegistry); 545 visitor->trace(m_idTargetObserverRegistry);
546 visitor->trace(m_selection); 546 visitor->trace(m_selection);
547 visitor->trace(m_elementsById); 547 visitor->trace(m_elementsById);
548 visitor->trace(m_imageMapsByName); 548 visitor->trace(m_imageMapsByName);
549 visitor->trace(m_labelsByForAttribute); 549 visitor->trace(m_labelsByForAttribute);
550 } 550 }
551 551
552 } // namespace blink 552 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/StyleEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698