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

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

Issue 1611413005: Make HTMLSlotElement.distributedNodeNextTo&distributedNodePreviousTo faster (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add Performance Test Created 4 years, 11 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
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 public: 43 public:
44 DECLARE_NODE_FACTORY(HTMLSlotElement); 44 DECLARE_NODE_FACTORY(HTMLSlotElement);
45 45
46 const WillBeHeapVector<RefPtrWillBeMember<Node>>& getAssignedNodes() const { ASSERT(!needsDistributionRecalc()); return m_assignedNodes; } 46 const WillBeHeapVector<RefPtrWillBeMember<Node>>& getAssignedNodes() const { ASSERT(!needsDistributionRecalc()); return m_assignedNodes; }
47 const WillBeHeapVector<RefPtrWillBeMember<Node>>& getDistributedNodes(); 47 const WillBeHeapVector<RefPtrWillBeMember<Node>>& getDistributedNodes();
48 const WillBeHeapVector<RefPtrWillBeMember<Node>> getAssignedNodesForBinding( const AssignedNodesOptions&); 48 const WillBeHeapVector<RefPtrWillBeMember<Node>> getAssignedNodesForBinding( const AssignedNodesOptions&);
49 49
50 Node* firstDistributedNode() const { return m_distributedNodes.isEmpty() ? n ullptr : m_distributedNodes.first().get(); } 50 Node* firstDistributedNode() const { return m_distributedNodes.isEmpty() ? n ullptr : m_distributedNodes.first().get(); }
51 Node* lastDistributedNode() const { return m_distributedNodes.isEmpty() ? nu llptr : m_distributedNodes.last().get(); } 51 Node* lastDistributedNode() const { return m_distributedNodes.isEmpty() ? nu llptr : m_distributedNodes.last().get(); }
52 52
53 // TODO(hayato): This takes O(N). Make it O(1) with node-to-index hash table . 53 // TODO(hayato): This takes O(N). Make it O(1) with node-to-index hash table .
kochi 2016/01/27 10:53:15 You should remove this TODO.
yuzuchan 2016/02/01 05:40:42 Done.
54 Node* distributedNodeNextTo(const Node&) const; 54 Node* distributedNodeNextTo(const Node&) const;
55 Node* distributedNodePreviousTo(const Node&) const; 55 Node* distributedNodePreviousTo(const Node&) const;
56 56
57 void appendAssignedNode(Node&); 57 void appendAssignedNode(Node&);
58 void appendDistributedNode(Node&); 58 void appendDistributedNode(Node&);
59 void appendDistributedNodesFrom(const HTMLSlotElement& other); 59 void appendDistributedNodesFrom(const HTMLSlotElement& other);
60 void clearDistribution(); 60 void clearDistribution();
61 61
62 void updateDistributedNodesWithFallback(); 62 void updateDistributedNodesWithFallback();
63 63
64 void attach(const AttachContext& = AttachContext()) override; 64 void attach(const AttachContext& = AttachContext()) override;
65 void detach(const AttachContext& = AttachContext()) override; 65 void detach(const AttachContext& = AttachContext()) override;
66 66
67 void attributeChanged(const QualifiedName&, const AtomicString& oldValue, co nst AtomicString& newValue, AttributeModificationReason = ModifiedDirectly) over ride; 67 void attributeChanged(const QualifiedName&, const AtomicString& oldValue, co nst AtomicString& newValue, AttributeModificationReason = ModifiedDirectly) over ride;
68 68
69 DECLARE_VIRTUAL_TRACE(); 69 DECLARE_VIRTUAL_TRACE();
70 70
71 protected: 71 protected:
72 void childrenChanged(const ChildrenChange&) override; 72 void childrenChanged(const ChildrenChange&) override;
73 InsertionNotificationRequest insertedInto(ContainerNode*) override; 73 InsertionNotificationRequest insertedInto(ContainerNode*) override;
74 void removedFrom(ContainerNode*) override; 74 void removedFrom(ContainerNode*) override;
75 75
76 private: 76 private:
77 HTMLSlotElement(Document&); 77 HTMLSlotElement(Document&);
78 78
79 WillBeHeapVector<RefPtrWillBeMember<Node>> m_assignedNodes; 79 WillBeHeapVector<RefPtrWillBeMember<Node>> m_assignedNodes;
80 // TODO(hayato): Share code with DistributedNode class
kochi 2016/01/27 08:29:14 Does this CL really address this TODO?
yuzuchan 2016/02/01 05:40:42 I have decided to use a hash table here instead of
81 WillBeHeapVector<RefPtrWillBeMember<Node>> m_distributedNodes; 80 WillBeHeapVector<RefPtrWillBeMember<Node>> m_distributedNodes;
81 WillBeHeapHashMap<RawPtrWillBeMember<const Node>, size_t> m_distributedIndic es;
82 }; 82 };
83 83
84 } // namespace blink 84 } // namespace blink
85 85
86 #endif // HTMLSlotElement_h 86 #endif // HTMLSlotElement_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698