| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of the render object implementation for KHTML. | 2 * This file is part of the render object implementation for KHTML. |
| 3 * | 3 * |
| 4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 5 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 5 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 6 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. | 6 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 RenderContainer* nextCont = currCont->continuation(); | 111 RenderContainer* nextCont = currCont->continuation(); |
| 112 currCont->setContinuation(0); | 112 currCont->setContinuation(0); |
| 113 currCont->setStyle(style()); | 113 currCont->setStyle(style()); |
| 114 currCont->setContinuation(nextCont); | 114 currCont->setContinuation(nextCont); |
| 115 } | 115 } |
| 116 | 116 |
| 117 m_lineHeight = -1; | 117 m_lineHeight = -1; |
| 118 | 118 |
| 119 // Update pseudos for :before and :after now. | 119 // Update pseudos for :before and :after now. |
| 120 if (!isAnonymous() && document()->usesBeforeAfterRules()) { | 120 if (!isAnonymous() && document()->usesBeforeAfterRules()) { |
| 121 updateBeforeAfterContent(RenderStyle::BEFORE); | 121 children()->updateBeforeAfterContent(this, RenderStyle::BEFORE); |
| 122 updateBeforeAfterContent(RenderStyle::AFTER); | 122 children()->updateBeforeAfterContent(this, RenderStyle::AFTER); |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 static inline bool isAfterContent(RenderObject* child) | 126 static inline bool isAfterContent(RenderObject* child) |
| 127 { | 127 { |
| 128 if (!child) | 128 if (!child) |
| 129 return false; | 129 return false; |
| 130 if (child->style()->styleType() != RenderStyle::AFTER) | 130 if (child->style()->styleType() != RenderStyle::AFTER) |
| 131 return false; | 131 return false; |
| 132 // Text nodes don't have their own styles, so ignore the style on a text nod
e. | 132 // Text nodes don't have their own styles, so ignore the style on a text nod
e. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 RenderBlock* newBox = new (renderArena()) RenderBlock(document() /* anon
ymous box */); | 192 RenderBlock* newBox = new (renderArena()) RenderBlock(document() /* anon
ymous box */); |
| 193 newBox->setStyle(newStyle.release()); | 193 newBox->setStyle(newStyle.release()); |
| 194 RenderContainer* oldContinuation = continuation(); | 194 RenderContainer* oldContinuation = continuation(); |
| 195 setContinuation(newBox); | 195 setContinuation(newBox); |
| 196 | 196 |
| 197 // Someone may have put a <p> inside a <q>, causing a split. When this
happens, the :after content | 197 // Someone may have put a <p> inside a <q>, causing a split. When this
happens, the :after content |
| 198 // has to move into the inline continuation. Call updateBeforeAfterCont
ent to ensure that our :after | 198 // has to move into the inline continuation. Call updateBeforeAfterCont
ent to ensure that our :after |
| 199 // content gets properly destroyed. | 199 // content gets properly destroyed. |
| 200 bool isLastChild = (beforeChild == lastChild()); | 200 bool isLastChild = (beforeChild == lastChild()); |
| 201 if (document()->usesBeforeAfterRules()) | 201 if (document()->usesBeforeAfterRules()) |
| 202 updateBeforeAfterContent(RenderStyle::AFTER); | 202 children()->updateBeforeAfterContent(this, RenderStyle::AFTER); |
| 203 if (isLastChild && beforeChild != lastChild()) | 203 if (isLastChild && beforeChild != lastChild()) |
| 204 beforeChild = 0; // We destroyed the last child, so now we need to u
pdate our insertion | 204 beforeChild = 0; // We destroyed the last child, so now we need to u
pdate our insertion |
| 205 // point to be 0. It's just a straight append now. | 205 // point to be 0. It's just a straight append now. |
| 206 | 206 |
| 207 splitFlow(beforeChild, newBox, newChild, oldContinuation); | 207 splitFlow(beforeChild, newBox, newChild, oldContinuation); |
| 208 return; | 208 return; |
| 209 } | 209 } |
| 210 | 210 |
| 211 RenderContainer::addChild(newChild, beforeChild); | 211 RenderContainer::addChild(newChild, beforeChild); |
| 212 | 212 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 227 // Create a clone of this inline. | 227 // Create a clone of this inline. |
| 228 RenderInline* clone = cloneInline(this); | 228 RenderInline* clone = cloneInline(this); |
| 229 clone->setContinuation(oldCont); | 229 clone->setContinuation(oldCont); |
| 230 | 230 |
| 231 // Now take all of the children from beforeChild to the end and remove | 231 // Now take all of the children from beforeChild to the end and remove |
| 232 // them from |this| and place them in the clone. | 232 // them from |this| and place them in the clone. |
| 233 RenderObject* o = beforeChild; | 233 RenderObject* o = beforeChild; |
| 234 while (o) { | 234 while (o) { |
| 235 RenderObject* tmp = o; | 235 RenderObject* tmp = o; |
| 236 o = tmp->nextSibling(); | 236 o = tmp->nextSibling(); |
| 237 clone->addChildIgnoringContinuation(removeChildNode(tmp), 0); | 237 clone->addChildIgnoringContinuation(children()->removeChildNode(this, tm
p), 0); |
| 238 tmp->setNeedsLayoutAndPrefWidthsRecalc(); | 238 tmp->setNeedsLayoutAndPrefWidthsRecalc(); |
| 239 } | 239 } |
| 240 | 240 |
| 241 // Hook |clone| up as the continuation of the middle block. | 241 // Hook |clone| up as the continuation of the middle block. |
| 242 middleBlock->setInlineContinuation(clone); | 242 middleBlock->setInlineContinuation(clone); |
| 243 | 243 |
| 244 // We have been reparented and are now under the fromBlock. We need | 244 // We have been reparented and are now under the fromBlock. We need |
| 245 // to walk up our inline parent chain until we hit the containing block. | 245 // to walk up our inline parent chain until we hit the containing block. |
| 246 // Once we hit the containing block we're done. | 246 // Once we hit the containing block we're done. |
| 247 RenderContainer* curr = static_cast<RenderContainer*>(parent()); | 247 RenderContainer* curr = static_cast<RenderContainer*>(parent()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 266 // Hook the clone up as a continuation of |curr|. | 266 // Hook the clone up as a continuation of |curr|. |
| 267 RenderInline* inlineCurr = toRenderInline(curr); | 267 RenderInline* inlineCurr = toRenderInline(curr); |
| 268 oldCont = inlineCurr->continuation(); | 268 oldCont = inlineCurr->continuation(); |
| 269 inlineCurr->setContinuation(clone); | 269 inlineCurr->setContinuation(clone); |
| 270 clone->setContinuation(oldCont); | 270 clone->setContinuation(oldCont); |
| 271 | 271 |
| 272 // Someone may have indirectly caused a <q> to split. When this hap
pens, the :after content | 272 // Someone may have indirectly caused a <q> to split. When this hap
pens, the :after content |
| 273 // has to move into the inline continuation. Call updateBeforeAfter
Content to ensure that the inline's :after | 273 // has to move into the inline continuation. Call updateBeforeAfter
Content to ensure that the inline's :after |
| 274 // content gets properly destroyed. | 274 // content gets properly destroyed. |
| 275 if (document()->usesBeforeAfterRules()) | 275 if (document()->usesBeforeAfterRules()) |
| 276 curr->updateBeforeAfterContent(RenderStyle::AFTER); | 276 inlineCurr->children()->updateBeforeAfterContent(this, RenderSty
le::AFTER); |
| 277 | 277 |
| 278 // Now we need to take all of the children starting from the first c
hild | 278 // Now we need to take all of the children starting from the first c
hild |
| 279 // *after* currChild and append them all to the clone. | 279 // *after* currChild and append them all to the clone. |
| 280 o = currChild->nextSibling(); | 280 o = currChild->nextSibling(); |
| 281 while (o) { | 281 while (o) { |
| 282 RenderObject* tmp = o; | 282 RenderObject* tmp = o; |
| 283 o = tmp->nextSibling(); | 283 o = tmp->nextSibling(); |
| 284 clone->addChildIgnoringContinuation(curr->removeChildNode(tmp),
0); | 284 clone->addChildIgnoringContinuation(curr->children()->removeChil
dNode(curr, tmp), 0); |
| 285 tmp->setNeedsLayoutAndPrefWidthsRecalc(); | 285 tmp->setNeedsLayoutAndPrefWidthsRecalc(); |
| 286 } | 286 } |
| 287 } | 287 } |
| 288 | 288 |
| 289 // Keep walking up the chain. | 289 // Keep walking up the chain. |
| 290 currChild = curr; | 290 currChild = curr; |
| 291 curr = static_cast<RenderContainer*>(curr->parent()); | 291 curr = static_cast<RenderContainer*>(curr->parent()); |
| 292 splitDepth++; | 292 splitDepth++; |
| 293 } | 293 } |
| 294 | 294 |
| 295 // Now we are at the block level. We need to put the clone into the toBlock. | 295 // Now we are at the block level. We need to put the clone into the toBlock. |
| 296 toBlock->appendChildNode(clone); | 296 toBlock->children()->appendChildNode(toBlock, clone); |
| 297 | 297 |
| 298 // Now take all the children after currChild and remove them from the fromBl
ock | 298 // Now take all the children after currChild and remove them from the fromBl
ock |
| 299 // and put them in the toBlock. | 299 // and put them in the toBlock. |
| 300 o = currChild->nextSibling(); | 300 o = currChild->nextSibling(); |
| 301 while (o) { | 301 while (o) { |
| 302 RenderObject* tmp = o; | 302 RenderObject* tmp = o; |
| 303 o = tmp->nextSibling(); | 303 o = tmp->nextSibling(); |
| 304 toBlock->appendChildNode(fromBlock->removeChildNode(tmp)); | 304 toBlock->children()->appendChildNode(toBlock, fromBlock->children()->rem
oveChildNode(fromBlock, tmp)); |
| 305 } | 305 } |
| 306 } | 306 } |
| 307 | 307 |
| 308 void RenderInline::splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox
, | 308 void RenderInline::splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox
, |
| 309 RenderObject* newChild, RenderContainer* oldCont) | 309 RenderObject* newChild, RenderContainer* oldCont) |
| 310 { | 310 { |
| 311 RenderBlock* pre = 0; | 311 RenderBlock* pre = 0; |
| 312 RenderBlock* block = containingBlock(); | 312 RenderBlock* block = containingBlock(); |
| 313 | 313 |
| 314 // Delete our line boxes before we do the inline split into continuations. | 314 // Delete our line boxes before we do the inline split into continuations. |
| 315 block->deleteLineBoxTree(); | 315 block->deleteLineBoxTree(); |
| 316 | 316 |
| 317 bool madeNewBeforeBlock = false; | 317 bool madeNewBeforeBlock = false; |
| 318 if (block->isAnonymousBlock() && (!block->parent() || !block->parent()->crea
tesAnonymousWrapper())) { | 318 if (block->isAnonymousBlock() && (!block->parent() || !block->parent()->crea
tesAnonymousWrapper())) { |
| 319 // We can reuse this block and make it the preBlock of the next continua
tion. | 319 // We can reuse this block and make it the preBlock of the next continua
tion. |
| 320 pre = block; | 320 pre = block; |
| 321 block = block->containingBlock(); | 321 block = block->containingBlock(); |
| 322 } else { | 322 } else { |
| 323 // No anonymous block available for use. Make one. | 323 // No anonymous block available for use. Make one. |
| 324 pre = block->createAnonymousBlock(); | 324 pre = block->createAnonymousBlock(); |
| 325 madeNewBeforeBlock = true; | 325 madeNewBeforeBlock = true; |
| 326 } | 326 } |
| 327 | 327 |
| 328 RenderBlock* post = block->createAnonymousBlock(); | 328 RenderBlock* post = block->createAnonymousBlock(); |
| 329 | 329 |
| 330 RenderObject* boxFirst = madeNewBeforeBlock ? block->firstChild() : pre->nex
tSibling(); | 330 RenderObject* boxFirst = madeNewBeforeBlock ? block->firstChild() : pre->nex
tSibling(); |
| 331 if (madeNewBeforeBlock) | 331 if (madeNewBeforeBlock) |
| 332 block->insertChildNode(pre, boxFirst); | 332 block->children()->insertChildNode(block, pre, boxFirst); |
| 333 block->insertChildNode(newBlockBox, boxFirst); | 333 block->children()->insertChildNode(block, newBlockBox, boxFirst); |
| 334 block->insertChildNode(post, boxFirst); | 334 block->children()->insertChildNode(block, post, boxFirst); |
| 335 block->setChildrenInline(false); | 335 block->setChildrenInline(false); |
| 336 | 336 |
| 337 if (madeNewBeforeBlock) { | 337 if (madeNewBeforeBlock) { |
| 338 RenderObject* o = boxFirst; | 338 RenderObject* o = boxFirst; |
| 339 while (o) { | 339 while (o) { |
| 340 RenderObject* no = o; | 340 RenderObject* no = o; |
| 341 o = no->nextSibling(); | 341 o = no->nextSibling(); |
| 342 pre->appendChildNode(block->removeChildNode(no)); | 342 pre->children()->appendChildNode(pre, block->children()->removeChild
Node(block, no)); |
| 343 no->setNeedsLayoutAndPrefWidthsRecalc(); | 343 no->setNeedsLayoutAndPrefWidthsRecalc(); |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 | 346 |
| 347 splitInlines(pre, post, newBlockBox, beforeChild, oldCont); | 347 splitInlines(pre, post, newBlockBox, beforeChild, oldCont); |
| 348 | 348 |
| 349 // We already know the newBlockBox isn't going to contain inline kids, so av
oid wasting | 349 // We already know the newBlockBox isn't going to contain inline kids, so av
oid wasting |
| 350 // time in makeChildrenNonInline by just setting this explicitly up front. | 350 // time in makeChildrenNonInline by just setting this explicitly up front. |
| 351 newBlockBox->setChildrenInline(false); | 351 newBlockBox->setChildrenInline(false); |
| 352 | 352 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 continuation()->updateDragState(dragOn); | 595 continuation()->updateDragState(dragOn); |
| 596 } | 596 } |
| 597 | 597 |
| 598 void RenderInline::childBecameNonInline(RenderObject* child) | 598 void RenderInline::childBecameNonInline(RenderObject* child) |
| 599 { | 599 { |
| 600 // We have to split the parent flow. | 600 // We have to split the parent flow. |
| 601 RenderBlock* newBox = createAnonymousBlock(); | 601 RenderBlock* newBox = createAnonymousBlock(); |
| 602 RenderContainer* oldContinuation = continuation(); | 602 RenderContainer* oldContinuation = continuation(); |
| 603 setContinuation(newBox); | 603 setContinuation(newBox); |
| 604 RenderObject* beforeChild = child->nextSibling(); | 604 RenderObject* beforeChild = child->nextSibling(); |
| 605 removeChildNode(child); | 605 children()->removeChildNode(this, child); |
| 606 splitFlow(beforeChild, newBox, child, oldContinuation); | 606 splitFlow(beforeChild, newBox, child, oldContinuation); |
| 607 } | 607 } |
| 608 | 608 |
| 609 void RenderInline::updateHitTestResult(HitTestResult& result, const IntPoint& po
int) | 609 void RenderInline::updateHitTestResult(HitTestResult& result, const IntPoint& po
int) |
| 610 { | 610 { |
| 611 if (result.innerNode()) | 611 if (result.innerNode()) |
| 612 return; | 612 return; |
| 613 | 613 |
| 614 Node* node = element(); | 614 Node* node = element(); |
| 615 IntPoint localPoint(point); | 615 IntPoint localPoint(point); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 max(!nextline.isEmpty() ? tx + nextline.right() : -1000000, l
- ow), | 833 max(!nextline.isEmpty() ? tx + nextline.right() : -1000000, l
- ow), |
| 834 b, | 834 b, |
| 835 r + ow, | 835 r + ow, |
| 836 b + ow, | 836 b + ow, |
| 837 BSBottom, oc, style()->color(), os, | 837 BSBottom, oc, style()->color(), os, |
| 838 (!nextline.isEmpty() && l - ow < tx + nextline.right()) ? -ow
: ow, | 838 (!nextline.isEmpty() && l - ow < tx + nextline.right()) ? -ow
: ow, |
| 839 ow); | 839 ow); |
| 840 } | 840 } |
| 841 | 841 |
| 842 } // namespace WebCore | 842 } // namespace WebCore |
| OLD | NEW |