OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 using namespace Unicode; | 48 using namespace Unicode; |
49 | 49 |
50 namespace WebCore { | 50 namespace WebCore { |
51 | 51 |
52 // Number of pixels to allow as a fudge factor when clicking above or below a li
ne. | 52 // Number of pixels to allow as a fudge factor when clicking above or below a li
ne. |
53 // clicking up to verticalLineClickFudgeFactor pixels above a line will correspo
nd to the closest point on the line. | 53 // clicking up to verticalLineClickFudgeFactor pixels above a line will correspo
nd to the closest point on the line. |
54 const int verticalLineClickFudgeFactor= 3; | 54 const int verticalLineClickFudgeFactor= 3; |
55 | 55 |
56 using namespace HTMLNames; | 56 using namespace HTMLNames; |
57 | 57 |
| 58 static void moveChild(RenderObject* to, RenderObjectChildList* toChildList, Rend
erObject* from, RenderObjectChildList* fromChildList, RenderObject* child) |
| 59 { |
| 60 ASSERT(from == child->parent()); |
| 61 toChildList->appendChildNode(to, fromChildList->removeChildNode(from, child,
false), false); |
| 62 } |
| 63 |
58 struct ColumnInfo { | 64 struct ColumnInfo { |
59 ColumnInfo() | 65 ColumnInfo() |
60 : m_desiredColumnWidth(0) | 66 : m_desiredColumnWidth(0) |
61 , m_desiredColumnCount(1) | 67 , m_desiredColumnCount(1) |
62 { } | 68 { } |
63 int m_desiredColumnWidth; | 69 int m_desiredColumnWidth; |
64 unsigned m_desiredColumnCount; | 70 unsigned m_desiredColumnCount; |
65 Vector<IntRect> m_columnRects; | 71 Vector<IntRect> m_columnRects; |
66 }; | 72 }; |
67 | 73 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 m_lineHeight = -1; | 244 m_lineHeight = -1; |
239 | 245 |
240 // Update pseudos for :before and :after now. | 246 // Update pseudos for :before and :after now. |
241 if (!isAnonymous() && document()->usesBeforeAfterRules() && canHaveChildren(
)) { | 247 if (!isAnonymous() && document()->usesBeforeAfterRules() && canHaveChildren(
)) { |
242 updateBeforeAfterContent(RenderStyle::BEFORE); | 248 updateBeforeAfterContent(RenderStyle::BEFORE); |
243 updateBeforeAfterContent(RenderStyle::AFTER); | 249 updateBeforeAfterContent(RenderStyle::AFTER); |
244 } | 250 } |
245 updateFirstLetter(); | 251 updateFirstLetter(); |
246 } | 252 } |
247 | 253 |
| 254 void RenderBlock::updateBeforeAfterContent(RenderStyle::PseudoId pseudoId) |
| 255 { |
| 256 // If this is an anonymous wrapper, then the parent applies its own pseudo-e
lement style to it. |
| 257 if (parent() && parent()->createsAnonymousWrapper()) |
| 258 return; |
| 259 return children()->updateBeforeAfterContent(this, pseudoId); |
| 260 } |
| 261 |
248 void RenderBlock::addChild(RenderObject* newChild, RenderObject* beforeChild) | 262 void RenderBlock::addChild(RenderObject* newChild, RenderObject* beforeChild) |
249 { | 263 { |
250 // Make sure we don't append things after :after-generated content if we hav
e it. | 264 // Make sure we don't append things after :after-generated content if we hav
e it. |
251 if (!beforeChild && isAfterContent(lastChild())) | 265 if (!beforeChild && isAfterContent(lastChild())) |
252 beforeChild = lastChild(); | 266 beforeChild = lastChild(); |
253 | 267 |
254 bool madeBoxesNonInline = false; | 268 bool madeBoxesNonInline = false; |
255 | 269 |
256 // If the requested beforeChild is not one of our children, then this is bec
ause | 270 // If the requested beforeChild is not one of our children, then this is bec
ause |
257 // there is an anonymous container within this object that contains the befo
reChild. | 271 // there is an anonymous container within this object that contains the befo
reChild. |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 | 429 |
416 while (child) { | 430 while (child) { |
417 RenderObject *inlineRunStart, *inlineRunEnd; | 431 RenderObject *inlineRunStart, *inlineRunEnd; |
418 getInlineRun(child, insertionPoint, inlineRunStart, inlineRunEnd); | 432 getInlineRun(child, insertionPoint, inlineRunStart, inlineRunEnd); |
419 | 433 |
420 if (!inlineRunStart) | 434 if (!inlineRunStart) |
421 break; | 435 break; |
422 | 436 |
423 child = inlineRunEnd->nextSibling(); | 437 child = inlineRunEnd->nextSibling(); |
424 | 438 |
425 RenderBlock* box = createAnonymousBlock(); | 439 RenderBlock* block = createAnonymousBlock(); |
426 insertChildNode(box, inlineRunStart); | 440 children()->insertChildNode(this, block, inlineRunStart); |
427 RenderObject* o = inlineRunStart; | 441 RenderObject* o = inlineRunStart; |
428 while(o != inlineRunEnd) | 442 while (o != inlineRunEnd) { |
429 { | |
430 RenderObject* no = o; | 443 RenderObject* no = o; |
431 o = no->nextSibling(); | 444 o = no->nextSibling(); |
432 box->moveChildNode(no); | 445 |
| 446 moveChild(block, block->children(), this, children(), no); |
433 } | 447 } |
434 box->moveChildNode(inlineRunEnd); | 448 moveChild(block, block->children(), this, children(), inlineRunEnd); |
435 } | 449 } |
436 | 450 |
437 #ifndef NDEBUG | 451 #ifndef NDEBUG |
438 for (RenderObject *c = firstChild(); c; c = c->nextSibling()) | 452 for (RenderObject *c = firstChild(); c; c = c->nextSibling()) |
439 ASSERT(!c->isInline()); | 453 ASSERT(!c->isInline()); |
440 #endif | 454 #endif |
441 | 455 |
442 repaint(); | 456 repaint(); |
443 } | 457 } |
444 | 458 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 RenderObject* next = oldChild->nextSibling(); | 507 RenderObject* next = oldChild->nextSibling(); |
494 bool canDeleteAnonymousBlocks = !documentBeingDestroyed() && !isInline() &&
!oldChild->isInline() && | 508 bool canDeleteAnonymousBlocks = !documentBeingDestroyed() && !isInline() &&
!oldChild->isInline() && |
495 (!oldChild->isRenderBlock() || !toRenderBloc
k(oldChild)->inlineContinuation()) && | 509 (!oldChild->isRenderBlock() || !toRenderBloc
k(oldChild)->inlineContinuation()) && |
496 (!prev || (prev->isAnonymousBlock() && prev-
>childrenInline())) && | 510 (!prev || (prev->isAnonymousBlock() && prev-
>childrenInline())) && |
497 (!next || (next->isAnonymousBlock() && next-
>childrenInline())); | 511 (!next || (next->isAnonymousBlock() && next-
>childrenInline())); |
498 if (canDeleteAnonymousBlocks && prev && next) { | 512 if (canDeleteAnonymousBlocks && prev && next) { |
499 // Take all the children out of the |next| block and put them in | 513 // Take all the children out of the |next| block and put them in |
500 // the |prev| block. | 514 // the |prev| block. |
501 prev->setNeedsLayoutAndPrefWidthsRecalc(); | 515 prev->setNeedsLayoutAndPrefWidthsRecalc(); |
502 RenderObject* o = next->firstChild(); | 516 RenderObject* o = next->firstChild(); |
| 517 |
| 518 RenderBlock* nextBlock = toRenderBlock(next); |
| 519 RenderBlock* prevBlock = toRenderBlock(prev); |
503 while (o) { | 520 while (o) { |
504 RenderObject* no = o; | 521 RenderObject* no = o; |
505 o = no->nextSibling(); | 522 o = no->nextSibling(); |
506 prev->moveChildNode(no); | 523 moveChild(prevBlock, prevBlock->children(), nextBlock, nextBlock->ch
ildren(), no); |
507 } | 524 } |
508 | 525 |
509 RenderBlock* nextBlock = toRenderBlock(next); | |
510 nextBlock->deleteLineBoxTree(); | 526 nextBlock->deleteLineBoxTree(); |
511 | 527 |
512 // Nuke the now-empty block. | 528 // Nuke the now-empty block. |
513 next->destroy(); | 529 next->destroy(); |
514 } | 530 } |
515 | 531 |
516 RenderContainer::removeChild(oldChild); | 532 RenderContainer::removeChild(oldChild); |
517 | 533 |
518 RenderObject* child = prev ? prev : next; | 534 RenderObject* child = prev ? prev : next; |
519 if (canDeleteAnonymousBlocks && child && !child->previousSibling() && !child
->nextSibling() && !isFlexibleBox()) { | 535 if (canDeleteAnonymousBlocks && child && !child->previousSibling() && !child
->nextSibling() && !isFlexibleBox()) { |
520 // The removal has knocked us down to containing only a single anonymous | 536 // The removal has knocked us down to containing only a single anonymous |
521 // box. We can go ahead and pull the content right back up into our | 537 // box. We can go ahead and pull the content right back up into our |
522 // box. | 538 // box. |
523 setNeedsLayoutAndPrefWidthsRecalc(); | 539 setNeedsLayoutAndPrefWidthsRecalc(); |
524 RenderBlock* anonBlock = toRenderBlock(removeChildNode(child, false)); | 540 RenderBlock* anonBlock = toRenderBlock(children()->removeChildNode(this,
child, false)); |
525 setChildrenInline(true); | 541 setChildrenInline(true); |
526 RenderObject* o = anonBlock->firstChild(); | 542 RenderObject* o = anonBlock->firstChild(); |
527 while (o) { | 543 while (o) { |
528 RenderObject* no = o; | 544 RenderObject* no = o; |
529 o = no->nextSibling(); | 545 o = no->nextSibling(); |
530 moveChildNode(no); | 546 moveChild(this, children(), anonBlock, anonBlock->children(), no); |
531 } | 547 } |
532 | 548 |
533 // Delete the now-empty block's lines and nuke it. | 549 // Delete the now-empty block's lines and nuke it. |
534 anonBlock->deleteLineBoxTree(); | 550 anonBlock->deleteLineBoxTree(); |
535 anonBlock->destroy(); | 551 anonBlock->destroy(); |
536 } | 552 } |
537 } | 553 } |
538 | 554 |
539 int RenderBlock::overflowHeight(bool includeInterior) const | 555 int RenderBlock::overflowHeight(bool includeInterior) const |
540 { | 556 { |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 if (child->isFloating()) { | 972 if (child->isFloating()) { |
957 handled = true; | 973 handled = true; |
958 insertFloatingObject(child); | 974 insertFloatingObject(child); |
959 adjustFloatingBlock(marginInfo); | 975 adjustFloatingBlock(marginInfo); |
960 return child->nextSiblingBox(); | 976 return child->nextSiblingBox(); |
961 } | 977 } |
962 | 978 |
963 return 0; | 979 return 0; |
964 } | 980 } |
965 | 981 |
966 RenderBox* RenderBlock::handleRunInChild(RenderBox* blockRunIn, bool& handled) | 982 RenderBox* RenderBlock::handleRunInChild(RenderBox* child, bool& handled) |
967 { | 983 { |
968 // See if we have a run-in element with inline children. If the | 984 // See if we have a run-in element with inline children. If the |
969 // children aren't inline, then just treat the run-in as a normal | 985 // children aren't inline, then just treat the run-in as a normal |
970 // block. | 986 // block. |
971 if (blockRunIn->isRunIn() && (blockRunIn->childrenInline() || blockRunIn->is
Replaced())) { | 987 if (child->isRunIn() && (child->childrenInline() || child->isReplaced())) { |
| 988 RenderBlock* blockRunIn = toRenderBlock(child); |
972 // Get the next non-positioned/non-floating RenderBlock. | 989 // Get the next non-positioned/non-floating RenderBlock. |
973 RenderObject* curr = blockRunIn->nextSibling(); | 990 RenderObject* curr = blockRunIn->nextSibling(); |
974 while (curr && curr->isFloatingOrPositioned()) | 991 while (curr && curr->isFloatingOrPositioned()) |
975 curr = curr->nextSibling(); | 992 curr = curr->nextSibling(); |
976 if (curr && (curr->isRenderBlock() && curr->childrenInline() && !curr->i
sRunIn())) { | 993 if (curr && (curr->isRenderBlock() && curr->childrenInline() && !curr->i
sRunIn())) { |
| 994 RenderBlock* currBlock = toRenderBlock(curr); |
| 995 |
977 // The block acts like an inline, so just null out its | 996 // The block acts like an inline, so just null out its |
978 // position. | 997 // position. |
979 handled = true; | 998 handled = true; |
980 | 999 |
981 // Remove the old child. | 1000 // Remove the old child. |
982 RenderBox* next = blockRunIn->nextSiblingBox(); | 1001 RenderBox* next = blockRunIn->nextSiblingBox(); |
983 removeChildNode(blockRunIn); | 1002 children()->removeChildNode(this, blockRunIn); |
984 | 1003 |
985 // Create an inline. | 1004 // Create an inline. |
986 RenderInline* inlineRunIn = new (renderArena()) RenderInline(blockRu
nIn->node()); | 1005 RenderInline* inlineRunIn = new (renderArena()) RenderInline(blockRu
nIn->node()); |
987 inlineRunIn->setStyle(blockRunIn->style()); | 1006 inlineRunIn->setStyle(blockRunIn->style()); |
988 | 1007 |
989 // Move the nodes from the old child to the new child. | 1008 // Move the nodes from the old child to the new child. |
990 for (RenderObject* runInChild = blockRunIn->firstChild(); runInChild
; runInChild = runInChild->nextSibling()) | 1009 for (RenderObject* runInChild = blockRunIn->firstChild(); runInChild
; runInChild = runInChild->nextSibling()) |
991 inlineRunIn->moveChildNode(runInChild); | 1010 moveChild(inlineRunIn, inlineRunIn->children(), blockRunIn, bloc
kRunIn->children(), runInChild); |
992 | 1011 |
993 // Now insert the new child under |curr|. | 1012 // Now insert the new child under |currBlock|. |
994 curr->insertChildNode(inlineRunIn, curr->firstChild()); | 1013 currBlock->children()->insertChildNode(currBlock, inlineRunIn, currB
lock->firstChild()); |
995 | 1014 |
996 // If the run-in had an element, we need to set the new renderer. | 1015 // If the run-in had an element, we need to set the new renderer. |
997 if (blockRunIn->element()) | 1016 if (blockRunIn->element()) |
998 blockRunIn->element()->setRenderer(inlineRunIn); | 1017 blockRunIn->element()->setRenderer(inlineRunIn); |
999 | 1018 |
1000 // Destroy the block run-in. | 1019 // Destroy the block run-in. |
1001 blockRunIn->destroy(); | 1020 blockRunIn->destroy(); |
1002 | 1021 |
1003 return next; | 1022 return next; |
1004 } | 1023 } |
(...skipping 3985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4990 return "RenderBlock (generated)"; | 5009 return "RenderBlock (generated)"; |
4991 if (isRelPositioned()) | 5010 if (isRelPositioned()) |
4992 return "RenderBlock (relative positioned)"; | 5011 return "RenderBlock (relative positioned)"; |
4993 if (isRunIn()) | 5012 if (isRunIn()) |
4994 return "RenderBlock (run-in)"; | 5013 return "RenderBlock (run-in)"; |
4995 return "RenderBlock"; | 5014 return "RenderBlock"; |
4996 } | 5015 } |
4997 | 5016 |
4998 } // namespace WebCore | 5017 } // namespace WebCore |
4999 | 5018 |
OLD | NEW |