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

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

Issue 2851513004: Ensure cell's replaced content doesn't get the wrong width (Closed)
Patch Set: bug 666730 Created 3 years, 7 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) 1997 Martin Jones (mjones@kde.org) 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org)
3 * (C) 1997 Torben Weis (weis@kde.org) 3 * (C) 1997 Torben Weis (weis@kde.org)
4 * (C) 1998 Waldo Bastian (bastian@kde.org) 4 * (C) 1998 Waldo Bastian (bastian@kde.org)
5 * (C) 1999 Lars Knoll (knoll@kde.org) 5 * (C) 1999 Lars Knoll (knoll@kde.org)
6 * (C) 1999 Antti Koivisto (koivisto@kde.org) 6 * (C) 1999 Antti Koivisto (koivisto@kde.org)
7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc.
8 * All rights reserved. 8 * All rights reserved.
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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 199 }
200 200
201 void LayoutTableCell::ComputePreferredLogicalWidths() { 201 void LayoutTableCell::ComputePreferredLogicalWidths() {
202 // The child cells rely on the grids up in the sections to do their 202 // The child cells rely on the grids up in the sections to do their
203 // computePreferredLogicalWidths work. Normally the sections are set up 203 // computePreferredLogicalWidths work. Normally the sections are set up
204 // early, as table cells are added, but relayout can cause the cells to be 204 // early, as table cells are added, but relayout can cause the cells to be
205 // freed, leaving stale pointers in the sections' grids. We must refresh those 205 // freed, leaving stale pointers in the sections' grids. We must refresh those
206 // grids before the child cells try to use them. 206 // grids before the child cells try to use them.
207 Table()->RecalcSectionsIfNeeded(); 207 Table()->RecalcSectionsIfNeeded();
208 208
209 // We don't want the preferred width from children to be affected by any
mstensho (USE GERRIT) 2017/05/12 11:44:07 Agreed. No preferred width calculation code should
rhogan 2017/05/12 19:12:23 Here you go: diff --git a/third_party/WebKit/Sour
mstensho (USE GERRIT) 2017/05/15 06:50:09 Here's the problem. Calculating preferred/intrinsi
210 // notional height on the cell, such as can happen when a percent sized image
211 // scales up its width to match the available height. Setting a zero override
212 // height prevents this from happening.
213 LayoutUnit content_height = HasOverrideLogicalContentHeight()
214 ? OverrideLogicalContentHeight()
215 : LayoutUnit(-1);
216 SetOverrideLogicalContentHeight(LayoutUnit());
mstensho (USE GERRIT) 2017/05/16 07:57:54 You wrote:
217
rhogan 2017/05/01 16:12:38 OK I know this is ugly, but I think what makes cel
mstensho (USE GERRIT) 2017/05/12 11:44:07 Yeah, if we really need a special height override
209 LayoutBlockFlow::ComputePreferredLogicalWidths(); 218 LayoutBlockFlow::ComputePreferredLogicalWidths();
219
220 if (content_height > -1)
221 SetOverrideLogicalContentHeight(content_height);
222 else
223 ClearOverrideLogicalContentHeight();
mstensho (USE GERRIT) 2017/05/16 07:57:54 And if it's possible to clear it above, you won't
224
210 if (GetNode() && Style()->AutoWrap()) { 225 if (GetNode() && Style()->AutoWrap()) {
211 // See if nowrap was set. 226 // See if nowrap was set.
212 Length w = StyleOrColLogicalWidth(); 227 Length w = StyleOrColLogicalWidth();
213 const AtomicString& nowrap = ToElement(GetNode())->getAttribute(nowrapAttr); 228 const AtomicString& nowrap = ToElement(GetNode())->getAttribute(nowrapAttr);
214 if (!nowrap.IsNull() && w.IsFixed()) { 229 if (!nowrap.IsNull() && w.IsFixed()) {
215 // Nowrap is set, but we didn't actually use it because of the fixed width 230 // Nowrap is set, but we didn't actually use it because of the fixed width
216 // set on the cell. Even so, it is a WinIE/Moz trait to make the minwidth 231 // set on the cell. Even so, it is a WinIE/Moz trait to make the minwidth
217 // of the cell into the fixed width. They do this even in strict mode, so 232 // of the cell into the fixed width. They do this even in strict mode, so
218 // do not make this a quirk. Affected the top of hiptop.com. 233 // do not make this a quirk. Affected the top of hiptop.com.
219 min_preferred_logical_width_ = 234 min_preferred_logical_width_ =
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 } 1500 }
1486 1501
1487 bool LayoutTableCell::HasLineIfEmpty() const { 1502 bool LayoutTableCell::HasLineIfEmpty() const {
1488 if (GetNode() && HasEditableStyle(*GetNode())) 1503 if (GetNode() && HasEditableStyle(*GetNode()))
1489 return true; 1504 return true;
1490 1505
1491 return LayoutBlock::HasLineIfEmpty(); 1506 return LayoutBlock::HasLineIfEmpty();
1492 } 1507 }
1493 1508
1494 } // namespace blink 1509 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698