OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2010. 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 | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 146 } |
147 | 147 |
148 void RenderObjectChildList::insertChildNode(RenderObject* owner, RenderObject* c
hild, RenderObject* beforeChild, bool notifyRenderer) | 148 void RenderObjectChildList::insertChildNode(RenderObject* owner, RenderObject* c
hild, RenderObject* beforeChild, bool notifyRenderer) |
149 { | 149 { |
150 if (!beforeChild) { | 150 if (!beforeChild) { |
151 appendChildNode(owner, child, notifyRenderer); | 151 appendChildNode(owner, child, notifyRenderer); |
152 return; | 152 return; |
153 } | 153 } |
154 | 154 |
155 ASSERT(!child->parent()); | 155 ASSERT(!child->parent()); |
156 while (beforeChild->parent() != owner && beforeChild->parent()->isAnonymousB
lock()) | 156 while (beforeChild->parent() && beforeChild->parent() != owner) |
157 beforeChild = beforeChild->parent(); | 157 beforeChild = beforeChild->parent(); |
158 ASSERT(beforeChild->parent() == owner); | 158 |
| 159 // This should never happen, but if it does prevent render tree corruption |
| 160 // where child->parent() ends up being owner but child->nextSibling()->paren
t() |
| 161 // is not owner. |
| 162 if (beforeChild->parent() != owner) { |
| 163 ASSERT_NOT_REACHED(); |
| 164 return; |
| 165 } |
159 | 166 |
160 ASSERT(!owner->isBlockFlow() || (!child->isTableSection() && !child->isTable
Row() && !child->isTableCell())); | 167 ASSERT(!owner->isBlockFlow() || (!child->isTableSection() && !child->isTable
Row() && !child->isTableCell())); |
161 | 168 |
162 if (beforeChild == firstChild()) | 169 if (beforeChild == firstChild()) |
163 setFirstChild(child); | 170 setFirstChild(child); |
164 | 171 |
165 RenderObject* prev = beforeChild->previousSibling(); | 172 RenderObject* prev = beforeChild->previousSibling(); |
166 child->setNextSibling(beforeChild); | 173 child->setNextSibling(beforeChild); |
167 beforeChild->setPreviousSibling(child); | 174 beforeChild->setPreviousSibling(child); |
168 if (prev) | 175 if (prev) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 RenderObject* last = const_cast<RenderObject*>(owner); | 232 RenderObject* last = const_cast<RenderObject*>(owner); |
226 do { | 233 do { |
227 last = last->lastChild(); | 234 last = last->lastChild(); |
228 } while (last && last->isAnonymous() && last->style()->styleType() == NOPSEU
DO && !last->isListMarker()); | 235 } while (last && last->isAnonymous() && last->style()->styleType() == NOPSEU
DO && !last->isListMarker()); |
229 if (last && !last->isAfterContent()) | 236 if (last && !last->isAfterContent()) |
230 return 0; | 237 return 0; |
231 return last; | 238 return last; |
232 } | 239 } |
233 | 240 |
234 } // namespace WebCore | 241 } // namespace WebCore |
OLD | NEW |