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

Side by Side Diff: Source/core/layout/LayoutObject.cpp

Issue 1162383003: C++11: Replace 0 with nullptr where applicable in layout code. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add one more file. Created 5 years, 6 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
« no previous file with comments | « Source/core/layout/LayoutObject.h ('k') | Source/core/layout/LayoutObjectChildList.cpp » ('j') | 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 unsigned m_bitfields2; 137 unsigned m_bitfields2;
138 LayoutRect rect; // Stores the previous paint invalidation rect. 138 LayoutRect rect; // Stores the previous paint invalidation rect.
139 LayoutPoint position; // Stores the previous position from the paint invalid ation container. 139 LayoutPoint position; // Stores the previous position from the paint invalid ation container.
140 }; 140 };
141 141
142 static_assert(sizeof(LayoutObject) == sizeof(SameSizeAsLayoutObject), "LayoutObj ect should stay small"); 142 static_assert(sizeof(LayoutObject) == sizeof(SameSizeAsLayoutObject), "LayoutObj ect should stay small");
143 143
144 bool LayoutObject::s_affectsParentBlock = false; 144 bool LayoutObject::s_affectsParentBlock = false;
145 145
146 typedef HashMap<const LayoutObject*, LayoutRect> SelectionPaintInvalidationMap; 146 typedef HashMap<const LayoutObject*, LayoutRect> SelectionPaintInvalidationMap;
147 static SelectionPaintInvalidationMap* selectionPaintInvalidationMap = 0; 147 static SelectionPaintInvalidationMap* selectionPaintInvalidationMap = nullptr;
148 148
149 void* LayoutObject::operator new(size_t sz) 149 void* LayoutObject::operator new(size_t sz)
150 { 150 {
151 ASSERT(isMainThread()); 151 ASSERT(isMainThread());
152 return partitionAlloc(WTF::Partitions::getRenderingPartition(), sz); 152 return partitionAlloc(WTF::Partitions::getRenderingPartition(), sz);
153 } 153 }
154 154
155 void LayoutObject::operator delete(void* ptr) 155 void LayoutObject::operator delete(void* ptr)
156 { 156 {
157 ASSERT(isMainThread()); 157 ASSERT(isMainThread());
(...skipping 19 matching lines...) Expand all
177 image->setIsGeneratedContent(); 177 image->setIsGeneratedContent();
178 } else { 178 } else {
179 image->setImageResource(LayoutImageResource::create()); 179 image->setImageResource(LayoutImageResource::create());
180 } 180 }
181 image->setStyleInternal(nullptr); 181 image->setStyleInternal(nullptr);
182 return image; 182 return image;
183 } 183 }
184 184
185 switch (style.display()) { 185 switch (style.display()) {
186 case NONE: 186 case NONE:
187 return 0; 187 return nullptr;
188 case INLINE: 188 case INLINE:
189 return new LayoutInline(element); 189 return new LayoutInline(element);
190 case BLOCK: 190 case BLOCK:
191 case INLINE_BLOCK: 191 case INLINE_BLOCK:
192 return new LayoutBlockFlow(element); 192 return new LayoutBlockFlow(element);
193 case LIST_ITEM: 193 case LIST_ITEM:
194 return new LayoutListItem(element); 194 return new LayoutListItem(element);
195 case TABLE: 195 case TABLE:
196 case INLINE_TABLE: 196 case INLINE_TABLE:
197 return new LayoutTable(element); 197 return new LayoutTable(element);
(...skipping 14 matching lines...) Expand all
212 case INLINE_BOX: 212 case INLINE_BOX:
213 return new LayoutDeprecatedFlexibleBox(*element); 213 return new LayoutDeprecatedFlexibleBox(*element);
214 case FLEX: 214 case FLEX:
215 case INLINE_FLEX: 215 case INLINE_FLEX:
216 return new LayoutFlexibleBox(element); 216 return new LayoutFlexibleBox(element);
217 case GRID: 217 case GRID:
218 case INLINE_GRID: 218 case INLINE_GRID:
219 return new LayoutGrid(element); 219 return new LayoutGrid(element);
220 } 220 }
221 221
222 return 0; 222 return nullptr;
223 } 223 }
224 224
225 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, layoutObjectCounter, ("Layo utObject")); 225 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, layoutObjectCounter, ("Layo utObject"));
226 unsigned LayoutObject::s_instanceCount = 0; 226 unsigned LayoutObject::s_instanceCount = 0;
227 227
228 LayoutObject::LayoutObject(Node* node) 228 LayoutObject::LayoutObject(Node* node)
229 : ImageResourceClient() 229 : ImageResourceClient()
230 , m_style(nullptr) 230 , m_style(nullptr)
231 , m_node(node) 231 , m_node(node)
232 , m_parent(nullptr) 232 , m_parent(nullptr)
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 { 443 {
444 if (LayoutObject* o = slowFirstChild()) 444 if (LayoutObject* o = slowFirstChild())
445 return o; 445 return o;
446 446
447 return nextInPreOrderAfterChildren(stayWithin); 447 return nextInPreOrderAfterChildren(stayWithin);
448 } 448 }
449 449
450 LayoutObject* LayoutObject::nextInPreOrderAfterChildren(const LayoutObject* stay Within) const 450 LayoutObject* LayoutObject::nextInPreOrderAfterChildren(const LayoutObject* stay Within) const
451 { 451 {
452 if (this == stayWithin) 452 if (this == stayWithin)
453 return 0; 453 return nullptr;
454 454
455 const LayoutObject* current = this; 455 const LayoutObject* current = this;
456 LayoutObject* next = current->nextSibling(); 456 LayoutObject* next = current->nextSibling();
457 for (; !next; next = current->nextSibling()) { 457 for (; !next; next = current->nextSibling()) {
458 current = current->parent(); 458 current = current->parent();
459 if (!current || current == stayWithin) 459 if (!current || current == stayWithin)
460 return 0; 460 return nullptr;
461 } 461 }
462 return next; 462 return next;
463 } 463 }
464 464
465 LayoutObject* LayoutObject::previousInPreOrder() const 465 LayoutObject* LayoutObject::previousInPreOrder() const
466 { 466 {
467 if (LayoutObject* o = previousSibling()) { 467 if (LayoutObject* o = previousSibling()) {
468 while (LayoutObject* lastChild = o->slowLastChild()) 468 while (LayoutObject* lastChild = o->slowLastChild())
469 o = lastChild; 469 o = lastChild;
470 return o; 470 return o;
471 } 471 }
472 472
473 return parent(); 473 return parent();
474 } 474 }
475 475
476 LayoutObject* LayoutObject::previousInPreOrder(const LayoutObject* stayWithin) c onst 476 LayoutObject* LayoutObject::previousInPreOrder(const LayoutObject* stayWithin) c onst
477 { 477 {
478 if (this == stayWithin) 478 if (this == stayWithin)
479 return 0; 479 return nullptr;
480 480
481 return previousInPreOrder(); 481 return previousInPreOrder();
482 } 482 }
483 483
484 LayoutObject* LayoutObject::childAt(unsigned index) const 484 LayoutObject* LayoutObject::childAt(unsigned index) const
485 { 485 {
486 LayoutObject* child = slowFirstChild(); 486 LayoutObject* child = slowFirstChild();
487 for (unsigned i = 0; child && i < index; i++) 487 for (unsigned i = 0; child && i < index; i++)
488 child = child->nextSibling(); 488 child = child->nextSibling();
489 return child; 489 return child;
490 } 490 }
491 491
492 LayoutObject* LayoutObject::lastLeafChild() const 492 LayoutObject* LayoutObject::lastLeafChild() const
493 { 493 {
494 LayoutObject* r = slowLastChild(); 494 LayoutObject* r = slowLastChild();
495 while (r) { 495 while (r) {
496 LayoutObject* n = 0; 496 LayoutObject* n = nullptr;
497 n = r->slowLastChild(); 497 n = r->slowLastChild();
498 if (!n) 498 if (!n)
499 break; 499 break;
500 r = n; 500 r = n;
501 } 501 }
502 return r; 502 return r;
503 } 503 }
504 504
505 static void addLayers(LayoutObject* obj, DeprecatedPaintLayer* parentLayer, Layo utObject*& newObject, 505 static void addLayers(LayoutObject* obj, DeprecatedPaintLayer* parentLayer, Layo utObject*& newObject,
506 DeprecatedPaintLayer*& beforeChild) 506 DeprecatedPaintLayer*& beforeChild)
507 { 507 {
508 if (obj->hasLayer()) { 508 if (obj->hasLayer()) {
509 if (!beforeChild && newObject) { 509 if (!beforeChild && newObject) {
510 // We need to figure out the layer that follows newObject. We only d o 510 // We need to figure out the layer that follows newObject. We only d o
511 // this the first time we find a child layer, and then we update the 511 // this the first time we find a child layer, and then we update the
512 // pointer values for newObject and beforeChild used by everyone els e. 512 // pointer values for newObject and beforeChild used by everyone els e.
513 beforeChild = newObject->parent()->findNextLayer(parentLayer, newObj ect); 513 beforeChild = newObject->parent()->findNextLayer(parentLayer, newObj ect);
514 newObject = 0; 514 newObject = nullptr;
515 } 515 }
516 parentLayer->addChild(toLayoutBoxModelObject(obj)->layer(), beforeChild) ; 516 parentLayer->addChild(toLayoutBoxModelObject(obj)->layer(), beforeChild) ;
517 return; 517 return;
518 } 518 }
519 519
520 for (LayoutObject* curr = obj->slowFirstChild(); curr; curr = curr->nextSibl ing()) 520 for (LayoutObject* curr = obj->slowFirstChild(); curr; curr = curr->nextSibl ing())
521 addLayers(curr, parentLayer, newObject, beforeChild); 521 addLayers(curr, parentLayer, newObject, beforeChild);
522 } 522 }
523 523
524 void LayoutObject::addLayers(DeprecatedPaintLayer* parentLayer) 524 void LayoutObject::addLayers(DeprecatedPaintLayer* parentLayer)
525 { 525 {
526 if (!parentLayer) 526 if (!parentLayer)
527 return; 527 return;
528 528
529 LayoutObject* object = this; 529 LayoutObject* object = this;
530 DeprecatedPaintLayer* beforeChild = 0; 530 DeprecatedPaintLayer* beforeChild = nullptr;
531 blink::addLayers(this, parentLayer, object, beforeChild); 531 blink::addLayers(this, parentLayer, object, beforeChild);
532 } 532 }
533 533
534 void LayoutObject::removeLayers(DeprecatedPaintLayer* parentLayer) 534 void LayoutObject::removeLayers(DeprecatedPaintLayer* parentLayer)
535 { 535 {
536 if (!parentLayer) 536 if (!parentLayer)
537 return; 537 return;
538 538
539 if (hasLayer()) { 539 if (hasLayer()) {
540 parentLayer->removeChild(toLayoutBoxModelObject(this)->layer()); 540 parentLayer->removeChild(toLayoutBoxModelObject(this)->layer());
(...skipping 22 matching lines...) Expand all
563 curr->moveLayers(oldParent, newParent); 563 curr->moveLayers(oldParent, newParent);
564 } 564 }
565 565
566 DeprecatedPaintLayer* LayoutObject::findNextLayer(DeprecatedPaintLayer* parentLa yer, LayoutObject* startPoint, bool checkParent) 566 DeprecatedPaintLayer* LayoutObject::findNextLayer(DeprecatedPaintLayer* parentLa yer, LayoutObject* startPoint, bool checkParent)
567 { 567 {
568 // Error check the parent layer passed in. If it's null, we can't find anyth ing. 568 // Error check the parent layer passed in. If it's null, we can't find anyth ing.
569 if (!parentLayer) 569 if (!parentLayer)
570 return 0; 570 return 0;
571 571
572 // Step 1: If our layer is a child of the desired parent, then return our la yer. 572 // Step 1: If our layer is a child of the desired parent, then return our la yer.
573 DeprecatedPaintLayer* ourLayer = hasLayer() ? toLayoutBoxModelObject(this)-> layer() : 0; 573 DeprecatedPaintLayer* ourLayer = hasLayer() ? toLayoutBoxModelObject(this)-> layer() : nullptr;
574 if (ourLayer && ourLayer->parent() == parentLayer) 574 if (ourLayer && ourLayer->parent() == parentLayer)
575 return ourLayer; 575 return ourLayer;
576 576
577 // Step 2: If we don't have a layer, or our layer is the desired parent, the n descend 577 // Step 2: If we don't have a layer, or our layer is the desired parent, the n descend
578 // into our siblings trying to find the next layer whose parent is the desir ed parent. 578 // into our siblings trying to find the next layer whose parent is the desir ed parent.
579 if (!ourLayer || ourLayer == parentLayer) { 579 if (!ourLayer || ourLayer == parentLayer) {
580 for (LayoutObject* curr = startPoint ? startPoint->nextSibling() : slowF irstChild(); 580 for (LayoutObject* curr = startPoint ? startPoint->nextSibling() : slowF irstChild();
581 curr; curr = curr->nextSibling()) { 581 curr; curr = curr->nextSibling()) {
582 DeprecatedPaintLayer* nextLayer = curr->findNextLayer(parentLayer, 0 , false); 582 DeprecatedPaintLayer* nextLayer = curr->findNextLayer(parentLayer, n ullptr, false);
583 if (nextLayer) 583 if (nextLayer)
584 return nextLayer; 584 return nextLayer;
585 } 585 }
586 } 586 }
587 587
588 // Step 3: If our layer is the desired parent layer, then we're finished. We didn't 588 // Step 3: If our layer is the desired parent layer, then we're finished. We didn't
589 // find anything. 589 // find anything.
590 if (parentLayer == ourLayer) 590 if (parentLayer == ourLayer)
591 return 0; 591 return nullptr;
592 592
593 // Step 4: If |checkParent| is set, climb up to our parent and check its sib lings that 593 // Step 4: If |checkParent| is set, climb up to our parent and check its sib lings that
594 // follow us to see if we can locate a layer. 594 // follow us to see if we can locate a layer.
595 if (checkParent && parent()) 595 if (checkParent && parent())
596 return parent()->findNextLayer(parentLayer, this, true); 596 return parent()->findNextLayer(parentLayer, this, true);
597 597
598 return 0; 598 return nullptr;
599 } 599 }
600 600
601 DeprecatedPaintLayer* LayoutObject::enclosingLayer() const 601 DeprecatedPaintLayer* LayoutObject::enclosingLayer() const
602 { 602 {
603 for (const LayoutObject* current = this; current; current = current->parent( )) { 603 for (const LayoutObject* current = this; current; current = current->parent( )) {
604 if (current->hasLayer()) 604 if (current->hasLayer())
605 return toLayoutBoxModelObject(current)->layer(); 605 return toLayoutBoxModelObject(current)->layer();
606 } 606 }
607 // FIXME: we should get rid of detached layout subtrees, at which point this code should 607 // FIXME: we should get rid of detached layout subtrees, at which point this code should
608 // not be reached. crbug.com/411429 608 // not be reached. crbug.com/411429
609 return 0; 609 return nullptr;
610 } 610 }
611 611
612 bool LayoutObject::scrollRectToVisible(const LayoutRect& rect, const ScrollAlign ment& alignX, const ScrollAlignment& alignY) 612 bool LayoutObject::scrollRectToVisible(const LayoutRect& rect, const ScrollAlign ment& alignX, const ScrollAlignment& alignY)
613 { 613 {
614 LayoutBox* enclosingBox = this->enclosingBox(); 614 LayoutBox* enclosingBox = this->enclosingBox();
615 if (!enclosingBox) 615 if (!enclosingBox)
616 return false; 616 return false;
617 617
618 enclosingBox->scrollRectToVisible(rect, alignX, alignY); 618 enclosingBox->scrollRectToVisible(rect, alignX, alignY);
619 return true; 619 return true;
620 } 620 }
621 621
622 LayoutBox* LayoutObject::enclosingBox() const 622 LayoutBox* LayoutObject::enclosingBox() const
623 { 623 {
624 LayoutObject* curr = const_cast<LayoutObject*>(this); 624 LayoutObject* curr = const_cast<LayoutObject*>(this);
625 while (curr) { 625 while (curr) {
626 if (curr->isBox()) 626 if (curr->isBox())
627 return toLayoutBox(curr); 627 return toLayoutBox(curr);
628 curr = curr->parent(); 628 curr = curr->parent();
629 } 629 }
630 630
631 ASSERT_NOT_REACHED(); 631 ASSERT_NOT_REACHED();
632 return 0; 632 return nullptr;
633 } 633 }
634 634
635 LayoutBoxModelObject* LayoutObject::enclosingBoxModelObject() const 635 LayoutBoxModelObject* LayoutObject::enclosingBoxModelObject() const
636 { 636 {
637 LayoutObject* curr = const_cast<LayoutObject*>(this); 637 LayoutObject* curr = const_cast<LayoutObject*>(this);
638 while (curr) { 638 while (curr) {
639 if (curr->isBoxModelObject()) 639 if (curr->isBoxModelObject())
640 return toLayoutBoxModelObject(curr); 640 return toLayoutBoxModelObject(curr);
641 curr = curr->parent(); 641 curr = curr->parent();
642 } 642 }
643 643
644 ASSERT_NOT_REACHED(); 644 ASSERT_NOT_REACHED();
645 return 0; 645 return nullptr;
646 } 646 }
647 647
648 LayoutBox* LayoutObject::enclosingScrollableBox() const 648 LayoutBox* LayoutObject::enclosingScrollableBox() const
649 { 649 {
650 for (LayoutObject* ancestor = parent(); ancestor; ancestor = ancestor->paren t()) { 650 for (LayoutObject* ancestor = parent(); ancestor; ancestor = ancestor->paren t()) {
651 if (!ancestor->isBox()) 651 if (!ancestor->isBox())
652 continue; 652 continue;
653 653
654 LayoutBox* ancestorBox = toLayoutBox(ancestor); 654 LayoutBox* ancestorBox = toLayoutBox(ancestor);
655 if (ancestorBox->canBeScrolledAndHasScrollableArea()) 655 if (ancestorBox->canBeScrolledAndHasScrollableArea())
656 return ancestorBox; 656 return ancestorBox;
657 } 657 }
658 658
659 return 0; 659 return nullptr;
660 } 660 }
661 661
662 LayoutFlowThread* LayoutObject::locateFlowThreadContainingBlock() const 662 LayoutFlowThread* LayoutObject::locateFlowThreadContainingBlock() const
663 { 663 {
664 ASSERT(isInsideFlowThread()); 664 ASSERT(isInsideFlowThread());
665 665
666 // See if we have the thread cached because we're in the middle of layout. 666 // See if we have the thread cached because we're in the middle of layout.
667 if (LayoutState* layoutState = view()->layoutState()) { 667 if (LayoutState* layoutState = view()->layoutState()) {
668 if (LayoutFlowThread* flowThread = layoutState->flowThread()) 668 if (LayoutFlowThread* flowThread = layoutState->flowThread())
669 return flowThread; 669 return flowThread;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 return false; 714 return false;
715 715
716 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && isDocumentElement()) 716 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && isDocumentElement())
717 return !hasBoxEffect(); 717 return !hasBoxEffect();
718 718
719 return layoutObjectHasNoBoxEffectObsolete(*this); 719 return layoutObjectHasNoBoxEffectObsolete(*this);
720 } 720 }
721 721
722 LayoutBlock* LayoutObject::firstLineBlock() const 722 LayoutBlock* LayoutObject::firstLineBlock() const
723 { 723 {
724 return 0; 724 return nullptr;
725 } 725 }
726 726
727 static inline bool objectIsRelayoutBoundary(const LayoutObject* object) 727 static inline bool objectIsRelayoutBoundary(const LayoutObject* object)
728 { 728 {
729 // FIXME: In future it may be possible to broaden these conditions in order to improve performance. 729 // FIXME: In future it may be possible to broaden these conditions in order to improve performance.
730 if (object->isTextControl()) 730 if (object->isTextControl())
731 return true; 731 return true;
732 732
733 if (object->isSVGRoot()) 733 if (object->isSVGRoot())
734 return true; 734 return true;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 while (o && o->isAnonymousBlock()) 903 while (o && o->isAnonymousBlock())
904 o = o->containingBlock(); 904 o = o->containingBlock();
905 } else if (isColumnSpanAll()) { 905 } else if (isColumnSpanAll()) {
906 o = spannerPlaceholder()->containingBlock(); 906 o = spannerPlaceholder()->containingBlock();
907 } else { 907 } else {
908 while (o && ((o->isInline() && !o->isReplaced()) || !o->isLayoutBlock()) ) 908 while (o && ((o->isInline() && !o->isReplaced()) || !o->isLayoutBlock()) )
909 o = o->parent(); 909 o = o->parent();
910 } 910 }
911 911
912 if (!o || !o->isLayoutBlock()) 912 if (!o || !o->isLayoutBlock())
913 return 0; // This can still happen in case of an orphaned tree 913 return nullptr; // This can still happen in case of an orphaned tree
914 914
915 return toLayoutBlock(o); 915 return toLayoutBlock(o);
916 } 916 }
917 917
918 bool LayoutObject::mustInvalidateFillLayersPaintOnHeightChange(const FillLayer& layer) const 918 bool LayoutObject::mustInvalidateFillLayersPaintOnHeightChange(const FillLayer& layer) const
919 { 919 {
920 // Nobody will use multiple layers without wanting fancy positioning. 920 // Nobody will use multiple layers without wanting fancy positioning.
921 if (layer.next()) 921 if (layer.next())
922 return true; 922 return true;
923 923
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 RELEASE_ASSERT(isRooted()); 1056 RELEASE_ASSERT(isRooted());
1057 1057
1058 const LayoutBoxModelObject* paintInvalidationContainer = containerForPaintIn validation(); 1058 const LayoutBoxModelObject* paintInvalidationContainer = containerForPaintIn validation();
1059 ASSERT(paintInvalidationContainer); 1059 ASSERT(paintInvalidationContainer);
1060 1060
1061 return *paintInvalidationContainer; 1061 return *paintInvalidationContainer;
1062 } 1062 }
1063 1063
1064 const LayoutBoxModelObject* LayoutObject::enclosingCompositedContainer() const 1064 const LayoutBoxModelObject* LayoutObject::enclosingCompositedContainer() const
1065 { 1065 {
1066 LayoutBoxModelObject* container = 0; 1066 LayoutBoxModelObject* container = nullptr;
1067 // FIXME: CompositingState is not necessarily up to date for many callers of this function. 1067 // FIXME: CompositingState is not necessarily up to date for many callers of this function.
1068 DisableCompositingQueryAsserts disabler; 1068 DisableCompositingQueryAsserts disabler;
1069 1069
1070 if (DeprecatedPaintLayer* compositingLayer = enclosingLayer()->enclosingLaye rForPaintInvalidationCrossingFrameBoundaries()) 1070 if (DeprecatedPaintLayer* compositingLayer = enclosingLayer()->enclosingLaye rForPaintInvalidationCrossingFrameBoundaries())
1071 container = compositingLayer->layoutObject(); 1071 container = compositingLayer->layoutObject();
1072 return container; 1072 return container;
1073 } 1073 }
1074 1074
1075 const LayoutBoxModelObject* LayoutObject::adjustCompositedContainerForSpecialAnc estors(const LayoutBoxModelObject* paintInvalidationContainer) const 1075 const LayoutBoxModelObject* LayoutObject::adjustCompositedContainerForSpecialAnc estors(const LayoutBoxModelObject* paintInvalidationContainer) const
1076 { 1076 {
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 2070
2071 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode, was Fixed, paintInvalidationState); 2071 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode, was Fixed, paintInvalidationState);
2072 } 2072 }
2073 2073
2074 const LayoutObject* LayoutObject::pushMappingToContainer(const LayoutBoxModelObj ect* ancestorToStopAt, LayoutGeometryMap& geometryMap) const 2074 const LayoutObject* LayoutObject::pushMappingToContainer(const LayoutBoxModelObj ect* ancestorToStopAt, LayoutGeometryMap& geometryMap) const
2075 { 2075 {
2076 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != this); 2076 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != this);
2077 2077
2078 LayoutObject* container = parent(); 2078 LayoutObject* container = parent();
2079 if (!container) 2079 if (!container)
2080 return 0; 2080 return nullptr;
2081 2081
2082 // FIXME: this should call offsetFromContainer to share code, but I'm not su re it's ever called. 2082 // FIXME: this should call offsetFromContainer to share code, but I'm not su re it's ever called.
2083 LayoutSize offset; 2083 LayoutSize offset;
2084 if (container->hasOverflowClip()) 2084 if (container->hasOverflowClip())
2085 offset = -LayoutSize(toLayoutBox(container)->scrolledContentOffset()); 2085 offset = -LayoutSize(toLayoutBox(container)->scrolledContentOffset());
2086 2086
2087 geometryMap.push(this, offset); 2087 geometryMap.push(this, offset);
2088 2088
2089 return container; 2089 return container;
2090 } 2090 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2210 *extraWidthToEndOfLine = 0; 2210 *extraWidthToEndOfLine = 0;
2211 2211
2212 return LayoutRect(); 2212 return LayoutRect();
2213 } 2213 }
2214 2214
2215 void LayoutObject::computeLayerHitTestRects(LayerHitTestRects& layerRects) const 2215 void LayoutObject::computeLayerHitTestRects(LayerHitTestRects& layerRects) const
2216 { 2216 {
2217 // Figure out what layer our container is in. Any offset (or new layer) for this 2217 // Figure out what layer our container is in. Any offset (or new layer) for this
2218 // layoutObject within it's container will be applied in addLayerHitTestRect s. 2218 // layoutObject within it's container will be applied in addLayerHitTestRect s.
2219 LayoutPoint layerOffset; 2219 LayoutPoint layerOffset;
2220 const DeprecatedPaintLayer* currentLayer = 0; 2220 const DeprecatedPaintLayer* currentLayer = nullptr;
2221 2221
2222 if (!hasLayer()) { 2222 if (!hasLayer()) {
2223 LayoutObject* container = this->container(); 2223 LayoutObject* container = this->container();
2224 currentLayer = container->enclosingLayer(); 2224 currentLayer = container->enclosingLayer();
2225 if (container && currentLayer->layoutObject() != container) { 2225 if (container && currentLayer->layoutObject() != container) {
2226 layerOffset.move(container->offsetFromAncestorContainer(currentLayer ->layoutObject())); 2226 layerOffset.move(container->offsetFromAncestorContainer(currentLayer ->layoutObject()));
2227 // If the layer itself is scrolled, we have to undo the subtraction of its scroll 2227 // If the layer itself is scrolled, we have to undo the subtraction of its scroll
2228 // offset since we want the offset relative to the scrolling content , not the 2228 // offset since we want the offset relative to the scrolling content , not the
2229 // element itself. 2229 // element itself.
2230 if (currentLayer->layoutObject()->hasOverflowClip()) 2230 if (currentLayer->layoutObject()->hasOverflowClip())
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
2446 2446
2447 clearLayoutRootIfNeeded(); 2447 clearLayoutRootIfNeeded();
2448 } 2448 }
2449 2449
2450 void LayoutObject::insertedIntoTree() 2450 void LayoutObject::insertedIntoTree()
2451 { 2451 {
2452 // FIXME: We should ASSERT(isRooted()) here but generated content makes some out-of-order insertion. 2452 // FIXME: We should ASSERT(isRooted()) here but generated content makes some out-of-order insertion.
2453 2453
2454 // Keep our layer hierarchy updated. Optimize for the common case where we d on't have any children 2454 // Keep our layer hierarchy updated. Optimize for the common case where we d on't have any children
2455 // and don't have a layer attached to ourselves. 2455 // and don't have a layer attached to ourselves.
2456 DeprecatedPaintLayer* layer = 0; 2456 DeprecatedPaintLayer* layer = nullptr;
2457 if (slowFirstChild() || hasLayer()) { 2457 if (slowFirstChild() || hasLayer()) {
2458 layer = parent()->enclosingLayer(); 2458 layer = parent()->enclosingLayer();
2459 addLayers(layer); 2459 addLayers(layer);
2460 } 2460 }
2461 2461
2462 // If |this| is visible but this object was not, tell the layer it has some visible content 2462 // If |this| is visible but this object was not, tell the layer it has some visible content
2463 // that needs to be drawn and layer visibility optimization can't be used 2463 // that needs to be drawn and layer visibility optimization can't be used
2464 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V ISIBLE && !hasLayer()) { 2464 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V ISIBLE && !hasLayer()) {
2465 if (!layer) 2465 if (!layer)
2466 layer = parent()->enclosingLayer(); 2466 layer = parent()->enclosingLayer();
2467 if (layer) 2467 if (layer)
2468 layer->dirtyVisibleContentStatus(); 2468 layer->dirtyVisibleContentStatus();
2469 } 2469 }
2470 2470
2471 if (!isFloating() && parent()->childrenInline()) 2471 if (!isFloating() && parent()->childrenInline())
2472 parent()->dirtyLinesFromChangedChild(this); 2472 parent()->dirtyLinesFromChangedChild(this);
2473 2473
2474 if (LayoutFlowThread* flowThread = flowThreadContainingBlock()) 2474 if (LayoutFlowThread* flowThread = flowThreadContainingBlock())
2475 flowThread->flowThreadDescendantWasInserted(this); 2475 flowThread->flowThreadDescendantWasInserted(this);
2476 } 2476 }
2477 2477
2478 void LayoutObject::willBeRemovedFromTree() 2478 void LayoutObject::willBeRemovedFromTree()
2479 { 2479 {
2480 // FIXME: We should ASSERT(isRooted()) but we have some out-of-order removal s which would need to be fixed first. 2480 // FIXME: We should ASSERT(isRooted()) but we have some out-of-order removal s which would need to be fixed first.
2481 2481
2482 // If we remove a visible child from an invisible parent, we don't know the layer visibility any more. 2482 // If we remove a visible child from an invisible parent, we don't know the layer visibility any more.
2483 DeprecatedPaintLayer* layer = 0; 2483 DeprecatedPaintLayer* layer = nullptr;
2484 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V ISIBLE && !hasLayer()) { 2484 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V ISIBLE && !hasLayer()) {
2485 layer = parent()->enclosingLayer(); 2485 layer = parent()->enclosingLayer();
2486 if (layer) 2486 if (layer)
2487 layer->dirtyVisibleContentStatus(); 2487 layer->dirtyVisibleContentStatus();
2488 } 2488 }
2489 2489
2490 // Keep our layer hierarchy updated. 2490 // Keep our layer hierarchy updated.
2491 if (slowFirstChild() || hasLayer()) { 2491 if (slowFirstChild() || hasLayer()) {
2492 if (!layer) 2492 if (!layer)
2493 layer = parent()->enclosingLayer(); 2493 layer = parent()->enclosingLayer();
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
2757 2757
2758 if (RefPtr<ComputedStyle> style = firstLineStyleForCachedUncachedType(Cached , isText() ? parent() : this, m_style.get())) 2758 if (RefPtr<ComputedStyle> style = firstLineStyleForCachedUncachedType(Cached , isText() ? parent() : this, m_style.get()))
2759 return style.get(); 2759 return style.get();
2760 2760
2761 return m_style.get(); 2761 return m_style.get();
2762 } 2762 }
2763 2763
2764 ComputedStyle* LayoutObject::getCachedPseudoStyle(PseudoId pseudo, const Compute dStyle* parentStyle) const 2764 ComputedStyle* LayoutObject::getCachedPseudoStyle(PseudoId pseudo, const Compute dStyle* parentStyle) const
2765 { 2765 {
2766 if (pseudo < FIRST_INTERNAL_PSEUDOID && !style()->hasPseudoStyle(pseudo)) 2766 if (pseudo < FIRST_INTERNAL_PSEUDOID && !style()->hasPseudoStyle(pseudo))
2767 return 0; 2767 return nullptr;
2768 2768
2769 ComputedStyle* cachedStyle = style()->getCachedPseudoStyle(pseudo); 2769 ComputedStyle* cachedStyle = style()->getCachedPseudoStyle(pseudo);
2770 if (cachedStyle) 2770 if (cachedStyle)
2771 return cachedStyle; 2771 return cachedStyle;
2772 2772
2773 RefPtr<ComputedStyle> result = getUncachedPseudoStyle(PseudoStyleRequest(pse udo), parentStyle); 2773 RefPtr<ComputedStyle> result = getUncachedPseudoStyle(PseudoStyleRequest(pse udo), parentStyle);
2774 if (result) 2774 if (result)
2775 return mutableStyleRef().addCachedPseudoStyle(result.release()); 2775 return mutableStyleRef().addCachedPseudoStyle(result.release());
2776 return 0; 2776 return nullptr;
2777 } 2777 }
2778 2778
2779 PassRefPtr<ComputedStyle> LayoutObject::getUncachedPseudoStyle(const PseudoStyle Request& pseudoStyleRequest, const ComputedStyle* parentStyle, const ComputedSty le* ownStyle) const 2779 PassRefPtr<ComputedStyle> LayoutObject::getUncachedPseudoStyle(const PseudoStyle Request& pseudoStyleRequest, const ComputedStyle* parentStyle, const ComputedSty le* ownStyle) const
2780 { 2780 {
2781 if (pseudoStyleRequest.pseudoId < FIRST_INTERNAL_PSEUDOID && !ownStyle && !s tyle()->hasPseudoStyle(pseudoStyleRequest.pseudoId)) 2781 if (pseudoStyleRequest.pseudoId < FIRST_INTERNAL_PSEUDOID && !ownStyle && !s tyle()->hasPseudoStyle(pseudoStyleRequest.pseudoId))
2782 return nullptr; 2782 return nullptr;
2783 2783
2784 if (!parentStyle) { 2784 if (!parentStyle) {
2785 ASSERT(!ownStyle); 2785 ASSERT(!ownStyle);
2786 parentStyle = style(); 2786 parentStyle = style();
(...skipping 27 matching lines...) Expand all
2814 } 2814 }
2815 } 2815 }
2816 } 2816 }
2817 2817
2818 return getUncachedPseudoStyle(PseudoStyleRequest(SELECTION)); 2818 return getUncachedPseudoStyle(PseudoStyleRequest(SELECTION));
2819 } 2819 }
2820 2820
2821 void LayoutObject::getTextDecorations(unsigned decorations, AppliedTextDecoratio n& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethroug h, bool quirksMode, bool firstlineStyle) 2821 void LayoutObject::getTextDecorations(unsigned decorations, AppliedTextDecoratio n& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethroug h, bool quirksMode, bool firstlineStyle)
2822 { 2822 {
2823 LayoutObject* curr = this; 2823 LayoutObject* curr = this;
2824 const ComputedStyle* styleToUse = 0; 2824 const ComputedStyle* styleToUse = nullptr;
2825 unsigned currDecs = TextDecorationNone; 2825 unsigned currDecs = TextDecorationNone;
2826 Color resultColor; 2826 Color resultColor;
2827 TextDecorationStyle resultStyle; 2827 TextDecorationStyle resultStyle;
2828 do { 2828 do {
2829 styleToUse = curr->style(firstlineStyle); 2829 styleToUse = curr->style(firstlineStyle);
2830 currDecs = styleToUse->textDecoration(); 2830 currDecs = styleToUse->textDecoration();
2831 currDecs &= decorations; 2831 currDecs &= decorations;
2832 resultColor = styleToUse->visitedDependentColor(CSSPropertyTextDecoratio nColor); 2832 resultColor = styleToUse->visitedDependentColor(CSSPropertyTextDecoratio nColor);
2833 resultStyle = styleToUse->textDecorationStyle(); 2833 resultStyle = styleToUse->textDecorationStyle();
2834 // Parameter 'decorations' is cast as an int to enable the bitwise opera tions below. 2834 // Parameter 'decorations' is cast as an int to enable the bitwise opera tions below.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2955 } 2955 }
2956 2956
2957 void LayoutObject::imageChanged(ImageResource* image, const IntRect* rect) 2957 void LayoutObject::imageChanged(ImageResource* image, const IntRect* rect)
2958 { 2958 {
2959 imageChanged(static_cast<WrappedImagePtr>(image), rect); 2959 imageChanged(static_cast<WrappedImagePtr>(image), rect);
2960 } 2960 }
2961 2961
2962 Element* LayoutObject::offsetParent() const 2962 Element* LayoutObject::offsetParent() const
2963 { 2963 {
2964 if (isDocumentElement() || isBody()) 2964 if (isDocumentElement() || isBody())
2965 return 0; 2965 return nullptr;
2966 2966
2967 if (isOutOfFlowPositioned() && style()->position() == FixedPosition) 2967 if (isOutOfFlowPositioned() && style()->position() == FixedPosition)
2968 return 0; 2968 return nullptr;
2969 2969
2970 float effectiveZoom = style()->effectiveZoom(); 2970 float effectiveZoom = style()->effectiveZoom();
2971 Node* node = 0; 2971 Node* node = nullptr;
2972 for (LayoutObject* ancestor = parent(); ancestor; ancestor = ancestor->paren t()) { 2972 for (LayoutObject* ancestor = parent(); ancestor; ancestor = ancestor->paren t()) {
2973 // Spec: http://www.w3.org/TR/cssom-view/#offset-attributes 2973 // Spec: http://www.w3.org/TR/cssom-view/#offset-attributes
2974 2974
2975 node = ancestor->node(); 2975 node = ancestor->node();
2976 2976
2977 if (!node) 2977 if (!node)
2978 continue; 2978 continue;
2979 2979
2980 if (ancestor->isPositioned()) 2980 if (ancestor->isPositioned())
2981 break; 2981 break;
2982 2982
2983 if (isHTMLBodyElement(*node)) 2983 if (isHTMLBodyElement(*node))
2984 break; 2984 break;
2985 2985
2986 if (!isPositioned() && (isHTMLTableElement(*node) || isHTMLTableCellElem ent(*node))) 2986 if (!isPositioned() && (isHTMLTableElement(*node) || isHTMLTableCellElem ent(*node)))
2987 break; 2987 break;
2988 2988
2989 // Webkit specific extension where offsetParent stops at zoom level chan ges. 2989 // Webkit specific extension where offsetParent stops at zoom level chan ges.
2990 if (effectiveZoom != ancestor->style()->effectiveZoom()) 2990 if (effectiveZoom != ancestor->style()->effectiveZoom())
2991 break; 2991 break;
2992 } 2992 }
2993 2993
2994 return node && node->isElementNode() ? toElement(node) : 0; 2994 return node && node->isElementNode() ? toElement(node) : nullptr;
2995 } 2995 }
2996 2996
2997 PositionWithAffinity LayoutObject::createPositionWithAffinity(int offset, EAffin ity affinity) 2997 PositionWithAffinity LayoutObject::createPositionWithAffinity(int offset, EAffin ity affinity)
2998 { 2998 {
2999 // If this is a non-anonymous layoutObject in an editable area, then it's si mple. 2999 // If this is a non-anonymous layoutObject in an editable area, then it's si mple.
3000 if (Node* node = nonPseudoNode()) { 3000 if (Node* node = nonPseudoNode()) {
3001 if (!node->hasEditableStyle()) { 3001 if (!node->hasEditableStyle()) {
3002 // If it can be found, we prefer a visually equivalent position that is editable. 3002 // If it can be found, we prefer a visually equivalent position that is editable.
3003 Position position = createLegacyEditingPosition(node, offset); 3003 Position position = createLegacyEditingPosition(node, offset);
3004 Position candidate = position.downstream(CanCrossEditingBoundary); 3004 Position candidate = position.downstream(CanCrossEditingBoundary);
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
3307 const blink::LayoutObject* root = object1; 3307 const blink::LayoutObject* root = object1;
3308 while (root->parent()) 3308 while (root->parent())
3309 root = root->parent(); 3309 root = root->parent();
3310 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3310 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3311 } else { 3311 } else {
3312 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); 3312 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n");
3313 } 3313 }
3314 } 3314 }
3315 3315
3316 #endif 3316 #endif
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutObject.h ('k') | Source/core/layout/LayoutObjectChildList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698