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

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

Issue 2552013002: Do not remove floating legend from inner block as it gets destroyed somewhere else. (Closed)
Patch Set: Created 4 years 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 | « no previous file | no next file » | 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) 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 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. 5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // Let anonymous block to be the 1st for correct layout positioning. 253 // Let anonymous block to be the 1st for correct layout positioning.
254 childStyle.setOrder(1); 254 childStyle.setOrder(1);
255 } 255 }
256 256
257 void LayoutFieldset::addChild(LayoutObject* newChild, 257 void LayoutFieldset::addChild(LayoutObject* newChild,
258 LayoutObject* beforeChild) { 258 LayoutObject* beforeChild) {
259 if (!m_innerBlock) 259 if (!m_innerBlock)
260 createInnerBlock(); 260 createInnerBlock();
261 261
262 if (isHTMLLegendElement(newChild->node())) { 262 if (isHTMLLegendElement(newChild->node())) {
263 // Let legend block to be the 2nd for correct layout positioning. 263 // Flexbox forces the floating legend to be non-floating => add the floating
264 newChild->mutableStyle()->setOrder(2); 264 // legend to the inner block.
265
266 // LayoutFlexibleBox::addChild will create an anonymous block if legend is
267 // float. Use the existing fieldset's anonymous block here instead.
268 if (newChild->isFloatingOrOutOfFlowPositioned()) { 265 if (newChild->isFloatingOrOutOfFlowPositioned()) {
269 m_innerBlock->addChild(newChild); 266 // Always add the legend first, i.e. before m_innerBlock->firstChild()
267 m_innerBlock->addChild(newChild, m_innerBlock->firstChild());
270 } else { 268 } else {
269 // Let legend block to be the 2nd for correct layout positioning.
270 newChild->mutableStyle()->setOrder(2);
271 LayoutFlexibleBox::addChild(newChild, m_innerBlock); 271 LayoutFlexibleBox::addChild(newChild, m_innerBlock);
272 } 272 }
273
274 } else { 273 } else {
275 if (beforeChild && isHTMLLegendElement(beforeChild->node())) { 274 if (beforeChild && isHTMLLegendElement(beforeChild->node())) {
276 m_innerBlock->addChild(newChild); 275 m_innerBlock->addChild(newChild);
277 } else { 276 } else {
278 m_innerBlock->addChild(newChild, beforeChild); 277 m_innerBlock->addChild(newChild, beforeChild);
279 } 278 }
280 if (AXObjectCache* cache = document().existingAXObjectCache()) 279 if (AXObjectCache* cache = document().existingAXObjectCache())
281 cache->childrenChanged(this); 280 cache->childrenChanged(this);
282 } 281 }
283 } 282 }
284 283
285 void LayoutFieldset::createInnerBlock() { 284 void LayoutFieldset::createInnerBlock() {
286 if (m_innerBlock) { 285 if (m_innerBlock) {
287 DCHECK(firstChild() == m_innerBlock); 286 DCHECK(firstChild() == m_innerBlock);
288 return; 287 return;
289 } 288 }
290 m_innerBlock = createAnonymousBlock(style()->display()); 289 m_innerBlock = createAnonymousBlock(style()->display());
291 LayoutFlexibleBox::addChild(m_innerBlock); 290 LayoutFlexibleBox::addChild(m_innerBlock);
292 } 291 }
293 292
294 void LayoutFieldset::removeChild(LayoutObject* oldChild) { 293 void LayoutFieldset::removeChild(LayoutObject* oldChild) {
295 if (isHTMLLegendElement(oldChild->node())) { 294 // Out flow positioned elements are wrapped into an anonymous
cbiesinger 2016/12/05 21:41:26 Out flow -> Out of flow
Gleb Lanbin 2016/12/06 00:03:28 Done.
296 if (oldChild->isFloatingOrOutOfFlowPositioned()) { 295 // block(see LayoutBlock::addChild) and then gets destroyed in
297 m_innerBlock->removeChild(oldChild); 296 // LayoutObject::destroyAndCleanupAnonymousWrappers.
298 } else { 297 if (isHTMLLegendElement(oldChild->node()) &&
299 LayoutFlexibleBox::removeChild(oldChild); 298 !oldChild->isFloatingOrOutOfFlowPositioned()) {
300 if (m_innerBlock) { 299 LayoutFlexibleBox::removeChild(oldChild);
301 resetInnerBlockPadding(isHorizontalWritingMode(), m_innerBlock); 300 if (m_innerBlock) {
302 m_innerBlock->setNeedsLayout(LayoutInvalidationReason::FieldsetChanged, 301 resetInnerBlockPadding(isHorizontalWritingMode(), m_innerBlock);
303 MarkOnlyThis); 302 m_innerBlock->setNeedsLayout(LayoutInvalidationReason::FieldsetChanged,
304 } 303 MarkOnlyThis);
305 } 304 }
306
307 setShouldDoFullPaintInvalidation(); 305 setShouldDoFullPaintInvalidation();
308 } else if (oldChild == m_innerBlock) { 306 } else if (oldChild == m_innerBlock) {
309 LayoutFlexibleBox::removeChild(oldChild); 307 LayoutFlexibleBox::removeChild(oldChild);
310 m_innerBlock = nullptr; 308 m_innerBlock = nullptr;
311 } else if (oldChild->parent() == this) { 309 } else if (oldChild->parent() == this) {
312 LayoutFlexibleBox::removeChild(oldChild); 310 LayoutFlexibleBox::removeChild(oldChild);
313 } else if (m_innerBlock) { 311 } else if (m_innerBlock) {
314 m_innerBlock->removeChild(oldChild); 312 m_innerBlock->removeChild(oldChild);
315 } 313 }
316 } 314 }
317 315
318 } // namespace blink 316 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698