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

Side by Side Diff: third_party/WebKit/Source/core/dom/shadow/FlatTreeTraversal.cpp

Issue 2257053003: Fix a crash when pseudo elements are used for a shadow host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a test Created 4 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 for (HTMLSlotElement* next = slot->assignedSlot(); next; next = next->assign edSlot()) { 93 for (HTMLSlotElement* next = slot->assignedSlot(); next; next = next->assign edSlot()) {
94 slot = next; 94 slot = next;
95 } 95 }
96 return slot; 96 return slot;
97 } 97 }
98 98
99 // TODO(hayato): This may return a wrong result for a node which is not in a 99 // TODO(hayato): This may return a wrong result for a node which is not in a
100 // document flat tree. See FlatTreeTraversalTest's redistribution test for deta ils. 100 // document flat tree. See FlatTreeTraversalTest's redistribution test for deta ils.
101 Node* FlatTreeTraversal::traverseSiblings(const Node& node, TraversalDirection d irection) 101 Node* FlatTreeTraversal::traverseSiblings(const Node& node, TraversalDirection d irection)
102 { 102 {
103 // TODO(hayato): Stop this hack for a pseudo element because a pseudo elemen t should not be in a document flat tree.
104 if (node.isPseudoElement())
105 return direction == TraversalDirectionForward ? node.nextSibling() : nod e.previousSibling();
rune 2016/08/18 23:54:54 Shouldn't LayoutTreeBuilderTraversal handle pseudo
hayato 2016/08/19 03:58:47 Good point! I missed LayoutTreeBuilderTraversal.
106
103 if (node.isChildOfV1ShadowHost()) 107 if (node.isChildOfV1ShadowHost())
104 return traverseSiblingsForV1HostChild(node, direction); 108 return traverseSiblingsForV1HostChild(node, direction);
105 109
106 if (shadowWhereNodeCanBeDistributed(node)) 110 if (shadowWhereNodeCanBeDistributed(node))
107 return traverseSiblingsForV0Distribution(node, direction); 111 return traverseSiblingsForV0Distribution(node, direction);
108 112
109 if (Node* found = resolveDistributionStartingAt(direction == TraversalDirect ionForward ? node.nextSibling() : node.previousSibling(), direction)) 113 if (Node* found = resolveDistributionStartingAt(direction == TraversalDirect ionForward ? node.nextSibling() : node.previousSibling(), direction))
110 return found; 114 return found;
111 115
112 if (!node.isInV0ShadowTree()) 116 if (!node.isInV0ShadowTree())
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 Node& FlatTreeTraversal::lastWithinOrSelf(const Node& node) 356 Node& FlatTreeTraversal::lastWithinOrSelf(const Node& node)
353 { 357 {
354 assertPrecondition(node); 358 assertPrecondition(node);
355 Node* lastDescendant = lastWithin(node); 359 Node* lastDescendant = lastWithin(node);
356 Node& result = lastDescendant ? *lastDescendant : const_cast<Node&>(node); 360 Node& result = lastDescendant ? *lastDescendant : const_cast<Node&>(node);
357 assertPostcondition(&result); 361 assertPostcondition(&result);
358 return result; 362 return result;
359 } 363 }
360 364
361 } // namespace blink 365 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698