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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // In this case we need insert a new run before the current one and
split the base. | 124 // In this case we need insert a new run before the current one and
split the base. |
125 RenderObject* ruby = parent(); | 125 RenderObject* ruby = parent(); |
126 RenderRubyRun* newRun = staticCreateRubyRun(ruby); | 126 RenderRubyRun* newRun = staticCreateRubyRun(ruby); |
127 ruby->addChild(newRun, this); | 127 ruby->addChild(newRun, this); |
128 newRun->addChild(child); | 128 newRun->addChild(child); |
129 rubyBaseSafe()->moveChildren(newRun->rubyBaseSafe(), beforeChild); | 129 rubyBaseSafe()->moveChildren(newRun->rubyBaseSafe(), beforeChild); |
130 } | 130 } |
131 } else { | 131 } else { |
132 // child is not a text -> insert it into the base | 132 // child is not a text -> insert it into the base |
133 // (append it instead if beforeChild is the ruby text) | 133 // (append it instead if beforeChild is the ruby text) |
| 134 RenderRubyBase* base = rubyBaseSafe(); |
| 135 if (beforeChild == base) |
| 136 beforeChild = base->firstChild(); |
134 if (beforeChild && beforeChild->isRubyText()) | 137 if (beforeChild && beforeChild->isRubyText()) |
135 beforeChild = 0; | 138 beforeChild = 0; |
136 rubyBaseSafe()->addChild(child, beforeChild); | 139 ASSERT(!beforeChild || beforeChild->isDescendantOf(base)); |
| 140 base->addChild(child, beforeChild); |
137 } | 141 } |
138 } | 142 } |
139 | 143 |
140 void RenderRubyRun::removeChild(RenderObject* child) | 144 void RenderRubyRun::removeChild(RenderObject* child) |
141 { | 145 { |
142 // If the child is a ruby text, then merge the ruby base with the base of | 146 // If the child is a ruby text, then merge the ruby base with the base of |
143 // the right sibling run, if possible. | 147 // the right sibling run, if possible. |
144 if (!beingDestroyed() && !documentBeingDestroyed() && child->isRubyText()) { | 148 if (!beingDestroyed() && !documentBeingDestroyed() && child->isRubyText()) { |
145 RenderRubyBase* base = rubyBase(); | 149 RenderRubyBase* base = rubyBase(); |
146 RenderObject* rightNeighbour = nextSibling(); | 150 RenderObject* rightNeighbour = nextSibling(); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 // We can overhang the ruby by no more than half the width of the neighborin
g text | 296 // We can overhang the ruby by no more than half the width of the neighborin
g text |
293 // and no more than half the font size. | 297 // and no more than half the font size. |
294 int halfWidthOfFontSize = rubyText->style(firstLine)->fontSize() / 2; | 298 int halfWidthOfFontSize = rubyText->style(firstLine)->fontSize() / 2; |
295 if (startOverhang) | 299 if (startOverhang) |
296 startOverhang = std::min<int>(startOverhang, std::min<int>(toRenderText(
startRenderer)->minLogicalWidth(), halfWidthOfFontSize)); | 300 startOverhang = std::min<int>(startOverhang, std::min<int>(toRenderText(
startRenderer)->minLogicalWidth(), halfWidthOfFontSize)); |
297 if (endOverhang) | 301 if (endOverhang) |
298 endOverhang = std::min<int>(endOverhang, std::min<int>(toRenderText(endR
enderer)->minLogicalWidth(), halfWidthOfFontSize)); | 302 endOverhang = std::min<int>(endOverhang, std::min<int>(toRenderText(endR
enderer)->minLogicalWidth(), halfWidthOfFontSize)); |
299 } | 303 } |
300 | 304 |
301 } // namespace blink | 305 } // namespace blink |
OLD | NEW |