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

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

Issue 945803004: Merge back LayoutLayerModelObject into RenderBoxModelObject (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Better rebasing. Created 5 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
« no previous file with comments | « Source/core/layout/LayoutObject.h ('k') | Source/core/layout/LayoutReplaced.h » ('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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 342
343 // SVG creates renderers for <g display="none">, as SVG requires children of hidden 343 // SVG creates renderers for <g display="none">, as SVG requires children of hidden
344 // <g>s to have renderers - at least that's how our implementation works. Co nsider: 344 // <g>s to have renderers - at least that's how our implementation works. Co nsider:
345 // <g display="none"><foreignObject><body style="position: relative">FOO... 345 // <g display="none"><foreignObject><body style="position: relative">FOO...
346 // - layerTypeRequired() would return true for the <body>, creating a new La yer 346 // - layerTypeRequired() would return true for the <body>, creating a new La yer
347 // - when the document is painted, both layers are painted. The <body> layer doesn't 347 // - when the document is painted, both layers are painted. The <body> layer doesn't
348 // know that it's inside a "hidden SVG subtree", and thus paints, even if it shouldn't. 348 // know that it's inside a "hidden SVG subtree", and thus paints, even if it shouldn't.
349 // To avoid the problem alltogether, detect early if we're inside a hidden S VG subtree 349 // To avoid the problem alltogether, detect early if we're inside a hidden S VG subtree
350 // and stop creating layers at all for these cases - they're not used anyway s. 350 // and stop creating layers at all for these cases - they're not used anyway s.
351 if (newChild->hasLayer() && !layerCreationAllowedForSubtree()) 351 if (newChild->hasLayer() && !layerCreationAllowedForSubtree())
352 toLayoutLayerModelObject(newChild)->layer()->removeOnlyThisLayer(); 352 toLayoutBoxModelObject(newChild)->layer()->removeOnlyThisLayer();
353 } 353 }
354 354
355 void LayoutObject::removeChild(LayoutObject* oldChild) 355 void LayoutObject::removeChild(LayoutObject* oldChild)
356 { 356 {
357 ASSERT(isAllowedToModifyRenderTreeStructure(document())); 357 ASSERT(isAllowedToModifyRenderTreeStructure(document()));
358 358
359 LayoutObjectChildList* children = virtualChildren(); 359 LayoutObjectChildList* children = virtualChildren();
360 ASSERT(children); 360 ASSERT(children);
361 if (!children) 361 if (!children)
362 return; 362 return;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 Layer*& beforeChild) 453 Layer*& beforeChild)
454 { 454 {
455 if (obj->hasLayer()) { 455 if (obj->hasLayer()) {
456 if (!beforeChild && newObject) { 456 if (!beforeChild && newObject) {
457 // We need to figure out the layer that follows newObject. We only d o 457 // We need to figure out the layer that follows newObject. We only d o
458 // this the first time we find a child layer, and then we update the 458 // this the first time we find a child layer, and then we update the
459 // pointer values for newObject and beforeChild used by everyone els e. 459 // pointer values for newObject and beforeChild used by everyone els e.
460 beforeChild = newObject->parent()->findNextLayer(parentLayer, newObj ect); 460 beforeChild = newObject->parent()->findNextLayer(parentLayer, newObj ect);
461 newObject = 0; 461 newObject = 0;
462 } 462 }
463 parentLayer->addChild(toLayoutLayerModelObject(obj)->layer(), beforeChil d); 463 parentLayer->addChild(toLayoutBoxModelObject(obj)->layer(), beforeChild) ;
464 return; 464 return;
465 } 465 }
466 466
467 for (LayoutObject* curr = obj->slowFirstChild(); curr; curr = curr->nextSibl ing()) 467 for (LayoutObject* curr = obj->slowFirstChild(); curr; curr = curr->nextSibl ing())
468 addLayers(curr, parentLayer, newObject, beforeChild); 468 addLayers(curr, parentLayer, newObject, beforeChild);
469 } 469 }
470 470
471 void LayoutObject::addLayers(Layer* parentLayer) 471 void LayoutObject::addLayers(Layer* parentLayer)
472 { 472 {
473 if (!parentLayer) 473 if (!parentLayer)
474 return; 474 return;
475 475
476 LayoutObject* object = this; 476 LayoutObject* object = this;
477 Layer* beforeChild = 0; 477 Layer* beforeChild = 0;
478 blink::addLayers(this, parentLayer, object, beforeChild); 478 blink::addLayers(this, parentLayer, object, beforeChild);
479 } 479 }
480 480
481 void LayoutObject::removeLayers(Layer* parentLayer) 481 void LayoutObject::removeLayers(Layer* parentLayer)
482 { 482 {
483 if (!parentLayer) 483 if (!parentLayer)
484 return; 484 return;
485 485
486 if (hasLayer()) { 486 if (hasLayer()) {
487 parentLayer->removeChild(toLayoutLayerModelObject(this)->layer()); 487 parentLayer->removeChild(toLayoutBoxModelObject(this)->layer());
488 return; 488 return;
489 } 489 }
490 490
491 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextSibling() ) 491 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextSibling() )
492 curr->removeLayers(parentLayer); 492 curr->removeLayers(parentLayer);
493 } 493 }
494 494
495 void LayoutObject::moveLayers(Layer* oldParent, Layer* newParent) 495 void LayoutObject::moveLayers(Layer* oldParent, Layer* newParent)
496 { 496 {
497 if (!newParent) 497 if (!newParent)
498 return; 498 return;
499 499
500 if (hasLayer()) { 500 if (hasLayer()) {
501 Layer* layer = toLayoutLayerModelObject(this)->layer(); 501 Layer* layer = toLayoutBoxModelObject(this)->layer();
502 ASSERT(oldParent == layer->parent()); 502 ASSERT(oldParent == layer->parent());
503 if (oldParent) 503 if (oldParent)
504 oldParent->removeChild(layer); 504 oldParent->removeChild(layer);
505 newParent->addChild(layer); 505 newParent->addChild(layer);
506 return; 506 return;
507 } 507 }
508 508
509 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextSibling() ) 509 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextSibling() )
510 curr->moveLayers(oldParent, newParent); 510 curr->moveLayers(oldParent, newParent);
511 } 511 }
512 512
513 Layer* LayoutObject::findNextLayer(Layer* parentLayer, LayoutObject* startPoint, bool checkParent) 513 Layer* LayoutObject::findNextLayer(Layer* parentLayer, LayoutObject* startPoint, bool checkParent)
514 { 514 {
515 // Error check the parent layer passed in. If it's null, we can't find anyth ing. 515 // Error check the parent layer passed in. If it's null, we can't find anyth ing.
516 if (!parentLayer) 516 if (!parentLayer)
517 return 0; 517 return 0;
518 518
519 // Step 1: If our layer is a child of the desired parent, then return our la yer. 519 // Step 1: If our layer is a child of the desired parent, then return our la yer.
520 Layer* ourLayer = hasLayer() ? toLayoutLayerModelObject(this)->layer() : 0; 520 Layer* ourLayer = hasLayer() ? toLayoutBoxModelObject(this)->layer() : 0;
521 if (ourLayer && ourLayer->parent() == parentLayer) 521 if (ourLayer && ourLayer->parent() == parentLayer)
522 return ourLayer; 522 return ourLayer;
523 523
524 // Step 2: If we don't have a layer, or our layer is the desired parent, the n descend 524 // Step 2: If we don't have a layer, or our layer is the desired parent, the n descend
525 // into our siblings trying to find the next layer whose parent is the desir ed parent. 525 // into our siblings trying to find the next layer whose parent is the desir ed parent.
526 if (!ourLayer || ourLayer == parentLayer) { 526 if (!ourLayer || ourLayer == parentLayer) {
527 for (LayoutObject* curr = startPoint ? startPoint->nextSibling() : slowF irstChild(); 527 for (LayoutObject* curr = startPoint ? startPoint->nextSibling() : slowF irstChild();
528 curr; curr = curr->nextSibling()) { 528 curr; curr = curr->nextSibling()) {
529 Layer* nextLayer = curr->findNextLayer(parentLayer, 0, false); 529 Layer* nextLayer = curr->findNextLayer(parentLayer, 0, false);
530 if (nextLayer) 530 if (nextLayer)
(...skipping 11 matching lines...) Expand all
542 if (checkParent && parent()) 542 if (checkParent && parent())
543 return parent()->findNextLayer(parentLayer, this, true); 543 return parent()->findNextLayer(parentLayer, this, true);
544 544
545 return 0; 545 return 0;
546 } 546 }
547 547
548 Layer* LayoutObject::enclosingLayer() const 548 Layer* LayoutObject::enclosingLayer() const
549 { 549 {
550 for (const LayoutObject* current = this; current; current = current->parent( )) { 550 for (const LayoutObject* current = this; current; current = current->parent( )) {
551 if (current->hasLayer()) 551 if (current->hasLayer())
552 return toLayoutLayerModelObject(current)->layer(); 552 return toLayoutBoxModelObject(current)->layer();
553 } 553 }
554 // FIXME: we should get rid of detached render subtrees, at which point this code should 554 // FIXME: we should get rid of detached render subtrees, at which point this code should
555 // not be reached. crbug.com/411429 555 // not be reached. crbug.com/411429
556 return 0; 556 return 0;
557 } 557 }
558 558
559 bool LayoutObject::scrollRectToVisible(const LayoutRect& rect, const ScrollAlign ment& alignX, const ScrollAlignment& alignY) 559 bool LayoutObject::scrollRectToVisible(const LayoutRect& rect, const ScrollAlign ment& alignX, const ScrollAlignment& alignY)
560 { 560 {
561 RenderBox* enclosingBox = this->enclosingBox(); 561 RenderBox* enclosingBox = this->enclosingBox();
562 if (!enclosingBox) 562 if (!enclosingBox)
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 o->m_bitfields.setPreferredLogicalWidthsDirty(true); 771 o->m_bitfields.setPreferredLogicalWidthsDirty(true);
772 if (o->style()->hasOutOfFlowPosition()) { 772 if (o->style()->hasOutOfFlowPosition()) {
773 // A positioned object has no effect on the min/max width of its con taining block ever. 773 // A positioned object has no effect on the min/max width of its con taining block ever.
774 // We can optimize this case and not go up any further. 774 // We can optimize this case and not go up any further.
775 break; 775 break;
776 } 776 }
777 o = container; 777 o = container;
778 } 778 }
779 } 779 }
780 780
781 RenderBlock* LayoutObject::containerForFixedPosition(const LayoutLayerModelObjec t* paintInvalidationContainer, bool* paintInvalidationContainerSkipped) const 781 RenderBlock* LayoutObject::containerForFixedPosition(const LayoutBoxModelObject* paintInvalidationContainer, bool* paintInvalidationContainerSkipped) const
782 { 782 {
783 ASSERT(!paintInvalidationContainerSkipped || !*paintInvalidationContainerSki pped); 783 ASSERT(!paintInvalidationContainerSkipped || !*paintInvalidationContainerSki pped);
784 ASSERT(!isText()); 784 ASSERT(!isText());
785 ASSERT(style()->position() == FixedPosition); 785 ASSERT(style()->position() == FixedPosition);
786 786
787 LayoutObject* ancestor = parent(); 787 LayoutObject* ancestor = parent();
788 for (; ancestor && !ancestor->canContainFixedPositionObjects(); ancestor = a ncestor->parent()) { 788 for (; ancestor && !ancestor->canContainFixedPositionObjects(); ancestor = a ncestor->parent()) {
789 if (paintInvalidationContainerSkipped && ancestor == paintInvalidationCo ntainer) 789 if (paintInvalidationContainerSkipped && ancestor == paintInvalidationCo ntainer)
790 *paintInvalidationContainerSkipped = true; 790 *paintInvalidationContainerSkipped = true;
791 } 791 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 988
989 LayoutRect result = rects[0]; 989 LayoutRect result = rects[0];
990 for (size_t i = 1; i < n; ++i) 990 for (size_t i = 1; i < n; ++i)
991 result.unite(rects[i]); 991 result.unite(rects[i]);
992 return pixelSnappedIntRect(result); 992 return pixelSnappedIntRect(result);
993 } 993 }
994 994
995 IntRect LayoutObject::absoluteFocusRingBoundingBoxRect() const 995 IntRect LayoutObject::absoluteFocusRingBoundingBoxRect() const
996 { 996 {
997 Vector<LayoutRect> rects; 997 Vector<LayoutRect> rects;
998 const LayoutLayerModelObject* container = enclosingLayer()->renderer(); 998 const LayoutBoxModelObject* container = enclosingLayer()->renderer();
999 addFocusRingRects(rects, LayoutPoint(localToContainerPoint(FloatPoint(), con tainer))); 999 addFocusRingRects(rects, LayoutPoint(localToContainerPoint(FloatPoint(), con tainer)));
1000 return container->localToAbsoluteQuad(FloatQuad(unionRect(rects))).enclosing BoundingBox(); 1000 return container->localToAbsoluteQuad(FloatQuad(unionRect(rects))).enclosing BoundingBox();
1001 } 1001 }
1002 1002
1003 FloatRect LayoutObject::absoluteBoundingBoxRectForRange(const Range* range) 1003 FloatRect LayoutObject::absoluteBoundingBoxRectForRange(const Range* range)
1004 { 1004 {
1005 if (!range || !range->startContainer()) 1005 if (!range || !range->startContainer())
1006 return FloatRect(); 1006 return FloatRect();
1007 1007
1008 range->ownerDocument().updateLayout(); 1008 range->ownerDocument().updateLayout();
(...skipping 22 matching lines...) Expand all
1031 topLevelRect = result; 1031 topLevelRect = result;
1032 for (LayoutObject* current = slowFirstChild(); current; current = current->n extSibling()) 1032 for (LayoutObject* current = slowFirstChild(); current; current = current->n extSibling())
1033 current->addAbsoluteRectForLayer(result); 1033 current->addAbsoluteRectForLayer(result);
1034 return result; 1034 return result;
1035 } 1035 }
1036 1036
1037 void LayoutObject::paint(const PaintInfo&, const LayoutPoint&) 1037 void LayoutObject::paint(const PaintInfo&, const LayoutPoint&)
1038 { 1038 {
1039 } 1039 }
1040 1040
1041 const LayoutLayerModelObject* LayoutObject::containerForPaintInvalidation() cons t 1041 const LayoutBoxModelObject* LayoutObject::containerForPaintInvalidation() const
1042 { 1042 {
1043 RELEASE_ASSERT(isRooted()); 1043 RELEASE_ASSERT(isRooted());
1044 return adjustCompositedContainerForSpecialAncestors(enclosingCompositedConta iner()); 1044 return adjustCompositedContainerForSpecialAncestors(enclosingCompositedConta iner());
1045 } 1045 }
1046 1046
1047 const LayoutLayerModelObject* LayoutObject::enclosingCompositedContainer() const 1047 const LayoutBoxModelObject* LayoutObject::enclosingCompositedContainer() const
1048 { 1048 {
1049 LayoutLayerModelObject* container = 0; 1049 LayoutBoxModelObject* container = 0;
1050 // FIXME: CompositingState is not necessarily up to date for many callers of this function. 1050 // FIXME: CompositingState is not necessarily up to date for many callers of this function.
1051 DisableCompositingQueryAsserts disabler; 1051 DisableCompositingQueryAsserts disabler;
1052 1052
1053 if (Layer* compositingLayer = enclosingLayer()->enclosingLayerForPaintInvali dationCrossingFrameBoundaries()) 1053 if (Layer* compositingLayer = enclosingLayer()->enclosingLayerForPaintInvali dationCrossingFrameBoundaries())
1054 container = compositingLayer->renderer(); 1054 container = compositingLayer->renderer();
1055 return container; 1055 return container;
1056 } 1056 }
1057 1057
1058 const LayoutLayerModelObject* LayoutObject::adjustCompositedContainerForSpecialA ncestors(const LayoutLayerModelObject* paintInvalidationContainer) const 1058 const LayoutBoxModelObject* LayoutObject::adjustCompositedContainerForSpecialAnc estors(const LayoutBoxModelObject* paintInvalidationContainer) const
1059 { 1059 {
1060 if (paintInvalidationContainer) 1060 if (paintInvalidationContainer)
1061 return paintInvalidationContainer; 1061 return paintInvalidationContainer;
1062 1062
1063 RenderView* renderView = view(); 1063 RenderView* renderView = view();
1064 while (renderView->frame()->ownerRenderer()) 1064 while (renderView->frame()->ownerRenderer())
1065 renderView = renderView->frame()->ownerRenderer()->view(); 1065 renderView = renderView->frame()->ownerRenderer()->view();
1066 return renderView; 1066 return renderView;
1067 } 1067 }
1068 1068
1069 bool LayoutObject::isPaintInvalidationContainer() const 1069 bool LayoutObject::isPaintInvalidationContainer() const
1070 { 1070 {
1071 return hasLayer() && toLayoutLayerModelObject(this)->layer()->isPaintInvalid ationContainer(); 1071 return hasLayer() && toLayoutBoxModelObject(this)->layer()->isPaintInvalidat ionContainer();
1072 } 1072 }
1073 1073
1074 template <typename T> 1074 template <typename T>
1075 void addJsonObjectForRect(TracedValue* value, const char* name, const T& rect) 1075 void addJsonObjectForRect(TracedValue* value, const char* name, const T& rect)
1076 { 1076 {
1077 value->beginDictionary(name); 1077 value->beginDictionary(name);
1078 value->setDouble("x", rect.x()); 1078 value->setDouble("x", rect.x());
1079 value->setDouble("y", rect.y()); 1079 value->setDouble("y", rect.y());
1080 value->setDouble("width", rect.width()); 1080 value->setDouble("width", rect.width());
1081 value->setDouble("height", rect.height()); 1081 value->setDouble("height", rect.height());
(...skipping 10 matching lines...) Expand all
1092 } 1092 }
1093 1093
1094 static PassRefPtr<TraceEvent::ConvertableToTraceFormat> jsonObjectForPaintInvali dationInfo(const LayoutRect& rect, const String& invalidationReason) 1094 static PassRefPtr<TraceEvent::ConvertableToTraceFormat> jsonObjectForPaintInvali dationInfo(const LayoutRect& rect, const String& invalidationReason)
1095 { 1095 {
1096 RefPtr<TracedValue> value = TracedValue::create(); 1096 RefPtr<TracedValue> value = TracedValue::create();
1097 addJsonObjectForRect(value.get(), "rect", rect); 1097 addJsonObjectForRect(value.get(), "rect", rect);
1098 value->setString("invalidation_reason", invalidationReason); 1098 value->setString("invalidation_reason", invalidationReason);
1099 return value; 1099 return value;
1100 } 1100 }
1101 1101
1102 LayoutRect LayoutObject::computePaintInvalidationRect(const LayoutLayerModelObje ct* paintInvalidationContainer, const PaintInvalidationState* paintInvalidationS tate) const 1102 LayoutRect LayoutObject::computePaintInvalidationRect(const LayoutBoxModelObject * paintInvalidationContainer, const PaintInvalidationState* paintInvalidationSta te) const
1103 { 1103 {
1104 return clippedOverflowRectForPaintInvalidation(paintInvalidationContainer, p aintInvalidationState); 1104 return clippedOverflowRectForPaintInvalidation(paintInvalidationContainer, p aintInvalidationState);
1105 } 1105 }
1106 1106
1107 void LayoutObject::invalidatePaintUsingContainer(const LayoutLayerModelObject* p aintInvalidationContainer, const LayoutRect& r, PaintInvalidationReason invalida tionReason) const 1107 void LayoutObject::invalidatePaintUsingContainer(const LayoutBoxModelObject* pai ntInvalidationContainer, const LayoutRect& r, PaintInvalidationReason invalidati onReason) const
1108 { 1108 {
1109 ASSERT(gDisablePaintInvalidationStateAsserts || document().lifecycle().state () == DocumentLifecycle::InPaintInvalidation); 1109 ASSERT(gDisablePaintInvalidationStateAsserts || document().lifecycle().state () == DocumentLifecycle::InPaintInvalidation);
1110 1110
1111 if (r.isEmpty()) 1111 if (r.isEmpty())
1112 return; 1112 return;
1113 1113
1114 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { 1114 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
1115 if (Layer* container = enclosingLayer()->enclosingLayerForPaintInvalidat ionCrossingFrameBoundaries()) 1115 if (Layer* container = enclosingLayer()->enclosingLayerForPaintInvalidat ionCrossingFrameBoundaries())
1116 invalidateDisplayItemClients(container->graphicsLayerBacking()->disp layItemList()); 1116 invalidateDisplayItemClients(container->graphicsLayerBacking()->disp layItemList());
1117 } 1117 }
(...skipping 17 matching lines...) Expand all
1135 ASSERT(paintInvalidationContainer->isPaintInvalidationContainer()); 1135 ASSERT(paintInvalidationContainer->isPaintInvalidationContainer());
1136 paintInvalidationContainer->setBackingNeedsPaintInvalidationInRect(r, in validationReason); 1136 paintInvalidationContainer->setBackingNeedsPaintInvalidationInRect(r, in validationReason);
1137 } 1137 }
1138 } 1138 }
1139 1139
1140 void LayoutObject::invalidateDisplayItemClients(DisplayItemList* displayItemList ) const 1140 void LayoutObject::invalidateDisplayItemClients(DisplayItemList* displayItemList ) const
1141 { 1141 {
1142 displayItemList->invalidate(displayItemClient()); 1142 displayItemList->invalidate(displayItemClient());
1143 } 1143 }
1144 1144
1145 LayoutRect LayoutObject::boundsRectForPaintInvalidation(const LayoutLayerModelOb ject* paintInvalidationContainer, const PaintInvalidationState* paintInvalidatio nState) const 1145 LayoutRect LayoutObject::boundsRectForPaintInvalidation(const LayoutBoxModelObje ct* paintInvalidationContainer, const PaintInvalidationState* paintInvalidationS tate) const
1146 { 1146 {
1147 if (!paintInvalidationContainer) 1147 if (!paintInvalidationContainer)
1148 return computePaintInvalidationRect(paintInvalidationContainer, paintInv alidationState); 1148 return computePaintInvalidationRect(paintInvalidationContainer, paintInv alidationState);
1149 return Layer::computePaintInvalidationRect(this, paintInvalidationContainer- >layer(), paintInvalidationState); 1149 return Layer::computePaintInvalidationRect(this, paintInvalidationContainer- >layer(), paintInvalidationState);
1150 } 1150 }
1151 1151
1152 void LayoutObject::invalidatePaintRectangle(const LayoutRect& r) const 1152 void LayoutObject::invalidatePaintRectangle(const LayoutRect& r) const
1153 { 1153 {
1154 RELEASE_ASSERT(isRooted()); 1154 RELEASE_ASSERT(isRooted());
1155 1155
1156 if (view()->document().printing()) 1156 if (view()->document().printing())
1157 return; // Don't invalidate paints if we're printing. 1157 return; // Don't invalidate paints if we're printing.
1158 1158
1159 LayoutRect dirtyRect(r); 1159 LayoutRect dirtyRect(r);
1160 1160
1161 const LayoutLayerModelObject* paintInvalidationContainer = containerForPaint Invalidation(); 1161 const LayoutBoxModelObject* paintInvalidationContainer = containerForPaintIn validation();
1162 Layer::mapRectToPaintInvalidationBacking(this, paintInvalidationContainer, d irtyRect); 1162 Layer::mapRectToPaintInvalidationBacking(this, paintInvalidationContainer, d irtyRect);
1163 invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRect, PaintIn validationRectangle); 1163 invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRect, PaintIn validationRectangle);
1164 } 1164 }
1165 1165
1166 void LayoutObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInv alidationState) 1166 void LayoutObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInv alidationState)
1167 { 1167 {
1168 ASSERT(!needsLayout()); 1168 ASSERT(!needsLayout());
1169 1169
1170 // If we didn't need paint invalidation then our children don't need as well . 1170 // If we didn't need paint invalidation then our children don't need as well .
1171 // Skip walking down the tree as everything should be fine below us. 1171 // Skip walking down the tree as everything should be fine below us.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 return; 1210 return;
1211 selectionPaintInvalidationMap = new SelectionPaintInvalidationMap(); 1211 selectionPaintInvalidationMap = new SelectionPaintInvalidationMap();
1212 } 1212 }
1213 1213
1214 if (selectionRect.isEmpty()) 1214 if (selectionRect.isEmpty())
1215 selectionPaintInvalidationMap->remove(this); 1215 selectionPaintInvalidationMap->remove(this);
1216 else 1216 else
1217 selectionPaintInvalidationMap->set(this, selectionRect); 1217 selectionPaintInvalidationMap->set(this, selectionRect);
1218 } 1218 }
1219 1219
1220 void LayoutObject::invalidateSelectionIfNeeded(const LayoutLayerModelObject& pai ntInvalidationContainer, PaintInvalidationReason invalidationReason) 1220 void LayoutObject::invalidateSelectionIfNeeded(const LayoutBoxModelObject& paint InvalidationContainer, PaintInvalidationReason invalidationReason)
1221 { 1221 {
1222 // Update selection rect when we are doing full invalidation (in case that t he object is moved, composite status changed, etc.) 1222 // Update selection rect when we are doing full invalidation (in case that t he object is moved, composite status changed, etc.)
1223 // or shouldInvalidationSelection is set (in case that the selection itself changed). 1223 // or shouldInvalidationSelection is set (in case that the selection itself changed).
1224 bool fullInvalidation = view()->doingFullPaintInvalidation() || isFullPaintI nvalidationReason(invalidationReason); 1224 bool fullInvalidation = view()->doingFullPaintInvalidation() || isFullPaintI nvalidationReason(invalidationReason);
1225 if (!fullInvalidation && !shouldInvalidateSelection()) 1225 if (!fullInvalidation && !shouldInvalidateSelection())
1226 return; 1226 return;
1227 1227
1228 LayoutRect oldSelectionRect = previousSelectionRectForPaintInvalidation(); 1228 LayoutRect oldSelectionRect = previousSelectionRectForPaintInvalidation();
1229 LayoutRect newSelectionRect = selectionRectForPaintInvalidation(&paintInvali dationContainer); 1229 LayoutRect newSelectionRect = selectionRectForPaintInvalidation(&paintInvali dationContainer);
1230 setPreviousSelectionRectForPaintInvalidation(newSelectionRect); 1230 setPreviousSelectionRectForPaintInvalidation(newSelectionRect);
1231 1231
1232 if (fullInvalidation) 1232 if (fullInvalidation)
1233 return; 1233 return;
1234 1234
1235 fullyInvalidatePaint(paintInvalidationContainer, PaintInvalidationSelection, oldSelectionRect, newSelectionRect); 1235 fullyInvalidatePaint(paintInvalidationContainer, PaintInvalidationSelection, oldSelectionRect, newSelectionRect);
1236 } 1236 }
1237 1237
1238 PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(const PaintInvalid ationState& paintInvalidationState, const LayoutLayerModelObject& paintInvalidat ionContainer) 1238 PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(const PaintInvalid ationState& paintInvalidationState, const LayoutBoxModelObject& paintInvalidatio nContainer)
1239 { 1239 {
1240 RenderView* v = view(); 1240 RenderView* v = view();
1241 if (v->document().printing()) 1241 if (v->document().printing())
1242 return PaintInvalidationNone; // Don't invalidate paints if we're printi ng. 1242 return PaintInvalidationNone; // Don't invalidate paints if we're printi ng.
1243 1243
1244 const LayoutRect oldBounds = previousPaintInvalidationRect(); 1244 const LayoutRect oldBounds = previousPaintInvalidationRect();
1245 const LayoutPoint oldLocation = previousPositionFromPaintInvalidationBacking (); 1245 const LayoutPoint oldLocation = previousPositionFromPaintInvalidationBacking ();
1246 const LayoutRect newBounds = boundsRectForPaintInvalidation(&paintInvalidati onContainer, &paintInvalidationState); 1246 const LayoutRect newBounds = boundsRectForPaintInvalidation(&paintInvalidati onContainer, &paintInvalidationState);
1247 const LayoutPoint newLocation = Layer::positionFromPaintInvalidationBacking( this, &paintInvalidationContainer, &paintInvalidationState); 1247 const LayoutPoint newLocation = Layer::positionFromPaintInvalidationBacking( this, &paintInvalidationContainer, &paintInvalidationState);
1248 setPreviousPaintInvalidationRect(newBounds); 1248 setPreviousPaintInvalidationRect(newBounds);
(...skipping 20 matching lines...) Expand all
1269 1269
1270 if (invalidationReason == PaintInvalidationIncremental) { 1270 if (invalidationReason == PaintInvalidationIncremental) {
1271 incrementallyInvalidatePaint(paintInvalidationContainer, oldBounds, newB ounds, newLocation); 1271 incrementallyInvalidatePaint(paintInvalidationContainer, oldBounds, newB ounds, newLocation);
1272 return invalidationReason; 1272 return invalidationReason;
1273 } 1273 }
1274 1274
1275 fullyInvalidatePaint(paintInvalidationContainer, invalidationReason, oldBoun ds, newBounds); 1275 fullyInvalidatePaint(paintInvalidationContainer, invalidationReason, oldBoun ds, newBounds);
1276 return invalidationReason; 1276 return invalidationReason;
1277 } 1277 }
1278 1278
1279 PaintInvalidationReason LayoutObject::paintInvalidationReason(const LayoutLayerM odelObject& paintInvalidationContainer, 1279 PaintInvalidationReason LayoutObject::paintInvalidationReason(const LayoutBoxMod elObject& paintInvalidationContainer,
1280 const LayoutRect& oldBounds, const LayoutPoint& oldPositionFromPaintInvalida tionBacking, 1280 const LayoutRect& oldBounds, const LayoutPoint& oldPositionFromPaintInvalida tionBacking,
1281 const LayoutRect& newBounds, const LayoutPoint& newPositionFromPaintInvalida tionBacking) const 1281 const LayoutRect& newBounds, const LayoutPoint& newPositionFromPaintInvalida tionBacking) const
1282 { 1282 {
1283 // First check for InvalidationLocationChange to avoid it from being hidden by other 1283 // First check for InvalidationLocationChange to avoid it from being hidden by other
1284 // invalidation reasons because we'll need to force check for paint invalida tion for 1284 // invalidation reasons because we'll need to force check for paint invalida tion for
1285 // children when location of this object changed. 1285 // children when location of this object changed.
1286 if (newPositionFromPaintInvalidationBacking != oldPositionFromPaintInvalidat ionBacking) 1286 if (newPositionFromPaintInvalidationBacking != oldPositionFromPaintInvalidat ionBacking)
1287 return PaintInvalidationLocationChange; 1287 return PaintInvalidationLocationChange;
1288 1288
1289 if (shouldDoFullPaintInvalidation()) 1289 if (shouldDoFullPaintInvalidation())
(...skipping 22 matching lines...) Expand all
1312 // into the incremental invalidation we'll issue two invalidations instead 1312 // into the incremental invalidation we'll issue two invalidations instead
1313 // of one. 1313 // of one.
1314 if (oldBounds.isEmpty()) 1314 if (oldBounds.isEmpty())
1315 return PaintInvalidationBecameVisible; 1315 return PaintInvalidationBecameVisible;
1316 if (newBounds.isEmpty()) 1316 if (newBounds.isEmpty())
1317 return PaintInvalidationBecameInvisible; 1317 return PaintInvalidationBecameInvisible;
1318 1318
1319 return PaintInvalidationIncremental; 1319 return PaintInvalidationIncremental;
1320 } 1320 }
1321 1321
1322 void LayoutObject::incrementallyInvalidatePaint(const LayoutLayerModelObject& pa intInvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBoun ds, const LayoutPoint& positionFromPaintInvalidationBacking) 1322 void LayoutObject::incrementallyInvalidatePaint(const LayoutBoxModelObject& pain tInvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds , const LayoutPoint& positionFromPaintInvalidationBacking)
1323 { 1323 {
1324 ASSERT(oldBounds.location() == newBounds.location()); 1324 ASSERT(oldBounds.location() == newBounds.location());
1325 1325
1326 LayoutUnit deltaRight = newBounds.maxX() - oldBounds.maxX(); 1326 LayoutUnit deltaRight = newBounds.maxX() - oldBounds.maxX();
1327 if (deltaRight > 0) 1327 if (deltaRight > 0)
1328 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ol dBounds.maxX(), newBounds.y(), deltaRight, newBounds.height()), PaintInvalidatio nIncremental); 1328 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ol dBounds.maxX(), newBounds.y(), deltaRight, newBounds.height()), PaintInvalidatio nIncremental);
1329 else if (deltaRight < 0) 1329 else if (deltaRight < 0)
1330 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ne wBounds.maxX(), oldBounds.y(), -deltaRight, oldBounds.height()), PaintInvalidati onIncremental); 1330 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ne wBounds.maxX(), oldBounds.y(), -deltaRight, oldBounds.height()), PaintInvalidati onIncremental);
1331 1331
1332 LayoutUnit deltaBottom = newBounds.maxY() - oldBounds.maxY(); 1332 LayoutUnit deltaBottom = newBounds.maxY() - oldBounds.maxY();
1333 if (deltaBottom > 0) 1333 if (deltaBottom > 0)
1334 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ne wBounds.x(), oldBounds.maxY(), newBounds.width(), deltaBottom), PaintInvalidatio nIncremental); 1334 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ne wBounds.x(), oldBounds.maxY(), newBounds.width(), deltaBottom), PaintInvalidatio nIncremental);
1335 else if (deltaBottom < 0) 1335 else if (deltaBottom < 0)
1336 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ol dBounds.x(), newBounds.maxY(), oldBounds.width(), -deltaBottom), PaintInvalidati onIncremental); 1336 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ol dBounds.x(), newBounds.maxY(), oldBounds.width(), -deltaBottom), PaintInvalidati onIncremental);
1337 } 1337 }
1338 1338
1339 void LayoutObject::fullyInvalidatePaint(const LayoutLayerModelObject& paintInval idationContainer, PaintInvalidationReason invalidationReason, const LayoutRect& oldBounds, const LayoutRect& newBounds) 1339 void LayoutObject::fullyInvalidatePaint(const LayoutBoxModelObject& paintInvalid ationContainer, PaintInvalidationReason invalidationReason, const LayoutRect& ol dBounds, const LayoutRect& newBounds)
1340 { 1340 {
1341 // Otherwise do full paint invalidation. 1341 // Otherwise do full paint invalidation.
1342 invalidatePaintUsingContainer(&paintInvalidationContainer, oldBounds, invali dationReason); 1342 invalidatePaintUsingContainer(&paintInvalidationContainer, oldBounds, invali dationReason);
1343 if (newBounds != oldBounds) 1343 if (newBounds != oldBounds)
1344 invalidatePaintUsingContainer(&paintInvalidationContainer, newBounds, in validationReason); 1344 invalidatePaintUsingContainer(&paintInvalidationContainer, newBounds, in validationReason);
1345 } 1345 }
1346 1346
1347 void LayoutObject::invalidatePaintForOverflow() 1347 void LayoutObject::invalidatePaintForOverflow()
1348 { 1348 {
1349 } 1349 }
1350 1350
1351 void LayoutObject::invalidatePaintForOverflowIfNeeded() 1351 void LayoutObject::invalidatePaintForOverflowIfNeeded()
1352 { 1352 {
1353 if (shouldInvalidateOverflowForPaint()) 1353 if (shouldInvalidateOverflowForPaint())
1354 invalidatePaintForOverflow(); 1354 invalidatePaintForOverflow();
1355 } 1355 }
1356 1356
1357 LayoutRect LayoutObject::rectWithOutlineForPaintInvalidation(const LayoutLayerMo delObject* paintInvalidationContainer, LayoutUnit outlineWidth, const PaintInval idationState* paintInvalidationState) const 1357 LayoutRect LayoutObject::rectWithOutlineForPaintInvalidation(const LayoutBoxMode lObject* paintInvalidationContainer, LayoutUnit outlineWidth, const PaintInvalid ationState* paintInvalidationState) const
1358 { 1358 {
1359 LayoutRect r(clippedOverflowRectForPaintInvalidation(paintInvalidationContai ner, paintInvalidationState)); 1359 LayoutRect r(clippedOverflowRectForPaintInvalidation(paintInvalidationContai ner, paintInvalidationState));
1360 r.inflate(outlineWidth); 1360 r.inflate(outlineWidth);
1361 return r; 1361 return r;
1362 } 1362 }
1363 1363
1364 LayoutRect LayoutObject::absoluteClippedOverflowRect() const 1364 LayoutRect LayoutObject::absoluteClippedOverflowRect() const
1365 { 1365 {
1366 return clippedOverflowRectForPaintInvalidation(view()); 1366 return clippedOverflowRectForPaintInvalidation(view());
1367 } 1367 }
1368 1368
1369 LayoutRect LayoutObject::clippedOverflowRectForPaintInvalidation(const LayoutLay erModelObject*, const PaintInvalidationState*) const 1369 LayoutRect LayoutObject::clippedOverflowRectForPaintInvalidation(const LayoutBox ModelObject*, const PaintInvalidationState*) const
1370 { 1370 {
1371 ASSERT_NOT_REACHED(); 1371 ASSERT_NOT_REACHED();
1372 return LayoutRect(); 1372 return LayoutRect();
1373 } 1373 }
1374 1374
1375 void LayoutObject::mapRectToPaintInvalidationBacking(const LayoutLayerModelObjec t* paintInvalidationContainer, LayoutRect& rect, const PaintInvalidationState* p aintInvalidationState) const 1375 void LayoutObject::mapRectToPaintInvalidationBacking(const LayoutBoxModelObject* paintInvalidationContainer, LayoutRect& rect, const PaintInvalidationState* pai ntInvalidationState) const
1376 { 1376 {
1377 if (paintInvalidationContainer == this) 1377 if (paintInvalidationContainer == this)
1378 return; 1378 return;
1379 1379
1380 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain tInvalidationContainer)) { 1380 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain tInvalidationContainer)) {
1381 rect.move(paintInvalidationState->paintOffset()); 1381 rect.move(paintInvalidationState->paintOffset());
1382 if (paintInvalidationState->isClipped()) 1382 if (paintInvalidationState->isClipped())
1383 rect.intersect(paintInvalidationState->clipRect()); 1383 rect.intersect(paintInvalidationState->clipRect());
1384 return; 1384 return;
1385 } 1385 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 1535
1536 StyleDifference LayoutObject::adjustStyleDifference(StyleDifference diff) const 1536 StyleDifference LayoutObject::adjustStyleDifference(StyleDifference diff) const
1537 { 1537 {
1538 if (diff.transformChanged() && isSVG()) 1538 if (diff.transformChanged() && isSVG())
1539 diff.setNeedsFullLayout(); 1539 diff.setNeedsFullLayout();
1540 1540
1541 // If transform changed, and the layer does not paint into its own separate backing, then we need to invalidate paints. 1541 // If transform changed, and the layer does not paint into its own separate backing, then we need to invalidate paints.
1542 if (diff.transformChanged()) { 1542 if (diff.transformChanged()) {
1543 // Text nodes share style with their parents but transforms don't apply to them, 1543 // Text nodes share style with their parents but transforms don't apply to them,
1544 // hence the !isText() check. 1544 // hence the !isText() check.
1545 if (!isText() && (!hasLayer() || !toLayoutLayerModelObject(this)->layer( )->hasStyleDeterminedDirectCompositingReasons())) 1545 if (!isText() && (!hasLayer() || !toLayoutBoxModelObject(this)->layer()- >hasStyleDeterminedDirectCompositingReasons()))
1546 diff.setNeedsPaintInvalidationLayer(); 1546 diff.setNeedsPaintInvalidationLayer();
1547 } 1547 }
1548 1548
1549 // If opacity or zIndex changed, and the layer does not paint into its own s eparate backing, then we need to invalidate paints (also 1549 // If opacity or zIndex changed, and the layer does not paint into its own s eparate backing, then we need to invalidate paints (also
1550 // ignoring text nodes) 1550 // ignoring text nodes)
1551 if (diff.opacityChanged() || diff.zIndexChanged()) { 1551 if (diff.opacityChanged() || diff.zIndexChanged()) {
1552 if (!isText() && (!hasLayer() || !toLayoutLayerModelObject(this)->layer( )->hasStyleDeterminedDirectCompositingReasons())) 1552 if (!isText() && (!hasLayer() || !toLayoutBoxModelObject(this)->layer()- >hasStyleDeterminedDirectCompositingReasons()))
1553 diff.setNeedsPaintInvalidationLayer(); 1553 diff.setNeedsPaintInvalidationLayer();
1554 } 1554 }
1555 1555
1556 // If filter changed, and the layer does not paint into its own separate bac king or it paints with filters, then we need to invalidate paints. 1556 // If filter changed, and the layer does not paint into its own separate bac king or it paints with filters, then we need to invalidate paints.
1557 if (diff.filterChanged() && hasLayer()) { 1557 if (diff.filterChanged() && hasLayer()) {
1558 Layer* layer = toLayoutLayerModelObject(this)->layer(); 1558 Layer* layer = toLayoutBoxModelObject(this)->layer();
1559 if (!layer->hasStyleDeterminedDirectCompositingReasons() || layer->paint sWithFilters()) 1559 if (!layer->hasStyleDeterminedDirectCompositingReasons() || layer->paint sWithFilters())
1560 diff.setNeedsPaintInvalidationLayer(); 1560 diff.setNeedsPaintInvalidationLayer();
1561 } 1561 }
1562 1562
1563 if (diff.textOrColorChanged() && !diff.needsPaintInvalidation()) { 1563 if (diff.textOrColorChanged() && !diff.needsPaintInvalidation()) {
1564 if (style()->hasBorder() || style()->hasOutline() 1564 if (style()->hasBorder() || style()->hasOutline()
1565 || (isText() && !toRenderText(this)->isAllCollapsibleWhitespace())) 1565 || (isText() && !toRenderText(this)->isAllCollapsibleWhitespace()))
1566 diff.setNeedsPaintInvalidationObject(); 1566 diff.setNeedsPaintInvalidationObject();
1567 } 1567 }
1568 1568
1569 // The answer to layerTypeRequired() for plugins, iframes, and canvas can ch ange without the actual 1569 // The answer to layerTypeRequired() for plugins, iframes, and canvas can ch ange without the actual
1570 // style changing, since it depends on whether we decide to composite these elements. When the 1570 // style changing, since it depends on whether we decide to composite these elements. When the
1571 // layer status of one of these elements changes, we need to force a layout. 1571 // layer status of one of these elements changes, we need to force a layout.
1572 if (!diff.needsFullLayout() && style() && isLayoutLayerModelObject()) { 1572 if (!diff.needsFullLayout() && style() && isLayoutBoxModelObject()) {
1573 bool requiresLayer = toLayoutLayerModelObject(this)->layerTypeRequired() != NoLayer; 1573 bool requiresLayer = toLayoutBoxModelObject(this)->layerTypeRequired() ! = NoLayer;
1574 if (hasLayer() != requiresLayer) 1574 if (hasLayer() != requiresLayer)
1575 diff.setNeedsFullLayout(); 1575 diff.setNeedsFullLayout();
1576 } 1576 }
1577 1577
1578 // If we have no layer(), just treat a PaintInvalidationLayer hint as a norm al paint invalidation. 1578 // If we have no layer(), just treat a PaintInvalidationLayer hint as a norm al paint invalidation.
1579 if (diff.needsPaintInvalidationLayer() && !hasLayer()) { 1579 if (diff.needsPaintInvalidationLayer() && !hasLayer()) {
1580 diff.clearNeedsPaintInvalidation(); 1580 diff.clearNeedsPaintInvalidation();
1581 diff.setNeedsPaintInvalidationObject(); 1581 diff.setNeedsPaintInvalidationObject();
1582 } 1582 }
1583 1583
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 else if (updatedDiff.needsPositionedMovementLayout()) 1672 else if (updatedDiff.needsPositionedMovementLayout())
1673 setNeedsPositionedMovementLayout(); 1673 setNeedsPositionedMovementLayout();
1674 } 1674 }
1675 1675
1676 if (diff.transformChanged() && !needsLayout()) { 1676 if (diff.transformChanged() && !needsLayout()) {
1677 if (RenderBlock* container = containingBlock()) 1677 if (RenderBlock* container = containingBlock())
1678 container->setNeedsOverflowRecalcAfterStyleChange(); 1678 container->setNeedsOverflowRecalcAfterStyleChange();
1679 } 1679 }
1680 1680
1681 if (updatedDiff.needsPaintInvalidationLayer()) 1681 if (updatedDiff.needsPaintInvalidationLayer())
1682 toLayoutLayerModelObject(this)->layer()->setShouldDoFullPaintInvalidatio nIncludingNonCompositingDescendants(); 1682 toLayoutBoxModelObject(this)->layer()->setShouldDoFullPaintInvalidationI ncludingNonCompositingDescendants();
1683 else if (diff.needsPaintInvalidationObject() || updatedDiff.needsPaintInvali dationObject()) 1683 else if (diff.needsPaintInvalidationObject() || updatedDiff.needsPaintInvali dationObject())
1684 setShouldDoFullPaintInvalidation(); 1684 setShouldDoFullPaintInvalidation();
1685 } 1685 }
1686 1686
1687 static inline bool rendererHasBackground(const LayoutObject* renderer) 1687 static inline bool rendererHasBackground(const LayoutObject* renderer)
1688 { 1688 {
1689 return renderer && renderer->hasBackground(); 1689 return renderer && renderer->hasBackground();
1690 } 1690 }
1691 1691
1692 void LayoutObject::styleWillChange(StyleDifference diff, const LayoutStyle& newS tyle) 1692 void LayoutObject::styleWillChange(StyleDifference diff, const LayoutStyle& newS tyle)
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 } 1922 }
1923 1923
1924 FloatQuad LayoutObject::absoluteToLocalQuad(const FloatQuad& quad, MapCoordinate sFlags mode) const 1924 FloatQuad LayoutObject::absoluteToLocalQuad(const FloatQuad& quad, MapCoordinate sFlags mode) const
1925 { 1925 {
1926 TransformState transformState(TransformState::UnapplyInverseTransformDirecti on, quad.boundingBox().center(), quad); 1926 TransformState transformState(TransformState::UnapplyInverseTransformDirecti on, quad.boundingBox().center(), quad);
1927 mapAbsoluteToLocalPoint(mode, transformState); 1927 mapAbsoluteToLocalPoint(mode, transformState);
1928 transformState.flatten(); 1928 transformState.flatten();
1929 return transformState.lastPlanarQuad(); 1929 return transformState.lastPlanarQuad();
1930 } 1930 }
1931 1931
1932 void LayoutObject::mapLocalToContainer(const LayoutLayerModelObject* paintInvali dationContainer, TransformState& transformState, MapCoordinatesFlags mode, bool* wasFixed, const PaintInvalidationState* paintInvalidationState) const 1932 void LayoutObject::mapLocalToContainer(const LayoutBoxModelObject* paintInvalida tionContainer, TransformState& transformState, MapCoordinatesFlags mode, bool* w asFixed, const PaintInvalidationState* paintInvalidationState) const
1933 { 1933 {
1934 if (paintInvalidationContainer == this) 1934 if (paintInvalidationContainer == this)
1935 return; 1935 return;
1936 1936
1937 LayoutObject* o = parent(); 1937 LayoutObject* o = parent();
1938 if (!o) 1938 if (!o)
1939 return; 1939 return;
1940 1940
1941 // FIXME: this should call offsetFromContainer to share code, but I'm not su re it's ever called. 1941 // FIXME: this should call offsetFromContainer to share code, but I'm not su re it's ever called.
1942 LayoutPoint centerPoint = roundedLayoutPoint(transformState.mappedPoint()); 1942 LayoutPoint centerPoint = roundedLayoutPoint(transformState.mappedPoint());
1943 if (mode & ApplyContainerFlip && o->isBox()) { 1943 if (mode & ApplyContainerFlip && o->isBox()) {
1944 if (o->style()->isFlippedBlocksWritingMode()) 1944 if (o->style()->isFlippedBlocksWritingMode())
1945 transformState.move(toRenderBox(o)->flipForWritingModeIncludingColum ns(roundedLayoutPoint(transformState.mappedPoint())) - centerPoint); 1945 transformState.move(toRenderBox(o)->flipForWritingModeIncludingColum ns(roundedLayoutPoint(transformState.mappedPoint())) - centerPoint);
1946 mode &= ~ApplyContainerFlip; 1946 mode &= ~ApplyContainerFlip;
1947 } 1947 }
1948 1948
1949 transformState.move(o->columnOffset(roundedLayoutPoint(transformState.mapped Point()))); 1949 transformState.move(o->columnOffset(roundedLayoutPoint(transformState.mapped Point())));
1950 1950
1951 if (o->hasOverflowClip()) 1951 if (o->hasOverflowClip())
1952 transformState.move(-toRenderBox(o)->scrolledContentOffset()); 1952 transformState.move(-toRenderBox(o)->scrolledContentOffset());
1953 1953
1954 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode, was Fixed, paintInvalidationState); 1954 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode, was Fixed, paintInvalidationState);
1955 } 1955 }
1956 1956
1957 const LayoutObject* LayoutObject::pushMappingToContainer(const LayoutLayerModelO bject* ancestorToStopAt, LayoutGeometryMap& geometryMap) const 1957 const LayoutObject* LayoutObject::pushMappingToContainer(const LayoutBoxModelObj ect* ancestorToStopAt, LayoutGeometryMap& geometryMap) const
1958 { 1958 {
1959 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != this); 1959 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != this);
1960 1960
1961 LayoutObject* container = parent(); 1961 LayoutObject* container = parent();
1962 if (!container) 1962 if (!container)
1963 return 0; 1963 return 0;
1964 1964
1965 // FIXME: this should call offsetFromContainer to share code, but I'm not su re it's ever called. 1965 // FIXME: this should call offsetFromContainer to share code, but I'm not su re it's ever called.
1966 LayoutSize offset; 1966 LayoutSize offset;
1967 if (container->hasOverflowClip()) 1967 if (container->hasOverflowClip())
(...skipping 11 matching lines...) Expand all
1979 o->mapAbsoluteToLocalPoint(mode, transformState); 1979 o->mapAbsoluteToLocalPoint(mode, transformState);
1980 if (o->hasOverflowClip()) 1980 if (o->hasOverflowClip())
1981 transformState.move(toRenderBox(o)->scrolledContentOffset()); 1981 transformState.move(toRenderBox(o)->scrolledContentOffset());
1982 } 1982 }
1983 } 1983 }
1984 1984
1985 bool LayoutObject::shouldUseTransformFromContainer(const LayoutObject* container Object) const 1985 bool LayoutObject::shouldUseTransformFromContainer(const LayoutObject* container Object) const
1986 { 1986 {
1987 // hasTransform() indicates whether the object has transform, transform-styl e or perspective. We just care about transform, 1987 // hasTransform() indicates whether the object has transform, transform-styl e or perspective. We just care about transform,
1988 // so check the layer's transform directly. 1988 // so check the layer's transform directly.
1989 return (hasLayer() && toLayoutLayerModelObject(this)->layer()->transform()) || (containerObject && containerObject->style()->hasPerspective()); 1989 return (hasLayer() && toLayoutBoxModelObject(this)->layer()->transform()) || (containerObject && containerObject->style()->hasPerspective());
1990 } 1990 }
1991 1991
1992 void LayoutObject::getTransformFromContainer(const LayoutObject* containerObject , const LayoutSize& offsetInContainer, TransformationMatrix& transform) const 1992 void LayoutObject::getTransformFromContainer(const LayoutObject* containerObject , const LayoutSize& offsetInContainer, TransformationMatrix& transform) const
1993 { 1993 {
1994 transform.makeIdentity(); 1994 transform.makeIdentity();
1995 transform.translate(offsetInContainer.width().toFloat(), offsetInContainer.h eight().toFloat()); 1995 transform.translate(offsetInContainer.width().toFloat(), offsetInContainer.h eight().toFloat());
1996 Layer* layer = hasLayer() ? toLayoutLayerModelObject(this)->layer() : 0; 1996 Layer* layer = hasLayer() ? toLayoutBoxModelObject(this)->layer() : 0;
1997 if (layer && layer->transform()) 1997 if (layer && layer->transform())
1998 transform.multiply(layer->currentTransform()); 1998 transform.multiply(layer->currentTransform());
1999 1999
2000 if (containerObject && containerObject->hasLayer() && containerObject->style ()->hasPerspective()) { 2000 if (containerObject && containerObject->hasLayer() && containerObject->style ()->hasPerspective()) {
2001 // Perpsective on the container affects us, so we have to factor it in h ere. 2001 // Perpsective on the container affects us, so we have to factor it in h ere.
2002 ASSERT(containerObject->hasLayer()); 2002 ASSERT(containerObject->hasLayer());
2003 FloatPoint perspectiveOrigin = toLayoutLayerModelObject(containerObject) ->layer()->perspectiveOrigin(); 2003 FloatPoint perspectiveOrigin = toLayoutBoxModelObject(containerObject)-> layer()->perspectiveOrigin();
2004 2004
2005 TransformationMatrix perspectiveMatrix; 2005 TransformationMatrix perspectiveMatrix;
2006 perspectiveMatrix.applyPerspective(containerObject->style()->perspective ()); 2006 perspectiveMatrix.applyPerspective(containerObject->style()->perspective ());
2007 2007
2008 transform.translateRight3d(-perspectiveOrigin.x(), -perspectiveOrigin.y( ), 0); 2008 transform.translateRight3d(-perspectiveOrigin.x(), -perspectiveOrigin.y( ), 0);
2009 transform = perspectiveMatrix * transform; 2009 transform = perspectiveMatrix * transform;
2010 transform.translateRight3d(perspectiveOrigin.x(), perspectiveOrigin.y(), 0); 2010 transform.translateRight3d(perspectiveOrigin.x(), perspectiveOrigin.y(), 0);
2011 } 2011 }
2012 } 2012 }
2013 2013
2014 FloatQuad LayoutObject::localToContainerQuad(const FloatQuad& localQuad, const L ayoutLayerModelObject* paintInvalidationContainer, MapCoordinatesFlags mode, boo l* wasFixed) const 2014 FloatQuad LayoutObject::localToContainerQuad(const FloatQuad& localQuad, const L ayoutBoxModelObject* paintInvalidationContainer, MapCoordinatesFlags mode, bool* wasFixed) const
2015 { 2015 {
2016 // Track the point at the center of the quad's bounding box. As mapLocalToCo ntainer() calls offsetFromContainer(), 2016 // Track the point at the center of the quad's bounding box. As mapLocalToCo ntainer() calls offsetFromContainer(),
2017 // it will use that point as the reference point to decide which column's tr ansform to apply in multiple-column blocks. 2017 // it will use that point as the reference point to decide which column's tr ansform to apply in multiple-column blocks.
2018 TransformState transformState(TransformState::ApplyTransformDirection, local Quad.boundingBox().center(), localQuad); 2018 TransformState transformState(TransformState::ApplyTransformDirection, local Quad.boundingBox().center(), localQuad);
2019 mapLocalToContainer(paintInvalidationContainer, transformState, mode | Apply ContainerFlip | UseTransforms, wasFixed); 2019 mapLocalToContainer(paintInvalidationContainer, transformState, mode | Apply ContainerFlip | UseTransforms, wasFixed);
2020 transformState.flatten(); 2020 transformState.flatten();
2021 2021
2022 return transformState.lastPlanarQuad(); 2022 return transformState.lastPlanarQuad();
2023 } 2023 }
2024 2024
2025 FloatPoint LayoutObject::localToContainerPoint(const FloatPoint& localPoint, con st LayoutLayerModelObject* paintInvalidationContainer, MapCoordinatesFlags mode, bool* wasFixed, const PaintInvalidationState* paintInvalidationState) const 2025 FloatPoint LayoutObject::localToContainerPoint(const FloatPoint& localPoint, con st LayoutBoxModelObject* paintInvalidationContainer, MapCoordinatesFlags mode, b ool* wasFixed, const PaintInvalidationState* paintInvalidationState) const
2026 { 2026 {
2027 TransformState transformState(TransformState::ApplyTransformDirection, local Point); 2027 TransformState transformState(TransformState::ApplyTransformDirection, local Point);
2028 mapLocalToContainer(paintInvalidationContainer, transformState, mode | Apply ContainerFlip | UseTransforms, wasFixed, paintInvalidationState); 2028 mapLocalToContainer(paintInvalidationContainer, transformState, mode | Apply ContainerFlip | UseTransforms, wasFixed, paintInvalidationState);
2029 transformState.flatten(); 2029 transformState.flatten();
2030 2030
2031 return transformState.lastPlanarPoint(); 2031 return transformState.lastPlanarPoint();
2032 } 2032 }
2033 2033
2034 FloatPoint LayoutObject::localToInvalidationBackingPoint(const LayoutPoint& loca lPoint, Layer** backingLayer) 2034 FloatPoint LayoutObject::localToInvalidationBackingPoint(const LayoutPoint& loca lPoint, Layer** backingLayer)
2035 { 2035 {
2036 const LayoutLayerModelObject* paintInvalidationContainer = containerForPaint Invalidation(); 2036 const LayoutBoxModelObject* paintInvalidationContainer = containerForPaintIn validation();
2037 ASSERT(paintInvalidationContainer); 2037 ASSERT(paintInvalidationContainer);
2038 ASSERT(paintInvalidationContainer->layer()); 2038 ASSERT(paintInvalidationContainer->layer());
2039 2039
2040 if (backingLayer) 2040 if (backingLayer)
2041 *backingLayer = paintInvalidationContainer->layer(); 2041 *backingLayer = paintInvalidationContainer->layer();
2042 FloatPoint containerPoint = localToContainerPoint(FloatPoint(localPoint), pa intInvalidationContainer, TraverseDocumentBoundaries); 2042 FloatPoint containerPoint = localToContainerPoint(FloatPoint(localPoint), pa intInvalidationContainer, TraverseDocumentBoundaries);
2043 2043
2044 // A renderer can have no invalidation backing if it is from a detached fram e, 2044 // A renderer can have no invalidation backing if it is from a detached fram e,
2045 // or when forced compositing is disabled. 2045 // or when forced compositing is disabled.
2046 if (paintInvalidationContainer->layer()->compositingState() == NotComposited ) 2046 if (paintInvalidationContainer->layer()->compositingState() == NotComposited )
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2173 } 2173 }
2174 } 2174 }
2175 } 2175 }
2176 2176
2177 bool LayoutObject::isRooted() const 2177 bool LayoutObject::isRooted() const
2178 { 2178 {
2179 const LayoutObject* object = this; 2179 const LayoutObject* object = this;
2180 while (object->parent() && !object->hasLayer()) 2180 while (object->parent() && !object->hasLayer())
2181 object = object->parent(); 2181 object = object->parent();
2182 if (object->hasLayer()) 2182 if (object->hasLayer())
2183 return toLayoutLayerModelObject(object)->layer()->root()->isRootLayer(); 2183 return toLayoutBoxModelObject(object)->layer()->root()->isRootLayer();
2184 return false; 2184 return false;
2185 } 2185 }
2186 2186
2187 LayoutObject* LayoutObject::rendererForRootBackground() 2187 LayoutObject* LayoutObject::rendererForRootBackground()
2188 { 2188 {
2189 ASSERT(isDocumentElement()); 2189 ASSERT(isDocumentElement());
2190 if (!hasBackground() && isHTMLHtmlElement(node())) { 2190 if (!hasBackground() && isHTMLHtmlElement(node())) {
2191 // Locate the <body> element using the DOM. This is easier than trying 2191 // Locate the <body> element using the DOM. This is easier than trying
2192 // to crawl around a render tree with potential :before/:after content a nd 2192 // to crawl around a render tree with potential :before/:after content a nd
2193 // anonymous blocks created by inline <body> tags etc. We can locate the <body> 2193 // anonymous blocks created by inline <body> tags etc. We can locate the <body>
(...skipping 13 matching lines...) Expand all
2207 // an <img> and the setting to respect it everywhere is set. 2207 // an <img> and the setting to respect it everywhere is set.
2208 return document().isImageDocument() 2208 return document().isImageDocument()
2209 || (document().settings() && document().settings()->shouldRespectImageOr ientation() && isHTMLImageElement(node())) ? RespectImageOrientation : DoNotResp ectImageOrientation; 2209 || (document().settings() && document().settings()->shouldRespectImageOr ientation() && isHTMLImageElement(node())) ? RespectImageOrientation : DoNotResp ectImageOrientation;
2210 } 2210 }
2211 2211
2212 bool LayoutObject::hasEntirelyFixedBackground() const 2212 bool LayoutObject::hasEntirelyFixedBackground() const
2213 { 2213 {
2214 return m_style->hasEntirelyFixedBackground(); 2214 return m_style->hasEntirelyFixedBackground();
2215 } 2215 }
2216 2216
2217 LayoutObject* LayoutObject::container(const LayoutLayerModelObject* paintInvalid ationContainer, bool* paintInvalidationContainerSkipped) const 2217 LayoutObject* LayoutObject::container(const LayoutBoxModelObject* paintInvalidat ionContainer, bool* paintInvalidationContainerSkipped) const
2218 { 2218 {
2219 if (paintInvalidationContainerSkipped) 2219 if (paintInvalidationContainerSkipped)
2220 *paintInvalidationContainerSkipped = false; 2220 *paintInvalidationContainerSkipped = false;
2221 2221
2222 // This method is extremely similar to containingBlock(), but with a few not able 2222 // This method is extremely similar to containingBlock(), but with a few not able
2223 // exceptions. 2223 // exceptions.
2224 // (1) It can be used on orphaned subtrees, i.e., it can be called safely ev en when 2224 // (1) It can be used on orphaned subtrees, i.e., it can be called safely ev en when
2225 // the object is not part of the primary document subtree yet. 2225 // the object is not part of the primary document subtree yet.
2226 // (2) For normal flow elements, it just returns the parent. 2226 // (2) For normal flow elements, it just returns the parent.
2227 // (3) For absolute positioned elements, it will return a relative positione d inline. 2227 // (3) For absolute positioned elements, it will return a relative positione d inline.
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
2514 node()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFor Tracing::create(StyleChangeReason::Drag)); 2514 node()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFor Tracing::create(StyleChangeReason::Drag));
2515 else if (style()->affectedByDrag()) 2515 else if (style()->affectedByDrag())
2516 node()->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTr acing::create(StyleChangeReason::Drag)); 2516 node()->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTr acing::create(StyleChangeReason::Drag));
2517 } 2517 }
2518 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextSibling() ) 2518 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextSibling() )
2519 curr->updateDragState(dragOn); 2519 curr->updateDragState(dragOn);
2520 } 2520 }
2521 2521
2522 CompositingState LayoutObject::compositingState() const 2522 CompositingState LayoutObject::compositingState() const
2523 { 2523 {
2524 return hasLayer() ? toLayoutLayerModelObject(this)->layer()->compositingStat e() : NotComposited; 2524 return hasLayer() ? toLayoutBoxModelObject(this)->layer()->compositingState( ) : NotComposited;
2525 } 2525 }
2526 2526
2527 CompositingReasons LayoutObject::additionalCompositingReasons() const 2527 CompositingReasons LayoutObject::additionalCompositingReasons() const
2528 { 2528 {
2529 return CompositingReasonNone; 2529 return CompositingReasonNone;
2530 } 2530 }
2531 2531
2532 bool LayoutObject::hitTest(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffse t, HitTestFilter hitTestFilter) 2532 bool LayoutObject::hitTest(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffse t, HitTestFilter hitTestFilter)
2533 { 2533 {
2534 bool inside = false; 2534 bool inside = false;
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
3146 : m_disabler(gDisablePaintInvalidationStateAsserts, true) 3146 : m_disabler(gDisablePaintInvalidationStateAsserts, true)
3147 { 3147 {
3148 } 3148 }
3149 3149
3150 // Since we're only painting non-composited layers, we know that they all share the same paintInvalidationContainer. 3150 // Since we're only painting non-composited layers, we know that they all share the same paintInvalidationContainer.
3151 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants() 3151 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants()
3152 { 3152 {
3153 invalidatePaintIncludingNonCompositingDescendantsInternal(containerForPaintI nvalidation()); 3153 invalidatePaintIncludingNonCompositingDescendantsInternal(containerForPaintI nvalidation());
3154 } 3154 }
3155 3155
3156 void LayoutObject::invalidatePaintIncludingNonCompositingDescendantsInternal(con st LayoutLayerModelObject* paintInvalidationContainer) 3156 void LayoutObject::invalidatePaintIncludingNonCompositingDescendantsInternal(con st LayoutBoxModelObject* paintInvalidationContainer)
3157 { 3157 {
3158 invalidatePaintUsingContainer(paintInvalidationContainer, previousPaintInval idationRect(), PaintInvalidationLayer); 3158 invalidatePaintUsingContainer(paintInvalidationContainer, previousPaintInval idationRect(), PaintInvalidationLayer);
3159 3159
3160 for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibli ng()) { 3160 for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibli ng()) {
3161 if (!child->isPaintInvalidationContainer()) 3161 if (!child->isPaintInvalidationContainer())
3162 child->invalidatePaintIncludingNonCompositingDescendantsInternal(pai ntInvalidationContainer); 3162 child->invalidatePaintIncludingNonCompositingDescendantsInternal(pai ntInvalidationContainer);
3163 } 3163 }
3164 } 3164 }
3165 3165
3166 3166
(...skipping 22 matching lines...) Expand all
3189 { 3189 {
3190 if (object1) { 3190 if (object1) {
3191 const blink::LayoutObject* root = object1; 3191 const blink::LayoutObject* root = object1;
3192 while (root->parent()) 3192 while (root->parent())
3193 root = root->parent(); 3193 root = root->parent();
3194 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3194 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3195 } 3195 }
3196 } 3196 }
3197 3197
3198 #endif 3198 #endif
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutObject.h ('k') | Source/core/layout/LayoutReplaced.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698