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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 const ComputedStyle&) const { | 48 const ComputedStyle&) const { |
49 return child->isInline(); | 49 return child->isInline(); |
50 } | 50 } |
51 | 51 |
52 void LayoutRubyBase::moveChildren(LayoutRubyBase* toBase, | 52 void LayoutRubyBase::moveChildren(LayoutRubyBase* toBase, |
53 LayoutObject* beforeChild) { | 53 LayoutObject* beforeChild) { |
54 // This function removes all children that are before (!) beforeChild | 54 // This function removes all children that are before (!) beforeChild |
55 // and appends them to toBase. | 55 // and appends them to toBase. |
56 DCHECK(toBase); | 56 DCHECK(toBase); |
57 // Callers should have handled the percent height descendant map. | 57 // Callers should have handled the percent height descendant map. |
58 ASSERT(!hasPercentHeightDescendants()); | 58 DCHECK(!hasPercentHeightDescendants()); |
59 | 59 |
60 if (beforeChild && beforeChild->parent() != this) | 60 if (beforeChild && beforeChild->parent() != this) |
61 beforeChild = splitAnonymousBoxesAroundChild(beforeChild); | 61 beforeChild = splitAnonymousBoxesAroundChild(beforeChild); |
62 | 62 |
63 if (childrenInline()) | 63 if (childrenInline()) |
64 moveInlineChildren(toBase, beforeChild); | 64 moveInlineChildren(toBase, beforeChild); |
65 else | 65 else |
66 moveBlockChildren(toBase, beforeChild); | 66 moveBlockChildren(toBase, beforeChild); |
67 | 67 |
68 setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( | 68 setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( |
69 LayoutInvalidationReason::Unknown); | 69 LayoutInvalidationReason::Unknown); |
70 toBase->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( | 70 toBase->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( |
71 LayoutInvalidationReason::Unknown); | 71 LayoutInvalidationReason::Unknown); |
72 } | 72 } |
73 | 73 |
74 void LayoutRubyBase::moveInlineChildren(LayoutRubyBase* toBase, | 74 void LayoutRubyBase::moveInlineChildren(LayoutRubyBase* toBase, |
75 LayoutObject* beforeChild) { | 75 LayoutObject* beforeChild) { |
76 ASSERT(childrenInline()); | 76 DCHECK(childrenInline()); |
77 DCHECK(toBase); | 77 DCHECK(toBase); |
78 | 78 |
79 if (!firstChild()) | 79 if (!firstChild()) |
80 return; | 80 return; |
81 | 81 |
82 LayoutBlock* toBlock; | 82 LayoutBlock* toBlock; |
83 if (toBase->childrenInline()) { | 83 if (toBase->childrenInline()) { |
84 // The standard and easy case: move the children into the target base | 84 // The standard and easy case: move the children into the target base |
85 toBlock = toBase; | 85 toBlock = toBase; |
86 } else { | 86 } else { |
87 // We need to wrap the inline objects into an anonymous block. | 87 // We need to wrap the inline objects into an anonymous block. |
88 // If toBase has a suitable block, we re-use it, otherwise create a new one. | 88 // If toBase has a suitable block, we re-use it, otherwise create a new one. |
89 LayoutObject* lastChild = toBase->lastChild(); | 89 LayoutObject* lastChild = toBase->lastChild(); |
90 if (lastChild && lastChild->isAnonymousBlock() && | 90 if (lastChild && lastChild->isAnonymousBlock() && |
91 lastChild->childrenInline()) { | 91 lastChild->childrenInline()) { |
92 toBlock = toLayoutBlock(lastChild); | 92 toBlock = toLayoutBlock(lastChild); |
93 } else { | 93 } else { |
94 toBlock = toBase->createAnonymousBlock(); | 94 toBlock = toBase->createAnonymousBlock(); |
95 toBase->children()->appendChildNode(toBase, toBlock); | 95 toBase->children()->appendChildNode(toBase, toBlock); |
96 } | 96 } |
97 } | 97 } |
98 // Move our inline children into the target block we determined above. | 98 // Move our inline children into the target block we determined above. |
99 moveChildrenTo(toBlock, firstChild(), beforeChild); | 99 moveChildrenTo(toBlock, firstChild(), beforeChild); |
100 } | 100 } |
101 | 101 |
102 void LayoutRubyBase::moveBlockChildren(LayoutRubyBase* toBase, | 102 void LayoutRubyBase::moveBlockChildren(LayoutRubyBase* toBase, |
103 LayoutObject* beforeChild) { | 103 LayoutObject* beforeChild) { |
104 ASSERT(!childrenInline()); | 104 DCHECK(!childrenInline()); |
105 DCHECK(toBase); | 105 DCHECK(toBase); |
106 | 106 |
107 if (!firstChild()) | 107 if (!firstChild()) |
108 return; | 108 return; |
109 | 109 |
110 if (toBase->childrenInline()) | 110 if (toBase->childrenInline()) |
111 toBase->makeChildrenNonInline(); | 111 toBase->makeChildrenNonInline(); |
112 | 112 |
113 // If an anonymous block would be put next to another such block, then merge | 113 // If an anonymous block would be put next to another such block, then merge |
114 // those. | 114 // those. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 153 |
154 // Inset the ruby base by half the inter-ideograph expansion amount. | 154 // Inset the ruby base by half the inter-ideograph expansion amount. |
155 LayoutUnit inset = (logicalWidth - maxPreferredLogicalWidth) / | 155 LayoutUnit inset = (logicalWidth - maxPreferredLogicalWidth) / |
156 (expansionOpportunityCount + 1); | 156 (expansionOpportunityCount + 1); |
157 | 157 |
158 logicalLeft += inset / 2; | 158 logicalLeft += inset / 2; |
159 logicalWidth -= inset; | 159 logicalWidth -= inset; |
160 } | 160 } |
161 | 161 |
162 } // namespace blink | 162 } // namespace blink |
OLD | NEW |