Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1327)

Side by Side Diff: Source/core/rendering/RenderRuby.cpp

Issue 163513002: Have RenderBlockFlow sub-classes' methods call their super-class method properly. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/rendering/RenderRegion.cpp ('k') | Source/core/rendering/RenderRubyRun.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 : RenderBlockFlow(element) 218 : RenderBlockFlow(element)
219 { 219 {
220 } 220 }
221 221
222 RenderRubyAsBlock::~RenderRubyAsBlock() 222 RenderRubyAsBlock::~RenderRubyAsBlock()
223 { 223 {
224 } 224 }
225 225
226 void RenderRubyAsBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) 226 void RenderRubyAsBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
227 { 227 {
228 RenderBlock::styleDidChange(diff, oldStyle); 228 RenderBlockFlow::styleDidChange(diff, oldStyle);
229 propagateStyleToAnonymousChildren(); 229 propagateStyleToAnonymousChildren();
230 } 230 }
231 231
232 void RenderRubyAsBlock::addChild(RenderObject* child, RenderObject* beforeChild) 232 void RenderRubyAsBlock::addChild(RenderObject* child, RenderObject* beforeChild)
233 { 233 {
234 // Insert :before and :after content before/after the RenderRubyRun(s) 234 // Insert :before and :after content before/after the RenderRubyRun(s)
235 if (child->isBeforeContent()) { 235 if (child->isBeforeContent()) {
236 if (child->isInline()) { 236 if (child->isInline()) {
237 // Add generated inline content normally 237 // Add generated inline content normally
238 RenderBlock::addChild(child, firstChild()); 238 RenderBlockFlow::addChild(child, firstChild());
239 } else { 239 } else {
240 // Wrap non-inline content with an anonymous inline-block. 240 // Wrap non-inline content with an anonymous inline-block.
241 RenderBlock* beforeBlock = rubyBeforeBlock(this); 241 RenderBlock* beforeBlock = rubyBeforeBlock(this);
242 if (!beforeBlock) { 242 if (!beforeBlock) {
243 beforeBlock = createAnonymousRubyInlineBlock(this); 243 beforeBlock = createAnonymousRubyInlineBlock(this);
244 RenderBlock::addChild(beforeBlock, firstChild()); 244 RenderBlockFlow::addChild(beforeBlock, firstChild());
245 } 245 }
246 beforeBlock->addChild(child); 246 beforeBlock->addChild(child);
247 } 247 }
248 return; 248 return;
249 } 249 }
250 if (child->isAfterContent()) { 250 if (child->isAfterContent()) {
251 if (child->isInline()) { 251 if (child->isInline()) {
252 // Add generated inline content normally 252 // Add generated inline content normally
253 RenderBlock::addChild(child); 253 RenderBlockFlow::addChild(child);
254 } else { 254 } else {
255 // Wrap non-inline content with an anonymous inline-block. 255 // Wrap non-inline content with an anonymous inline-block.
256 RenderBlock* afterBlock = rubyAfterBlock(this); 256 RenderBlock* afterBlock = rubyAfterBlock(this);
257 if (!afterBlock) { 257 if (!afterBlock) {
258 afterBlock = createAnonymousRubyInlineBlock(this); 258 afterBlock = createAnonymousRubyInlineBlock(this);
259 RenderBlock::addChild(afterBlock); 259 RenderBlockFlow::addChild(afterBlock);
260 } 260 }
261 afterBlock->addChild(child); 261 afterBlock->addChild(child);
262 } 262 }
263 return; 263 return;
264 } 264 }
265 265
266 // If the child is a ruby run, just add it normally. 266 // If the child is a ruby run, just add it normally.
267 if (child->isRubyRun()) { 267 if (child->isRubyRun()) {
268 RenderBlock::addChild(child, beforeChild); 268 RenderBlockFlow::addChild(child, beforeChild);
269 return; 269 return;
270 } 270 }
271 271
272 if (beforeChild && !isAfterContent(beforeChild)) { 272 if (beforeChild && !isAfterContent(beforeChild)) {
273 // insert child into run 273 // insert child into run
274 ASSERT(!beforeChild->isRubyRun()); 274 ASSERT(!beforeChild->isRubyRun());
275 RenderObject* run = beforeChild; 275 RenderObject* run = beforeChild;
276 while (run && !run->isRubyRun()) 276 while (run && !run->isRubyRun())
277 run = run->parent(); 277 run = run->parent();
278 if (run) { 278 if (run) {
279 run->addChild(child, beforeChild); 279 run->addChild(child, beforeChild);
280 return; 280 return;
281 } 281 }
282 ASSERT_NOT_REACHED(); // beforeChild should always have a run as parent! 282 ASSERT_NOT_REACHED(); // beforeChild should always have a run as parent!
283 // Emergency fallback: fall through and just append. 283 // Emergency fallback: fall through and just append.
284 } 284 }
285 285
286 // If the new child would be appended, try to add the child to the previous run 286 // If the new child would be appended, try to add the child to the previous run
287 // if possible, or create a new run otherwise. 287 // if possible, or create a new run otherwise.
288 // (The RenderRubyRun object will handle the details) 288 // (The RenderRubyRun object will handle the details)
289 RenderRubyRun* lastRun = lastRubyRun(this); 289 RenderRubyRun* lastRun = lastRubyRun(this);
290 if (!lastRun || lastRun->hasRubyText()) { 290 if (!lastRun || lastRun->hasRubyText()) {
291 lastRun = RenderRubyRun::staticCreateRubyRun(this); 291 lastRun = RenderRubyRun::staticCreateRubyRun(this);
292 RenderBlock::addChild(lastRun, beforeChild); 292 RenderBlockFlow::addChild(lastRun, beforeChild);
293 } 293 }
294 lastRun->addChild(child); 294 lastRun->addChild(child);
295 } 295 }
296 296
297 void RenderRubyAsBlock::removeChild(RenderObject* child) 297 void RenderRubyAsBlock::removeChild(RenderObject* child)
298 { 298 {
299 // If the child's parent is *this (must be a ruby run or generated content o r anonymous block), 299 // If the child's parent is *this (must be a ruby run or generated content o r anonymous block),
300 // just use the normal remove method. 300 // just use the normal remove method.
301 if (child->parent() == this) { 301 if (child->parent() == this) {
302 ASSERT(child->isRubyRun() || child->isBeforeContent() || child->isAfterC ontent() || isAnonymousRubyInlineBlock(child)); 302 ASSERT(child->isRubyRun() || child->isBeforeContent() || child->isAfterC ontent() || isAnonymousRubyInlineBlock(child));
303 RenderBlock::removeChild(child); 303 RenderBlockFlow::removeChild(child);
304 return; 304 return;
305 } 305 }
306 // If the child's parent is an anoymous block (must be generated :before/:af ter content) 306 // If the child's parent is an anoymous block (must be generated :before/:af ter content)
307 // just use the block's remove method. 307 // just use the block's remove method.
308 if (isAnonymousRubyInlineBlock(child->parent())) { 308 if (isAnonymousRubyInlineBlock(child->parent())) {
309 ASSERT(child->isBeforeContent() || child->isAfterContent()); 309 ASSERT(child->isBeforeContent() || child->isAfterContent());
310 child->parent()->removeChild(child); 310 child->parent()->removeChild(child);
311 removeChild(child->parent()); 311 removeChild(child->parent());
312 return; 312 return;
313 } 313 }
314 314
315 // Otherwise find the containing run and remove it from there. 315 // Otherwise find the containing run and remove it from there.
316 RenderRubyRun* run = findRubyRunParent(child); 316 RenderRubyRun* run = findRubyRunParent(child);
317 ASSERT(run); 317 ASSERT(run);
318 run->removeChild(child); 318 run->removeChild(child);
319 } 319 }
320 320
321 } // namespace WebCore 321 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderRegion.cpp ('k') | Source/core/rendering/RenderRubyRun.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698