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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 2262973002: Switch override containing block sizes to use LayoutRareData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
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) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 #include "platform/geometry/FloatRoundedRect.h" 64 #include "platform/geometry/FloatRoundedRect.h"
65 #include "wtf/PtrUtil.h" 65 #include "wtf/PtrUtil.h"
66 #include <algorithm> 66 #include <algorithm>
67 #include <math.h> 67 #include <math.h>
68 68
69 namespace blink { 69 namespace blink {
70 70
71 // Used by flexible boxes when flexing this element and by table cells. 71 // Used by flexible boxes when flexing this element and by table cells.
72 typedef WTF::HashMap<const LayoutBox*, LayoutUnit> OverrideSizeMap; 72 typedef WTF::HashMap<const LayoutBox*, LayoutUnit> OverrideSizeMap;
73 73
74 // Used by grid elements to properly size their grid items.
75 // FIXME: Move these into LayoutBoxRareData.
76 static OverrideSizeMap* gOverrideContainingBlockLogicalHeightMap = nullptr;
77 static OverrideSizeMap* gOverrideContainingBlockLogicalWidthMap = nullptr;
78 static OverrideSizeMap* gExtraInlineOffsetMap = nullptr; 74 static OverrideSizeMap* gExtraInlineOffsetMap = nullptr;
79 static OverrideSizeMap* gExtraBlockOffsetMap = nullptr; 75 static OverrideSizeMap* gExtraBlockOffsetMap = nullptr;
80 76
81 77
82 // Size of border belt for autoscroll. When mouse pointer in border belt, 78 // Size of border belt for autoscroll. When mouse pointer in border belt,
83 // autoscroll is started. 79 // autoscroll is started.
84 static const int autoscrollBeltSize = 20; 80 static const int autoscrollBeltSize = 20;
85 static const unsigned backgroundObscurationTestMaxDepth = 4; 81 static const unsigned backgroundObscurationTestMaxDepth = 4;
86 82
87 struct SameSizeAsLayoutBox : public LayoutBoxModelObject { 83 struct SameSizeAsLayoutBox : public LayoutBoxModelObject {
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 1128
1133 LayoutUnit LayoutBox::overrideLogicalContentHeight() const 1129 LayoutUnit LayoutBox::overrideLogicalContentHeight() const
1134 { 1130 {
1135 ASSERT(hasOverrideLogicalContentHeight()); 1131 ASSERT(hasOverrideLogicalContentHeight());
1136 return m_rareData->m_overrideLogicalContentHeight; 1132 return m_rareData->m_overrideLogicalContentHeight;
1137 } 1133 }
1138 1134
1139 // TODO (lajava) Now that we have implemented these functions based on physical direction, we'd rather remove the logical ones. 1135 // TODO (lajava) Now that we have implemented these functions based on physical direction, we'd rather remove the logical ones.
1140 LayoutUnit LayoutBox::overrideContainingBlockContentLogicalWidth() const 1136 LayoutUnit LayoutBox::overrideContainingBlockContentLogicalWidth() const
1141 { 1137 {
1142 ASSERT(hasOverrideContainingBlockLogicalWidth()); 1138 DCHECK(hasOverrideContainingBlockLogicalWidth());
1143 return gOverrideContainingBlockLogicalWidthMap->get(this); 1139 return m_rareData->m_overrideContainingBlockContentLogicalWidth;
1144 } 1140 }
1145 1141
1146 // TODO (lajava) Shouldn't we implement these functions based on physical direct ion ?. 1142 // TODO (lajava) Shouldn't we implement these functions based on physical direct ion ?.
1147 LayoutUnit LayoutBox::overrideContainingBlockContentLogicalHeight() const 1143 LayoutUnit LayoutBox::overrideContainingBlockContentLogicalHeight() const
1148 { 1144 {
1149 ASSERT(hasOverrideContainingBlockLogicalHeight()); 1145 DCHECK(hasOverrideContainingBlockLogicalHeight());
1150 return gOverrideContainingBlockLogicalHeightMap->get(this); 1146 return m_rareData->m_overrideContainingBlockContentLogicalHeight;
1151 } 1147 }
1152 1148
1153 // TODO (lajava) Shouldn't we implement these functions based on physical direct ion ?. 1149 // TODO (lajava) Shouldn't we implement these functions based on physical direct ion ?.
1154 bool LayoutBox::hasOverrideContainingBlockLogicalWidth() const 1150 bool LayoutBox::hasOverrideContainingBlockLogicalWidth() const
1155 { 1151 {
1156 return gOverrideContainingBlockLogicalWidthMap && gOverrideContainingBlockLo gicalWidthMap->contains(this); 1152 return m_rareData && m_rareData->m_overrideContainingBlockContentLogicalWidt h != LayoutUnit(-2);
1157 } 1153 }
1158 1154
1159 // TODO (lajava) Shouldn't we implement these functions based on physical direct ion ?. 1155 // TODO (lajava) Shouldn't we implement these functions based on physical direct ion ?.
1160 bool LayoutBox::hasOverrideContainingBlockLogicalHeight() const 1156 bool LayoutBox::hasOverrideContainingBlockLogicalHeight() const
1161 { 1157 {
1162 return gOverrideContainingBlockLogicalHeightMap && gOverrideContainingBlockL ogicalHeightMap->contains(this); 1158 return m_rareData && m_rareData->m_overrideContainingBlockContentLogicalHeig ht != LayoutUnit(-2);
jfernandez 2016/08/22 14:56:03 thinking about this ... is this "-2" value intende
1163 } 1159 }
1164 1160
1165 // TODO (lajava) Shouldn't we implement these functions based on physical direct ion ?. 1161 // TODO (lajava) Shouldn't we implement these functions based on physical direct ion ?.
1166 void LayoutBox::setOverrideContainingBlockContentLogicalWidth(LayoutUnit logical Width) 1162 void LayoutBox::setOverrideContainingBlockContentLogicalWidth(LayoutUnit logical Width)
1167 { 1163 {
1168 if (!gOverrideContainingBlockLogicalWidthMap) 1164 DCHECK_NE(logicalWidth, LayoutUnit(-2));
1169 gOverrideContainingBlockLogicalWidthMap = new OverrideSizeMap; 1165 ensureRareData().m_overrideContainingBlockContentLogicalWidth = logicalWidth ;
1170 gOverrideContainingBlockLogicalWidthMap->set(this, logicalWidth);
1171 } 1166 }
1172 1167
1173 // TODO (lajava) Shouldn't we implement these functions based on physical direct ion ?. 1168 // TODO (lajava) Shouldn't we implement these functions based on physical direct ion ?.
1174 void LayoutBox::setOverrideContainingBlockContentLogicalHeight(LayoutUnit logica lHeight) 1169 void LayoutBox::setOverrideContainingBlockContentLogicalHeight(LayoutUnit logica lHeight)
1175 { 1170 {
1176 if (!gOverrideContainingBlockLogicalHeightMap) 1171 DCHECK_NE(logicalHeight, LayoutUnit(-2));
1177 gOverrideContainingBlockLogicalHeightMap = new OverrideSizeMap; 1172 ensureRareData().m_overrideContainingBlockContentLogicalHeight = logicalHeig ht;
1178 gOverrideContainingBlockLogicalHeightMap->set(this, logicalHeight);
1179 } 1173 }
1180 1174
1181 // TODO (lajava) Shouldn't we implement these functions based on physical direct ion ?. 1175 // TODO (lajava) Shouldn't we implement these functions based on physical direct ion ?.
1182 void LayoutBox::clearContainingBlockOverrideSize() 1176 void LayoutBox::clearContainingBlockOverrideSize()
1183 { 1177 {
1184 if (gOverrideContainingBlockLogicalWidthMap) 1178 ensureRareData().m_overrideContainingBlockContentLogicalWidth = LayoutUnit(- 2);
1185 gOverrideContainingBlockLogicalWidthMap->remove(this); 1179 ensureRareData().m_overrideContainingBlockContentLogicalHeight = LayoutUnit( -2);
1186 clearOverrideContainingBlockContentLogicalHeight();
1187 } 1180 }
1188 1181
1189 // TODO (lajava) Shouldn't we implement these functions based on physical direct ion ?. 1182 // TODO (lajava) Shouldn't we implement these functions based on physical direct ion ?.
1190 void LayoutBox::clearOverrideContainingBlockContentLogicalHeight() 1183 void LayoutBox::clearOverrideContainingBlockContentLogicalHeight()
1191 { 1184 {
1192 if (gOverrideContainingBlockLogicalHeightMap) 1185 ensureRareData().m_overrideContainingBlockContentLogicalHeight = LayoutUnit( -2);
1193 gOverrideContainingBlockLogicalHeightMap->remove(this);
1194 } 1186 }
1195 1187
1196 LayoutUnit LayoutBox::extraInlineOffset() const 1188 LayoutUnit LayoutBox::extraInlineOffset() const
1197 { 1189 {
1198 return gExtraInlineOffsetMap ? gExtraInlineOffsetMap->get(this) : LayoutUnit (); 1190 return gExtraInlineOffsetMap ? gExtraInlineOffsetMap->get(this) : LayoutUnit ();
1199 } 1191 }
1200 1192
1201 LayoutUnit LayoutBox::extraBlockOffset() const 1193 LayoutUnit LayoutBox::extraBlockOffset() const
1202 { 1194 {
1203 return gExtraBlockOffsetMap ? gExtraBlockOffsetMap->get(this) : LayoutUnit() ; 1195 return gExtraBlockOffsetMap ? gExtraBlockOffsetMap->get(this) : LayoutUnit() ;
(...skipping 3627 matching lines...) Expand 10 before | Expand all | Expand 10 after
4831 m_rareData->m_snapAreas->remove(&snapArea); 4823 m_rareData->m_snapAreas->remove(&snapArea);
4832 } 4824 }
4833 } 4825 }
4834 4826
4835 SnapAreaSet* LayoutBox::snapAreas() const 4827 SnapAreaSet* LayoutBox::snapAreas() const
4836 { 4828 {
4837 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; 4829 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr;
4838 } 4830 }
4839 4831
4840 } // namespace blink 4832 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698