| OLD | NEW |
| 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) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
| 6 * All rights reserved. | 6 * All rights reserved. |
| 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // LayoutBlockFlow calls setChildrenInline(true). | 104 // LayoutBlockFlow calls setChildrenInline(true). |
| 105 // By default, subclasses do not have inline children. | 105 // By default, subclasses do not have inline children. |
| 106 } | 106 } |
| 107 | 107 |
| 108 void LayoutBlock::removeFromGlobalMaps() { | 108 void LayoutBlock::removeFromGlobalMaps() { |
| 109 if (hasPositionedObjects()) { | 109 if (hasPositionedObjects()) { |
| 110 std::unique_ptr<TrackedLayoutBoxListHashSet> descendants = | 110 std::unique_ptr<TrackedLayoutBoxListHashSet> descendants = |
| 111 gPositionedDescendantsMap->take(this); | 111 gPositionedDescendantsMap->take(this); |
| 112 ASSERT(!descendants->isEmpty()); | 112 ASSERT(!descendants->isEmpty()); |
| 113 for (LayoutBox* descendant : *descendants) { | 113 for (LayoutBox* descendant : *descendants) { |
| 114 ASSERT(gPositionedContainerMap->get(descendant) == this); | 114 ASSERT(gPositionedContainerMap->at(descendant) == this); |
| 115 gPositionedContainerMap->erase(descendant); | 115 gPositionedContainerMap->erase(descendant); |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 if (hasPercentHeightDescendants()) { | 118 if (hasPercentHeightDescendants()) { |
| 119 std::unique_ptr<TrackedLayoutBoxListHashSet> descendants = | 119 std::unique_ptr<TrackedLayoutBoxListHashSet> descendants = |
| 120 gPercentHeightDescendantsMap->take(this); | 120 gPercentHeightDescendantsMap->take(this); |
| 121 ASSERT(!descendants->isEmpty()); | 121 ASSERT(!descendants->isEmpty()); |
| 122 for (LayoutBox* descendant : *descendants) { | 122 for (LayoutBox* descendant : *descendants) { |
| 123 ASSERT(descendant->percentHeightContainer() == this); | 123 ASSERT(descendant->percentHeightContainer() == this); |
| 124 descendant->setPercentHeightContainer(nullptr); | 124 descendant->setPercentHeightContainer(nullptr); |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 } | 965 } |
| 966 | 966 |
| 967 void LayoutBlock::setSelectionState(SelectionState state) { | 967 void LayoutBlock::setSelectionState(SelectionState state) { |
| 968 LayoutBox::setSelectionState(state); | 968 LayoutBox::setSelectionState(state); |
| 969 | 969 |
| 970 if (inlineBoxWrapper() && canUpdateSelectionOnRootLineBoxes()) | 970 if (inlineBoxWrapper() && canUpdateSelectionOnRootLineBoxes()) |
| 971 inlineBoxWrapper()->root().setHasSelectedChildren(state != SelectionNone); | 971 inlineBoxWrapper()->root().setHasSelectedChildren(state != SelectionNone); |
| 972 } | 972 } |
| 973 | 973 |
| 974 TrackedLayoutBoxListHashSet* LayoutBlock::positionedObjectsInternal() const { | 974 TrackedLayoutBoxListHashSet* LayoutBlock::positionedObjectsInternal() const { |
| 975 return gPositionedDescendantsMap ? gPositionedDescendantsMap->get(this) | 975 return gPositionedDescendantsMap ? gPositionedDescendantsMap->at(this) |
| 976 : nullptr; | 976 : nullptr; |
| 977 } | 977 } |
| 978 | 978 |
| 979 void LayoutBlock::insertPositionedObject(LayoutBox* o) { | 979 void LayoutBlock::insertPositionedObject(LayoutBox* o) { |
| 980 ASSERT(!isAnonymousBlock()); | 980 ASSERT(!isAnonymousBlock()); |
| 981 ASSERT(o->containingBlock() == this); | 981 ASSERT(o->containingBlock() == this); |
| 982 | 982 |
| 983 if (gPositionedContainerMap) { | 983 if (gPositionedContainerMap) { |
| 984 auto containerMapIt = gPositionedContainerMap->find(o); | 984 auto containerMapIt = gPositionedContainerMap->find(o); |
| 985 if (containerMapIt != gPositionedContainerMap->end()) { | 985 if (containerMapIt != gPositionedContainerMap->end()) { |
| 986 if (containerMapIt->value == this) { | 986 if (containerMapIt->value == this) { |
| 987 ASSERT(hasPositionedObjects() && positionedObjects()->contains(o)); | 987 ASSERT(hasPositionedObjects() && positionedObjects()->contains(o)); |
| 988 return; | 988 return; |
| 989 } | 989 } |
| 990 removePositionedObject(o); | 990 removePositionedObject(o); |
| 991 } | 991 } |
| 992 } else { | 992 } else { |
| 993 gPositionedContainerMap = new TrackedContainerMap; | 993 gPositionedContainerMap = new TrackedContainerMap; |
| 994 } | 994 } |
| 995 gPositionedContainerMap->set(o, this); | 995 gPositionedContainerMap->set(o, this); |
| 996 | 996 |
| 997 if (!gPositionedDescendantsMap) | 997 if (!gPositionedDescendantsMap) |
| 998 gPositionedDescendantsMap = new TrackedDescendantsMap; | 998 gPositionedDescendantsMap = new TrackedDescendantsMap; |
| 999 TrackedLayoutBoxListHashSet* descendantSet = | 999 TrackedLayoutBoxListHashSet* descendantSet = |
| 1000 gPositionedDescendantsMap->get(this); | 1000 gPositionedDescendantsMap->at(this); |
| 1001 if (!descendantSet) { | 1001 if (!descendantSet) { |
| 1002 descendantSet = new TrackedLayoutBoxListHashSet; | 1002 descendantSet = new TrackedLayoutBoxListHashSet; |
| 1003 gPositionedDescendantsMap->set(this, WTF::wrapUnique(descendantSet)); | 1003 gPositionedDescendantsMap->set(this, WTF::wrapUnique(descendantSet)); |
| 1004 } | 1004 } |
| 1005 descendantSet->add(o); | 1005 descendantSet->add(o); |
| 1006 | 1006 |
| 1007 m_hasPositionedObjects = true; | 1007 m_hasPositionedObjects = true; |
| 1008 } | 1008 } |
| 1009 | 1009 |
| 1010 void LayoutBlock::removePositionedObject(LayoutBox* o) { | 1010 void LayoutBlock::removePositionedObject(LayoutBox* o) { |
| 1011 if (!gPositionedContainerMap) | 1011 if (!gPositionedContainerMap) |
| 1012 return; | 1012 return; |
| 1013 | 1013 |
| 1014 LayoutBlock* container = gPositionedContainerMap->take(o); | 1014 LayoutBlock* container = gPositionedContainerMap->take(o); |
| 1015 if (!container) | 1015 if (!container) |
| 1016 return; | 1016 return; |
| 1017 | 1017 |
| 1018 TrackedLayoutBoxListHashSet* positionedDescendants = | 1018 TrackedLayoutBoxListHashSet* positionedDescendants = |
| 1019 gPositionedDescendantsMap->get(container); | 1019 gPositionedDescendantsMap->at(container); |
| 1020 ASSERT(positionedDescendants && positionedDescendants->contains(o)); | 1020 ASSERT(positionedDescendants && positionedDescendants->contains(o)); |
| 1021 positionedDescendants->remove(o); | 1021 positionedDescendants->remove(o); |
| 1022 if (positionedDescendants->isEmpty()) { | 1022 if (positionedDescendants->isEmpty()) { |
| 1023 gPositionedDescendantsMap->erase(container); | 1023 gPositionedDescendantsMap->erase(container); |
| 1024 container->m_hasPositionedObjects = false; | 1024 container->m_hasPositionedObjects = false; |
| 1025 } | 1025 } |
| 1026 } | 1026 } |
| 1027 | 1027 |
| 1028 PaintInvalidationReason LayoutBlock::invalidatePaintIfNeeded( | 1028 PaintInvalidationReason LayoutBlock::invalidatePaintIfNeeded( |
| 1029 const PaintInvalidationState& paintInvalidationState) { | 1029 const PaintInvalidationState& paintInvalidationState) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1076 while (p && !p->isLayoutBlock()) | 1076 while (p && !p->isLayoutBlock()) |
| 1077 p = p->parent(); | 1077 p = p->parent(); |
| 1078 if (p) | 1078 if (p) |
| 1079 p->setChildNeedsLayout(); | 1079 p->setChildNeedsLayout(); |
| 1080 | 1080 |
| 1081 deadObjects.push_back(positionedObject); | 1081 deadObjects.push_back(positionedObject); |
| 1082 } | 1082 } |
| 1083 } | 1083 } |
| 1084 | 1084 |
| 1085 for (auto object : deadObjects) { | 1085 for (auto object : deadObjects) { |
| 1086 ASSERT(gPositionedContainerMap->get(object) == this); | 1086 ASSERT(gPositionedContainerMap->at(object) == this); |
| 1087 positionedDescendants->remove(object); | 1087 positionedDescendants->remove(object); |
| 1088 gPositionedContainerMap->erase(object); | 1088 gPositionedContainerMap->erase(object); |
| 1089 } | 1089 } |
| 1090 if (positionedDescendants->isEmpty()) { | 1090 if (positionedDescendants->isEmpty()) { |
| 1091 gPositionedDescendantsMap->erase(this); | 1091 gPositionedDescendantsMap->erase(this); |
| 1092 m_hasPositionedObjects = false; | 1092 m_hasPositionedObjects = false; |
| 1093 } | 1093 } |
| 1094 } | 1094 } |
| 1095 | 1095 |
| 1096 void LayoutBlock::addPercentHeightDescendant(LayoutBox* descendant) { | 1096 void LayoutBlock::addPercentHeightDescendant(LayoutBox* descendant) { |
| 1097 if (descendant->percentHeightContainer()) { | 1097 if (descendant->percentHeightContainer()) { |
| 1098 if (descendant->percentHeightContainer() == this) { | 1098 if (descendant->percentHeightContainer() == this) { |
| 1099 ASSERT(hasPercentHeightDescendant(descendant)); | 1099 ASSERT(hasPercentHeightDescendant(descendant)); |
| 1100 return; | 1100 return; |
| 1101 } | 1101 } |
| 1102 descendant->removeFromPercentHeightContainer(); | 1102 descendant->removeFromPercentHeightContainer(); |
| 1103 } | 1103 } |
| 1104 descendant->setPercentHeightContainer(this); | 1104 descendant->setPercentHeightContainer(this); |
| 1105 | 1105 |
| 1106 if (!gPercentHeightDescendantsMap) | 1106 if (!gPercentHeightDescendantsMap) |
| 1107 gPercentHeightDescendantsMap = new TrackedDescendantsMap; | 1107 gPercentHeightDescendantsMap = new TrackedDescendantsMap; |
| 1108 TrackedLayoutBoxListHashSet* descendantSet = | 1108 TrackedLayoutBoxListHashSet* descendantSet = |
| 1109 gPercentHeightDescendantsMap->get(this); | 1109 gPercentHeightDescendantsMap->at(this); |
| 1110 if (!descendantSet) { | 1110 if (!descendantSet) { |
| 1111 descendantSet = new TrackedLayoutBoxListHashSet; | 1111 descendantSet = new TrackedLayoutBoxListHashSet; |
| 1112 gPercentHeightDescendantsMap->set(this, WTF::wrapUnique(descendantSet)); | 1112 gPercentHeightDescendantsMap->set(this, WTF::wrapUnique(descendantSet)); |
| 1113 } | 1113 } |
| 1114 descendantSet->add(descendant); | 1114 descendantSet->add(descendant); |
| 1115 | 1115 |
| 1116 m_hasPercentHeightDescendants = true; | 1116 m_hasPercentHeightDescendants = true; |
| 1117 } | 1117 } |
| 1118 | 1118 |
| 1119 void LayoutBlock::removePercentHeightDescendant(LayoutBox* descendant) { | 1119 void LayoutBlock::removePercentHeightDescendant(LayoutBox* descendant) { |
| 1120 if (TrackedLayoutBoxListHashSet* descendants = percentHeightDescendants()) { | 1120 if (TrackedLayoutBoxListHashSet* descendants = percentHeightDescendants()) { |
| 1121 descendants->remove(descendant); | 1121 descendants->remove(descendant); |
| 1122 descendant->setPercentHeightContainer(nullptr); | 1122 descendant->setPercentHeightContainer(nullptr); |
| 1123 if (descendants->isEmpty()) { | 1123 if (descendants->isEmpty()) { |
| 1124 gPercentHeightDescendantsMap->erase(this); | 1124 gPercentHeightDescendantsMap->erase(this); |
| 1125 m_hasPercentHeightDescendants = false; | 1125 m_hasPercentHeightDescendants = false; |
| 1126 } | 1126 } |
| 1127 } | 1127 } |
| 1128 } | 1128 } |
| 1129 | 1129 |
| 1130 TrackedLayoutBoxListHashSet* LayoutBlock::percentHeightDescendantsInternal() | 1130 TrackedLayoutBoxListHashSet* LayoutBlock::percentHeightDescendantsInternal() |
| 1131 const { | 1131 const { |
| 1132 return gPercentHeightDescendantsMap ? gPercentHeightDescendantsMap->get(this) | 1132 return gPercentHeightDescendantsMap ? gPercentHeightDescendantsMap->at(this) |
| 1133 : nullptr; | 1133 : nullptr; |
| 1134 } | 1134 } |
| 1135 | 1135 |
| 1136 void LayoutBlock::dirtyForLayoutFromPercentageHeightDescendants( | 1136 void LayoutBlock::dirtyForLayoutFromPercentageHeightDescendants( |
| 1137 SubtreeLayoutScope& layoutScope) { | 1137 SubtreeLayoutScope& layoutScope) { |
| 1138 TrackedLayoutBoxListHashSet* descendants = percentHeightDescendants(); | 1138 TrackedLayoutBoxListHashSet* descendants = percentHeightDescendants(); |
| 1139 if (!descendants) | 1139 if (!descendants) |
| 1140 return; | 1140 return; |
| 1141 | 1141 |
| 1142 for (auto* box : *descendants) { | 1142 for (auto* box : *descendants) { |
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2215 } | 2215 } |
| 2216 | 2216 |
| 2217 return availableHeight; | 2217 return availableHeight; |
| 2218 } | 2218 } |
| 2219 | 2219 |
| 2220 bool LayoutBlock::hasDefiniteLogicalHeight() const { | 2220 bool LayoutBlock::hasDefiniteLogicalHeight() const { |
| 2221 return availableLogicalHeightForPercentageComputation() != LayoutUnit(-1); | 2221 return availableLogicalHeightForPercentageComputation() != LayoutUnit(-1); |
| 2222 } | 2222 } |
| 2223 | 2223 |
| 2224 } // namespace blink | 2224 } // namespace blink |
| OLD | NEW |