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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLSlotElement.cpp

Issue 1489433002: Support the essential part of Shadow DOM v1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert Internals.* Created 5 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2015 Google Inc. All rights reserved. 2 * Copyright (C) 2015 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 19 matching lines...) Expand all
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/html/HTMLSlotElement.h" 32 #include "core/html/HTMLSlotElement.h"
33 33
34 #include "core/HTMLNames.h" 34 #include "core/HTMLNames.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 using namespace HTMLNames; 38 using namespace HTMLNames;
39 39
40 PassRefPtrWillBeRawPtr<HTMLSlotElement> HTMLSlotElement::create(Document& docume nt)
41 {
42 return adoptRefWillBeNoop(new HTMLSlotElement(document));
43 }
44
45 inline HTMLSlotElement::HTMLSlotElement(Document& document) 40 inline HTMLSlotElement::HTMLSlotElement(Document& document)
46 : HTMLElement(slotTag, document) 41 : HTMLElement(slotTag, document)
47 { 42 {
48 } 43 }
49 44
50 HTMLSlotElement::~HTMLSlotElement() 45 DEFINE_NODE_FACTORY(HTMLSlotElement);
46
47 void HTMLSlotElement::appendAssignedNode(Node& node)
51 { 48 {
49 m_assignedNodes.append(&node);
50 }
51
52 void HTMLSlotElement::appendDistributedNode(Node& node)
53 {
54 m_distributedNodes.append(&node);
55 }
56
57 void HTMLSlotElement::appendDistributedNodes(const WillBeHeapVector<RefPtrWillBe Member<Node>>& nodes)
58 {
59 m_distributedNodes.appendVector(nodes);
60 }
61
62 void HTMLSlotElement::clearDistribution()
63 {
64 m_assignedNodes.clear();
65 m_distributedNodes.clear();
66 }
67
68 Node* HTMLSlotElement::distributedNodeNextTo(const Node& node) const
69 {
70 size_t index = m_distributedNodes.find(&node);
71 if (index == kNotFound || index + 1 == m_distributedNodes.size())
72 return nullptr;
73 return m_distributedNodes[index + 1].get();
74 }
75
76 Node* HTMLSlotElement::distributedNodePreviousTo(const Node& node) const
77 {
78 size_t index = m_distributedNodes.find(&node);
79 if (index == kNotFound || index == 0)
80 return nullptr;
81 return m_distributedNodes[index - 1].get();
82 }
83
84 void HTMLSlotElement::attach(const AttachContext& context)
85 {
86 for (auto& node : m_distributedNodes) {
87 if (node->needsAttach())
88 node->attach(context);
89 }
90
91 HTMLElement::attach(context);
92 }
93
94 void HTMLSlotElement::detach(const AttachContext& context)
95 {
96 for (auto& node : m_distributedNodes)
97 node->lazyReattachIfAttached();
98
99 HTMLElement::detach(context);
52 } 100 }
53 101
54 DEFINE_TRACE(HTMLSlotElement) 102 DEFINE_TRACE(HTMLSlotElement)
55 { 103 {
104 visitor->trace(m_assignedNodes);
105 visitor->trace(m_distributedNodes);
56 HTMLElement::trace(visitor); 106 HTMLElement::trace(visitor);
57 } 107 }
58 108
59 } 109 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSlotElement.h ('k') | third_party/WebKit/Source/core/html/HTMLSlotElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698