| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 return m_currentChild; | 67 return m_currentChild; |
| 68 } | 68 } |
| 69 | 69 |
| 70 void OrderIterator::reset() | 70 void OrderIterator::reset() |
| 71 { | 71 { |
| 72 m_currentOrderIndex = 0; | 72 m_currentOrderIndex = 0; |
| 73 m_currentChildIndex = 0; | 73 m_currentChildIndex = 0; |
| 74 m_currentChild = 0; | 74 m_currentChild = 0; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void OrderIterator::invalidate() |
| 78 { |
| 79 // Note that we don't release the memory here, we only invalidate the size. |
| 80 // This avoids unneeded reallocation if the size ends up not changing. |
| 81 m_orderValues.shrink(0); |
| 82 m_orderedValues.clear(); |
| 83 |
| 84 reset(); |
| 85 } |
| 86 |
| 77 OrderIteratorPopulator::~OrderIteratorPopulator() | 87 OrderIteratorPopulator::~OrderIteratorPopulator() |
| 78 { | 88 { |
| 79 m_iterator.reset(); | 89 m_iterator.reset(); |
| 80 | 90 |
| 81 std::sort(m_iterator.m_orderValues.begin(), m_iterator.m_orderValues.end()); | 91 std::sort(m_iterator.m_orderValues.begin(), m_iterator.m_orderValues.end()); |
| 82 | 92 |
| 83 // Ensure that we release any extra memory we hold onto. | 93 // Ensure that we release any extra memory we hold onto. |
| 84 m_iterator.m_orderValues.shrinkToFit(); | 94 m_iterator.m_orderValues.shrinkToFit(); |
| 85 } | 95 } |
| 86 | 96 |
| 87 void OrderIteratorPopulator::collectChild(RenderBox* child) | 97 void OrderIteratorPopulator::collectChild(RenderBox* child) |
| 88 { | 98 { |
| 89 int order = child->style()->order(); | 99 int order = child->style()->order(); |
| 90 | 100 |
| 91 // FIXME: Ideally we would want to avoid inserting into the HashMap for the
common case where there are only items | 101 // FIXME: Ideally we would want to avoid inserting into the HashMap for the
common case where there are only items |
| 92 // with the default 'order' 0. The current API is designed to blend into a s
ingle iteration which makes having a | 102 // with the default 'order' 0. The current API is designed to blend into a s
ingle iteration which makes having a |
| 93 // slower fallback difficult without having to store the children (grid item
s may not be contiguous in DOM order). | 103 // slower fallback difficult without having to store the children (grid item
s may not be contiguous in DOM order). |
| 94 OrderIterator::OrderedValuesMap::AddResult result = m_iterator.m_orderedValu
es.add(order, Vector<RenderBox*>()); | 104 OrderIterator::OrderedValuesMap::AddResult result = m_iterator.m_orderedValu
es.add(order, Vector<RenderBox*>()); |
| 95 result.iterator->value.append(child); | 105 result.iterator->value.append(child); |
| 96 if (result.isNewEntry) | 106 if (result.isNewEntry) |
| 97 m_iterator.m_orderValues.append(order); | 107 m_iterator.m_orderValues.append(order); |
| 98 } | 108 } |
| 99 | 109 |
| 100 } // namespace WebCore | 110 } // namespace WebCore |
| OLD | NEW |