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

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: 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
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 toRenderBoxModelObject(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(toRenderBoxModelObject(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(toRenderBoxModelObject(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 = toRenderBoxModelObject(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() ? toRenderBoxModelObject(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 toRenderBoxModelObject(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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 o->m_bitfields.setPreferredLogicalWidthsDirty(true); 766 o->m_bitfields.setPreferredLogicalWidthsDirty(true);
767 if (o->style()->hasOutOfFlowPosition()) { 767 if (o->style()->hasOutOfFlowPosition()) {
768 // A positioned object has no effect on the min/max width of its con taining block ever. 768 // A positioned object has no effect on the min/max width of its con taining block ever.
769 // We can optimize this case and not go up any further. 769 // We can optimize this case and not go up any further.
770 break; 770 break;
771 } 771 }
772 o = container; 772 o = container;
773 } 773 }
774 } 774 }
775 775
776 RenderBlock* LayoutObject::containerForFixedPosition(const LayoutLayerModelObjec t* paintInvalidationContainer, bool* paintInvalidationContainerSkipped) const 776 RenderBlock* LayoutObject::containerForFixedPosition(const RenderBoxModelObject* paintInvalidationContainer, bool* paintInvalidationContainerSkipped) const
777 { 777 {
778 ASSERT(!paintInvalidationContainerSkipped || !*paintInvalidationContainerSki pped); 778 ASSERT(!paintInvalidationContainerSkipped || !*paintInvalidationContainerSki pped);
779 ASSERT(!isText()); 779 ASSERT(!isText());
780 ASSERT(style()->position() == FixedPosition); 780 ASSERT(style()->position() == FixedPosition);
781 781
782 LayoutObject* ancestor = parent(); 782 LayoutObject* ancestor = parent();
783 for (; ancestor && !ancestor->canContainFixedPositionObjects(); ancestor = a ncestor->parent()) { 783 for (; ancestor && !ancestor->canContainFixedPositionObjects(); ancestor = a ncestor->parent()) {
784 if (paintInvalidationContainerSkipped && ancestor == paintInvalidationCo ntainer) 784 if (paintInvalidationContainerSkipped && ancestor == paintInvalidationCo ntainer)
785 *paintInvalidationContainerSkipped = true; 785 *paintInvalidationContainerSkipped = true;
786 } 786 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 983
984 LayoutRect result = rects[0]; 984 LayoutRect result = rects[0];
985 for (size_t i = 1; i < n; ++i) 985 for (size_t i = 1; i < n; ++i)
986 result.unite(rects[i]); 986 result.unite(rects[i]);
987 return pixelSnappedIntRect(result); 987 return pixelSnappedIntRect(result);
988 } 988 }
989 989
990 IntRect LayoutObject::absoluteFocusRingBoundingBoxRect() const 990 IntRect LayoutObject::absoluteFocusRingBoundingBoxRect() const
991 { 991 {
992 Vector<LayoutRect> rects; 992 Vector<LayoutRect> rects;
993 const LayoutLayerModelObject* container = enclosingLayer()->renderer(); 993 const RenderBoxModelObject* container = enclosingLayer()->renderer();
994 addFocusRingRects(rects, LayoutPoint(localToContainerPoint(FloatPoint(), con tainer))); 994 addFocusRingRects(rects, LayoutPoint(localToContainerPoint(FloatPoint(), con tainer)));
995 return container->localToAbsoluteQuad(FloatQuad(unionRect(rects))).enclosing BoundingBox(); 995 return container->localToAbsoluteQuad(FloatQuad(unionRect(rects))).enclosing BoundingBox();
996 } 996 }
997 997
998 FloatRect LayoutObject::absoluteBoundingBoxRectForRange(const Range* range) 998 FloatRect LayoutObject::absoluteBoundingBoxRectForRange(const Range* range)
999 { 999 {
1000 if (!range || !range->startContainer()) 1000 if (!range || !range->startContainer())
1001 return FloatRect(); 1001 return FloatRect();
1002 1002
1003 range->ownerDocument().updateLayout(); 1003 range->ownerDocument().updateLayout();
(...skipping 22 matching lines...) Expand all
1026 topLevelRect = result; 1026 topLevelRect = result;
1027 for (LayoutObject* current = slowFirstChild(); current; current = current->n extSibling()) 1027 for (LayoutObject* current = slowFirstChild(); current; current = current->n extSibling())
1028 current->addAbsoluteRectForLayer(result); 1028 current->addAbsoluteRectForLayer(result);
1029 return result; 1029 return result;
1030 } 1030 }
1031 1031
1032 void LayoutObject::paint(const PaintInfo&, const LayoutPoint&) 1032 void LayoutObject::paint(const PaintInfo&, const LayoutPoint&)
1033 { 1033 {
1034 } 1034 }
1035 1035
1036 const LayoutLayerModelObject* LayoutObject::containerForPaintInvalidation() cons t 1036 const RenderBoxModelObject* LayoutObject::containerForPaintInvalidation() const
1037 { 1037 {
1038 RELEASE_ASSERT(isRooted()); 1038 RELEASE_ASSERT(isRooted());
1039 return adjustCompositedContainerForSpecialAncestors(enclosingCompositedConta iner()); 1039 return adjustCompositedContainerForSpecialAncestors(enclosingCompositedConta iner());
1040 } 1040 }
1041 1041
1042 const LayoutLayerModelObject* LayoutObject::enclosingCompositedContainer() const 1042 const RenderBoxModelObject* LayoutObject::enclosingCompositedContainer() const
1043 { 1043 {
1044 LayoutLayerModelObject* container = 0; 1044 RenderBoxModelObject* container = 0;
1045 // FIXME: CompositingState is not necessarily up to date for many callers of this function. 1045 // FIXME: CompositingState is not necessarily up to date for many callers of this function.
1046 DisableCompositingQueryAsserts disabler; 1046 DisableCompositingQueryAsserts disabler;
1047 1047
1048 if (Layer* compositingLayer = enclosingLayer()->enclosingLayerForPaintInvali dationCrossingFrameBoundaries()) 1048 if (Layer* compositingLayer = enclosingLayer()->enclosingLayerForPaintInvali dationCrossingFrameBoundaries())
1049 container = compositingLayer->renderer(); 1049 container = compositingLayer->renderer();
1050 return container; 1050 return container;
1051 } 1051 }
1052 1052
1053 const LayoutLayerModelObject* LayoutObject::adjustCompositedContainerForSpecialA ncestors(const LayoutLayerModelObject* paintInvalidationContainer) const 1053 const RenderBoxModelObject* LayoutObject::adjustCompositedContainerForSpecialAnc estors(const RenderBoxModelObject* paintInvalidationContainer) const
1054 { 1054 {
1055 if (paintInvalidationContainer) 1055 if (paintInvalidationContainer)
1056 return paintInvalidationContainer; 1056 return paintInvalidationContainer;
1057 1057
1058 RenderView* renderView = view(); 1058 RenderView* renderView = view();
1059 while (renderView->frame()->ownerRenderer()) 1059 while (renderView->frame()->ownerRenderer())
1060 renderView = renderView->frame()->ownerRenderer()->view(); 1060 renderView = renderView->frame()->ownerRenderer()->view();
1061 return renderView; 1061 return renderView;
1062 } 1062 }
1063 1063
1064 bool LayoutObject::isPaintInvalidationContainer() const 1064 bool LayoutObject::isPaintInvalidationContainer() const
1065 { 1065 {
1066 return hasLayer() && toLayoutLayerModelObject(this)->layer()->isPaintInvalid ationContainer(); 1066 return hasLayer() && toRenderBoxModelObject(this)->layer()->isPaintInvalidat ionContainer();
1067 } 1067 }
1068 1068
1069 template <typename T> 1069 template <typename T>
1070 void addJsonObjectForRect(TracedValue* value, const char* name, const T& rect) 1070 void addJsonObjectForRect(TracedValue* value, const char* name, const T& rect)
1071 { 1071 {
1072 value->beginDictionary(name); 1072 value->beginDictionary(name);
1073 value->setDouble("x", rect.x()); 1073 value->setDouble("x", rect.x());
1074 value->setDouble("y", rect.y()); 1074 value->setDouble("y", rect.y());
1075 value->setDouble("width", rect.width()); 1075 value->setDouble("width", rect.width());
1076 value->setDouble("height", rect.height()); 1076 value->setDouble("height", rect.height());
(...skipping 10 matching lines...) Expand all
1087 } 1087 }
1088 1088
1089 static PassRefPtr<TraceEvent::ConvertableToTraceFormat> jsonObjectForPaintInvali dationInfo(const LayoutRect& rect, const String& invalidationReason) 1089 static PassRefPtr<TraceEvent::ConvertableToTraceFormat> jsonObjectForPaintInvali dationInfo(const LayoutRect& rect, const String& invalidationReason)
1090 { 1090 {
1091 RefPtr<TracedValue> value = TracedValue::create(); 1091 RefPtr<TracedValue> value = TracedValue::create();
1092 addJsonObjectForRect(value.get(), "rect", rect); 1092 addJsonObjectForRect(value.get(), "rect", rect);
1093 value->setString("invalidation_reason", invalidationReason); 1093 value->setString("invalidation_reason", invalidationReason);
1094 return value; 1094 return value;
1095 } 1095 }
1096 1096
1097 LayoutRect LayoutObject::computePaintInvalidationRect(const LayoutLayerModelObje ct* paintInvalidationContainer, const PaintInvalidationState* paintInvalidationS tate) const 1097 LayoutRect LayoutObject::computePaintInvalidationRect(const RenderBoxModelObject * paintInvalidationContainer, const PaintInvalidationState* paintInvalidationSta te) const
1098 { 1098 {
1099 return clippedOverflowRectForPaintInvalidation(paintInvalidationContainer, p aintInvalidationState); 1099 return clippedOverflowRectForPaintInvalidation(paintInvalidationContainer, p aintInvalidationState);
1100 } 1100 }
1101 1101
1102 void LayoutObject::invalidatePaintUsingContainer(const LayoutLayerModelObject* p aintInvalidationContainer, const LayoutRect& r, PaintInvalidationReason invalida tionReason) const 1102 void LayoutObject::invalidatePaintUsingContainer(const RenderBoxModelObject* pai ntInvalidationContainer, const LayoutRect& r, PaintInvalidationReason invalidati onReason) const
1103 { 1103 {
1104 ASSERT(gDisablePaintInvalidationStateAsserts || document().lifecycle().state () == DocumentLifecycle::InPaintInvalidation); 1104 ASSERT(gDisablePaintInvalidationStateAsserts || document().lifecycle().state () == DocumentLifecycle::InPaintInvalidation);
1105 1105
1106 if (r.isEmpty()) 1106 if (r.isEmpty())
1107 return; 1107 return;
1108 1108
1109 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { 1109 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
1110 if (Layer* container = enclosingLayer()->enclosingLayerForPaintInvalidat ionCrossingFrameBoundaries()) 1110 if (Layer* container = enclosingLayer()->enclosingLayerForPaintInvalidat ionCrossingFrameBoundaries())
1111 invalidateDisplayItemClients(container->graphicsLayerBacking()->disp layItemList()); 1111 invalidateDisplayItemClients(container->graphicsLayerBacking()->disp layItemList());
1112 } 1112 }
(...skipping 17 matching lines...) Expand all
1130 ASSERT(paintInvalidationContainer->isPaintInvalidationContainer()); 1130 ASSERT(paintInvalidationContainer->isPaintInvalidationContainer());
1131 paintInvalidationContainer->setBackingNeedsPaintInvalidationInRect(r, in validationReason); 1131 paintInvalidationContainer->setBackingNeedsPaintInvalidationInRect(r, in validationReason);
1132 } 1132 }
1133 } 1133 }
1134 1134
1135 void LayoutObject::invalidateDisplayItemClients(DisplayItemList* displayItemList ) const 1135 void LayoutObject::invalidateDisplayItemClients(DisplayItemList* displayItemList ) const
1136 { 1136 {
1137 displayItemList->invalidate(displayItemClient()); 1137 displayItemList->invalidate(displayItemClient());
1138 } 1138 }
1139 1139
1140 LayoutRect LayoutObject::boundsRectForPaintInvalidation(const LayoutLayerModelOb ject* paintInvalidationContainer, const PaintInvalidationState* paintInvalidatio nState) const 1140 LayoutRect LayoutObject::boundsRectForPaintInvalidation(const RenderBoxModelObje ct* paintInvalidationContainer, const PaintInvalidationState* paintInvalidationS tate) const
1141 { 1141 {
1142 if (!paintInvalidationContainer) 1142 if (!paintInvalidationContainer)
1143 return computePaintInvalidationRect(paintInvalidationContainer, paintInv alidationState); 1143 return computePaintInvalidationRect(paintInvalidationContainer, paintInv alidationState);
1144 return Layer::computePaintInvalidationRect(this, paintInvalidationContainer- >layer(), paintInvalidationState); 1144 return Layer::computePaintInvalidationRect(this, paintInvalidationContainer- >layer(), paintInvalidationState);
1145 } 1145 }
1146 1146
1147 void LayoutObject::invalidatePaintRectangle(const LayoutRect& r) const 1147 void LayoutObject::invalidatePaintRectangle(const LayoutRect& r) const
1148 { 1148 {
1149 RELEASE_ASSERT(isRooted()); 1149 RELEASE_ASSERT(isRooted());
1150 1150
1151 if (view()->document().printing()) 1151 if (view()->document().printing())
1152 return; // Don't invalidate paints if we're printing. 1152 return; // Don't invalidate paints if we're printing.
1153 1153
1154 LayoutRect dirtyRect(r); 1154 LayoutRect dirtyRect(r);
1155 1155
1156 const LayoutLayerModelObject* paintInvalidationContainer = containerForPaint Invalidation(); 1156 const RenderBoxModelObject* paintInvalidationContainer = containerForPaintIn validation();
1157 Layer::mapRectToPaintInvalidationBacking(this, paintInvalidationContainer, d irtyRect); 1157 Layer::mapRectToPaintInvalidationBacking(this, paintInvalidationContainer, d irtyRect);
1158 invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRect, PaintIn validationRectangle); 1158 invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRect, PaintIn validationRectangle);
1159 } 1159 }
1160 1160
1161 void LayoutObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInv alidationState) 1161 void LayoutObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInv alidationState)
1162 { 1162 {
1163 ASSERT(!needsLayout()); 1163 ASSERT(!needsLayout());
1164 1164
1165 // If we didn't need paint invalidation then our children don't need as well . 1165 // If we didn't need paint invalidation then our children don't need as well .
1166 // Skip walking down the tree as everything should be fine below us. 1166 // Skip walking down the tree as everything should be fine below us.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 return; 1205 return;
1206 selectionPaintInvalidationMap = new SelectionPaintInvalidationMap(); 1206 selectionPaintInvalidationMap = new SelectionPaintInvalidationMap();
1207 } 1207 }
1208 1208
1209 if (selectionRect.isEmpty()) 1209 if (selectionRect.isEmpty())
1210 selectionPaintInvalidationMap->remove(this); 1210 selectionPaintInvalidationMap->remove(this);
1211 else 1211 else
1212 selectionPaintInvalidationMap->set(this, selectionRect); 1212 selectionPaintInvalidationMap->set(this, selectionRect);
1213 } 1213 }
1214 1214
1215 void LayoutObject::invalidateSelectionIfNeeded(const LayoutLayerModelObject& pai ntInvalidationContainer, PaintInvalidationReason invalidationReason) 1215 void LayoutObject::invalidateSelectionIfNeeded(const RenderBoxModelObject& paint InvalidationContainer, PaintInvalidationReason invalidationReason)
1216 { 1216 {
1217 // Update selection rect when we are doing full invalidation (in case that t he object is moved, composite status changed, etc.) 1217 // Update selection rect when we are doing full invalidation (in case that t he object is moved, composite status changed, etc.)
1218 // or shouldInvalidationSelection is set (in case that the selection itself changed). 1218 // or shouldInvalidationSelection is set (in case that the selection itself changed).
1219 bool fullInvalidation = view()->doingFullPaintInvalidation() || isFullPaintI nvalidationReason(invalidationReason); 1219 bool fullInvalidation = view()->doingFullPaintInvalidation() || isFullPaintI nvalidationReason(invalidationReason);
1220 if (!fullInvalidation && !shouldInvalidateSelection()) 1220 if (!fullInvalidation && !shouldInvalidateSelection())
1221 return; 1221 return;
1222 1222
1223 LayoutRect oldSelectionRect = previousSelectionRectForPaintInvalidation(); 1223 LayoutRect oldSelectionRect = previousSelectionRectForPaintInvalidation();
1224 LayoutRect newSelectionRect = selectionRectForPaintInvalidation(&paintInvali dationContainer); 1224 LayoutRect newSelectionRect = selectionRectForPaintInvalidation(&paintInvali dationContainer);
1225 setPreviousSelectionRectForPaintInvalidation(newSelectionRect); 1225 setPreviousSelectionRectForPaintInvalidation(newSelectionRect);
1226 1226
1227 if (fullInvalidation) 1227 if (fullInvalidation)
1228 return; 1228 return;
1229 1229
1230 fullyInvalidatePaint(paintInvalidationContainer, PaintInvalidationSelection, oldSelectionRect, newSelectionRect); 1230 fullyInvalidatePaint(paintInvalidationContainer, PaintInvalidationSelection, oldSelectionRect, newSelectionRect);
1231 } 1231 }
1232 1232
1233 PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(const PaintInvalid ationState& paintInvalidationState, const LayoutLayerModelObject& paintInvalidat ionContainer) 1233 PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(const PaintInvalid ationState& paintInvalidationState, const RenderBoxModelObject& paintInvalidatio nContainer)
1234 { 1234 {
1235 RenderView* v = view(); 1235 RenderView* v = view();
1236 if (v->document().printing()) 1236 if (v->document().printing())
1237 return PaintInvalidationNone; // Don't invalidate paints if we're printi ng. 1237 return PaintInvalidationNone; // Don't invalidate paints if we're printi ng.
1238 1238
1239 const LayoutRect oldBounds = previousPaintInvalidationRect(); 1239 const LayoutRect oldBounds = previousPaintInvalidationRect();
1240 const LayoutPoint oldLocation = previousPositionFromPaintInvalidationBacking (); 1240 const LayoutPoint oldLocation = previousPositionFromPaintInvalidationBacking ();
1241 const LayoutRect newBounds = boundsRectForPaintInvalidation(&paintInvalidati onContainer, &paintInvalidationState); 1241 const LayoutRect newBounds = boundsRectForPaintInvalidation(&paintInvalidati onContainer, &paintInvalidationState);
1242 const LayoutPoint newLocation = Layer::positionFromPaintInvalidationBacking( this, &paintInvalidationContainer, &paintInvalidationState); 1242 const LayoutPoint newLocation = Layer::positionFromPaintInvalidationBacking( this, &paintInvalidationContainer, &paintInvalidationState);
1243 setPreviousPaintInvalidationRect(newBounds); 1243 setPreviousPaintInvalidationRect(newBounds);
(...skipping 20 matching lines...) Expand all
1264 1264
1265 if (invalidationReason == PaintInvalidationIncremental) { 1265 if (invalidationReason == PaintInvalidationIncremental) {
1266 incrementallyInvalidatePaint(paintInvalidationContainer, oldBounds, newB ounds, newLocation); 1266 incrementallyInvalidatePaint(paintInvalidationContainer, oldBounds, newB ounds, newLocation);
1267 return invalidationReason; 1267 return invalidationReason;
1268 } 1268 }
1269 1269
1270 fullyInvalidatePaint(paintInvalidationContainer, invalidationReason, oldBoun ds, newBounds); 1270 fullyInvalidatePaint(paintInvalidationContainer, invalidationReason, oldBoun ds, newBounds);
1271 return invalidationReason; 1271 return invalidationReason;
1272 } 1272 }
1273 1273
1274 PaintInvalidationReason LayoutObject::paintInvalidationReason(const LayoutLayerM odelObject& paintInvalidationContainer, 1274 PaintInvalidationReason LayoutObject::paintInvalidationReason(const RenderBoxMod elObject& paintInvalidationContainer,
1275 const LayoutRect& oldBounds, const LayoutPoint& oldPositionFromPaintInvalida tionBacking, 1275 const LayoutRect& oldBounds, const LayoutPoint& oldPositionFromPaintInvalida tionBacking,
1276 const LayoutRect& newBounds, const LayoutPoint& newPositionFromPaintInvalida tionBacking) const 1276 const LayoutRect& newBounds, const LayoutPoint& newPositionFromPaintInvalida tionBacking) const
1277 { 1277 {
1278 // First check for InvalidationLocationChange to avoid it from being hidden by other 1278 // First check for InvalidationLocationChange to avoid it from being hidden by other
1279 // invalidation reasons because we'll need to force check for paint invalida tion for 1279 // invalidation reasons because we'll need to force check for paint invalida tion for
1280 // children when location of this object changed. 1280 // children when location of this object changed.
1281 if (newPositionFromPaintInvalidationBacking != oldPositionFromPaintInvalidat ionBacking) 1281 if (newPositionFromPaintInvalidationBacking != oldPositionFromPaintInvalidat ionBacking)
1282 return PaintInvalidationLocationChange; 1282 return PaintInvalidationLocationChange;
1283 1283
1284 if (shouldDoFullPaintInvalidation()) 1284 if (shouldDoFullPaintInvalidation())
(...skipping 22 matching lines...) Expand all
1307 // into the incremental invalidation we'll issue two invalidations instead 1307 // into the incremental invalidation we'll issue two invalidations instead
1308 // of one. 1308 // of one.
1309 if (oldBounds.isEmpty()) 1309 if (oldBounds.isEmpty())
1310 return PaintInvalidationBecameVisible; 1310 return PaintInvalidationBecameVisible;
1311 if (newBounds.isEmpty()) 1311 if (newBounds.isEmpty())
1312 return PaintInvalidationBecameInvisible; 1312 return PaintInvalidationBecameInvisible;
1313 1313
1314 return PaintInvalidationIncremental; 1314 return PaintInvalidationIncremental;
1315 } 1315 }
1316 1316
1317 void LayoutObject::incrementallyInvalidatePaint(const LayoutLayerModelObject& pa intInvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBoun ds, const LayoutPoint& positionFromPaintInvalidationBacking) 1317 void LayoutObject::incrementallyInvalidatePaint(const RenderBoxModelObject& pain tInvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds , const LayoutPoint& positionFromPaintInvalidationBacking)
1318 { 1318 {
1319 ASSERT(oldBounds.location() == newBounds.location()); 1319 ASSERT(oldBounds.location() == newBounds.location());
1320 1320
1321 LayoutUnit deltaRight = newBounds.maxX() - oldBounds.maxX(); 1321 LayoutUnit deltaRight = newBounds.maxX() - oldBounds.maxX();
1322 if (deltaRight > 0) 1322 if (deltaRight > 0)
1323 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ol dBounds.maxX(), newBounds.y(), deltaRight, newBounds.height()), PaintInvalidatio nIncremental); 1323 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ol dBounds.maxX(), newBounds.y(), deltaRight, newBounds.height()), PaintInvalidatio nIncremental);
1324 else if (deltaRight < 0) 1324 else if (deltaRight < 0)
1325 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ne wBounds.maxX(), oldBounds.y(), -deltaRight, oldBounds.height()), PaintInvalidati onIncremental); 1325 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ne wBounds.maxX(), oldBounds.y(), -deltaRight, oldBounds.height()), PaintInvalidati onIncremental);
1326 1326
1327 LayoutUnit deltaBottom = newBounds.maxY() - oldBounds.maxY(); 1327 LayoutUnit deltaBottom = newBounds.maxY() - oldBounds.maxY();
1328 if (deltaBottom > 0) 1328 if (deltaBottom > 0)
1329 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ne wBounds.x(), oldBounds.maxY(), newBounds.width(), deltaBottom), PaintInvalidatio nIncremental); 1329 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ne wBounds.x(), oldBounds.maxY(), newBounds.width(), deltaBottom), PaintInvalidatio nIncremental);
1330 else if (deltaBottom < 0) 1330 else if (deltaBottom < 0)
1331 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ol dBounds.x(), newBounds.maxY(), oldBounds.width(), -deltaBottom), PaintInvalidati onIncremental); 1331 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ol dBounds.x(), newBounds.maxY(), oldBounds.width(), -deltaBottom), PaintInvalidati onIncremental);
1332 } 1332 }
1333 1333
1334 void LayoutObject::fullyInvalidatePaint(const LayoutLayerModelObject& paintInval idationContainer, PaintInvalidationReason invalidationReason, const LayoutRect& oldBounds, const LayoutRect& newBounds) 1334 void LayoutObject::fullyInvalidatePaint(const RenderBoxModelObject& paintInvalid ationContainer, PaintInvalidationReason invalidationReason, const LayoutRect& ol dBounds, const LayoutRect& newBounds)
1335 { 1335 {
1336 // Otherwise do full paint invalidation. 1336 // Otherwise do full paint invalidation.
1337 invalidatePaintUsingContainer(&paintInvalidationContainer, oldBounds, invali dationReason); 1337 invalidatePaintUsingContainer(&paintInvalidationContainer, oldBounds, invali dationReason);
1338 if (newBounds != oldBounds) 1338 if (newBounds != oldBounds)
1339 invalidatePaintUsingContainer(&paintInvalidationContainer, newBounds, in validationReason); 1339 invalidatePaintUsingContainer(&paintInvalidationContainer, newBounds, in validationReason);
1340 } 1340 }
1341 1341
1342 void LayoutObject::invalidatePaintForOverflow() 1342 void LayoutObject::invalidatePaintForOverflow()
1343 { 1343 {
1344 } 1344 }
1345 1345
1346 void LayoutObject::invalidatePaintForOverflowIfNeeded() 1346 void LayoutObject::invalidatePaintForOverflowIfNeeded()
1347 { 1347 {
1348 if (shouldInvalidateOverflowForPaint()) 1348 if (shouldInvalidateOverflowForPaint())
1349 invalidatePaintForOverflow(); 1349 invalidatePaintForOverflow();
1350 } 1350 }
1351 1351
1352 LayoutRect LayoutObject::rectWithOutlineForPaintInvalidation(const LayoutLayerMo delObject* paintInvalidationContainer, LayoutUnit outlineWidth, const PaintInval idationState* paintInvalidationState) const 1352 LayoutRect LayoutObject::rectWithOutlineForPaintInvalidation(const RenderBoxMode lObject* paintInvalidationContainer, LayoutUnit outlineWidth, const PaintInvalid ationState* paintInvalidationState) const
1353 { 1353 {
1354 LayoutRect r(clippedOverflowRectForPaintInvalidation(paintInvalidationContai ner, paintInvalidationState)); 1354 LayoutRect r(clippedOverflowRectForPaintInvalidation(paintInvalidationContai ner, paintInvalidationState));
1355 r.inflate(outlineWidth); 1355 r.inflate(outlineWidth);
1356 return r; 1356 return r;
1357 } 1357 }
1358 1358
1359 LayoutRect LayoutObject::absoluteClippedOverflowRect() const 1359 LayoutRect LayoutObject::absoluteClippedOverflowRect() const
1360 { 1360 {
1361 return clippedOverflowRectForPaintInvalidation(view()); 1361 return clippedOverflowRectForPaintInvalidation(view());
1362 } 1362 }
1363 1363
1364 LayoutRect LayoutObject::clippedOverflowRectForPaintInvalidation(const LayoutLay erModelObject*, const PaintInvalidationState*) const 1364 LayoutRect LayoutObject::clippedOverflowRectForPaintInvalidation(const RenderBox ModelObject*, const PaintInvalidationState*) const
1365 { 1365 {
1366 ASSERT_NOT_REACHED(); 1366 ASSERT_NOT_REACHED();
1367 return LayoutRect(); 1367 return LayoutRect();
1368 } 1368 }
1369 1369
1370 void LayoutObject::mapRectToPaintInvalidationBacking(const LayoutLayerModelObjec t* paintInvalidationContainer, LayoutRect& rect, const PaintInvalidationState* p aintInvalidationState) const 1370 void LayoutObject::mapRectToPaintInvalidationBacking(const RenderBoxModelObject* paintInvalidationContainer, LayoutRect& rect, const PaintInvalidationState* pai ntInvalidationState) const
1371 { 1371 {
1372 if (paintInvalidationContainer == this) 1372 if (paintInvalidationContainer == this)
1373 return; 1373 return;
1374 1374
1375 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain tInvalidationContainer)) { 1375 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain tInvalidationContainer)) {
1376 rect.move(paintInvalidationState->paintOffset()); 1376 rect.move(paintInvalidationState->paintOffset());
1377 if (paintInvalidationState->isClipped()) 1377 if (paintInvalidationState->isClipped())
1378 rect.intersect(paintInvalidationState->clipRect()); 1378 rect.intersect(paintInvalidationState->clipRect());
1379 return; 1379 return;
1380 } 1380 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 1530
1531 StyleDifference LayoutObject::adjustStyleDifference(StyleDifference diff) const 1531 StyleDifference LayoutObject::adjustStyleDifference(StyleDifference diff) const
1532 { 1532 {
1533 if (diff.transformChanged() && isSVG()) 1533 if (diff.transformChanged() && isSVG())
1534 diff.setNeedsFullLayout(); 1534 diff.setNeedsFullLayout();
1535 1535
1536 // If transform changed, and the layer does not paint into its own separate backing, then we need to invalidate paints. 1536 // If transform changed, and the layer does not paint into its own separate backing, then we need to invalidate paints.
1537 if (diff.transformChanged()) { 1537 if (diff.transformChanged()) {
1538 // Text nodes share style with their parents but transforms don't apply to them, 1538 // Text nodes share style with their parents but transforms don't apply to them,
1539 // hence the !isText() check. 1539 // hence the !isText() check.
1540 if (!isText() && (!hasLayer() || !toLayoutLayerModelObject(this)->layer( )->hasStyleDeterminedDirectCompositingReasons())) 1540 if (!isText() && (!hasLayer() || !toRenderBoxModelObject(this)->layer()- >hasStyleDeterminedDirectCompositingReasons()))
1541 diff.setNeedsPaintInvalidationLayer(); 1541 diff.setNeedsPaintInvalidationLayer();
1542 } 1542 }
1543 1543
1544 // If opacity or zIndex changed, and the layer does not paint into its own s eparate backing, then we need to invalidate paints (also 1544 // If opacity or zIndex changed, and the layer does not paint into its own s eparate backing, then we need to invalidate paints (also
1545 // ignoring text nodes) 1545 // ignoring text nodes)
1546 if (diff.opacityChanged() || diff.zIndexChanged()) { 1546 if (diff.opacityChanged() || diff.zIndexChanged()) {
1547 if (!isText() && (!hasLayer() || !toLayoutLayerModelObject(this)->layer( )->hasStyleDeterminedDirectCompositingReasons())) 1547 if (!isText() && (!hasLayer() || !toRenderBoxModelObject(this)->layer()- >hasStyleDeterminedDirectCompositingReasons()))
1548 diff.setNeedsPaintInvalidationLayer(); 1548 diff.setNeedsPaintInvalidationLayer();
1549 } 1549 }
1550 1550
1551 // 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. 1551 // 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.
1552 if (diff.filterChanged() && hasLayer()) { 1552 if (diff.filterChanged() && hasLayer()) {
1553 Layer* layer = toLayoutLayerModelObject(this)->layer(); 1553 Layer* layer = toRenderBoxModelObject(this)->layer();
1554 if (!layer->hasStyleDeterminedDirectCompositingReasons() || layer->paint sWithFilters()) 1554 if (!layer->hasStyleDeterminedDirectCompositingReasons() || layer->paint sWithFilters())
1555 diff.setNeedsPaintInvalidationLayer(); 1555 diff.setNeedsPaintInvalidationLayer();
1556 } 1556 }
1557 1557
1558 if (diff.textOrColorChanged() && !diff.needsPaintInvalidation()) { 1558 if (diff.textOrColorChanged() && !diff.needsPaintInvalidation()) {
1559 if (style()->hasBorder() || style()->hasOutline() 1559 if (style()->hasBorder() || style()->hasOutline()
1560 || (isText() && !toRenderText(this)->isAllCollapsibleWhitespace())) 1560 || (isText() && !toRenderText(this)->isAllCollapsibleWhitespace()))
1561 diff.setNeedsPaintInvalidationObject(); 1561 diff.setNeedsPaintInvalidationObject();
1562 } 1562 }
1563 1563
1564 // The answer to layerTypeRequired() for plugins, iframes, and canvas can ch ange without the actual 1564 // The answer to layerTypeRequired() for plugins, iframes, and canvas can ch ange without the actual
1565 // style changing, since it depends on whether we decide to composite these elements. When the 1565 // style changing, since it depends on whether we decide to composite these elements. When the
1566 // layer status of one of these elements changes, we need to force a layout. 1566 // layer status of one of these elements changes, we need to force a layout.
1567 if (!diff.needsFullLayout() && style() && isLayoutLayerModelObject()) { 1567 if (!diff.needsFullLayout() && style() && isRenderBoxModelObject()) {
1568 bool requiresLayer = toLayoutLayerModelObject(this)->layerTypeRequired() != NoLayer; 1568 bool requiresLayer = toRenderBoxModelObject(this)->layerTypeRequired() ! = NoLayer;
1569 if (hasLayer() != requiresLayer) 1569 if (hasLayer() != requiresLayer)
1570 diff.setNeedsFullLayout(); 1570 diff.setNeedsFullLayout();
1571 } 1571 }
1572 1572
1573 // If we have no layer(), just treat a PaintInvalidationLayer hint as a norm al paint invalidation. 1573 // If we have no layer(), just treat a PaintInvalidationLayer hint as a norm al paint invalidation.
1574 if (diff.needsPaintInvalidationLayer() && !hasLayer()) { 1574 if (diff.needsPaintInvalidationLayer() && !hasLayer()) {
1575 diff.clearNeedsPaintInvalidation(); 1575 diff.clearNeedsPaintInvalidation();
1576 diff.setNeedsPaintInvalidationObject(); 1576 diff.setNeedsPaintInvalidationObject();
1577 } 1577 }
1578 1578
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 else if (updatedDiff.needsPositionedMovementLayout()) 1667 else if (updatedDiff.needsPositionedMovementLayout())
1668 setNeedsPositionedMovementLayout(); 1668 setNeedsPositionedMovementLayout();
1669 } 1669 }
1670 1670
1671 if (diff.transformChanged() && !needsLayout()) { 1671 if (diff.transformChanged() && !needsLayout()) {
1672 if (RenderBlock* container = containingBlock()) 1672 if (RenderBlock* container = containingBlock())
1673 container->setNeedsOverflowRecalcAfterStyleChange(); 1673 container->setNeedsOverflowRecalcAfterStyleChange();
1674 } 1674 }
1675 1675
1676 if (updatedDiff.needsPaintInvalidationLayer()) 1676 if (updatedDiff.needsPaintInvalidationLayer())
1677 toLayoutLayerModelObject(this)->layer()->setShouldDoFullPaintInvalidatio nIncludingNonCompositingDescendants(); 1677 toRenderBoxModelObject(this)->layer()->setShouldDoFullPaintInvalidationI ncludingNonCompositingDescendants();
1678 else if (diff.needsPaintInvalidationObject() || updatedDiff.needsPaintInvali dationObject()) 1678 else if (diff.needsPaintInvalidationObject() || updatedDiff.needsPaintInvali dationObject())
1679 setShouldDoFullPaintInvalidation(); 1679 setShouldDoFullPaintInvalidation();
1680 } 1680 }
1681 1681
1682 static inline bool rendererHasBackground(const LayoutObject* renderer) 1682 static inline bool rendererHasBackground(const LayoutObject* renderer)
1683 { 1683 {
1684 return renderer && renderer->hasBackground(); 1684 return renderer && renderer->hasBackground();
1685 } 1685 }
1686 1686
1687 void LayoutObject::styleWillChange(StyleDifference diff, const LayoutStyle& newS tyle) 1687 void LayoutObject::styleWillChange(StyleDifference diff, const LayoutStyle& newS tyle)
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 } 1917 }
1918 1918
1919 FloatQuad LayoutObject::absoluteToLocalQuad(const FloatQuad& quad, MapCoordinate sFlags mode) const 1919 FloatQuad LayoutObject::absoluteToLocalQuad(const FloatQuad& quad, MapCoordinate sFlags mode) const
1920 { 1920 {
1921 TransformState transformState(TransformState::UnapplyInverseTransformDirecti on, quad.boundingBox().center(), quad); 1921 TransformState transformState(TransformState::UnapplyInverseTransformDirecti on, quad.boundingBox().center(), quad);
1922 mapAbsoluteToLocalPoint(mode, transformState); 1922 mapAbsoluteToLocalPoint(mode, transformState);
1923 transformState.flatten(); 1923 transformState.flatten();
1924 return transformState.lastPlanarQuad(); 1924 return transformState.lastPlanarQuad();
1925 } 1925 }
1926 1926
1927 void LayoutObject::mapLocalToContainer(const LayoutLayerModelObject* paintInvali dationContainer, TransformState& transformState, MapCoordinatesFlags mode, bool* wasFixed, const PaintInvalidationState* paintInvalidationState) const 1927 void LayoutObject::mapLocalToContainer(const RenderBoxModelObject* paintInvalida tionContainer, TransformState& transformState, MapCoordinatesFlags mode, bool* w asFixed, const PaintInvalidationState* paintInvalidationState) const
1928 { 1928 {
1929 if (paintInvalidationContainer == this) 1929 if (paintInvalidationContainer == this)
1930 return; 1930 return;
1931 1931
1932 LayoutObject* o = parent(); 1932 LayoutObject* o = parent();
1933 if (!o) 1933 if (!o)
1934 return; 1934 return;
1935 1935
1936 // FIXME: this should call offsetFromContainer to share code, but I'm not su re it's ever called. 1936 // FIXME: this should call offsetFromContainer to share code, but I'm not su re it's ever called.
1937 LayoutPoint centerPoint = roundedLayoutPoint(transformState.mappedPoint()); 1937 LayoutPoint centerPoint = roundedLayoutPoint(transformState.mappedPoint());
1938 if (mode & ApplyContainerFlip && o->isBox()) { 1938 if (mode & ApplyContainerFlip && o->isBox()) {
1939 if (o->style()->isFlippedBlocksWritingMode()) 1939 if (o->style()->isFlippedBlocksWritingMode())
1940 transformState.move(toRenderBox(o)->flipForWritingModeIncludingColum ns(roundedLayoutPoint(transformState.mappedPoint())) - centerPoint); 1940 transformState.move(toRenderBox(o)->flipForWritingModeIncludingColum ns(roundedLayoutPoint(transformState.mappedPoint())) - centerPoint);
1941 mode &= ~ApplyContainerFlip; 1941 mode &= ~ApplyContainerFlip;
1942 } 1942 }
1943 1943
1944 transformState.move(o->columnOffset(roundedLayoutPoint(transformState.mapped Point()))); 1944 transformState.move(o->columnOffset(roundedLayoutPoint(transformState.mapped Point())));
1945 1945
1946 if (o->hasOverflowClip()) 1946 if (o->hasOverflowClip())
1947 transformState.move(-toRenderBox(o)->scrolledContentOffset()); 1947 transformState.move(-toRenderBox(o)->scrolledContentOffset());
1948 1948
1949 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode, was Fixed, paintInvalidationState); 1949 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode, was Fixed, paintInvalidationState);
1950 } 1950 }
1951 1951
1952 const LayoutObject* LayoutObject::pushMappingToContainer(const LayoutLayerModelO bject* ancestorToStopAt, LayoutGeometryMap& geometryMap) const 1952 const LayoutObject* LayoutObject::pushMappingToContainer(const RenderBoxModelObj ect* ancestorToStopAt, LayoutGeometryMap& geometryMap) const
1953 { 1953 {
1954 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != this); 1954 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != this);
1955 1955
1956 LayoutObject* container = parent(); 1956 LayoutObject* container = parent();
1957 if (!container) 1957 if (!container)
1958 return 0; 1958 return 0;
1959 1959
1960 // FIXME: this should call offsetFromContainer to share code, but I'm not su re it's ever called. 1960 // FIXME: this should call offsetFromContainer to share code, but I'm not su re it's ever called.
1961 LayoutSize offset; 1961 LayoutSize offset;
1962 if (container->hasOverflowClip()) 1962 if (container->hasOverflowClip())
(...skipping 11 matching lines...) Expand all
1974 o->mapAbsoluteToLocalPoint(mode, transformState); 1974 o->mapAbsoluteToLocalPoint(mode, transformState);
1975 if (o->hasOverflowClip()) 1975 if (o->hasOverflowClip())
1976 transformState.move(toRenderBox(o)->scrolledContentOffset()); 1976 transformState.move(toRenderBox(o)->scrolledContentOffset());
1977 } 1977 }
1978 } 1978 }
1979 1979
1980 bool LayoutObject::shouldUseTransformFromContainer(const LayoutObject* container Object) const 1980 bool LayoutObject::shouldUseTransformFromContainer(const LayoutObject* container Object) const
1981 { 1981 {
1982 // hasTransform() indicates whether the object has transform, transform-styl e or perspective. We just care about transform, 1982 // hasTransform() indicates whether the object has transform, transform-styl e or perspective. We just care about transform,
1983 // so check the layer's transform directly. 1983 // so check the layer's transform directly.
1984 return (hasLayer() && toLayoutLayerModelObject(this)->layer()->transform()) || (containerObject && containerObject->style()->hasPerspective()); 1984 return (hasLayer() && toRenderBoxModelObject(this)->layer()->transform()) || (containerObject && containerObject->style()->hasPerspective());
1985 } 1985 }
1986 1986
1987 void LayoutObject::getTransformFromContainer(const LayoutObject* containerObject , const LayoutSize& offsetInContainer, TransformationMatrix& transform) const 1987 void LayoutObject::getTransformFromContainer(const LayoutObject* containerObject , const LayoutSize& offsetInContainer, TransformationMatrix& transform) const
1988 { 1988 {
1989 transform.makeIdentity(); 1989 transform.makeIdentity();
1990 transform.translate(offsetInContainer.width().toFloat(), offsetInContainer.h eight().toFloat()); 1990 transform.translate(offsetInContainer.width().toFloat(), offsetInContainer.h eight().toFloat());
1991 Layer* layer = hasLayer() ? toLayoutLayerModelObject(this)->layer() : 0; 1991 Layer* layer = hasLayer() ? toRenderBoxModelObject(this)->layer() : 0;
1992 if (layer && layer->transform()) 1992 if (layer && layer->transform())
1993 transform.multiply(layer->currentTransform()); 1993 transform.multiply(layer->currentTransform());
1994 1994
1995 if (containerObject && containerObject->hasLayer() && containerObject->style ()->hasPerspective()) { 1995 if (containerObject && containerObject->hasLayer() && containerObject->style ()->hasPerspective()) {
1996 // Perpsective on the container affects us, so we have to factor it in h ere. 1996 // Perpsective on the container affects us, so we have to factor it in h ere.
1997 ASSERT(containerObject->hasLayer()); 1997 ASSERT(containerObject->hasLayer());
1998 FloatPoint perspectiveOrigin = toLayoutLayerModelObject(containerObject) ->layer()->perspectiveOrigin(); 1998 FloatPoint perspectiveOrigin = toRenderBoxModelObject(containerObject)-> layer()->perspectiveOrigin();
1999 1999
2000 TransformationMatrix perspectiveMatrix; 2000 TransformationMatrix perspectiveMatrix;
2001 perspectiveMatrix.applyPerspective(containerObject->style()->perspective ()); 2001 perspectiveMatrix.applyPerspective(containerObject->style()->perspective ());
2002 2002
2003 transform.translateRight3d(-perspectiveOrigin.x(), -perspectiveOrigin.y( ), 0); 2003 transform.translateRight3d(-perspectiveOrigin.x(), -perspectiveOrigin.y( ), 0);
2004 transform = perspectiveMatrix * transform; 2004 transform = perspectiveMatrix * transform;
2005 transform.translateRight3d(perspectiveOrigin.x(), perspectiveOrigin.y(), 0); 2005 transform.translateRight3d(perspectiveOrigin.x(), perspectiveOrigin.y(), 0);
2006 } 2006 }
2007 } 2007 }
2008 2008
2009 FloatQuad LayoutObject::localToContainerQuad(const FloatQuad& localQuad, const L ayoutLayerModelObject* paintInvalidationContainer, MapCoordinatesFlags mode, boo l* wasFixed) const 2009 FloatQuad LayoutObject::localToContainerQuad(const FloatQuad& localQuad, const R enderBoxModelObject* paintInvalidationContainer, MapCoordinatesFlags mode, bool* wasFixed) const
2010 { 2010 {
2011 // Track the point at the center of the quad's bounding box. As mapLocalToCo ntainer() calls offsetFromContainer(), 2011 // Track the point at the center of the quad's bounding box. As mapLocalToCo ntainer() calls offsetFromContainer(),
2012 // it will use that point as the reference point to decide which column's tr ansform to apply in multiple-column blocks. 2012 // it will use that point as the reference point to decide which column's tr ansform to apply in multiple-column blocks.
2013 TransformState transformState(TransformState::ApplyTransformDirection, local Quad.boundingBox().center(), localQuad); 2013 TransformState transformState(TransformState::ApplyTransformDirection, local Quad.boundingBox().center(), localQuad);
2014 mapLocalToContainer(paintInvalidationContainer, transformState, mode | Apply ContainerFlip | UseTransforms, wasFixed); 2014 mapLocalToContainer(paintInvalidationContainer, transformState, mode | Apply ContainerFlip | UseTransforms, wasFixed);
2015 transformState.flatten(); 2015 transformState.flatten();
2016 2016
2017 return transformState.lastPlanarQuad(); 2017 return transformState.lastPlanarQuad();
2018 } 2018 }
2019 2019
2020 FloatPoint LayoutObject::localToContainerPoint(const FloatPoint& localPoint, con st LayoutLayerModelObject* paintInvalidationContainer, MapCoordinatesFlags mode, bool* wasFixed, const PaintInvalidationState* paintInvalidationState) const 2020 FloatPoint LayoutObject::localToContainerPoint(const FloatPoint& localPoint, con st RenderBoxModelObject* paintInvalidationContainer, MapCoordinatesFlags mode, b ool* wasFixed, const PaintInvalidationState* paintInvalidationState) const
2021 { 2021 {
2022 TransformState transformState(TransformState::ApplyTransformDirection, local Point); 2022 TransformState transformState(TransformState::ApplyTransformDirection, local Point);
2023 mapLocalToContainer(paintInvalidationContainer, transformState, mode | Apply ContainerFlip | UseTransforms, wasFixed, paintInvalidationState); 2023 mapLocalToContainer(paintInvalidationContainer, transformState, mode | Apply ContainerFlip | UseTransforms, wasFixed, paintInvalidationState);
2024 transformState.flatten(); 2024 transformState.flatten();
2025 2025
2026 return transformState.lastPlanarPoint(); 2026 return transformState.lastPlanarPoint();
2027 } 2027 }
2028 2028
2029 FloatPoint LayoutObject::localToInvalidationBackingPoint(const LayoutPoint& loca lPoint, Layer** backingLayer) 2029 FloatPoint LayoutObject::localToInvalidationBackingPoint(const LayoutPoint& loca lPoint, Layer** backingLayer)
2030 { 2030 {
2031 const LayoutLayerModelObject* paintInvalidationContainer = containerForPaint Invalidation(); 2031 const RenderBoxModelObject* paintInvalidationContainer = containerForPaintIn validation();
2032 ASSERT(paintInvalidationContainer); 2032 ASSERT(paintInvalidationContainer);
2033 ASSERT(paintInvalidationContainer->layer()); 2033 ASSERT(paintInvalidationContainer->layer());
2034 2034
2035 if (backingLayer) 2035 if (backingLayer)
2036 *backingLayer = paintInvalidationContainer->layer(); 2036 *backingLayer = paintInvalidationContainer->layer();
2037 FloatPoint containerPoint = localToContainerPoint(FloatPoint(localPoint), pa intInvalidationContainer, TraverseDocumentBoundaries); 2037 FloatPoint containerPoint = localToContainerPoint(FloatPoint(localPoint), pa intInvalidationContainer, TraverseDocumentBoundaries);
2038 2038
2039 // A renderer can have no invalidation backing if it is from a detached fram e, 2039 // A renderer can have no invalidation backing if it is from a detached fram e,
2040 // or when forced compositing is disabled. 2040 // or when forced compositing is disabled.
2041 if (paintInvalidationContainer->layer()->compositingState() == NotComposited ) 2041 if (paintInvalidationContainer->layer()->compositingState() == NotComposited )
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 } 2168 }
2169 } 2169 }
2170 } 2170 }
2171 2171
2172 bool LayoutObject::isRooted() const 2172 bool LayoutObject::isRooted() const
2173 { 2173 {
2174 const LayoutObject* object = this; 2174 const LayoutObject* object = this;
2175 while (object->parent() && !object->hasLayer()) 2175 while (object->parent() && !object->hasLayer())
2176 object = object->parent(); 2176 object = object->parent();
2177 if (object->hasLayer()) 2177 if (object->hasLayer())
2178 return toLayoutLayerModelObject(object)->layer()->root()->isRootLayer(); 2178 return toRenderBoxModelObject(object)->layer()->root()->isRootLayer();
2179 return false; 2179 return false;
2180 } 2180 }
2181 2181
2182 LayoutObject* LayoutObject::rendererForRootBackground() 2182 LayoutObject* LayoutObject::rendererForRootBackground()
2183 { 2183 {
2184 ASSERT(isDocumentElement()); 2184 ASSERT(isDocumentElement());
2185 if (!hasBackground() && isHTMLHtmlElement(node())) { 2185 if (!hasBackground() && isHTMLHtmlElement(node())) {
2186 // Locate the <body> element using the DOM. This is easier than trying 2186 // Locate the <body> element using the DOM. This is easier than trying
2187 // to crawl around a render tree with potential :before/:after content a nd 2187 // to crawl around a render tree with potential :before/:after content a nd
2188 // anonymous blocks created by inline <body> tags etc. We can locate the <body> 2188 // anonymous blocks created by inline <body> tags etc. We can locate the <body>
(...skipping 13 matching lines...) Expand all
2202 // an <img> and the setting to respect it everywhere is set. 2202 // an <img> and the setting to respect it everywhere is set.
2203 return document().isImageDocument() 2203 return document().isImageDocument()
2204 || (document().settings() && document().settings()->shouldRespectImageOr ientation() && isHTMLImageElement(node())) ? RespectImageOrientation : DoNotResp ectImageOrientation; 2204 || (document().settings() && document().settings()->shouldRespectImageOr ientation() && isHTMLImageElement(node())) ? RespectImageOrientation : DoNotResp ectImageOrientation;
2205 } 2205 }
2206 2206
2207 bool LayoutObject::hasEntirelyFixedBackground() const 2207 bool LayoutObject::hasEntirelyFixedBackground() const
2208 { 2208 {
2209 return m_style->hasEntirelyFixedBackground(); 2209 return m_style->hasEntirelyFixedBackground();
2210 } 2210 }
2211 2211
2212 LayoutObject* LayoutObject::container(const LayoutLayerModelObject* paintInvalid ationContainer, bool* paintInvalidationContainerSkipped) const 2212 LayoutObject* LayoutObject::container(const RenderBoxModelObject* paintInvalidat ionContainer, bool* paintInvalidationContainerSkipped) const
2213 { 2213 {
2214 if (paintInvalidationContainerSkipped) 2214 if (paintInvalidationContainerSkipped)
2215 *paintInvalidationContainerSkipped = false; 2215 *paintInvalidationContainerSkipped = false;
2216 2216
2217 // This method is extremely similar to containingBlock(), but with a few not able 2217 // This method is extremely similar to containingBlock(), but with a few not able
2218 // exceptions. 2218 // exceptions.
2219 // (1) It can be used on orphaned subtrees, i.e., it can be called safely ev en when 2219 // (1) It can be used on orphaned subtrees, i.e., it can be called safely ev en when
2220 // the object is not part of the primary document subtree yet. 2220 // the object is not part of the primary document subtree yet.
2221 // (2) For normal flow elements, it just returns the parent. 2221 // (2) For normal flow elements, it just returns the parent.
2222 // (3) For absolute positioned elements, it will return a relative positione d inline. 2222 // (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
2509 node()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFor Tracing::create(StyleChangeReason::Drag)); 2509 node()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFor Tracing::create(StyleChangeReason::Drag));
2510 else if (style()->affectedByDrag()) 2510 else if (style()->affectedByDrag())
2511 node()->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTr acing::create(StyleChangeReason::Drag)); 2511 node()->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTr acing::create(StyleChangeReason::Drag));
2512 } 2512 }
2513 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextSibling() ) 2513 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextSibling() )
2514 curr->updateDragState(dragOn); 2514 curr->updateDragState(dragOn);
2515 } 2515 }
2516 2516
2517 CompositingState LayoutObject::compositingState() const 2517 CompositingState LayoutObject::compositingState() const
2518 { 2518 {
2519 return hasLayer() ? toLayoutLayerModelObject(this)->layer()->compositingStat e() : NotComposited; 2519 return hasLayer() ? toRenderBoxModelObject(this)->layer()->compositingState( ) : NotComposited;
2520 } 2520 }
2521 2521
2522 CompositingReasons LayoutObject::additionalCompositingReasons() const 2522 CompositingReasons LayoutObject::additionalCompositingReasons() const
2523 { 2523 {
2524 return CompositingReasonNone; 2524 return CompositingReasonNone;
2525 } 2525 }
2526 2526
2527 bool LayoutObject::hitTest(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffse t, HitTestFilter hitTestFilter) 2527 bool LayoutObject::hitTest(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffse t, HitTestFilter hitTestFilter)
2528 { 2528 {
2529 bool inside = false; 2529 bool inside = false;
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
3141 : m_disabler(gDisablePaintInvalidationStateAsserts, true) 3141 : m_disabler(gDisablePaintInvalidationStateAsserts, true)
3142 { 3142 {
3143 } 3143 }
3144 3144
3145 // Since we're only painting non-composited layers, we know that they all share the same paintInvalidationContainer. 3145 // Since we're only painting non-composited layers, we know that they all share the same paintInvalidationContainer.
3146 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants() 3146 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants()
3147 { 3147 {
3148 invalidatePaintIncludingNonCompositingDescendantsInternal(containerForPaintI nvalidation()); 3148 invalidatePaintIncludingNonCompositingDescendantsInternal(containerForPaintI nvalidation());
3149 } 3149 }
3150 3150
3151 void LayoutObject::invalidatePaintIncludingNonCompositingDescendantsInternal(con st LayoutLayerModelObject* paintInvalidationContainer) 3151 void LayoutObject::invalidatePaintIncludingNonCompositingDescendantsInternal(con st RenderBoxModelObject* paintInvalidationContainer)
3152 { 3152 {
3153 invalidatePaintUsingContainer(paintInvalidationContainer, previousPaintInval idationRect(), PaintInvalidationLayer); 3153 invalidatePaintUsingContainer(paintInvalidationContainer, previousPaintInval idationRect(), PaintInvalidationLayer);
3154 3154
3155 for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibli ng()) { 3155 for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibli ng()) {
3156 if (!child->isPaintInvalidationContainer()) 3156 if (!child->isPaintInvalidationContainer())
3157 child->invalidatePaintIncludingNonCompositingDescendantsInternal(pai ntInvalidationContainer); 3157 child->invalidatePaintIncludingNonCompositingDescendantsInternal(pai ntInvalidationContainer);
3158 } 3158 }
3159 } 3159 }
3160 3160
3161 3161
(...skipping 22 matching lines...) Expand all
3184 { 3184 {
3185 if (object1) { 3185 if (object1) {
3186 const blink::LayoutObject* root = object1; 3186 const blink::LayoutObject* root = object1;
3187 while (root->parent()) 3187 while (root->parent())
3188 root = root->parent(); 3188 root = root->parent();
3189 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3189 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3190 } 3190 }
3191 } 3191 }
3192 3192
3193 #endif 3193 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698