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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 return object | 51 return object |
52 && object->parent()->isRuby() | 52 && object->parent()->isRuby() |
53 && object->isRenderBlock() | 53 && object->isRenderBlock() |
54 && !object->isRubyRun(); | 54 && !object->isRubyRun(); |
55 } | 55 } |
56 | 56 |
57 static inline bool isRubyBeforeBlock(const RenderObject* object) | 57 static inline bool isRubyBeforeBlock(const RenderObject* object) |
58 { | 58 { |
59 return isAnonymousRubyInlineBlock(object) | 59 return isAnonymousRubyInlineBlock(object) |
60 && !object->previousSibling() | 60 && !object->previousSibling() |
61 && object->firstChild() | 61 && toRenderBlock(object)->firstChild() |
62 && object->firstChild()->style()->styleType() == BEFORE; | 62 && toRenderBlock(object)->firstChild()->style()->styleType() == BEFORE; |
63 } | 63 } |
64 | 64 |
65 static inline bool isRubyAfterBlock(const RenderObject* object) | 65 static inline bool isRubyAfterBlock(const RenderObject* object) |
66 { | 66 { |
67 return isAnonymousRubyInlineBlock(object) | 67 return isAnonymousRubyInlineBlock(object) |
68 && !object->nextSibling() | 68 && !object->nextSibling() |
69 && object->firstChild() | 69 && toRenderBlock(object)->firstChild() |
70 && object->firstChild()->style()->styleType() == AFTER; | 70 && toRenderBlock(object)->firstChild()->style()->styleType() == AFTER; |
71 } | 71 } |
72 | 72 |
73 static inline RenderBlock* rubyBeforeBlock(const RenderObject* ruby) | 73 static inline RenderBlock* rubyBeforeBlock(const RenderObject* ruby) |
74 { | 74 { |
75 RenderObject* child = ruby->firstChild(); | 75 RenderObject* child = ruby->slowFirstChild(); |
76 return isRubyBeforeBlock(child) ? toRenderBlock(child) : 0; | 76 return isRubyBeforeBlock(child) ? toRenderBlock(child) : 0; |
77 } | 77 } |
78 | 78 |
79 static inline RenderBlock* rubyAfterBlock(const RenderObject* ruby) | 79 static inline RenderBlock* rubyAfterBlock(const RenderObject* ruby) |
80 { | 80 { |
81 RenderObject* child = ruby->lastChild(); | 81 RenderObject* child = ruby->slowLastChild(); |
82 return isRubyAfterBlock(child) ? toRenderBlock(child) : 0; | 82 return isRubyAfterBlock(child) ? toRenderBlock(child) : 0; |
83 } | 83 } |
84 | 84 |
85 static RenderBlockFlow* createAnonymousRubyInlineBlock(RenderObject* ruby) | 85 static RenderBlockFlow* createAnonymousRubyInlineBlock(RenderObject* ruby) |
86 { | 86 { |
87 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(
ruby->style(), INLINE_BLOCK); | 87 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(
ruby->style(), INLINE_BLOCK); |
88 RenderBlockFlow* newBlock = RenderBlockFlow::createAnonymous(&ruby->document
()); | 88 RenderBlockFlow* newBlock = RenderBlockFlow::createAnonymous(&ruby->document
()); |
89 newBlock->setStyle(newStyle.release()); | 89 newBlock->setStyle(newStyle.release()); |
90 return newBlock; | 90 return newBlock; |
91 } | 91 } |
92 | 92 |
93 static RenderRubyRun* lastRubyRun(const RenderObject* ruby) | 93 static RenderRubyRun* lastRubyRun(const RenderObject* ruby) |
94 { | 94 { |
95 RenderObject* child = ruby->lastChild(); | 95 RenderObject* child = ruby->slowLastChild(); |
96 if (child && !child->isRubyRun()) | 96 if (child && !child->isRubyRun()) |
97 child = child->previousSibling(); | 97 child = child->previousSibling(); |
98 ASSERT(!child || child->isRubyRun() || child->isBeforeContent() || child ==
rubyBeforeBlock(ruby)); | 98 ASSERT(!child || child->isRubyRun() || child->isBeforeContent() || child ==
rubyBeforeBlock(ruby)); |
99 return child && child->isRubyRun() ? toRenderRubyRun(child) : 0; | 99 return child && child->isRubyRun() ? toRenderRubyRun(child) : 0; |
100 } | 100 } |
101 | 101 |
102 static inline RenderRubyRun* findRubyRunParent(RenderObject* child) | 102 static inline RenderRubyRun* findRubyRunParent(RenderObject* child) |
103 { | 103 { |
104 while (child && !child->isRubyRun()) | 104 while (child && !child->isRubyRun()) |
105 child = child->parent(); | 105 child = child->parent(); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |