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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutRuby.cpp

Issue 2770123003: Replace ASSERT with DCHECK in core/layout/ excluding subdirs (Closed)
Patch Set: Split some DCHECKs and add DCHECK_ops wherever possible Created 3 years, 8 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
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 21 matching lines...) Expand all
32 32
33 #include "core/frame/UseCounter.h" 33 #include "core/frame/UseCounter.h"
34 #include "core/layout/LayoutRubyRun.h" 34 #include "core/layout/LayoutRubyRun.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 // === generic helper functions to avoid excessive code duplication === 38 // === generic helper functions to avoid excessive code duplication ===
39 39
40 static LayoutRubyRun* lastRubyRun(const LayoutObject* ruby) { 40 static LayoutRubyRun* lastRubyRun(const LayoutObject* ruby) {
41 LayoutObject* child = ruby->slowLastChild(); 41 LayoutObject* child = ruby->slowLastChild();
42 ASSERT(!child || child->isRubyRun()); 42 DCHECK(!child || child->isRubyRun());
43 return toLayoutRubyRun(child); 43 return toLayoutRubyRun(child);
44 } 44 }
45 45
46 static inline LayoutRubyRun* findRubyRunParent(LayoutObject* child) { 46 static inline LayoutRubyRun* findRubyRunParent(LayoutObject* child) {
47 while (child && !child->isRubyRun()) 47 while (child && !child->isRubyRun())
48 child = child->parent(); 48 child = child->parent();
49 return toLayoutRubyRun(child); 49 return toLayoutRubyRun(child);
50 } 50 }
51 51
52 // === ruby as inline object === 52 // === ruby as inline object ===
(...skipping 20 matching lines...) Expand all
73 } 73 }
74 74
75 if (beforeChild) { 75 if (beforeChild) {
76 // insert child into run 76 // insert child into run
77 LayoutObject* run = beforeChild; 77 LayoutObject* run = beforeChild;
78 while (run && !run->isRubyRun()) 78 while (run && !run->isRubyRun())
79 run = run->parent(); 79 run = run->parent();
80 if (run) { 80 if (run) {
81 if (beforeChild == run) 81 if (beforeChild == run)
82 beforeChild = toLayoutRubyRun(beforeChild)->firstChild(); 82 beforeChild = toLayoutRubyRun(beforeChild)->firstChild();
83 ASSERT(!beforeChild || beforeChild->isDescendantOf(run)); 83 DCHECK(!beforeChild || beforeChild->isDescendantOf(run));
84 run->addChild(child, beforeChild); 84 run->addChild(child, beforeChild);
85 return; 85 return;
86 } 86 }
87 NOTREACHED(); // beforeChild should always have a run as parent! 87 NOTREACHED(); // beforeChild should always have a run as parent!
88 // Emergency fallback: fall through and just append. 88 // Emergency fallback: fall through and just append.
89 } 89 }
90 90
91 // If the new child would be appended, try to add the child to the previous 91 // If the new child would be appended, try to add the child to the previous
92 // run if possible, or create a new run otherwise. 92 // run if possible, or create a new run otherwise.
93 // (The LayoutRubyRun object will handle the details) 93 // (The LayoutRubyRun object will handle the details)
94 LayoutRubyRun* lastRun = lastRubyRun(this); 94 LayoutRubyRun* lastRun = lastRubyRun(this);
95 if (!lastRun || lastRun->hasRubyText()) { 95 if (!lastRun || lastRun->hasRubyText()) {
96 lastRun = LayoutRubyRun::staticCreateRubyRun(this); 96 lastRun = LayoutRubyRun::staticCreateRubyRun(this);
97 LayoutInline::addChild(lastRun, beforeChild); 97 LayoutInline::addChild(lastRun, beforeChild);
98 } 98 }
99 lastRun->addChild(child); 99 lastRun->addChild(child);
100 } 100 }
101 101
102 void LayoutRubyAsInline::removeChild(LayoutObject* child) { 102 void LayoutRubyAsInline::removeChild(LayoutObject* child) {
103 // If the child's parent is *this (must be a ruby run), just use the normal 103 // If the child's parent is *this (must be a ruby run), just use the normal
104 // remove method. 104 // remove method.
105 if (child->parent() == this) { 105 if (child->parent() == this) {
106 ASSERT(child->isRubyRun()); 106 DCHECK(child->isRubyRun());
107 LayoutInline::removeChild(child); 107 LayoutInline::removeChild(child);
108 return; 108 return;
109 } 109 }
110 110
111 // Otherwise find the containing run and remove it from there. 111 // Otherwise find the containing run and remove it from there.
112 LayoutRubyRun* run = findRubyRunParent(child); 112 LayoutRubyRun* run = findRubyRunParent(child);
113 ASSERT(run); 113 DCHECK(run);
114 run->removeChild(child); 114 run->removeChild(child);
115 } 115 }
116 116
117 // === ruby as block object === 117 // === ruby as block object ===
118 118
119 LayoutRubyAsBlock::LayoutRubyAsBlock(Element* element) 119 LayoutRubyAsBlock::LayoutRubyAsBlock(Element* element)
120 : LayoutBlockFlow(element) { 120 : LayoutBlockFlow(element) {
121 UseCounter::count(document(), UseCounter::RenderRuby); 121 UseCounter::count(document(), UseCounter::RenderRuby);
122 } 122 }
123 123
(...skipping 14 matching lines...) Expand all
138 } 138 }
139 139
140 if (beforeChild) { 140 if (beforeChild) {
141 // insert child into run 141 // insert child into run
142 LayoutObject* run = beforeChild; 142 LayoutObject* run = beforeChild;
143 while (run && !run->isRubyRun()) 143 while (run && !run->isRubyRun())
144 run = run->parent(); 144 run = run->parent();
145 if (run) { 145 if (run) {
146 if (beforeChild == run) 146 if (beforeChild == run)
147 beforeChild = toLayoutRubyRun(beforeChild)->firstChild(); 147 beforeChild = toLayoutRubyRun(beforeChild)->firstChild();
148 ASSERT(!beforeChild || beforeChild->isDescendantOf(run)); 148 DCHECK(!beforeChild || beforeChild->isDescendantOf(run));
149 run->addChild(child, beforeChild); 149 run->addChild(child, beforeChild);
150 return; 150 return;
151 } 151 }
152 NOTREACHED(); // beforeChild should always have a run as parent! 152 NOTREACHED(); // beforeChild should always have a run as parent!
153 // Emergency fallback: fall through and just append. 153 // Emergency fallback: fall through and just append.
154 } 154 }
155 155
156 // If the new child would be appended, try to add the child to the previous 156 // If the new child would be appended, try to add the child to the previous
157 // run if possible, or create a new run otherwise. 157 // run if possible, or create a new run otherwise.
158 // (The LayoutRubyRun object will handle the details) 158 // (The LayoutRubyRun object will handle the details)
159 LayoutRubyRun* lastRun = lastRubyRun(this); 159 LayoutRubyRun* lastRun = lastRubyRun(this);
160 if (!lastRun || lastRun->hasRubyText()) { 160 if (!lastRun || lastRun->hasRubyText()) {
161 lastRun = LayoutRubyRun::staticCreateRubyRun(this); 161 lastRun = LayoutRubyRun::staticCreateRubyRun(this);
162 LayoutBlockFlow::addChild(lastRun, beforeChild); 162 LayoutBlockFlow::addChild(lastRun, beforeChild);
163 } 163 }
164 lastRun->addChild(child); 164 lastRun->addChild(child);
165 } 165 }
166 166
167 void LayoutRubyAsBlock::removeChild(LayoutObject* child) { 167 void LayoutRubyAsBlock::removeChild(LayoutObject* child) {
168 // If the child's parent is *this (must be a ruby run), just use the normal 168 // If the child's parent is *this (must be a ruby run), just use the normal
169 // remove method. 169 // remove method.
170 if (child->parent() == this) { 170 if (child->parent() == this) {
171 ASSERT(child->isRubyRun()); 171 DCHECK(child->isRubyRun());
172 LayoutBlockFlow::removeChild(child); 172 LayoutBlockFlow::removeChild(child);
173 return; 173 return;
174 } 174 }
175 175
176 // Otherwise find the containing run and remove it from there. 176 // Otherwise find the containing run and remove it from there.
177 LayoutRubyRun* run = findRubyRunParent(child); 177 LayoutRubyRun* run = findRubyRunParent(child);
178 ASSERT(run); 178 DCHECK(run);
179 run->removeChild(child); 179 run->removeChild(child);
180 } 180 }
181 181
182 } // namespace blink 182 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutReplaced.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutRubyBase.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698