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

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

Issue 170603003: Use nullptr_t for RefPtr, PassRefPtr and RawPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final rebase 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 | Annotate | Revision Log
OLDNEW
1 /** 1 /**
2 * Copyright (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 2 * Copyright (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 182
183 static bool findPlaceForCounter(RenderObject& counterOwner, const AtomicString& identifier, bool isReset, RefPtr<CounterNode>& parent, RefPtr<CounterNode>& prev iousSibling) 183 static bool findPlaceForCounter(RenderObject& counterOwner, const AtomicString& identifier, bool isReset, RefPtr<CounterNode>& parent, RefPtr<CounterNode>& prev iousSibling)
184 { 184 {
185 // We cannot stop searching for counters with the same identifier before we also 185 // We cannot stop searching for counters with the same identifier before we also
186 // check this renderer, because it may affect the positioning in the tree of our counter. 186 // check this renderer, because it may affect the positioning in the tree of our counter.
187 RenderObject* searchEndRenderer = previousSiblingOrParent(counterOwner); 187 RenderObject* searchEndRenderer = previousSiblingOrParent(counterOwner);
188 // We check renderers in preOrder from the renderer that our counter is atta ched to 188 // We check renderers in preOrder from the renderer that our counter is atta ched to
189 // towards the begining of the document for counters with the same identifie r as the one 189 // towards the begining of the document for counters with the same identifie r as the one
190 // we are trying to find a place for. This is the next renderer to be checke d. 190 // we are trying to find a place for. This is the next renderer to be checke d.
191 RenderObject* currentRenderer = previousInPreOrder(counterOwner); 191 RenderObject* currentRenderer = previousInPreOrder(counterOwner);
192 previousSibling = 0; 192 previousSibling = nullptr;
193 RefPtr<CounterNode> previousSiblingProtector = 0; 193 RefPtr<CounterNode> previousSiblingProtector = nullptr;
194 194
195 while (currentRenderer) { 195 while (currentRenderer) {
196 CounterNode* currentCounter = makeCounterNode(*currentRenderer, identifi er, false); 196 CounterNode* currentCounter = makeCounterNode(*currentRenderer, identifi er, false);
197 if (searchEndRenderer == currentRenderer) { 197 if (searchEndRenderer == currentRenderer) {
198 // We may be at the end of our search. 198 // We may be at the end of our search.
199 if (currentCounter) { 199 if (currentCounter) {
200 // We have a suitable counter on the EndSearchRenderer. 200 // We have a suitable counter on the EndSearchRenderer.
201 if (previousSiblingProtector) { // But we already found another counter that we come after. 201 if (previousSiblingProtector) { // But we already found another counter that we come after.
202 if (currentCounter->actsAsReset()) { 202 if (currentCounter->actsAsReset()) {
203 // We found a reset counter that is on a renderer that i s a sibling of ours or a parent. 203 // We found a reset counter that is on a renderer that i s a sibling of ours or a parent.
204 if (isReset && areRenderersElementsSiblings(*currentRend erer, counterOwner)) { 204 if (isReset && areRenderersElementsSiblings(*currentRend erer, counterOwner)) {
205 // We are also a reset counter and the previous rese t was on a sibling renderer 205 // We are also a reset counter and the previous rese t was on a sibling renderer
206 // hence we are the next sibling of that counter if that reset is not a root or 206 // hence we are the next sibling of that counter if that reset is not a root or
207 // we are a root node if that reset is a root. 207 // we are a root node if that reset is a root.
208 parent = currentCounter->parent(); 208 parent = currentCounter->parent();
209 previousSibling = parent ? currentCounter : 0; 209 previousSibling = parent ? currentCounter : 0;
210 return parent; 210 return parent;
211 } 211 }
212 // We are not a reset node or the previous reset must be on an ancestor of our owner renderer 212 // We are not a reset node or the previous reset must be on an ancestor of our owner renderer
213 // hence we must be a child of that reset counter. 213 // hence we must be a child of that reset counter.
214 parent = currentCounter; 214 parent = currentCounter;
215 // In some cases renders can be reparented (ex. nodes in side a table but not in a column or row). 215 // In some cases renders can be reparented (ex. nodes in side a table but not in a column or row).
216 // In these cases the identified previousSibling will be invalid as its parent is different from 216 // In these cases the identified previousSibling will be invalid as its parent is different from
217 // our identified parent. 217 // our identified parent.
218 if (previousSiblingProtector->parent() != currentCounter ) 218 if (previousSiblingProtector->parent() != currentCounter )
219 previousSiblingProtector = 0; 219 previousSiblingProtector = nullptr;
220 220
221 previousSibling = previousSiblingProtector.get(); 221 previousSibling = previousSiblingProtector.get();
222 return true; 222 return true;
223 } 223 }
224 // CurrentCounter, the counter at the EndSearchRenderer, is not reset. 224 // CurrentCounter, the counter at the EndSearchRenderer, is not reset.
225 if (!isReset || !areRenderersElementsSiblings(*currentRender er, counterOwner)) { 225 if (!isReset || !areRenderersElementsSiblings(*currentRender er, counterOwner)) {
226 // If the node we are placing is not reset or we have fo und a counter that is attached 226 // If the node we are placing is not reset or we have fo und a counter that is attached
227 // to an ancestor of the placed counter's owner renderer we know we are a sibling of that node. 227 // to an ancestor of the placed counter's owner renderer we know we are a sibling of that node.
228 if (currentCounter->parent() != previousSiblingProtector ->parent()) 228 if (currentCounter->parent() != previousSiblingProtector ->parent())
229 return false; 229 return false;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 if (CounterNode* node = nodeMap->get(identifier)) 300 if (CounterNode* node = nodeMap->get(identifier))
301 return node; 301 return node;
302 } 302 }
303 } 303 }
304 304
305 bool isReset = false; 305 bool isReset = false;
306 int value = 0; 306 int value = 0;
307 if (!planCounter(object, identifier, isReset, value) && !alwaysCreateCounter ) 307 if (!planCounter(object, identifier, isReset, value) && !alwaysCreateCounter )
308 return 0; 308 return 0;
309 309
310 RefPtr<CounterNode> newParent = 0; 310 RefPtr<CounterNode> newParent = nullptr;
311 RefPtr<CounterNode> newPreviousSibling = 0; 311 RefPtr<CounterNode> newPreviousSibling = nullptr;
312 RefPtr<CounterNode> newNode = CounterNode::create(object, isReset, value); 312 RefPtr<CounterNode> newNode = CounterNode::create(object, isReset, value);
313 if (findPlaceForCounter(object, identifier, isReset, newParent, newPreviousS ibling)) 313 if (findPlaceForCounter(object, identifier, isReset, newParent, newPreviousS ibling))
314 newParent->insertAfter(newNode.get(), newPreviousSibling.get(), identifi er); 314 newParent->insertAfter(newNode.get(), newPreviousSibling.get(), identifi er);
315 CounterMap* nodeMap; 315 CounterMap* nodeMap;
316 if (object.hasCounterNodeMap()) 316 if (object.hasCounterNodeMap())
317 nodeMap = counterMaps().get(&object); 317 nodeMap = counterMaps().get(&object);
318 else { 318 else {
319 nodeMap = new CounterMap; 319 nodeMap = new CounterMap;
320 counterMaps().set(&object, adoptPtr(nodeMap)); 320 counterMaps().set(&object, adoptPtr(nodeMap));
321 object.setHasCounterNodeMap(true); 321 object.setHasCounterNodeMap(true);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 { 378 {
379 return true; 379 return true;
380 } 380 }
381 381
382 PassRefPtr<StringImpl> RenderCounter::originalText() const 382 PassRefPtr<StringImpl> RenderCounter::originalText() const
383 { 383 {
384 if (!m_counterNode) { 384 if (!m_counterNode) {
385 RenderObject* beforeAfterContainer = parent(); 385 RenderObject* beforeAfterContainer = parent();
386 while (true) { 386 while (true) {
387 if (!beforeAfterContainer) 387 if (!beforeAfterContainer)
388 return 0; 388 return nullptr;
389 if (!beforeAfterContainer->isAnonymous() && !beforeAfterContainer->i sPseudoElement()) 389 if (!beforeAfterContainer->isAnonymous() && !beforeAfterContainer->i sPseudoElement())
390 return 0; // RenderCounters are restricted to before and after p seudo elements 390 return nullptr; // RenderCounters are restricted to before and a fter pseudo elements
391 PseudoId containerStyle = beforeAfterContainer->style()->styleType() ; 391 PseudoId containerStyle = beforeAfterContainer->style()->styleType() ;
392 if ((containerStyle == BEFORE) || (containerStyle == AFTER)) 392 if ((containerStyle == BEFORE) || (containerStyle == AFTER))
393 break; 393 break;
394 beforeAfterContainer = beforeAfterContainer->parent(); 394 beforeAfterContainer = beforeAfterContainer->parent();
395 } 395 }
396 makeCounterNode(*beforeAfterContainer, m_counter.identifier(), true)->ad dRenderer(const_cast<RenderCounter*>(this)); 396 makeCounterNode(*beforeAfterContainer, m_counter.identifier(), true)->ad dRenderer(const_cast<RenderCounter*>(this));
397 ASSERT(m_counterNode); 397 ASSERT(m_counterNode);
398 } 398 }
399 CounterNode* child = m_counterNode; 399 CounterNode* child = m_counterNode;
400 int value = child->actsAsReset() ? child->value() : child->countInParent(); 400 int value = child->actsAsReset() ? child->value() : child->countInParent();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 return; 508 return;
509 } 509 }
510 CounterMap* counterMap = counterMaps().get(&renderer); 510 CounterMap* counterMap = counterMaps().get(&renderer);
511 ASSERT(counterMap); 511 ASSERT(counterMap);
512 for (CounterDirectiveMap::const_iterator it = directiveMap->begin(); it != e nd; ++it) { 512 for (CounterDirectiveMap::const_iterator it = directiveMap->begin(); it != e nd; ++it) {
513 RefPtr<CounterNode> node = counterMap->get(it->key); 513 RefPtr<CounterNode> node = counterMap->get(it->key);
514 if (!node) { 514 if (!node) {
515 makeCounterNode(renderer, it->key, false); 515 makeCounterNode(renderer, it->key, false);
516 continue; 516 continue;
517 } 517 }
518 RefPtr<CounterNode> newParent = 0; 518 RefPtr<CounterNode> newParent = nullptr;
519 RefPtr<CounterNode> newPreviousSibling = 0; 519 RefPtr<CounterNode> newPreviousSibling = nullptr;
520 520
521 findPlaceForCounter(renderer, it->key, node->hasResetType(), newParent, newPreviousSibling); 521 findPlaceForCounter(renderer, it->key, node->hasResetType(), newParent, newPreviousSibling);
522 if (node != counterMap->get(it->key)) 522 if (node != counterMap->get(it->key))
523 continue; 523 continue;
524 CounterNode* parent = node->parent(); 524 CounterNode* parent = node->parent();
525 if (newParent == parent && newPreviousSibling == node->previousSibling() ) 525 if (newParent == parent && newPreviousSibling == node->previousSibling() )
526 continue; 526 continue;
527 if (parent) 527 if (parent)
528 parent->removeChild(node.get()); 528 parent->removeChild(node.get());
529 if (newParent) 529 if (newParent)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 fprintf(stderr, " "); 609 fprintf(stderr, " ");
610 fprintf(stderr, "%p N:%p P:%p PS:%p NS:%p C:%p\n", 610 fprintf(stderr, "%p N:%p P:%p PS:%p NS:%p C:%p\n",
611 current, current->node(), current->parent(), current->previousSiblin g(), 611 current, current->node(), current->parent(), current->previousSiblin g(),
612 current->nextSibling(), current->hasCounterNodeMap() ? 612 current->nextSibling(), current->hasCounterNodeMap() ?
613 counterName ? WebCore::counterMaps().get(current)->get(identifier) : (WebCore::CounterNode*)1 : (WebCore::CounterNode*)0); 613 counterName ? WebCore::counterMaps().get(current)->get(identifier) : (WebCore::CounterNode*)1 : (WebCore::CounterNode*)0);
614 } 614 }
615 fflush(stderr); 615 fflush(stderr);
616 } 616 }
617 617
618 #endif // NDEBUG 618 #endif // NDEBUG
OLDNEW
« no previous file with comments | « Source/core/rendering/AbstractInlineTextBox.cpp ('k') | Source/core/rendering/RenderEmbeddedObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698