OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 if (oldContentPresent) { | 381 if (oldContentPresent) { |
382 if (child && child->style()->styleType() == type) { | 382 if (child && child->style()->styleType() == type) { |
383 // We have generated content present still. We want to walk this co
ntent and update our | 383 // We have generated content present still. We want to walk this co
ntent and update our |
384 // style information with the new pseudo-element style. | 384 // style information with the new pseudo-element style. |
385 child->setStyle(pseudoElementStyle); | 385 child->setStyle(pseudoElementStyle); |
386 | 386 |
387 RenderObject* beforeAfterParent = findBeforeAfterParent(child); | 387 RenderObject* beforeAfterParent = findBeforeAfterParent(child); |
388 if (!beforeAfterParent) | 388 if (!beforeAfterParent) |
389 return; | 389 return; |
390 | 390 |
| 391 // When beforeAfterParent is not equal to child (e.g. in tables), |
| 392 // we need to create new styles inheriting from pseudoElementStyle |
| 393 // on all the intermediate parents (leaving their display same). |
| 394 if (beforeAfterParent != child) { |
| 395 RenderObject* curr = beforeAfterParent; |
| 396 while (curr && curr != child) { |
| 397 ASSERT(curr->isAnonymous()); |
| 398 RefPtr<RenderStyle> newStyle = RenderStyle::create(); |
| 399 newStyle->inheritFrom(pseudoElementStyle); |
| 400 newStyle->setDisplay(curr->style()->display()); |
| 401 curr->setStyle(newStyle); |
| 402 curr = curr->parent(); |
| 403 } |
| 404 } |
| 405 |
391 // Note that if we ever support additional types of generated conten
t (which should be way off | 406 // Note that if we ever support additional types of generated conten
t (which should be way off |
392 // in the future), this code will need to be patched. | 407 // in the future), this code will need to be patched. |
393 for (RenderObject* genChild = beforeAfterParent->firstChild(); genCh
ild; genChild = genChild->nextSibling()) { | 408 for (RenderObject* genChild = beforeAfterParent->firstChild(); genCh
ild; genChild = genChild->nextSibling()) { |
394 if (genChild->isText()) | 409 if (genChild->isText()) |
395 // Generated text content is a child whose style also needs
to be set to the pseudo-element style. | 410 // Generated text content is a child whose style also needs
to be set to the pseudo-element style. |
396 genChild->setStyle(pseudoElementStyle); | 411 genChild->setStyle(pseudoElementStyle); |
397 else if (genChild->isImage()) { | 412 else if (genChild->isImage()) { |
398 // Images get an empty style that inherits from the pseudo. | 413 // Images get an empty style that inherits from the pseudo. |
399 RefPtr<RenderStyle> style = RenderStyle::create(); | 414 RefPtr<RenderStyle> style = RenderStyle::create(); |
400 style->inheritFrom(pseudoElementStyle); | 415 style->inheritFrom(pseudoElementStyle); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 } | 480 } |
466 if (generatedContentContainer->isChildAllowed(renderer, pseudoElemen
tStyle)) | 481 if (generatedContentContainer->isChildAllowed(renderer, pseudoElemen
tStyle)) |
467 generatedContentContainer->addChild(renderer); | 482 generatedContentContainer->addChild(renderer); |
468 else | 483 else |
469 renderer->destroy(); | 484 renderer->destroy(); |
470 } | 485 } |
471 } | 486 } |
472 } | 487 } |
473 | 488 |
474 } // namespace WebCore | 489 } // namespace WebCore |
OLD | NEW |