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

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

Issue 13913013: Only update composited scrolling state when necessary (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updating test expectations. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/rendering/RenderLayer.h ('k') | Source/core/rendering/RenderLayerCompositor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 RenderLayer::RenderLayer(RenderLayerModelObject* renderer) 141 RenderLayer::RenderLayer(RenderLayerModelObject* renderer)
142 : m_inResizeMode(false) 142 : m_inResizeMode(false)
143 , m_scrollDimensionsDirty(true) 143 , m_scrollDimensionsDirty(true)
144 , m_normalFlowListDirty(true) 144 , m_normalFlowListDirty(true)
145 , m_hasSelfPaintingLayerDescendant(false) 145 , m_hasSelfPaintingLayerDescendant(false)
146 , m_hasSelfPaintingLayerDescendantDirty(false) 146 , m_hasSelfPaintingLayerDescendantDirty(false)
147 , m_hasOutOfFlowPositionedDescendant(false) 147 , m_hasOutOfFlowPositionedDescendant(false)
148 , m_hasOutOfFlowPositionedDescendantDirty(true) 148 , m_hasOutOfFlowPositionedDescendantDirty(true)
149 , m_needsCompositedScrolling(false) 149 , m_needsCompositedScrolling(false)
150 , m_descendantsAreContiguousInStackingOrder(false) 150 , m_descendantsAreContiguousInStackingOrder(false)
151 , m_descendantsAreContiguousInStackingOrderDirty(true)
151 , m_isRootLayer(renderer->isRenderView()) 152 , m_isRootLayer(renderer->isRenderView())
152 , m_usedTransparency(false) 153 , m_usedTransparency(false)
153 , m_paintingInsideReflection(false) 154 , m_paintingInsideReflection(false)
154 , m_inOverflowRelayout(false) 155 , m_inOverflowRelayout(false)
155 , m_repaintStatus(NeedsNormalRepaint) 156 , m_repaintStatus(NeedsNormalRepaint)
156 , m_visibleContentStatusDirty(true) 157 , m_visibleContentStatusDirty(true)
157 , m_hasVisibleContent(false) 158 , m_hasVisibleContent(false)
158 , m_visibleDescendantStatusDirty(false) 159 , m_visibleDescendantStatusDirty(false)
159 , m_hasVisibleDescendant(false) 160 , m_hasVisibleDescendant(false)
160 , m_isPaginated(false) 161 , m_isPaginated(false)
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 // numSCDecendants = 3 559 // numSCDecendants = 3
559 // 560 //
560 // and so, 561 // and so,
561 // maxStackIndex - minStackIndex == numSCDescendants 562 // maxStackIndex - minStackIndex == numSCDescendants
562 // ===> 3 - 0 == 3 563 // ===> 3 - 0 == 3
563 // ===> 3 == 3 564 // ===> 3 == 3
564 // 565 //
565 // And we would conclude that C could be promoted. 566 // And we would conclude that C could be promoted.
566 void RenderLayer::updateDescendantsAreContiguousInStackingOrder() 567 void RenderLayer::updateDescendantsAreContiguousInStackingOrder()
567 { 568 {
568 if (!isStackingContext() || !acceleratedCompositingForOverflowScrollEnabled( )) 569 if (!m_descendantsAreContiguousInStackingOrderDirty || !isStackingContext() || !acceleratedCompositingForOverflowScrollEnabled())
569 return; 570 return;
570 571
571 ASSERT(!m_normalFlowListDirty); 572 ASSERT(!m_normalFlowListDirty);
572 ASSERT(!m_zOrderListsDirty); 573 ASSERT(!m_zOrderListsDirty);
573 574
574 OwnPtr<Vector<RenderLayer*> > posZOrderList; 575 OwnPtr<Vector<RenderLayer*> > posZOrderList;
575 OwnPtr<Vector<RenderLayer*> > negZOrderList; 576 OwnPtr<Vector<RenderLayer*> > negZOrderList;
576 rebuildZOrderLists(StopAtStackingContexts, posZOrderList, negZOrderList); 577 rebuildZOrderLists(StopAtStackingContexts, posZOrderList, negZOrderList);
577 578
578 // Create a reverse lookup. 579 // Create a reverse lookup.
(...skipping 19 matching lines...) Expand all
598 continue; 599 continue;
599 lookup.set(currentLayer, stackingOrderIndex++); 600 lookup.set(currentLayer, stackingOrderIndex++);
600 } 601 }
601 } 602 }
602 603
603 int minIndex = 0; 604 int minIndex = 0;
604 int maxIndex = 0; 605 int maxIndex = 0;
605 int count = 0; 606 int count = 0;
606 bool firstIteration = true; 607 bool firstIteration = true;
607 updateDescendantsAreContiguousInStackingOrderRecursive(lookup, minIndex, max Index, count, firstIteration); 608 updateDescendantsAreContiguousInStackingOrderRecursive(lookup, minIndex, max Index, count, firstIteration);
609
610 m_descendantsAreContiguousInStackingOrderDirty = false;
608 } 611 }
609 612
610 void RenderLayer::updateDescendantsAreContiguousInStackingOrderRecursive(const H ashMap<const RenderLayer*, int>& lookup, int& minIndex, int& maxIndex, int& coun t, bool firstIteration) 613 void RenderLayer::updateDescendantsAreContiguousInStackingOrderRecursive(const H ashMap<const RenderLayer*, int>& lookup, int& minIndex, int& maxIndex, int& coun t, bool firstIteration)
611 { 614 {
612 if (isStackingContext() && !firstIteration) { 615 if (isStackingContext() && !firstIteration) {
613 if (lookup.contains(this)) { 616 if (lookup.contains(this)) {
614 minIndex = std::min(minIndex, lookup.get(this)); 617 minIndex = std::min(minIndex, lookup.get(this));
615 maxIndex = std::max(maxIndex, lookup.get(this)); 618 maxIndex = std::max(maxIndex, lookup.get(this));
616 count++; 619 count++;
617 } 620 }
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 m_enclosingPaginationLayer = containingBlock->layer()->enclosing PaginationLayer(); 921 m_enclosingPaginationLayer = containingBlock->layer()->enclosing PaginationLayer();
919 if (m_enclosingPaginationLayer && m_enclosingPaginationLayer->ha sTransform()) 922 if (m_enclosingPaginationLayer && m_enclosingPaginationLayer->ha sTransform())
920 m_enclosingPaginationLayer = 0; 923 m_enclosingPaginationLayer = 0;
921 return; 924 return;
922 } 925 }
923 } 926 }
924 return; 927 return;
925 } 928 }
926 929
927 // If we're not normal flow, then we need to look for a multi-column object between us and our stacking container. 930 // If we're not normal flow, then we need to look for a multi-column object between us and our stacking container.
928 RenderLayer* ancestorStackingContainer = stackingContainer(); 931 RenderLayer* ancestorStackingContainer = this->ancestorStackingContainer();
929 for (RenderLayer* curr = parent(); curr; curr = curr->parent()) { 932 for (RenderLayer* curr = parent(); curr; curr = curr->parent()) {
930 if (curr->renderer()->hasColumns()) { 933 if (curr->renderer()->hasColumns()) {
931 m_isPaginated = checkContainingBlockChainForPagination(renderer(), c urr->renderBox()); 934 m_isPaginated = checkContainingBlockChainForPagination(renderer(), c urr->renderBox());
932 return; 935 return;
933 } 936 }
934 if (curr == ancestorStackingContainer) 937 if (curr == ancestorStackingContainer)
935 return; 938 return;
936 } 939 }
937 } 940 }
938 941
939 bool RenderLayer::canBeStackingContainer() const 942 bool RenderLayer::canBeStackingContainer() const
940 { 943 {
941 if (isStackingContext() || !stackingContainer()) 944 if (isStackingContext() || !ancestorStackingContainer())
942 return true; 945 return true;
943 946
944 return m_descendantsAreContiguousInStackingOrder; 947 return m_descendantsAreContiguousInStackingOrder;
945 } 948 }
946 949
947 void RenderLayer::setHasVisibleContent() 950 void RenderLayer::setHasVisibleContent()
948 { 951 {
949 if (m_hasVisibleContent && !m_visibleContentStatusDirty) { 952 if (m_hasVisibleContent && !m_visibleContentStatusDirty) {
950 ASSERT(!parent() || parent()->hasVisibleDescendant()); 953 ASSERT(!parent() || parent()->hasVisibleDescendant());
951 return; 954 return;
952 } 955 }
953 956
954 m_visibleContentStatusDirty = false; 957 m_visibleContentStatusDirty = false;
955 m_hasVisibleContent = true; 958 m_hasVisibleContent = true;
956 computeRepaintRects(renderer()->containerForRepaint()); 959 computeRepaintRects(renderer()->containerForRepaint());
957 if (!isNormalFlowOnly()) { 960 if (!isNormalFlowOnly()) {
958 // We don't collect invisible layers in z-order lists if we are not in c ompositing mode. 961 // We don't collect invisible layers in z-order lists if we are not in c ompositing mode.
959 // As we became visible, we need to dirty our stacking containers ancest ors to be properly 962 // As we became visible, we need to dirty our stacking containers ancest ors to be properly
960 // collected. FIXME: When compositing, we could skip this dirtying phase . 963 // collected. FIXME: When compositing, we could skip this dirtying phase .
961 for (RenderLayer* sc = stackingContainer(); sc; sc = sc->stackingContain er()) { 964 for (RenderLayer* sc = ancestorStackingContainer(); sc; sc = sc->ancesto rStackingContainer()) {
962 sc->dirtyZOrderLists(); 965 sc->dirtyZOrderLists();
963 if (sc->hasVisibleContent()) 966 if (sc->hasVisibleContent())
964 break; 967 break;
965 } 968 }
966 } 969 }
967 970
968 if (parent()) 971 if (parent())
969 parent()->setAncestorChainHasVisibleDescendant(); 972 parent()->setAncestorChainHasVisibleDescendant();
970 } 973 }
971 974
(...skipping 21 matching lines...) Expand all
993 break; 996 break;
994 997
995 layer->m_hasVisibleDescendant = true; 998 layer->m_hasVisibleDescendant = true;
996 layer->m_visibleDescendantStatusDirty = false; 999 layer->m_visibleDescendantStatusDirty = false;
997 } 1000 }
998 } 1001 }
999 1002
1000 void RenderLayer::updateDescendantDependentFlags(HashSet<const RenderObject*>* o utOfFlowDescendantContainingBlocks) 1003 void RenderLayer::updateDescendantDependentFlags(HashSet<const RenderObject*>* o utOfFlowDescendantContainingBlocks)
1001 { 1004 {
1002 if (m_visibleDescendantStatusDirty || m_hasSelfPaintingLayerDescendantDirty || m_hasOutOfFlowPositionedDescendantDirty) { 1005 if (m_visibleDescendantStatusDirty || m_hasSelfPaintingLayerDescendantDirty || m_hasOutOfFlowPositionedDescendantDirty) {
1006 const bool hadVisibleDescendant = m_hasVisibleDescendant;
1007 const bool hadOutOfFlowPositionedDescendant = m_hasOutOfFlowPositionedDe scendant;
1008
1003 m_hasVisibleDescendant = false; 1009 m_hasVisibleDescendant = false;
1004 m_hasSelfPaintingLayerDescendant = false; 1010 m_hasSelfPaintingLayerDescendant = false;
1005 m_hasOutOfFlowPositionedDescendant = false; 1011 m_hasOutOfFlowPositionedDescendant = false;
1006 1012
1007 HashSet<const RenderObject*> childOutOfFlowDescendantContainingBlocks; 1013 HashSet<const RenderObject*> childOutOfFlowDescendantContainingBlocks;
1008 for (RenderLayer* child = firstChild(); child; child = child->nextSiblin g()) { 1014 for (RenderLayer* child = firstChild(); child; child = child->nextSiblin g()) {
1009 childOutOfFlowDescendantContainingBlocks.clear(); 1015 childOutOfFlowDescendantContainingBlocks.clear();
1010 child->updateDescendantDependentFlags(&childOutOfFlowDescendantConta iningBlocks); 1016 child->updateDescendantDependentFlags(&childOutOfFlowDescendantConta iningBlocks);
1011 1017
1012 bool childIsOutOfFlowPositioned = child->renderer() && child->render er()->isOutOfFlowPositioned(); 1018 bool childIsOutOfFlowPositioned = child->renderer() && child->render er()->isOutOfFlowPositioned();
1013 if (childIsOutOfFlowPositioned) 1019 if (childIsOutOfFlowPositioned)
1014 childOutOfFlowDescendantContainingBlocks.add(child->renderer()-> containingBlock()); 1020 childOutOfFlowDescendantContainingBlocks.add(child->renderer()-> containingBlock());
1015 1021
1016 if (outOfFlowDescendantContainingBlocks) { 1022 if (outOfFlowDescendantContainingBlocks) {
1017 HashSet<const RenderObject*>::const_iterator it = childOutOfFlow DescendantContainingBlocks.begin(); 1023 HashSet<const RenderObject*>::const_iterator it = childOutOfFlow DescendantContainingBlocks.begin();
1018 for (; it != childOutOfFlowDescendantContainingBlocks.end(); ++i t) 1024 for (; it != childOutOfFlowDescendantContainingBlocks.end(); ++i t)
1019 outOfFlowDescendantContainingBlocks->add(*it); 1025 outOfFlowDescendantContainingBlocks->add(*it);
1020 } 1026 }
1021 1027
1022 bool hasVisibleDescendant = child->m_hasVisibleContent || child->m_h asVisibleDescendant; 1028 bool hasVisibleDescendant = child->m_hasVisibleContent || child->m_h asVisibleDescendant;
1023 bool hasSelfPaintingLayerDescendant = child->isSelfPaintingLayer() | | child->hasSelfPaintingLayerDescendant(); 1029 bool hasSelfPaintingLayerDescendant = child->isSelfPaintingLayer() | | child->hasSelfPaintingLayerDescendant();
1024 bool hasOutOfFlowPositionedDescendant = !childOutOfFlowDescendantCon tainingBlocks.isEmpty(); 1030 bool hasOutOfFlowPositionedDescendant = hasVisibleDescendant && (!ch ildOutOfFlowDescendantContainingBlocks.isEmpty() || child->hasOutOfFlowPositione dDescendant());
1025 1031
1026 m_hasVisibleDescendant |= hasVisibleDescendant; 1032 m_hasVisibleDescendant |= hasVisibleDescendant;
1027 m_hasSelfPaintingLayerDescendant |= hasSelfPaintingLayerDescendant; 1033 m_hasSelfPaintingLayerDescendant |= hasSelfPaintingLayerDescendant;
1028 m_hasOutOfFlowPositionedDescendant |= hasOutOfFlowPositionedDescenda nt; 1034 m_hasOutOfFlowPositionedDescendant |= hasOutOfFlowPositionedDescenda nt;
1029 1035
1030 if (m_hasVisibleDescendant && m_hasSelfPaintingLayerDescendant && m_ hasOutOfFlowPositionedDescendant) 1036 if (m_hasVisibleDescendant && m_hasSelfPaintingLayerDescendant && m_ hasOutOfFlowPositionedDescendant)
1031 break; 1037 break;
1032 } 1038 }
1033 1039
1034 if (outOfFlowDescendantContainingBlocks && renderer()) 1040 if (outOfFlowDescendantContainingBlocks && renderer())
1035 outOfFlowDescendantContainingBlocks->remove(renderer()); 1041 outOfFlowDescendantContainingBlocks->remove(renderer());
1036 1042
1037 m_visibleDescendantStatusDirty = false; 1043 m_visibleDescendantStatusDirty = false;
1038 m_hasSelfPaintingLayerDescendantDirty = false; 1044 m_hasSelfPaintingLayerDescendantDirty = false;
1045 m_hasOutOfFlowPositionedDescendantDirty = false;
1039 1046
1040 if (m_hasOutOfFlowPositionedDescendantDirty) 1047 if (m_hasVisibleDescendant != hadVisibleDescendant || m_hasOutOfFlowPosi tionedDescendant != hadOutOfFlowPositionedDescendant)
1041 updateNeedsCompositedScrolling(); 1048 updateNeedsCompositedScrolling();
1042
1043 m_hasOutOfFlowPositionedDescendantDirty = false;
1044 } 1049 }
1045 1050
1046 if (m_visibleContentStatusDirty) { 1051 if (m_visibleContentStatusDirty) {
1052 const bool hadVisibleContent = m_hasVisibleContent;
1047 if (renderer()->style()->visibility() == VISIBLE) 1053 if (renderer()->style()->visibility() == VISIBLE)
1048 m_hasVisibleContent = true; 1054 m_hasVisibleContent = true;
1049 else { 1055 else {
1050 // layer may be hidden but still have some visible content, check fo r this 1056 // layer may be hidden but still have some visible content, check fo r this
1051 m_hasVisibleContent = false; 1057 m_hasVisibleContent = false;
1052 RenderObject* r = renderer()->firstChild(); 1058 RenderObject* r = renderer()->firstChild();
1053 while (r) { 1059 while (r) {
1054 if (r->style()->visibility() == VISIBLE && !r->hasLayer()) { 1060 if (r->style()->visibility() == VISIBLE && !r->hasLayer()) {
1055 m_hasVisibleContent = true; 1061 m_hasVisibleContent = true;
1056 break; 1062 break;
1057 } 1063 }
1058 if (r->firstChild() && !r->hasLayer()) 1064 if (r->firstChild() && !r->hasLayer())
1059 r = r->firstChild(); 1065 r = r->firstChild();
1060 else if (r->nextSibling()) 1066 else if (r->nextSibling())
1061 r = r->nextSibling(); 1067 r = r->nextSibling();
1062 else { 1068 else {
1063 do { 1069 do {
1064 r = r->parent(); 1070 r = r->parent();
1065 if (r == renderer()) 1071 if (r == renderer())
1066 r = 0; 1072 r = 0;
1067 } while (r && !r->nextSibling()); 1073 } while (r && !r->nextSibling());
1068 if (r) 1074 if (r)
1069 r = r->nextSibling(); 1075 r = r->nextSibling();
1070 } 1076 }
1071 } 1077 }
1072 } 1078 }
1073 m_visibleContentStatusDirty = false; 1079 m_visibleContentStatusDirty = false;
1080 if (hadVisibleContent != m_hasVisibleContent)
1081 updateNeedsCompositedScrolling();
1074 } 1082 }
1075 } 1083 }
1076 1084
1077 void RenderLayer::dirty3DTransformedDescendantStatus() 1085 void RenderLayer::dirty3DTransformedDescendantStatus()
1078 { 1086 {
1079 RenderLayer* curr = stackingContainer(); 1087 RenderLayer* curr = ancestorStackingContainer();
1080 if (curr) 1088 if (curr)
1081 curr->m_3DTransformedDescendantStatusDirty = true; 1089 curr->m_3DTransformedDescendantStatusDirty = true;
1082 1090
1083 // This propagates up through preserve-3d hierarchies to the enclosing flatt ening layer. 1091 // This propagates up through preserve-3d hierarchies to the enclosing flatt ening layer.
1084 // Note that preserves3D() creates stacking context, so we can just run up t he stacking containers. 1092 // Note that preserves3D() creates stacking context, so we can just run up t he stacking containers.
1085 while (curr && curr->preserves3D()) { 1093 while (curr && curr->preserves3D()) {
1086 curr->m_3DTransformedDescendantStatusDirty = true; 1094 curr->m_3DTransformedDescendantStatusDirty = true;
1087 curr = curr->stackingContainer(); 1095 curr = curr->ancestorStackingContainer();
1088 } 1096 }
1089 } 1097 }
1090 1098
1091 // Return true if this layer or any preserve-3d descendants have 3d. 1099 // Return true if this layer or any preserve-3d descendants have 3d.
1092 bool RenderLayer::update3DTransformedDescendantStatus() 1100 bool RenderLayer::update3DTransformedDescendantStatus()
1093 { 1101 {
1094 if (m_3DTransformedDescendantStatusDirty) { 1102 if (m_3DTransformedDescendantStatusDirty) {
1095 m_has3DTransformedDescendant = false; 1103 m_has3DTransformedDescendant = false;
1096 1104
1097 updateZOrderLists(); 1105 updateZOrderLists();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 if (!renderer()->hasTransform()) 1248 if (!renderer()->hasTransform())
1241 return FloatPoint(); 1249 return FloatPoint();
1242 1250
1243 const LayoutRect borderBox = toRenderBox(renderer())->borderBoxRect(); 1251 const LayoutRect borderBox = toRenderBox(renderer())->borderBoxRect();
1244 RenderStyle* style = renderer()->style(); 1252 RenderStyle* style = renderer()->style();
1245 1253
1246 return FloatPoint(floatValueForLength(style->perspectiveOriginX(), borderBox .width()), 1254 return FloatPoint(floatValueForLength(style->perspectiveOriginX(), borderBox .width()),
1247 floatValueForLength(style->perspectiveOriginY(), borderBox .height())); 1255 floatValueForLength(style->perspectiveOriginY(), borderBox .height()));
1248 } 1256 }
1249 1257
1250 RenderLayer* RenderLayer::stackingContainer() const 1258 RenderLayer* RenderLayer::ancestorStackingContainer() const
1251 { 1259 {
1252 RenderLayer* layer = parent(); 1260 RenderLayer* ancestor = parent();
1253 while (layer && !layer->isStackingContainer()) 1261 while (ancestor && !ancestor->isStackingContainer())
1254 layer = layer->parent(); 1262 ancestor = ancestor->parent();
1263 return ancestor;
1264 }
1255 1265
1256 ASSERT(!layer || layer->isStackingContainer()); 1266 RenderLayer* RenderLayer::ancestorStackingContext() const
1257 return layer; 1267 {
1268 RenderLayer* ancestor = parent();
1269 while (ancestor && !ancestor->isStackingContext())
1270 ancestor = ancestor->parent();
1271 return ancestor;
1258 } 1272 }
1259 1273
1260 static inline bool isPositionedContainer(RenderLayer* layer) 1274 static inline bool isPositionedContainer(RenderLayer* layer)
1261 { 1275 {
1262 RenderLayerModelObject* layerRenderer = layer->renderer(); 1276 RenderLayerModelObject* layerRenderer = layer->renderer();
1263 return layer->isRootLayer() || layerRenderer->isPositioned() || layer->hasTr ansform(); 1277 return layer->isRootLayer() || layerRenderer->isPositioned() || layer->hasTr ansform();
1264 } 1278 }
1265 1279
1266 static inline bool isFixedPositionedContainer(RenderLayer* layer) 1280 static inline bool isFixedPositionedContainer(RenderLayer* layer)
1267 { 1281 {
(...skipping 28 matching lines...) Expand all
1296 { 1310 {
1297 RenderLayer* curr = parent(); 1311 RenderLayer* curr = parent();
1298 while (curr && !curr->isRootLayer() && !curr->transform()) 1312 while (curr && !curr->isRootLayer() && !curr->transform())
1299 curr = curr->parent(); 1313 curr = curr->parent();
1300 1314
1301 return curr; 1315 return curr;
1302 } 1316 }
1303 1317
1304 static inline const RenderLayer* compositingContainer(const RenderLayer* layer) 1318 static inline const RenderLayer* compositingContainer(const RenderLayer* layer)
1305 { 1319 {
1306 return layer->isNormalFlowOnly() ? layer->parent() : layer->stackingContaine r(); 1320 return layer->isNormalFlowOnly() ? layer->parent() : layer->ancestorStacking Container();
1307 } 1321 }
1308 1322
1309 inline bool RenderLayer::shouldRepaintAfterLayout() const 1323 inline bool RenderLayer::shouldRepaintAfterLayout() const
1310 { 1324 {
1311 if (m_repaintStatus == NeedsNormalRepaint) 1325 if (m_repaintStatus == NeedsNormalRepaint)
1312 return true; 1326 return true;
1313 1327
1314 // Composited layers that were moved during a positioned movement only 1328 // Composited layers that were moved during a positioned movement only
1315 // layout, don't need to be repainted. They just need to be recomposited. 1329 // layout, don't need to be repainted. They just need to be recomposited.
1316 ASSERT(m_repaintStatus == NeedsFullRepaintForPositionedMovementLayout); 1330 ASSERT(m_repaintStatus == NeedsFullRepaintForPositionedMovementLayout);
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 ASSERT(beforeChild != child); 1644 ASSERT(beforeChild != child);
1631 } else 1645 } else
1632 setLastChild(child); 1646 setLastChild(child);
1633 1647
1634 child->setParent(this); 1648 child->setParent(this);
1635 1649
1636 if (child->isNormalFlowOnly()) 1650 if (child->isNormalFlowOnly())
1637 dirtyNormalFlowList(); 1651 dirtyNormalFlowList();
1638 1652
1639 if (!child->isNormalFlowOnly() || child->firstChild()) { 1653 if (!child->isNormalFlowOnly() || child->firstChild()) {
1640 // Dirty the z-order list in which we are contained. The stackingContain er() can be null in the 1654 // Dirty the z-order list in which we are contained. The ancestorStackin gContainer() can be null in the
1641 // case where we're building up generated content layers. This is ok, si nce the lists will start 1655 // case where we're building up generated content layers. This is ok, si nce the lists will start
1642 // off dirty in that case anyway. 1656 // off dirty in that case anyway.
1643 child->dirtyStackingContainerZOrderLists(); 1657 child->dirtyStackingContainerZOrderLists();
1658
1659 // Adding an out of flow positioned descendant can only affect
1660 // the opt-in decision for layers beneath and including our
1661 // containing block.
1662 RenderObject* containingBlock = child->renderer()->containingBlock();
1663 for (RenderLayer* layer = child; layer; layer = layer->parent()) {
1664 layer->updateNeedsCompositedScrolling();
1665 if (layer->renderer() == containingBlock)
1666 break;
1667 }
1644 } 1668 }
1645 1669
1646 child->updateDescendantDependentFlags(); 1670 child->updateDescendantDependentFlags();
1647 if (child->m_hasVisibleContent || child->m_hasVisibleDescendant) 1671 if (child->m_hasVisibleContent || child->m_hasVisibleDescendant)
1648 setAncestorChainHasVisibleDescendant(); 1672 setAncestorChainHasVisibleDescendant();
1649 1673
1650 if (child->isSelfPaintingLayer() || child->hasSelfPaintingLayerDescendant()) 1674 if (child->isSelfPaintingLayer() || child->hasSelfPaintingLayerDescendant())
1651 setAncestorChainHasSelfPaintingLayerDescendant(); 1675 setAncestorChainHasSelfPaintingLayerDescendant();
1652 1676
1653 if (child->renderer() && (child->renderer()->isOutOfFlowPositioned() || chil d->hasOutOfFlowPositionedDescendant())) 1677 if (child->renderer() && (child->renderer()->isOutOfFlowPositioned() || chil d->hasOutOfFlowPositionedDescendant()))
(...skipping 13 matching lines...) Expand all
1667 if (oldChild->nextSibling()) 1691 if (oldChild->nextSibling())
1668 oldChild->nextSibling()->setPreviousSibling(oldChild->previousSibling()) ; 1692 oldChild->nextSibling()->setPreviousSibling(oldChild->previousSibling()) ;
1669 1693
1670 if (m_first == oldChild) 1694 if (m_first == oldChild)
1671 m_first = oldChild->nextSibling(); 1695 m_first = oldChild->nextSibling();
1672 if (m_last == oldChild) 1696 if (m_last == oldChild)
1673 m_last = oldChild->previousSibling(); 1697 m_last = oldChild->previousSibling();
1674 1698
1675 if (oldChild->isNormalFlowOnly()) 1699 if (oldChild->isNormalFlowOnly())
1676 dirtyNormalFlowList(); 1700 dirtyNormalFlowList();
1677 if (!oldChild->isNormalFlowOnly() || oldChild->firstChild()) { 1701 if (!oldChild->isNormalFlowOnly() || oldChild->firstChild()) {
1678 // Dirty the z-order list in which we are contained. When called via th e 1702 // Dirty the z-order list in which we are contained. When called via th e
1679 // reattachment process in removeOnlyThisLayer, the layer may already be disconnected 1703 // reattachment process in removeOnlyThisLayer, the layer may already be disconnected
1680 // from the main layer tree, so we need to null-check the |stackingConta iner| value. 1704 // from the main layer tree, so we need to null-check the |stackingConta iner| value.
1681 oldChild->dirtyStackingContainerZOrderLists(); 1705 oldChild->dirtyStackingContainerZOrderLists();
1706
1707 // This could affect whether or not a layer has an out of flow
1708 // positioned descendant so we need to schedule some updates.
1709 // Removing an out of flow positioned descendant can only affect
1710 // the opt-in decision for layers beneath and including the old child's
1711 // containing block.
1712 RenderObject* containingBlock = oldChild->renderer()->containingBlock();
1713 for (RenderLayer* layer = this; layer; layer = layer->parent()) {
1714 layer->updateNeedsCompositedScrolling();
1715 if (layer->renderer() == containingBlock)
1716 break;
1717 }
1682 } 1718 }
1683 1719
1684 if ((oldChild->renderer() && oldChild->renderer()->isOutOfFlowPositioned()) || oldChild->hasOutOfFlowPositionedDescendant()) 1720 if ((oldChild->renderer() && oldChild->renderer()->isOutOfFlowPositioned()) || oldChild->hasOutOfFlowPositionedDescendant())
1685 dirtyAncestorChainHasOutOfFlowPositionedDescendantStatus(); 1721 dirtyAncestorChainHasOutOfFlowPositionedDescendantStatus();
1686 1722
1687 oldChild->setPreviousSibling(0); 1723 oldChild->setPreviousSibling(0);
1688 oldChild->setNextSibling(0); 1724 oldChild->setNextSibling(0);
1689 oldChild->setParent(0); 1725 oldChild->setParent(0);
1690 1726
1691 oldChild->updateDescendantDependentFlags(); 1727 oldChild->updateDescendantDependentFlags();
1692 if (oldChild->m_hasVisibleContent || oldChild->m_hasVisibleDescendant) 1728 if (oldChild->m_hasVisibleContent || oldChild->m_hasVisibleDescendant)
1693 dirtyAncestorChainVisibleDescendantStatus(); 1729 dirtyAncestorChainVisibleDescendantStatus();
1694 1730
1695 if (oldChild->isSelfPaintingLayer() || oldChild->hasSelfPaintingLayerDescend ant()) 1731 if (oldChild->isSelfPaintingLayer() || oldChild->hasSelfPaintingLayerDescend ant())
1696 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); 1732 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus();
1697 1733
1698 return oldChild; 1734 return oldChild;
1699 } 1735 }
1700 1736
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 return isComposited() && backing()->scrollingLayer(); 1937 return isComposited() && backing()->scrollingLayer();
1902 } 1938 }
1903 1939
1904 bool RenderLayer::needsCompositedScrolling() const 1940 bool RenderLayer::needsCompositedScrolling() const
1905 { 1941 {
1906 return m_needsCompositedScrolling; 1942 return m_needsCompositedScrolling;
1907 } 1943 }
1908 1944
1909 void RenderLayer::updateNeedsCompositedScrolling() 1945 void RenderLayer::updateNeedsCompositedScrolling()
1910 { 1946 {
1911 bool oldNeedsCompositedScrolling = m_needsCompositedScrolling; 1947 bool needsCompositedScrolling = false;
1912 1948
1913 FrameView* frameView = renderer()->view()->frameView(); 1949 FrameView* frameView = renderer()->view()->frameView();
1914 if (!frameView || !frameView->containsScrollableArea(this)) 1950 if (frameView && frameView->containsScrollableArea(this)) {
1915 m_needsCompositedScrolling = false; 1951 updateDescendantDependentFlags();
1916 else { 1952
1917 bool forceUseCompositedScrolling = acceleratedCompositingForOverflowScro llEnabled() 1953 bool forceUseCompositedScrolling = acceleratedCompositingForOverflowScro llEnabled()
1918 && canBeStackingContainer() 1954 && canBeStackingContainer()
1919 && !hasOutOfFlowPositionedDescendant(); 1955 && !hasOutOfFlowPositionedDescendant();
1920 1956
1921 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING) 1957 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
1922 m_needsCompositedScrolling = forceUseCompositedScrolling || renderer()-> style()->useTouchOverflowScrolling(); 1958 needsCompositedScrolling = forceUseCompositedScrolling || renderer()->st yle()->useTouchOverflowScrolling();
1923 #else 1959 #else
1924 m_needsCompositedScrolling = forceUseCompositedScrolling; 1960 needsCompositedScrolling = forceUseCompositedScrolling;
1925 #endif 1961 #endif
1926 // We gather a boolean value for use with Google UMA histograms to 1962 // We gather a boolean value for use with Google UMA histograms to
1927 // quantify the actual effects of a set of patches attempting to 1963 // quantify the actual effects of a set of patches attempting to
1928 // relax composited scrolling requirements, thereby increasing the 1964 // relax composited scrolling requirements, thereby increasing the
1929 // number of composited overflow divs. 1965 // number of composited overflow divs.
1930 if (acceleratedCompositingForOverflowScrollEnabled()) 1966 if (acceleratedCompositingForOverflowScrollEnabled())
1931 HistogramSupport::histogramEnumeration("Renderer.NeedsCompositedScro lling", m_needsCompositedScrolling, 2); 1967 HistogramSupport::histogramEnumeration("Renderer.NeedsCompositedScro lling", needsCompositedScrolling, 2);
1932 } 1968 }
1933 1969
1934 if (oldNeedsCompositedScrolling != m_needsCompositedScrolling) { 1970 if (m_needsCompositedScrolling == needsCompositedScrolling)
1935 updateSelfPaintingLayer(); 1971 return;
1936 if (isStackingContainer())
1937 dirtyZOrderLists();
1938 else
1939 clearZOrderLists();
1940 1972
1941 dirtyStackingContainerZOrderLists(); 1973 m_needsCompositedScrolling = needsCompositedScrolling;
1942 1974
1943 compositor()->setShouldReevaluateCompositingAfterLayout(); 1975 updateIsNormalFlowOnly();
1944 compositor()->setCompositingLayersNeedRebuild(); 1976 updateSelfPaintingLayer();
1945 } 1977
1978 if (isStackingContainer())
1979 dirtyZOrderLists();
1980 else
1981 clearZOrderLists();
1982
1983 dirtyStackingContainerZOrderLists();
1984
1985 compositor()->setShouldReevaluateCompositingAfterLayout();
1986 compositor()->setCompositingLayersNeedRebuild();
1946 } 1987 }
1947 1988
1948 static inline int adjustedScrollDelta(int beginningDelta) { 1989 static inline int adjustedScrollDelta(int beginningDelta) {
1949 // This implemention matches Firefox's. 1990 // This implemention matches Firefox's.
1950 // http://mxr.mozilla.org/firefox/source/toolkit/content/widgets/browser.xml #856. 1991 // http://mxr.mozilla.org/firefox/source/toolkit/content/widgets/browser.xml #856.
1951 const int speedReducer = 12; 1992 const int speedReducer = 12;
1952 1993
1953 int adjustedDelta = beginningDelta / speedReducer; 1994 int adjustedDelta = beginningDelta / speedReducer;
1954 if (adjustedDelta > 1) 1995 if (adjustedDelta > 1)
1955 adjustedDelta = static_cast<int>(adjustedDelta * sqrt(static_cast<double >(adjustedDelta))) - 1; 1996 adjustedDelta = static_cast<int>(adjustedDelta * sqrt(static_cast<double >(adjustedDelta))) - 1;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 2267
2227 if (frameView) 2268 if (frameView)
2228 frameView->resumeScheduledEvents(); 2269 frameView->resumeScheduledEvents();
2229 } 2270 }
2230 2271
2231 void RenderLayer::updateCompositingLayersAfterScroll() 2272 void RenderLayer::updateCompositingLayersAfterScroll()
2232 { 2273 {
2233 if (compositor()->inCompositingMode()) { 2274 if (compositor()->inCompositingMode()) {
2234 // Our stacking container is guaranteed to contain all of our descendant s that may need 2275 // Our stacking container is guaranteed to contain all of our descendant s that may need
2235 // repositioning, so update compositing layers from there. 2276 // repositioning, so update compositing layers from there.
2236 if (RenderLayer* compositingAncestor = stackingContainer()->enclosingCom positingLayer()) { 2277 if (RenderLayer* compositingAncestor = ancestorStackingContainer()->encl osingCompositingLayer()) {
2237 if (usesCompositedScrolling() && !hasOutOfFlowPositionedDescendant() ) 2278 if (usesCompositedScrolling())
2238 compositor()->updateCompositingLayers(CompositingUpdateOnComposi tedScroll, compositingAncestor); 2279 compositor()->updateCompositingLayers(CompositingUpdateOnComposi tedScroll, compositingAncestor);
2239 else 2280 else
2240 compositor()->updateCompositingLayers(CompositingUpdateOnScroll, compositingAncestor); 2281 compositor()->updateCompositingLayers(CompositingUpdateOnScroll, compositingAncestor);
2241 } 2282 }
2242 } 2283 }
2243 } 2284 }
2244 2285
2245 LayoutRect RenderLayer::getRectToExpose(const LayoutRect &visibleRect, const Lay outRect &exposeRect, const ScrollAlignment& alignX, const ScrollAlignment& align Y) 2286 LayoutRect RenderLayer::getRectToExpose(const LayoutRect &visibleRect, const Lay outRect &exposeRect, const ScrollAlignment& alignX, const ScrollAlignment& align Y)
2246 { 2287 {
2247 // Determine the appropriate X behavior. 2288 // Determine the appropriate X behavior.
(...skipping 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after
4036 paintOverflowControls(context, roundedIntPoint(toPoint(fragment.layerBou nds.location() - renderBoxLocation() + localPaintingInfo.subPixelAccumulation)), 4077 paintOverflowControls(context, roundedIntPoint(toPoint(fragment.layerBou nds.location() - renderBoxLocation() + localPaintingInfo.subPixelAccumulation)),
4037 pixelSnappedIntRect(fragment.backgroundRect.rect()), true); 4078 pixelSnappedIntRect(fragment.backgroundRect.rect()), true);
4038 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.backgrou ndRect); 4079 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.backgrou ndRect);
4039 } 4080 }
4040 } 4081 }
4041 4082
4042 void RenderLayer::paintPaginatedChildLayer(RenderLayer* childLayer, GraphicsCont ext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 4083 void RenderLayer::paintPaginatedChildLayer(RenderLayer* childLayer, GraphicsCont ext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
4043 { 4084 {
4044 // We need to do multiple passes, breaking up our child layer into strips. 4085 // We need to do multiple passes, breaking up our child layer into strips.
4045 Vector<RenderLayer*> columnLayers; 4086 Vector<RenderLayer*> columnLayers;
4046 RenderLayer* ancestorLayer = isNormalFlowOnly() ? parent() : stackingContain er(); 4087 RenderLayer* ancestorLayer = isNormalFlowOnly() ? parent() : ancestorStackin gContainer();
4047 for (RenderLayer* curr = childLayer->parent(); curr; curr = curr->parent()) { 4088 for (RenderLayer* curr = childLayer->parent(); curr; curr = curr->parent()) {
4048 if (curr->renderer()->hasColumns() && checkContainingBlockChainForPagina tion(childLayer->renderer(), curr->renderBox())) 4089 if (curr->renderer()->hasColumns() && checkContainingBlockChainForPagina tion(childLayer->renderer(), curr->renderBox()))
4049 columnLayers.append(curr); 4090 columnLayers.append(curr);
4050 if (curr == ancestorLayer) 4091 if (curr == ancestorLayer)
4051 break; 4092 break;
4052 } 4093 }
4053 4094
4054 // It is possible for paintLayer() to be called after the child layer ceases to be paginated but before 4095 // It is possible for paintLayer() to be called after the child layer ceases to be paginated but before
4055 // updateLayerPositions() is called and resets the isPaginated() flag, see < rdar://problem/10098679>. 4096 // updateLayerPositions() is called and resets the isPaginated() flag, see < rdar://problem/10098679>.
4056 // If this is the case, just bail out, since the upcoming call to updateLaye rPositions() will repaint the layer. 4097 // If this is the case, just bail out, since the upcoming call to updateLaye rPositions() will repaint the layer.
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
4634 } 4675 }
4635 } 4676 }
4636 4677
4637 return resultLayer; 4678 return resultLayer;
4638 } 4679 }
4639 4680
4640 RenderLayer* RenderLayer::hitTestPaginatedChildLayer(RenderLayer* childLayer, Re nderLayer* rootLayer, const HitTestRequest& request, HitTestResult& result, 4681 RenderLayer* RenderLayer::hitTestPaginatedChildLayer(RenderLayer* childLayer, Re nderLayer* rootLayer, const HitTestRequest& request, HitTestResult& result,
4641 const LayoutRect& hitTestRe ct, const HitTestLocation& hitTestLocation, const HitTestingTransformState* tran sformState, double* zOffset) 4682 const LayoutRect& hitTestRe ct, const HitTestLocation& hitTestLocation, const HitTestingTransformState* tran sformState, double* zOffset)
4642 { 4683 {
4643 Vector<RenderLayer*> columnLayers; 4684 Vector<RenderLayer*> columnLayers;
4644 RenderLayer* ancestorLayer = isNormalFlowOnly() ? parent() : stackingContain er(); 4685 RenderLayer* ancestorLayer = isNormalFlowOnly() ? parent() : ancestorStackin gContainer();
4645 for (RenderLayer* curr = childLayer->parent(); curr; curr = curr->parent()) { 4686 for (RenderLayer* curr = childLayer->parent(); curr; curr = curr->parent()) {
4646 if (curr->renderer()->hasColumns() && checkContainingBlockChainForPagina tion(childLayer->renderer(), curr->renderBox())) 4687 if (curr->renderer()->hasColumns() && checkContainingBlockChainForPagina tion(childLayer->renderer(), curr->renderBox()))
4647 columnLayers.append(curr); 4688 columnLayers.append(curr);
4648 if (curr == ancestorLayer) 4689 if (curr == ancestorLayer)
4649 break; 4690 break;
4650 } 4691 }
4651 4692
4652 ASSERT(columnLayers.size()); 4693 ASSERT(columnLayers.size());
4653 return hitTestChildLayerColumns(childLayer, rootLayer, request, result, hitT estRect, hitTestLocation, transformState, zOffset, 4694 return hitTestChildLayerColumns(childLayer, rootLayer, request, result, hitT estRect, hitTestLocation, transformState, zOffset,
4654 columnLayers, columnLayers.size() - 1); 4695 columnLayers, columnLayers.size() - 1);
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
5447 { 5488 {
5448 ASSERT(m_layerListMutationAllowed); 5489 ASSERT(m_layerListMutationAllowed);
5449 ASSERT(isStackingContainer()); 5490 ASSERT(isStackingContainer());
5450 5491
5451 if (m_posZOrderList) 5492 if (m_posZOrderList)
5452 m_posZOrderList->clear(); 5493 m_posZOrderList->clear();
5453 if (m_negZOrderList) 5494 if (m_negZOrderList)
5454 m_negZOrderList->clear(); 5495 m_negZOrderList->clear();
5455 m_zOrderListsDirty = true; 5496 m_zOrderListsDirty = true;
5456 5497
5498 m_descendantsAreContiguousInStackingOrderDirty = true;
5499
5457 if (!renderer()->documentBeingDestroyed()) { 5500 if (!renderer()->documentBeingDestroyed()) {
5458 compositor()->setCompositingLayersNeedRebuild(); 5501 compositor()->setCompositingLayersNeedRebuild();
5459 if (acceleratedCompositingForOverflowScrollEnabled()) 5502 if (acceleratedCompositingForOverflowScrollEnabled())
5460 compositor()->setShouldReevaluateCompositingAfterLayout(); 5503 compositor()->setShouldReevaluateCompositingAfterLayout();
5461 } 5504 }
5462 } 5505 }
5463 5506
5464 void RenderLayer::dirtyStackingContainerZOrderLists() 5507 void RenderLayer::dirtyStackingContainerZOrderLists()
5465 { 5508 {
5466 RenderLayer* sc = stackingContainer(); 5509 RenderLayer* stackingContainer = this->ancestorStackingContainer();
5467 if (sc) 5510 if (stackingContainer)
5468 sc->dirtyZOrderLists(); 5511 stackingContainer->dirtyZOrderLists();
5512
5513 // Any change that could affect our stacking container's z-order list could
5514 // cause other RenderLayers in our stacking context to either opt in or out
5515 // of composited scrolling. It is important that we make our stacking
5516 // context aware of these z-order changes so the appropriate updating can
5517 // happen.
5518 RenderLayer* stackingContext = this->ancestorStackingContext();
5519 if (stackingContext && stackingContext != stackingContainer)
5520 stackingContext->dirtyZOrderLists();
5469 } 5521 }
5470 5522
5471 void RenderLayer::dirtyNormalFlowList() 5523 void RenderLayer::dirtyNormalFlowList()
5472 { 5524 {
5473 ASSERT(m_layerListMutationAllowed); 5525 ASSERT(m_layerListMutationAllowed);
5474 5526
5475 if (m_normalFlowList) 5527 if (m_normalFlowList)
5476 m_normalFlowList->clear(); 5528 m_normalFlowList->clear();
5477 m_normalFlowListDirty = true; 5529 m_normalFlowListDirty = true;
5478 5530
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
5571 for (RenderLayer* child = firstChild(); child; child = child->nextSiblin g()) { 5623 for (RenderLayer* child = firstChild(); child; child = child->nextSiblin g()) {
5572 // Ignore reflections. 5624 // Ignore reflections.
5573 if (!m_reflection || reflectionLayer() != child) 5625 if (!m_reflection || reflectionLayer() != child)
5574 child->collectLayers(includeHiddenLayers, behavior, posBuffer, n egBuffer); 5626 child->collectLayers(includeHiddenLayers, behavior, posBuffer, n egBuffer);
5575 } 5627 }
5576 } 5628 }
5577 } 5629 }
5578 5630
5579 void RenderLayer::updateLayerListsIfNeeded() 5631 void RenderLayer::updateLayerListsIfNeeded()
5580 { 5632 {
5581 bool shouldUpdateDescendantsAreContiguousInStackingOrder = isStackingContext () && (m_zOrderListsDirty || m_normalFlowListDirty); 5633 bool shouldUpdateDescendantsAreContiguousInStackingOrder = acceleratedCompos itingForOverflowScrollEnabled() && isStackingContext() && (m_zOrderListsDirty || m_normalFlowListDirty) && m_descendantsAreContiguousInStackingOrderDirty;
5582 updateZOrderLists(); 5634 updateZOrderLists();
5583 updateNormalFlowList(); 5635 updateNormalFlowList();
5584 5636
5585 if (RenderLayer* reflectionLayer = this->reflectionLayer()) { 5637 if (RenderLayer* reflectionLayer = this->reflectionLayer()) {
5586 reflectionLayer->updateZOrderLists(); 5638 reflectionLayer->updateZOrderLists();
5587 reflectionLayer->updateNormalFlowList(); 5639 reflectionLayer->updateNormalFlowList();
5588 } 5640 }
5589 5641
5590 if (shouldUpdateDescendantsAreContiguousInStackingOrder) { 5642 if (shouldUpdateDescendantsAreContiguousInStackingOrder) {
5591 updateDescendantsAreContiguousInStackingOrder(); 5643 updateDescendantsAreContiguousInStackingOrder();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
5665 && !renderer()->hasBlendMode() 5717 && !renderer()->hasBlendMode()
5666 #endif 5718 #endif
5667 && !isTransparent() 5719 && !isTransparent()
5668 && !needsCompositedScrolling() 5720 && !needsCompositedScrolling()
5669 #if ENABLE(CSS_EXCLUSIONS) 5721 #if ENABLE(CSS_EXCLUSIONS)
5670 && !renderer()->isFloatingWithShapeOutside() 5722 && !renderer()->isFloatingWithShapeOutside()
5671 #endif 5723 #endif
5672 ; 5724 ;
5673 } 5725 }
5674 5726
5727 void RenderLayer::updateIsNormalFlowOnly()
5728 {
5729 bool isNormalFlowOnly = shouldBeNormalFlowOnly();
5730 if (isNormalFlowOnly == m_isNormalFlowOnly)
5731 return;
5732
5733 m_isNormalFlowOnly = isNormalFlowOnly;
5734 if (RenderLayer* p = parent())
5735 p->dirtyNormalFlowList();
5736 dirtyStackingContainerZOrderLists();
5737 }
5738
5675 bool RenderLayer::shouldBeSelfPaintingLayer() const 5739 bool RenderLayer::shouldBeSelfPaintingLayer() const
5676 { 5740 {
5677 return !isNormalFlowOnly() 5741 return !isNormalFlowOnly()
5678 || hasOverlayScrollbars() 5742 || hasOverlayScrollbars()
5679 || needsCompositedScrolling() 5743 || needsCompositedScrolling()
5680 || renderer()->hasReflection() 5744 || renderer()->hasReflection()
5681 || renderer()->hasMask() 5745 || renderer()->hasMask()
5682 || renderer()->isTableRow() 5746 || renderer()->isTableRow()
5683 || renderer()->isCanvas() 5747 || renderer()->isCanvas()
5684 || renderer()->isVideo() 5748 || renderer()->isVideo()
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
5747 5811
5748 if (renderer()->isReplaced() || renderer()->hasMask()) 5812 if (renderer()->isReplaced() || renderer()->hasMask())
5749 return true; 5813 return true;
5750 5814
5751 if (hasVisibleBoxDecorations()) 5815 if (hasVisibleBoxDecorations())
5752 return true; 5816 return true;
5753 5817
5754 return false; 5818 return false;
5755 } 5819 }
5756 5820
5821 void RenderLayer::updateVisibilityAfterStyleChange(const RenderStyle* oldStyle)
5822 {
5823 EVisibility oldVisibility = oldStyle ? oldStyle->visibility() : VISIBLE;
5824 if (oldVisibility == renderer()->style()->visibility() || !renderer()->isOut OfFlowPositioned())
5825 return;
5826
5827 if (renderer()->style()->visibility() == VISIBLE)
5828 setAncestorChainHasOutOfFlowPositionedDescendant(renderer()->containingB lock());
5829 else
5830 dirtyAncestorChainHasOutOfFlowPositionedDescendantStatus();
5831 }
5832
5757 void RenderLayer::updateStackingContextsAfterStyleChange(const RenderStyle* oldS tyle) 5833 void RenderLayer::updateStackingContextsAfterStyleChange(const RenderStyle* oldS tyle)
5758 { 5834 {
5759 if (!oldStyle) 5835 bool wasStackingContext = oldStyle ? isStackingContext(oldStyle) : false;
5760 return; 5836 EVisibility oldVisibility = oldStyle ? oldStyle->visibility() : VISIBLE;
5761 5837 int oldZIndex = oldStyle ? oldStyle->zIndex() : 0;
5762 bool wasStackingContext = isStackingContext(oldStyle);
5763 bool isStackingContext = this->isStackingContext();
5764 if (isStackingContext != wasStackingContext) {
5765 dirtyStackingContainerZOrderLists();
5766 if (isStackingContext)
5767 dirtyZOrderLists();
5768 else
5769 clearZOrderLists();
5770 return;
5771 }
5772 5838
5773 // FIXME: RenderLayer already handles visibility changes through our visibli ty dirty bits. This logic could 5839 // FIXME: RenderLayer already handles visibility changes through our visibli ty dirty bits. This logic could
5774 // likely be folded along with the rest. 5840 // likely be folded along with the rest.
5775 if (oldStyle->zIndex() != renderer()->style()->zIndex() || oldStyle->visibil ity() != renderer()->style()->visibility()) { 5841 bool isStackingContext = this->isStackingContext();
5776 dirtyStackingContainerZOrderLists(); 5842 if (isStackingContext == wasStackingContext && oldVisibility == renderer()-> style()->visibility() && oldZIndex == renderer()->style()->zIndex())
5777 if (isStackingContext) 5843 return;
5778 dirtyZOrderLists(); 5844
5779 } 5845 dirtyStackingContainerZOrderLists();
5846
5847 if (isStackingContainer())
5848 dirtyZOrderLists();
5849 else
5850 clearZOrderLists();
5851
5852 updateNeedsCompositedScrolling();
5780 } 5853 }
5781 5854
5782 static bool overflowRequiresScrollbar(EOverflow overflow) 5855 static bool overflowRequiresScrollbar(EOverflow overflow)
5783 { 5856 {
5784 return overflow == OSCROLL; 5857 return overflow == OSCROLL;
5785 } 5858 }
5786 5859
5787 static bool overflowDefinesAutomaticScrollbar(EOverflow overflow) 5860 static bool overflowDefinesAutomaticScrollbar(EOverflow overflow)
5788 { 5861 {
5789 return overflow == OAUTO || overflow == OOVERLAY; 5862 return overflow == OAUTO || overflow == OOVERLAY;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
5835 layer->m_hasOutOfFlowPositionedDescendant = true; 5908 layer->m_hasOutOfFlowPositionedDescendant = true;
5836 layer->updateNeedsCompositedScrolling(); 5909 layer->updateNeedsCompositedScrolling();
5837 5910
5838 if (layer->renderer() && layer->renderer() == containingBlock) 5911 if (layer->renderer() && layer->renderer() == containingBlock)
5839 break; 5912 break;
5840 } 5913 }
5841 } 5914 }
5842 5915
5843 void RenderLayer::dirtyAncestorChainHasOutOfFlowPositionedDescendantStatus() 5916 void RenderLayer::dirtyAncestorChainHasOutOfFlowPositionedDescendantStatus()
5844 { 5917 {
5845 m_hasOutOfFlowPositionedDescendantDirty = true; 5918 if (m_hasOutOfFlowPositionedDescendant) {
5919 m_hasOutOfFlowPositionedDescendantDirty = true;
5920 // FIXME It would be nice to avoid this when we clean up render layer
5921 // updating. We shouldn't have to update the composited scrolling state
5922 // nearly as frequently if all the updates happen in a single, well
5923 // defined phase.
5924 updateNeedsCompositedScrolling();
5925 }
5926
5846 if (parent()) 5927 if (parent())
5847 parent()->dirtyAncestorChainHasOutOfFlowPositionedDescendantStatus(); 5928 parent()->dirtyAncestorChainHasOutOfFlowPositionedDescendantStatus();
5848 } 5929 }
5849 5930
5850 void RenderLayer::updateOutOfFlowPositioned(const RenderStyle* oldStyle) 5931 void RenderLayer::updateOutOfFlowPositioned(const RenderStyle* oldStyle)
5851 { 5932 {
5852 bool wasOutOfFlowPositioned = oldStyle && (oldStyle->position() == AbsoluteP osition || oldStyle->position() == FixedPosition); 5933 bool wasOutOfFlowPositioned = oldStyle && (oldStyle->position() == AbsoluteP osition || oldStyle->position() == FixedPosition);
5853 if (parent() && ((renderer() && renderer()->isOutOfFlowPositioned()) != wasO utOfFlowPositioned)) { 5934 bool isOutOfFlowPositioned = renderer()->isOutOfFlowPositioned();
5854 parent()->dirtyAncestorChainHasOutOfFlowPositionedDescendantStatus(); 5935 if (parent() && isOutOfFlowPositioned != wasOutOfFlowPositioned) {
5855 if (!renderer()->documentBeingDestroyed() && acceleratedCompositingForOv erflowScrollEnabled()) 5936 if (isOutOfFlowPositioned)
5856 compositor()->setShouldReevaluateCompositingAfterLayout(); 5937 parent()->setAncestorChainHasOutOfFlowPositionedDescendant(renderer( )->containingBlock());
5938 else
5939 parent()->dirtyAncestorChainHasOutOfFlowPositionedDescendantStatus() ;
5857 } 5940 }
5858 } 5941 }
5859 5942
5860 static bool hasOrHadFilters(const RenderStyle* oldStyle, const RenderStyle* newS tyle) 5943 static bool hasOrHadFilters(const RenderStyle* oldStyle, const RenderStyle* newS tyle)
5861 { 5944 {
5862 ASSERT(newStyle); 5945 ASSERT(newStyle);
5863 return (oldStyle && oldStyle->hasFilter()) || newStyle->hasFilter(); 5946 return (oldStyle && oldStyle->hasFilter()) || newStyle->hasFilter();
5864 } 5947 }
5865 5948
5866 inline bool RenderLayer::needsCompositingLayersRebuiltForClip(const RenderStyle* oldStyle, const RenderStyle* newStyle) const 5949 inline bool RenderLayer::needsCompositingLayersRebuiltForClip(const RenderStyle* oldStyle, const RenderStyle* newStyle) const
5867 { 5950 {
5868 ASSERT(newStyle); 5951 ASSERT(newStyle);
5869 return oldStyle && (oldStyle->clip() != newStyle->clip() || oldStyle->hasCli p() != newStyle->hasClip()); 5952 return oldStyle && (oldStyle->clip() != newStyle->clip() || oldStyle->hasCli p() != newStyle->hasClip());
5870 } 5953 }
5871 5954
5872 inline bool RenderLayer::needsCompositingLayersRebuiltForOverflow(const RenderSt yle* oldStyle, const RenderStyle* newStyle) const 5955 inline bool RenderLayer::needsCompositingLayersRebuiltForOverflow(const RenderSt yle* oldStyle, const RenderStyle* newStyle) const
5873 { 5956 {
5874 ASSERT(newStyle); 5957 ASSERT(newStyle);
5875 return !isComposited() && oldStyle && (oldStyle->overflowX() != newStyle->ov erflowX()) && stackingContainer()->hasCompositingDescendant(); 5958 return !isComposited() && oldStyle && (oldStyle->overflowX() != newStyle->ov erflowX()) && ancestorStackingContainer()->hasCompositingDescendant();
5876 } 5959 }
5877 5960
5878 inline bool RenderLayer::needsCompositingLayersRebuiltForFilters(const RenderSty le* oldStyle, const RenderStyle* newStyle, bool didPaintWithFilters) const 5961 inline bool RenderLayer::needsCompositingLayersRebuiltForFilters(const RenderSty le* oldStyle, const RenderStyle* newStyle, bool didPaintWithFilters) const
5879 { 5962 {
5880 if (!hasOrHadFilters(oldStyle, newStyle)) 5963 if (!hasOrHadFilters(oldStyle, newStyle))
5881 return false; 5964 return false;
5882 5965
5883 if (renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(rendere r(), CSSPropertyWebkitFilter)) { 5966 if (renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(rendere r(), CSSPropertyWebkitFilter)) {
5884 // When the compositor is performing the filter animation, we shouldn't touch the compositing layers. 5967 // When the compositor is performing the filter animation, we shouldn't touch the compositing layers.
5885 // All of the layers above us should have been promoted to compositing l ayers already. 5968 // All of the layers above us should have been promoted to compositing l ayers already.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
5924 // Thus, we have to call updateFilters again, after we have a FilterEffectRe nderer. 6007 // Thus, we have to call updateFilters again, after we have a FilterEffectRe nderer.
5925 // FilterEffectRenderer is intended to render software filters and shouldn't be needed for accelerated filters. 6008 // FilterEffectRenderer is intended to render software filters and shouldn't be needed for accelerated filters.
5926 // We should extract the SVG graph building functionality out of FilterEffec tRenderer, and it should happen in RenderLayer::computeFilterOperations. 6009 // We should extract the SVG graph building functionality out of FilterEffec tRenderer, and it should happen in RenderLayer::computeFilterOperations.
5927 // https://bugs.webkit.org/show_bug.cgi?id=114051 6010 // https://bugs.webkit.org/show_bug.cgi?id=114051
5928 if (shouldUpdateFilters && newStyle->filter().hasReferenceFilter()) 6011 if (shouldUpdateFilters && newStyle->filter().hasReferenceFilter())
5929 backing()->updateFilters(renderer()->style()); 6012 backing()->updateFilters(renderer()->style());
5930 } 6013 }
5931 6014
5932 void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle) 6015 void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle)
5933 { 6016 {
5934 bool isNormalFlowOnly = shouldBeNormalFlowOnly();
5935 if (isNormalFlowOnly != m_isNormalFlowOnly) {
5936 m_isNormalFlowOnly = isNormalFlowOnly;
5937 RenderLayer* p = parent();
5938 if (p)
5939 p->dirtyNormalFlowList();
5940 dirtyStackingContainerZOrderLists();
5941 }
5942
5943 if (renderer()->style()->overflowX() == OMARQUEE && renderer()->style()->mar queeBehavior() != MNONE && renderer()->isBox()) { 6017 if (renderer()->style()->overflowX() == OMARQUEE && renderer()->style()->mar queeBehavior() != MNONE && renderer()->isBox()) {
5944 if (!m_marquee) 6018 if (!m_marquee)
5945 m_marquee = adoptPtr(new RenderMarquee(this)); 6019 m_marquee = adoptPtr(new RenderMarquee(this));
5946 UseCounter::observe(renderer()->document(), renderer()->isHTMLMarquee() ? UseCounter::HTMLMarqueeElement : UseCounter::CSSOverflowMarquee); 6020 UseCounter::observe(renderer()->document(), renderer()->isHTMLMarquee() ? UseCounter::HTMLMarqueeElement : UseCounter::CSSOverflowMarquee);
5947 m_marquee->updateMarqueeStyle(); 6021 m_marquee->updateMarqueeStyle();
5948 } 6022 }
5949 else if (m_marquee) { 6023 else if (m_marquee) {
5950 m_marquee.clear(); 6024 m_marquee.clear();
5951 } 6025 }
5952 6026
5953 updateScrollbarsAfterStyleChange(oldStyle); 6027 updateScrollbarsAfterStyleChange(oldStyle);
5954 updateStackingContextsAfterStyleChange(oldStyle); 6028 updateStackingContextsAfterStyleChange(oldStyle);
6029 updateVisibilityAfterStyleChange(oldStyle);
5955 // Overlay scrollbars can make this layer self-painting so we need 6030 // Overlay scrollbars can make this layer self-painting so we need
5956 // to recompute the bit once scrollbars have been updated. 6031 // to recompute the bit once scrollbars have been updated.
5957 updateSelfPaintingLayer(); 6032 updateSelfPaintingLayer();
5958 updateOutOfFlowPositioned(oldStyle); 6033 updateOutOfFlowPositioned(oldStyle);
5959 6034
5960 if (!hasReflection() && m_reflection) 6035 if (!hasReflection() && m_reflection)
5961 removeReflection(); 6036 removeReflection();
5962 else if (hasReflection()) { 6037 else if (hasReflection()) {
5963 if (!m_reflection) 6038 if (!m_reflection)
5964 createReflection(); 6039 createReflection();
(...skipping 15 matching lines...) Expand all
5980 #if ENABLE(CSS_COMPOSITING) 6055 #if ENABLE(CSS_COMPOSITING)
5981 updateBlendMode(); 6056 updateBlendMode();
5982 #endif 6057 #endif
5983 6058
5984 bool didPaintWithFilters = false; 6059 bool didPaintWithFilters = false;
5985 6060
5986 if (paintsWithFilters()) 6061 if (paintsWithFilters())
5987 didPaintWithFilters = true; 6062 didPaintWithFilters = true;
5988 updateFilters(oldStyle, renderer()->style()); 6063 updateFilters(oldStyle, renderer()->style());
5989 6064
5990 updateNeedsCompositedScrolling();
5991
5992 const RenderStyle* newStyle = renderer()->style(); 6065 const RenderStyle* newStyle = renderer()->style();
5993 if (compositor()->updateLayerCompositingState(this) 6066 if (compositor()->updateLayerCompositingState(this)
5994 || needsCompositingLayersRebuiltForClip(oldStyle, newStyle) 6067 || needsCompositingLayersRebuiltForClip(oldStyle, newStyle)
5995 || needsCompositingLayersRebuiltForOverflow(oldStyle, newStyle) 6068 || needsCompositingLayersRebuiltForOverflow(oldStyle, newStyle)
5996 || needsCompositingLayersRebuiltForFilters(oldStyle, newStyle, didPaintW ithFilters)) 6069 || needsCompositingLayersRebuiltForFilters(oldStyle, newStyle, didPaintW ithFilters))
5997 compositor()->setCompositingLayersNeedRebuild(); 6070 compositor()->setCompositingLayersNeedRebuild();
5998 else if (isComposited()) 6071 else if (isComposited())
5999 backing()->updateGraphicsLayerGeometry(); 6072 backing()->updateGraphicsLayerGeometry();
6000 } 6073 }
6001 6074
6002 void RenderLayer::updateScrollableAreaSet(bool hasOverflow) 6075 void RenderLayer::updateScrollableAreaSet(bool hasOverflow)
6003 { 6076 {
6004 Frame* frame = renderer()->frame(); 6077 Frame* frame = renderer()->frame();
6005 if (!frame) 6078 if (!frame)
6006 return; 6079 return;
6007 6080
6008 FrameView* frameView = frame->view(); 6081 FrameView* frameView = frame->view();
6009 if (!frameView) 6082 if (!frameView)
6010 return; 6083 return;
6011 6084
6012 bool isVisibleToHitTest = renderer()->visibleToHitTesting(); 6085 bool isVisibleToHitTest = renderer()->visibleToHitTesting();
6013 if (HTMLFrameOwnerElement* owner = frame->ownerElement()) 6086 if (HTMLFrameOwnerElement* owner = frame->ownerElement())
6014 isVisibleToHitTest &= owner->renderer() && owner->renderer()->visibleToH itTesting(); 6087 isVisibleToHitTest &= owner->renderer() && owner->renderer()->visibleToH itTesting();
6015 6088
6016 if (hasOverflow && isVisibleToHitTest ? frameView->addScrollableArea(this) : frameView->removeScrollableArea(this)) 6089 bool updatedScrollableAreaSet = false;
6090 if (hasOverflow && isVisibleToHitTest)
6091 updatedScrollableAreaSet = frameView->addScrollableArea(this);
6092 else
6093 updatedScrollableAreaSet = frameView->removeScrollableArea(this);
6094
6095 if (updatedScrollableAreaSet)
6017 updateNeedsCompositedScrolling(); 6096 updateNeedsCompositedScrolling();
6018 } 6097 }
6019 6098
6020 void RenderLayer::updateScrollCornerStyle() 6099 void RenderLayer::updateScrollCornerStyle()
6021 { 6100 {
6022 RenderObject* actualRenderer = rendererForScrollbar(renderer()); 6101 RenderObject* actualRenderer = rendererForScrollbar(renderer());
6023 RefPtr<RenderStyle> corner = renderer()->hasOverflowClip() ? actualRenderer- >getUncachedPseudoStyle(PseudoStyleRequest(SCROLLBAR_CORNER), actualRenderer->st yle()) : PassRefPtr<RenderStyle>(0); 6102 RefPtr<RenderStyle> corner = renderer()->hasOverflowClip() ? actualRenderer- >getUncachedPseudoStyle(PseudoStyleRequest(SCROLLBAR_CORNER), actualRenderer->st yle()) : PassRefPtr<RenderStyle>(0);
6024 if (corner) { 6103 if (corner) {
6025 if (!m_scrollCorner) { 6104 if (!m_scrollCorner) {
6026 m_scrollCorner = RenderScrollbarPart::createAnonymous(renderer()->do cument()); 6105 m_scrollCorner = RenderScrollbarPart::createAnonymous(renderer()->do cument());
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
6258 } 6337 }
6259 } 6338 }
6260 6339
6261 void showLayerTree(const WebCore::RenderObject* renderer) 6340 void showLayerTree(const WebCore::RenderObject* renderer)
6262 { 6341 {
6263 if (!renderer) 6342 if (!renderer)
6264 return; 6343 return;
6265 showLayerTree(renderer->enclosingLayer()); 6344 showLayerTree(renderer->enclosingLayer());
6266 } 6345 }
6267 #endif 6346 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderLayer.h ('k') | Source/core/rendering/RenderLayerCompositor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698