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

Side by Side Diff: Source/web/WebElementCollection.cpp

Issue 280123002: Oilpan: move LiveNodeList collections to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Have NodeRareData clear out NodeListsNodeData instead. Created 6 years, 7 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/web/WebDocument.cpp ('k') | Source/web/WebFormElement.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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2014 Samsung Electronics. All rights reserved. 3 * Copyright (C) 2014 Samsung Electronics. 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 are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 25 matching lines...) Expand all
36 #include "core/html/HTMLCollection.h" 36 #include "core/html/HTMLCollection.h"
37 #include "public/web/WebElement.h" 37 #include "public/web/WebElement.h"
38 #include "wtf/PassRefPtr.h" 38 #include "wtf/PassRefPtr.h"
39 39
40 using namespace WebCore; 40 using namespace WebCore;
41 41
42 namespace blink { 42 namespace blink {
43 43
44 void WebElementCollection::reset() 44 void WebElementCollection::reset()
45 { 45 {
46 assign(0); 46 m_private.reset();
47 } 47 }
48 48
49 void WebElementCollection::assign(const WebElementCollection& other) 49 void WebElementCollection::assign(const WebElementCollection& other)
50 { 50 {
51 HTMLCollection* p = const_cast<HTMLCollection*>(other.m_private); 51 m_private = other.m_private;
52 if (p)
53 p->ref();
54 assign(p);
55 } 52 }
56 53
57 WebElementCollection::WebElementCollection(const PassRefPtr<HTMLCollection>& col ) 54 WebElementCollection::WebElementCollection(const PassRefPtrWillBeRawPtr<HTMLColl ection>& col)
58 : m_private(static_cast<HTMLCollection*>(col.leakRef())) 55 : m_private(col)
59 { 56 {
60 } 57 }
61 58
62 void WebElementCollection::assign(HTMLCollection* p) 59 WebElementCollection& WebElementCollection::operator=(const PassRefPtrWillBeRawP tr<HTMLCollection>& col)
63 { 60 {
64 // p is already ref'd for us by the caller 61 m_private = col;
65 if (m_private) 62 return *this;
66 m_private->deref();
67 m_private = p;
68 } 63 }
69 64
70 unsigned WebElementCollection::length() const 65 unsigned WebElementCollection::length() const
71 { 66 {
72 return m_private->length(); 67 return m_private->length();
73 } 68 }
74 69
75 WebElement WebElementCollection::nextItem() const 70 WebElement WebElementCollection::nextItem() const
76 { 71 {
77 Element* element = m_private->item(m_current); 72 Element* element = m_private->item(m_current);
78 if (element) 73 if (element)
79 m_current++; 74 m_current++;
80 return WebElement(element); 75 return WebElement(element);
81 } 76 }
82 77
83 WebElement WebElementCollection::firstItem() const 78 WebElement WebElementCollection::firstItem() const
84 { 79 {
85 m_current = 0; 80 m_current = 0;
86 return nextItem(); 81 return nextItem();
87 } 82 }
88 83
89 } // namespace blink 84 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebDocument.cpp ('k') | Source/web/WebFormElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698