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

Side by Side Diff: WebCore/rendering/RenderRubyRun.cpp

Issue 554075: Merge 53525 - Bug 33266 WebCore::InlineFlowBox::determineSpacingForFlowBoxes... (Closed) Base URL: svn://chrome-svn/chrome/branches/WebKit/249s/
Patch Set: Created 10 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « WebCore/rendering/RenderRubyBase.cpp ('k') | no next file » | 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 RenderBlock::removeChild(beforeChild); 141 RenderBlock::removeChild(beforeChild);
142 newRun->addChild(beforeChild); 142 newRun->addChild(beforeChild);
143 } else { 143 } else {
144 ASSERT(hasRubyBase()); // Otherwise beforeChild would be borked. 144 ASSERT(hasRubyBase()); // Otherwise beforeChild would be borked.
145 // Insertion before a ruby base object. 145 // Insertion before a ruby base object.
146 // In this case we need insert a new run before the current one and split the base. 146 // In this case we need insert a new run before the current one and split the base.
147 RenderObject* ruby = parent(); 147 RenderObject* ruby = parent();
148 RenderRubyRun* newRun = staticCreateRubyRun(ruby); 148 RenderRubyRun* newRun = staticCreateRubyRun(ruby);
149 ruby->addChild(newRun, this); 149 ruby->addChild(newRun, this);
150 newRun->addChild(child); 150 newRun->addChild(child);
151 rubyBaseSafe()->splitToLeft(newRun->rubyBaseSafe(), beforeChild); 151 rubyBaseSafe()->moveChildren(newRun->rubyBaseSafe(), beforeChild);
152 } 152 }
153 } else { 153 } else {
154 // child is not a text -> insert it into the base 154 // child is not a text -> insert it into the base
155 // (append it instead if beforeChild is the ruby text) 155 // (append it instead if beforeChild is the ruby text)
156 if (beforeChild && beforeChild->isRubyText()) 156 if (beforeChild && beforeChild->isRubyText())
157 beforeChild = 0; 157 beforeChild = 0;
158 rubyBaseSafe()->addChild(child, beforeChild); 158 rubyBaseSafe()->addChild(child, beforeChild);
159 } 159 }
160 } 160 }
161 161
162 void RenderRubyRun::removeChild(RenderObject* child) 162 void RenderRubyRun::removeChild(RenderObject* child)
163 { 163 {
164 // If the child is a ruby text, then merge the ruby base with the base of 164 // If the child is a ruby text, then merge the ruby base with the base of
165 // the right sibling run, if possible. 165 // the right sibling run, if possible.
166 if (!m_beingDestroyed && !documentBeingDestroyed() && child->isRubyText()) { 166 if (!m_beingDestroyed && !documentBeingDestroyed() && child->isRubyText()) {
167 RenderRubyBase* base = rubyBase(); 167 RenderRubyBase* base = rubyBase();
168 RenderObject* rightNeighbour = nextSibling(); 168 RenderObject* rightNeighbour = nextSibling();
169 if (base && rightNeighbour && rightNeighbour->isRubyRun()) { 169 if (base && rightNeighbour && rightNeighbour->isRubyRun()) {
170 // Ruby run without a base can happen only at the first run. 170 // Ruby run without a base can happen only at the first run.
171 RenderRubyRun* rightRun = static_cast<RenderRubyRun*>(rightNeighbour ); 171 RenderRubyRun* rightRun = static_cast<RenderRubyRun*>(rightNeighbour );
172 ASSERT(rightRun->hasRubyBase()); 172 ASSERT(rightRun->hasRubyBase());
173 base->mergeWithRight(rightRun->rubyBaseSafe()); 173 RenderRubyBase* rightBase = rightRun->rubyBaseSafe();
174 // Collect all children in a single base, then swap the bases.
175 rightBase->moveChildren(base);
176 moveChildTo(rightRun, rightRun->children(), base);
177 rightRun->moveChildTo(this, children(), rightBase);
174 // The now empty ruby base will be removed below. 178 // The now empty ruby base will be removed below.
175 } 179 }
176 } 180 }
177 181
178 RenderBlock::removeChild(child); 182 RenderBlock::removeChild(child);
179 183
180 if (!m_beingDestroyed && !documentBeingDestroyed()) { 184 if (!m_beingDestroyed && !documentBeingDestroyed()) {
181 // Check if our base (if any) is now empty. If so, destroy it. 185 // Check if our base (if any) is now empty. If so, destroy it.
182 RenderBlock* base = rubyBase(); 186 RenderBlock* base = rubyBase();
183 if (base && !base->firstChild()) { 187 if (base && !base->firstChild()) {
(...skipping 27 matching lines...) Expand all
211 ASSERT(parentRuby && parentRuby->isRuby()); 215 ASSERT(parentRuby && parentRuby->isRuby());
212 RenderRubyRun* rr = new (parentRuby->renderArena()) RenderRubyRun(parentRuby ->document() /* anonymous */); 216 RenderRubyRun* rr = new (parentRuby->renderArena()) RenderRubyRun(parentRuby ->document() /* anonymous */);
213 RefPtr<RenderStyle> newStyle = RenderStyle::create(); 217 RefPtr<RenderStyle> newStyle = RenderStyle::create();
214 newStyle->inheritFrom(parentRuby->style()); 218 newStyle->inheritFrom(parentRuby->style());
215 newStyle->setDisplay(INLINE_BLOCK); 219 newStyle->setDisplay(INLINE_BLOCK);
216 rr->setStyle(newStyle.release()); 220 rr->setStyle(newStyle.release());
217 return rr; 221 return rr;
218 } 222 }
219 223
220 } // namespace WebCore 224 } // namespace WebCore
OLDNEW
« no previous file with comments | « WebCore/rendering/RenderRubyBase.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698