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

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

Issue 2554813004: Revert "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 // Flexbox forces the floating legend to be non-floating => add the floating 263 // Let legend block to be the 2nd for correct layout positioning.
264 // legend to the inner block. 264 newChild->mutableStyle()->setOrder(2);
265
266 // LayoutFlexibleBox::addChild will create an anonymous block if legend is
267 // float. Use the existing fieldset's anonymous block here instead.
265 if (newChild->isFloatingOrOutOfFlowPositioned()) { 268 if (newChild->isFloatingOrOutOfFlowPositioned()) {
266 // Always add the legend first, i.e. before m_innerBlock->firstChild() 269 m_innerBlock->addChild(newChild);
267 m_innerBlock->addChild(newChild, m_innerBlock->firstChild());
268 } else { 270 } 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
273 } else { 274 } else {
274 if (beforeChild && isHTMLLegendElement(beforeChild->node())) { 275 if (beforeChild && isHTMLLegendElement(beforeChild->node())) {
275 m_innerBlock->addChild(newChild); 276 m_innerBlock->addChild(newChild);
276 } else { 277 } else {
277 m_innerBlock->addChild(newChild, beforeChild); 278 m_innerBlock->addChild(newChild, beforeChild);
278 } 279 }
279 if (AXObjectCache* cache = document().existingAXObjectCache()) 280 if (AXObjectCache* cache = document().existingAXObjectCache())
280 cache->childrenChanged(this); 281 cache->childrenChanged(this);
281 } 282 }
282 } 283 }
283 284
284 void LayoutFieldset::createInnerBlock() { 285 void LayoutFieldset::createInnerBlock() {
285 if (m_innerBlock) { 286 if (m_innerBlock) {
286 DCHECK(firstChild() == m_innerBlock); 287 DCHECK(firstChild() == m_innerBlock);
287 return; 288 return;
288 } 289 }
289 m_innerBlock = createAnonymousBlock(style()->display()); 290 m_innerBlock = createAnonymousBlock(style()->display());
290 LayoutFlexibleBox::addChild(m_innerBlock); 291 LayoutFlexibleBox::addChild(m_innerBlock);
291 } 292 }
292 293
293 void LayoutFieldset::removeChild(LayoutObject* oldChild) { 294 void LayoutFieldset::removeChild(LayoutObject* oldChild) {
294 if (isHTMLLegendElement(oldChild->node())) { 295 if (isHTMLLegendElement(oldChild->node())) {
295 LayoutFlexibleBox::removeChild(oldChild); 296 if (oldChild->isFloatingOrOutOfFlowPositioned()) {
296 if (m_innerBlock) { 297 m_innerBlock->removeChild(oldChild);
297 resetInnerBlockPadding(isHorizontalWritingMode(), m_innerBlock); 298 } else {
298 m_innerBlock->setNeedsLayout(LayoutInvalidationReason::FieldsetChanged, 299 LayoutFlexibleBox::removeChild(oldChild);
299 MarkOnlyThis); 300 if (m_innerBlock) {
301 resetInnerBlockPadding(isHorizontalWritingMode(), m_innerBlock);
302 m_innerBlock->setNeedsLayout(LayoutInvalidationReason::FieldsetChanged,
303 MarkOnlyThis);
304 }
300 } 305 }
306
301 setShouldDoFullPaintInvalidation(); 307 setShouldDoFullPaintInvalidation();
302 } else if (oldChild == m_innerBlock) { 308 } else if (oldChild == m_innerBlock) {
303 LayoutFlexibleBox::removeChild(oldChild); 309 LayoutFlexibleBox::removeChild(oldChild);
304 m_innerBlock = nullptr; 310 m_innerBlock = nullptr;
305 } else if (oldChild->parent() == this) { 311 } else if (oldChild->parent() == this) {
306 LayoutFlexibleBox::removeChild(oldChild); 312 LayoutFlexibleBox::removeChild(oldChild);
307 } else if (m_innerBlock) { 313 } else if (m_innerBlock) {
308 m_innerBlock->removeChild(oldChild); 314 m_innerBlock->removeChild(oldChild);
309 } 315 }
310 } 316 }
311 317
312 } // namespace blink 318 } // 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