| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 { | 46 { |
| 47 } | 47 } |
| 48 | 48 |
| 49 LayoutRubyBase* LayoutRubyBase::createAnonymous(Document* document) | 49 LayoutRubyBase* LayoutRubyBase::createAnonymous(Document* document) |
| 50 { | 50 { |
| 51 LayoutRubyBase* layoutObject = new LayoutRubyBase(); | 51 LayoutRubyBase* layoutObject = new LayoutRubyBase(); |
| 52 layoutObject->setDocumentForAnonymous(document); | 52 layoutObject->setDocumentForAnonymous(document); |
| 53 return layoutObject; | 53 return layoutObject; |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool LayoutRubyBase::isChildAllowed(RenderObject* child, RenderStyle*) const | 56 bool LayoutRubyBase::isChildAllowed(LayoutObject* child, RenderStyle*) const |
| 57 { | 57 { |
| 58 return child->isInline(); | 58 return child->isInline(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void LayoutRubyBase::moveChildren(LayoutRubyBase* toBase, RenderObject* beforeCh
ild) | 61 void LayoutRubyBase::moveChildren(LayoutRubyBase* toBase, LayoutObject* beforeCh
ild) |
| 62 { | 62 { |
| 63 // This function removes all children that are before (!) beforeChild | 63 // This function removes all children that are before (!) beforeChild |
| 64 // and appends them to toBase. | 64 // and appends them to toBase. |
| 65 ASSERT_ARG(toBase, toBase); | 65 ASSERT_ARG(toBase, toBase); |
| 66 | 66 |
| 67 if (beforeChild && beforeChild->parent() != this) | 67 if (beforeChild && beforeChild->parent() != this) |
| 68 beforeChild = splitAnonymousBoxesAroundChild(beforeChild); | 68 beforeChild = splitAnonymousBoxesAroundChild(beforeChild); |
| 69 | 69 |
| 70 if (childrenInline()) | 70 if (childrenInline()) |
| 71 moveInlineChildren(toBase, beforeChild); | 71 moveInlineChildren(toBase, beforeChild); |
| 72 else | 72 else |
| 73 moveBlockChildren(toBase, beforeChild); | 73 moveBlockChildren(toBase, beforeChild); |
| 74 | 74 |
| 75 setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); | 75 setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); |
| 76 toBase->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); | 76 toBase->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void LayoutRubyBase::moveInlineChildren(LayoutRubyBase* toBase, RenderObject* be
foreChild) | 79 void LayoutRubyBase::moveInlineChildren(LayoutRubyBase* toBase, LayoutObject* be
foreChild) |
| 80 { | 80 { |
| 81 ASSERT(childrenInline()); | 81 ASSERT(childrenInline()); |
| 82 ASSERT_ARG(toBase, toBase); | 82 ASSERT_ARG(toBase, toBase); |
| 83 | 83 |
| 84 if (!firstChild()) | 84 if (!firstChild()) |
| 85 return; | 85 return; |
| 86 | 86 |
| 87 RenderBlock* toBlock; | 87 RenderBlock* toBlock; |
| 88 if (toBase->childrenInline()) { | 88 if (toBase->childrenInline()) { |
| 89 // The standard and easy case: move the children into the target base | 89 // The standard and easy case: move the children into the target base |
| 90 toBlock = toBase; | 90 toBlock = toBase; |
| 91 } else { | 91 } else { |
| 92 // We need to wrap the inline objects into an anonymous block. | 92 // We need to wrap the inline objects into an anonymous block. |
| 93 // If toBase has a suitable block, we re-use it, otherwise create a new
one. | 93 // If toBase has a suitable block, we re-use it, otherwise create a new
one. |
| 94 RenderObject* lastChild = toBase->lastChild(); | 94 LayoutObject* lastChild = toBase->lastChild(); |
| 95 if (lastChild && lastChild->isAnonymousBlock() && lastChild->childrenInl
ine()) { | 95 if (lastChild && lastChild->isAnonymousBlock() && lastChild->childrenInl
ine()) { |
| 96 toBlock = toRenderBlock(lastChild); | 96 toBlock = toRenderBlock(lastChild); |
| 97 } else { | 97 } else { |
| 98 toBlock = toBase->createAnonymousBlock(); | 98 toBlock = toBase->createAnonymousBlock(); |
| 99 toBase->children()->appendChildNode(toBase, toBlock); | 99 toBase->children()->appendChildNode(toBase, toBlock); |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 // Move our inline children into the target block we determined above. | 102 // Move our inline children into the target block we determined above. |
| 103 moveChildrenTo(toBlock, firstChild(), beforeChild); | 103 moveChildrenTo(toBlock, firstChild(), beforeChild); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void LayoutRubyBase::moveBlockChildren(LayoutRubyBase* toBase, RenderObject* bef
oreChild) | 106 void LayoutRubyBase::moveBlockChildren(LayoutRubyBase* toBase, LayoutObject* bef
oreChild) |
| 107 { | 107 { |
| 108 ASSERT(!childrenInline()); | 108 ASSERT(!childrenInline()); |
| 109 ASSERT_ARG(toBase, toBase); | 109 ASSERT_ARG(toBase, toBase); |
| 110 | 110 |
| 111 if (!firstChild()) | 111 if (!firstChild()) |
| 112 return; | 112 return; |
| 113 | 113 |
| 114 if (toBase->childrenInline()) | 114 if (toBase->childrenInline()) |
| 115 toBase->makeChildrenNonInline(); | 115 toBase->makeChildrenNonInline(); |
| 116 | 116 |
| 117 // If an anonymous block would be put next to another such block, then merge
those. | 117 // If an anonymous block would be put next to another such block, then merge
those. |
| 118 RenderObject* firstChildHere = firstChild(); | 118 LayoutObject* firstChildHere = firstChild(); |
| 119 RenderObject* lastChildThere = toBase->lastChild(); | 119 LayoutObject* lastChildThere = toBase->lastChild(); |
| 120 if (firstChildHere->isAnonymousBlock() && firstChildHere->childrenInline() | 120 if (firstChildHere->isAnonymousBlock() && firstChildHere->childrenInline() |
| 121 && lastChildThere && lastChildThere->isAnonymousBlock() && lastChildTher
e->childrenInline()) { | 121 && lastChildThere && lastChildThere->isAnonymousBlock() && lastChildTher
e->childrenInline()) { |
| 122 RenderBlock* anonBlockHere = toRenderBlock(firstChildHere); | 122 RenderBlock* anonBlockHere = toRenderBlock(firstChildHere); |
| 123 RenderBlock* anonBlockThere = toRenderBlock(lastChildThere); | 123 RenderBlock* anonBlockThere = toRenderBlock(lastChildThere); |
| 124 anonBlockHere->moveAllChildrenTo(anonBlockThere, anonBlockThere->childre
n()); | 124 anonBlockHere->moveAllChildrenTo(anonBlockThere, anonBlockThere->childre
n()); |
| 125 anonBlockHere->deleteLineBoxTree(); | 125 anonBlockHere->deleteLineBoxTree(); |
| 126 anonBlockHere->destroy(); | 126 anonBlockHere->destroy(); |
| 127 } | 127 } |
| 128 // Move all remaining children normally. | 128 // Move all remaining children normally. |
| 129 moveChildrenTo(toBase, firstChild(), beforeChild); | 129 moveChildrenTo(toBase, firstChild(), beforeChild); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 141 return; | 141 return; |
| 142 | 142 |
| 143 // Inset the ruby base by half the inter-ideograph expansion amount. | 143 // Inset the ruby base by half the inter-ideograph expansion amount. |
| 144 float inset = (logicalWidth - maxPreferredLogicalWidth) / (expansionOpportun
ityCount + 1); | 144 float inset = (logicalWidth - maxPreferredLogicalWidth) / (expansionOpportun
ityCount + 1); |
| 145 | 145 |
| 146 logicalLeft += inset / 2; | 146 logicalLeft += inset / 2; |
| 147 logicalWidth -= inset; | 147 logicalWidth -= inset; |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace blink | 150 } // namespace blink |
| OLD | NEW |