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

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

Issue 2552373002: Revert "Floating legend should be added to the fieldset's anonymous block." (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 | « third_party/WebKit/LayoutTests/fast/forms/fieldset/fieldset-legend-float-expected.html ('k') | 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Let legend block to be the 2nd for correct layout positioning.
264 newChild->mutableStyle()->setOrder(2); 264 newChild->mutableStyle()->setOrder(2);
265 265 LayoutFlexibleBox::addChild(newChild, m_innerBlock);
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()) {
269 m_innerBlock->addChild(newChild);
270 } else {
271 LayoutFlexibleBox::addChild(newChild, m_innerBlock);
272 }
273
274 } else { 266 } else {
275 if (beforeChild && isHTMLLegendElement(beforeChild->node())) { 267 if (beforeChild && isHTMLLegendElement(beforeChild->node())) {
276 m_innerBlock->addChild(newChild); 268 m_innerBlock->addChild(newChild);
277 } else { 269 } else {
278 m_innerBlock->addChild(newChild, beforeChild); 270 m_innerBlock->addChild(newChild, beforeChild);
279 } 271 }
280 if (AXObjectCache* cache = document().existingAXObjectCache()) 272 if (AXObjectCache* cache = document().existingAXObjectCache())
281 cache->childrenChanged(this); 273 cache->childrenChanged(this);
282 } 274 }
283 } 275 }
284 276
285 void LayoutFieldset::createInnerBlock() { 277 void LayoutFieldset::createInnerBlock() {
286 if (m_innerBlock) { 278 if (m_innerBlock) {
287 DCHECK(firstChild() == m_innerBlock); 279 DCHECK(firstChild() == m_innerBlock);
288 return; 280 return;
289 } 281 }
290 m_innerBlock = createAnonymousBlock(style()->display()); 282 m_innerBlock = createAnonymousBlock(style()->display());
291 LayoutFlexibleBox::addChild(m_innerBlock); 283 LayoutFlexibleBox::addChild(m_innerBlock);
292 } 284 }
293 285
294 void LayoutFieldset::removeChild(LayoutObject* oldChild) { 286 void LayoutFieldset::removeChild(LayoutObject* oldChild) {
295 if (isHTMLLegendElement(oldChild->node())) { 287 if (isHTMLLegendElement(oldChild->node())) {
296 if (oldChild->isFloatingOrOutOfFlowPositioned()) { 288 LayoutFlexibleBox::removeChild(oldChild);
297 m_innerBlock->removeChild(oldChild); 289 if (m_innerBlock) {
298 } else { 290 resetInnerBlockPadding(isHorizontalWritingMode(), m_innerBlock);
299 LayoutFlexibleBox::removeChild(oldChild); 291 m_innerBlock->setNeedsLayout(LayoutInvalidationReason::FieldsetChanged,
300 if (m_innerBlock) { 292 MarkOnlyThis);
301 resetInnerBlockPadding(isHorizontalWritingMode(), m_innerBlock);
302 m_innerBlock->setNeedsLayout(LayoutInvalidationReason::FieldsetChanged,
303 MarkOnlyThis);
304 }
305 } 293 }
306
307 setShouldDoFullPaintInvalidation(); 294 setShouldDoFullPaintInvalidation();
308 } else if (oldChild == m_innerBlock) { 295 } else if (oldChild == m_innerBlock) {
309 LayoutFlexibleBox::removeChild(oldChild); 296 LayoutFlexibleBox::removeChild(oldChild);
310 m_innerBlock = nullptr; 297 m_innerBlock = nullptr;
311 } else if (oldChild->parent() == this) { 298 } else if (oldChild->parent() == this) {
312 LayoutFlexibleBox::removeChild(oldChild); 299 LayoutFlexibleBox::removeChild(oldChild);
313 } else if (m_innerBlock) { 300 } else if (m_innerBlock) {
314 m_innerBlock->removeChild(oldChild); 301 m_innerBlock->removeChild(oldChild);
315 } 302 }
316 } 303 }
317 304
318 } // namespace blink 305 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/forms/fieldset/fieldset-legend-float-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698