| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 2 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 int CounterNode::computeCountInParent() const { | 144 int CounterNode::computeCountInParent() const { |
| 145 int increment = actsAsReset() ? 0 : m_value; | 145 int increment = actsAsReset() ? 0 : m_value; |
| 146 if (m_previousSibling) | 146 if (m_previousSibling) |
| 147 return m_previousSibling->m_countInParent + increment; | 147 return m_previousSibling->m_countInParent + increment; |
| 148 ASSERT(m_parent->m_firstChild == this); | 148 ASSERT(m_parent->m_firstChild == this); |
| 149 return m_parent->m_value + increment; | 149 return m_parent->m_value + increment; |
| 150 } | 150 } |
| 151 | 151 |
| 152 void CounterNode::addLayoutObject(LayoutCounter* value) { | 152 void CounterNode::addLayoutObject(LayoutCounter* value) { |
| 153 if (!value) { | 153 if (!value) { |
| 154 ASSERT_NOT_REACHED(); | 154 NOTREACHED(); |
| 155 return; | 155 return; |
| 156 } | 156 } |
| 157 if (value->m_counterNode) { | 157 if (value->m_counterNode) { |
| 158 ASSERT_NOT_REACHED(); | 158 NOTREACHED(); |
| 159 value->m_counterNode->removeLayoutObject(value); | 159 value->m_counterNode->removeLayoutObject(value); |
| 160 } | 160 } |
| 161 ASSERT(!value->m_nextForSameCounter); | 161 ASSERT(!value->m_nextForSameCounter); |
| 162 for (LayoutCounter* iterator = m_rootLayoutObject; iterator; | 162 for (LayoutCounter* iterator = m_rootLayoutObject; iterator; |
| 163 iterator = iterator->m_nextForSameCounter) { | 163 iterator = iterator->m_nextForSameCounter) { |
| 164 if (iterator == value) { | 164 if (iterator == value) { |
| 165 ASSERT_NOT_REACHED(); | 165 NOTREACHED(); |
| 166 return; | 166 return; |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 value->m_nextForSameCounter = m_rootLayoutObject; | 169 value->m_nextForSameCounter = m_rootLayoutObject; |
| 170 m_rootLayoutObject = value; | 170 m_rootLayoutObject = value; |
| 171 if (value->m_counterNode != this) { | 171 if (value->m_counterNode != this) { |
| 172 if (value->m_counterNode) { | 172 if (value->m_counterNode) { |
| 173 ASSERT_NOT_REACHED(); | 173 NOTREACHED(); |
| 174 value->m_counterNode->removeLayoutObject(value); | 174 value->m_counterNode->removeLayoutObject(value); |
| 175 } | 175 } |
| 176 value->m_counterNode = this; | 176 value->m_counterNode = this; |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 | 179 |
| 180 void CounterNode::removeLayoutObject(LayoutCounter* value) { | 180 void CounterNode::removeLayoutObject(LayoutCounter* value) { |
| 181 if (!value) { | 181 if (!value) { |
| 182 ASSERT_NOT_REACHED(); | 182 NOTREACHED(); |
| 183 return; | 183 return; |
| 184 } | 184 } |
| 185 if (value->m_counterNode && value->m_counterNode != this) { | 185 if (value->m_counterNode && value->m_counterNode != this) { |
| 186 ASSERT_NOT_REACHED(); | 186 NOTREACHED(); |
| 187 value->m_counterNode->removeLayoutObject(value); | 187 value->m_counterNode->removeLayoutObject(value); |
| 188 } | 188 } |
| 189 LayoutCounter* previous = nullptr; | 189 LayoutCounter* previous = nullptr; |
| 190 for (LayoutCounter* iterator = m_rootLayoutObject; iterator; | 190 for (LayoutCounter* iterator = m_rootLayoutObject; iterator; |
| 191 iterator = iterator->m_nextForSameCounter) { | 191 iterator = iterator->m_nextForSameCounter) { |
| 192 if (iterator == value) { | 192 if (iterator == value) { |
| 193 if (previous) | 193 if (previous) |
| 194 previous->m_nextForSameCounter = value->m_nextForSameCounter; | 194 previous->m_nextForSameCounter = value->m_nextForSameCounter; |
| 195 else | 195 else |
| 196 m_rootLayoutObject = value->m_nextForSameCounter; | 196 m_rootLayoutObject = value->m_nextForSameCounter; |
| 197 value->m_nextForSameCounter = nullptr; | 197 value->m_nextForSameCounter = nullptr; |
| 198 value->m_counterNode = nullptr; | 198 value->m_counterNode = nullptr; |
| 199 return; | 199 return; |
| 200 } | 200 } |
| 201 previous = iterator; | 201 previous = iterator; |
| 202 } | 202 } |
| 203 ASSERT_NOT_REACHED(); | 203 NOTREACHED(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void CounterNode::resetLayoutObjects() { | 206 void CounterNode::resetLayoutObjects() { |
| 207 while (m_rootLayoutObject) { | 207 while (m_rootLayoutObject) { |
| 208 // This makes m_rootLayoutObject point to the next layoutObject if any since | 208 // This makes m_rootLayoutObject point to the next layoutObject if any since |
| 209 // it disconnects the m_rootLayoutObject from this. | 209 // it disconnects the m_rootLayoutObject from this. |
| 210 m_rootLayoutObject->invalidate(); | 210 m_rootLayoutObject->invalidate(); |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 #ifndef NDEBUG | 382 #ifndef NDEBUG |
| 383 | 383 |
| 384 void showCounterTree(const blink::CounterNode* counter) { | 384 void showCounterTree(const blink::CounterNode* counter) { |
| 385 if (counter) | 385 if (counter) |
| 386 showTreeAndMark(counter); | 386 showTreeAndMark(counter); |
| 387 else | 387 else |
| 388 fprintf(stderr, "Cannot showCounterTree for (nil).\n"); | 388 fprintf(stderr, "Cannot showCounterTree for (nil).\n"); |
| 389 } | 389 } |
| 390 | 390 |
| 391 #endif | 391 #endif |
| OLD | NEW |