| 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 LayoutFlexibleBox::addChild(newChild, m_innerBlock); | 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()) { |
| 269 m_innerBlock->addChild(newChild); |
| 270 } else { |
| 271 LayoutFlexibleBox::addChild(newChild, m_innerBlock); |
| 272 } |
| 273 |
| 266 } else { | 274 } else { |
| 267 if (beforeChild && isHTMLLegendElement(beforeChild->node())) { | 275 if (beforeChild && isHTMLLegendElement(beforeChild->node())) { |
| 268 m_innerBlock->addChild(newChild); | 276 m_innerBlock->addChild(newChild); |
| 269 } else { | 277 } else { |
| 270 m_innerBlock->addChild(newChild, beforeChild); | 278 m_innerBlock->addChild(newChild, beforeChild); |
| 271 } | 279 } |
| 272 if (AXObjectCache* cache = document().existingAXObjectCache()) | 280 if (AXObjectCache* cache = document().existingAXObjectCache()) |
| 273 cache->childrenChanged(this); | 281 cache->childrenChanged(this); |
| 274 } | 282 } |
| 275 } | 283 } |
| 276 | 284 |
| 277 void LayoutFieldset::createInnerBlock() { | 285 void LayoutFieldset::createInnerBlock() { |
| 278 if (m_innerBlock) { | 286 if (m_innerBlock) { |
| 279 DCHECK(firstChild() == m_innerBlock); | 287 DCHECK(firstChild() == m_innerBlock); |
| 280 return; | 288 return; |
| 281 } | 289 } |
| 282 m_innerBlock = createAnonymousBlock(style()->display()); | 290 m_innerBlock = createAnonymousBlock(style()->display()); |
| 283 LayoutFlexibleBox::addChild(m_innerBlock); | 291 LayoutFlexibleBox::addChild(m_innerBlock); |
| 284 } | 292 } |
| 285 | 293 |
| 286 void LayoutFieldset::removeChild(LayoutObject* oldChild) { | 294 void LayoutFieldset::removeChild(LayoutObject* oldChild) { |
| 287 if (isHTMLLegendElement(oldChild->node())) { | 295 if (isHTMLLegendElement(oldChild->node())) { |
| 288 LayoutFlexibleBox::removeChild(oldChild); | 296 if (oldChild->isFloatingOrOutOfFlowPositioned()) { |
| 289 if (m_innerBlock) { | 297 m_innerBlock->removeChild(oldChild); |
| 290 resetInnerBlockPadding(isHorizontalWritingMode(), m_innerBlock); | 298 } else { |
| 291 m_innerBlock->setNeedsLayout(LayoutInvalidationReason::FieldsetChanged, | 299 LayoutFlexibleBox::removeChild(oldChild); |
| 292 MarkOnlyThis); | 300 if (m_innerBlock) { |
| 301 resetInnerBlockPadding(isHorizontalWritingMode(), m_innerBlock); |
| 302 m_innerBlock->setNeedsLayout(LayoutInvalidationReason::FieldsetChanged, |
| 303 MarkOnlyThis); |
| 304 } |
| 293 } | 305 } |
| 306 |
| 294 setShouldDoFullPaintInvalidation(); | 307 setShouldDoFullPaintInvalidation(); |
| 295 } else if (oldChild == m_innerBlock) { | 308 } else if (oldChild == m_innerBlock) { |
| 296 LayoutFlexibleBox::removeChild(oldChild); | 309 LayoutFlexibleBox::removeChild(oldChild); |
| 297 m_innerBlock = nullptr; | 310 m_innerBlock = nullptr; |
| 298 } else if (oldChild->parent() == this) { | 311 } else if (oldChild->parent() == this) { |
| 299 LayoutFlexibleBox::removeChild(oldChild); | 312 LayoutFlexibleBox::removeChild(oldChild); |
| 300 } else if (m_innerBlock) { | 313 } else if (m_innerBlock) { |
| 301 m_innerBlock->removeChild(oldChild); | 314 m_innerBlock->removeChild(oldChild); |
| 302 } | 315 } |
| 303 } | 316 } |
| 304 | 317 |
| 305 } // namespace blink | 318 } // namespace blink |
| OLD | NEW |