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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 if (beforeChild == run) | 81 if (beforeChild == run) |
82 beforeChild = toLayoutRubyRun(beforeChild)->firstChild(); | 82 beforeChild = toLayoutRubyRun(beforeChild)->firstChild(); |
83 ASSERT(!beforeChild || beforeChild->isDescendantOf(run)); | 83 ASSERT(!beforeChild || beforeChild->isDescendantOf(run)); |
84 run->addChild(child, beforeChild); | 84 run->addChild(child, beforeChild); |
85 return; | 85 return; |
86 } | 86 } |
87 ASSERT_NOT_REACHED(); // beforeChild should always have a run as parent! | 87 ASSERT_NOT_REACHED(); // beforeChild should always have a run as parent! |
88 // Emergency fallback: fall through and just append. | 88 // Emergency fallback: fall through and just append. |
89 } | 89 } |
90 | 90 |
91 // If the new child would be appended, try to add the child to the previous ru
n | 91 // If the new child would be appended, try to add the child to the previous |
92 // if possible, or create a new run otherwise. | 92 // run if possible, or create a new run otherwise. |
93 // (The LayoutRubyRun object will handle the details) | 93 // (The LayoutRubyRun object will handle the details) |
94 LayoutRubyRun* lastRun = lastRubyRun(this); | 94 LayoutRubyRun* lastRun = lastRubyRun(this); |
95 if (!lastRun || lastRun->hasRubyText()) { | 95 if (!lastRun || lastRun->hasRubyText()) { |
96 lastRun = LayoutRubyRun::staticCreateRubyRun(this); | 96 lastRun = LayoutRubyRun::staticCreateRubyRun(this); |
97 LayoutInline::addChild(lastRun, beforeChild); | 97 LayoutInline::addChild(lastRun, beforeChild); |
98 } | 98 } |
99 lastRun->addChild(child); | 99 lastRun->addChild(child); |
100 } | 100 } |
101 | 101 |
102 void LayoutRubyAsInline::removeChild(LayoutObject* child) { | 102 void LayoutRubyAsInline::removeChild(LayoutObject* child) { |
103 // If the child's parent is *this (must be a ruby run), just use the normal re
move method. | 103 // If the child's parent is *this (must be a ruby run), just use the normal |
| 104 // remove method. |
104 if (child->parent() == this) { | 105 if (child->parent() == this) { |
105 ASSERT(child->isRubyRun()); | 106 ASSERT(child->isRubyRun()); |
106 LayoutInline::removeChild(child); | 107 LayoutInline::removeChild(child); |
107 return; | 108 return; |
108 } | 109 } |
109 | 110 |
110 // Otherwise find the containing run and remove it from there. | 111 // Otherwise find the containing run and remove it from there. |
111 LayoutRubyRun* run = findRubyRunParent(child); | 112 LayoutRubyRun* run = findRubyRunParent(child); |
112 ASSERT(run); | 113 ASSERT(run); |
113 run->removeChild(child); | 114 run->removeChild(child); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 if (beforeChild == run) | 146 if (beforeChild == run) |
146 beforeChild = toLayoutRubyRun(beforeChild)->firstChild(); | 147 beforeChild = toLayoutRubyRun(beforeChild)->firstChild(); |
147 ASSERT(!beforeChild || beforeChild->isDescendantOf(run)); | 148 ASSERT(!beforeChild || beforeChild->isDescendantOf(run)); |
148 run->addChild(child, beforeChild); | 149 run->addChild(child, beforeChild); |
149 return; | 150 return; |
150 } | 151 } |
151 ASSERT_NOT_REACHED(); // beforeChild should always have a run as parent! | 152 ASSERT_NOT_REACHED(); // beforeChild should always have a run as parent! |
152 // Emergency fallback: fall through and just append. | 153 // Emergency fallback: fall through and just append. |
153 } | 154 } |
154 | 155 |
155 // If the new child would be appended, try to add the child to the previous ru
n | 156 // If the new child would be appended, try to add the child to the previous |
156 // if possible, or create a new run otherwise. | 157 // run if possible, or create a new run otherwise. |
157 // (The LayoutRubyRun object will handle the details) | 158 // (The LayoutRubyRun object will handle the details) |
158 LayoutRubyRun* lastRun = lastRubyRun(this); | 159 LayoutRubyRun* lastRun = lastRubyRun(this); |
159 if (!lastRun || lastRun->hasRubyText()) { | 160 if (!lastRun || lastRun->hasRubyText()) { |
160 lastRun = LayoutRubyRun::staticCreateRubyRun(this); | 161 lastRun = LayoutRubyRun::staticCreateRubyRun(this); |
161 LayoutBlockFlow::addChild(lastRun, beforeChild); | 162 LayoutBlockFlow::addChild(lastRun, beforeChild); |
162 } | 163 } |
163 lastRun->addChild(child); | 164 lastRun->addChild(child); |
164 } | 165 } |
165 | 166 |
166 void LayoutRubyAsBlock::removeChild(LayoutObject* child) { | 167 void LayoutRubyAsBlock::removeChild(LayoutObject* child) { |
167 // If the child's parent is *this (must be a ruby run), just use the normal re
move method. | 168 // If the child's parent is *this (must be a ruby run), just use the normal |
| 169 // remove method. |
168 if (child->parent() == this) { | 170 if (child->parent() == this) { |
169 ASSERT(child->isRubyRun()); | 171 ASSERT(child->isRubyRun()); |
170 LayoutBlockFlow::removeChild(child); | 172 LayoutBlockFlow::removeChild(child); |
171 return; | 173 return; |
172 } | 174 } |
173 | 175 |
174 // Otherwise find the containing run and remove it from there. | 176 // Otherwise find the containing run and remove it from there. |
175 LayoutRubyRun* run = findRubyRunParent(child); | 177 LayoutRubyRun* run = findRubyRunParent(child); |
176 ASSERT(run); | 178 ASSERT(run); |
177 run->removeChild(child); | 179 run->removeChild(child); |
178 } | 180 } |
179 | 181 |
180 } // namespace blink | 182 } // namespace blink |
OLD | NEW |