| OLD | NEW |
| 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 Loading... |
| 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 if (isHTMLLegendElement(oldChild->node())) { |
| 296 if (oldChild->isFloatingOrOutOfFlowPositioned()) { | 295 LayoutFlexibleBox::removeChild(oldChild); |
| 297 m_innerBlock->removeChild(oldChild); | 296 if (m_innerBlock) { |
| 298 } else { | 297 resetInnerBlockPadding(isHorizontalWritingMode(), m_innerBlock); |
| 299 LayoutFlexibleBox::removeChild(oldChild); | 298 m_innerBlock->setNeedsLayout(LayoutInvalidationReason::FieldsetChanged, |
| 300 if (m_innerBlock) { | 299 MarkOnlyThis); |
| 301 resetInnerBlockPadding(isHorizontalWritingMode(), m_innerBlock); | |
| 302 m_innerBlock->setNeedsLayout(LayoutInvalidationReason::FieldsetChanged, | |
| 303 MarkOnlyThis); | |
| 304 } | |
| 305 } | 300 } |
| 306 | |
| 307 setShouldDoFullPaintInvalidation(); | 301 setShouldDoFullPaintInvalidation(); |
| 308 } else if (oldChild == m_innerBlock) { | 302 } else if (oldChild == m_innerBlock) { |
| 309 LayoutFlexibleBox::removeChild(oldChild); | 303 LayoutFlexibleBox::removeChild(oldChild); |
| 310 m_innerBlock = nullptr; | 304 m_innerBlock = nullptr; |
| 311 } else if (oldChild->parent() == this) { | 305 } else if (oldChild->parent() == this) { |
| 312 LayoutFlexibleBox::removeChild(oldChild); | 306 LayoutFlexibleBox::removeChild(oldChild); |
| 313 } else if (m_innerBlock) { | 307 } else if (m_innerBlock) { |
| 314 m_innerBlock->removeChild(oldChild); | 308 m_innerBlock->removeChild(oldChild); |
| 315 } | 309 } |
| 316 } | 310 } |
| 317 | 311 |
| 318 } // namespace blink | 312 } // namespace blink |
| OLD | NEW |