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

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

Issue 2288563002: Treat implicit height on positioned objects as non-auto (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bug 61049 Created 4 years, 3 months 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
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) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2010 Google Inc. All rights reserved. 7 * Copyright (C) 2010 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 485
486 void LayoutBoxModelObject::updateFromStyle() 486 void LayoutBoxModelObject::updateFromStyle()
487 { 487 {
488 const ComputedStyle& styleToUse = styleRef(); 488 const ComputedStyle& styleToUse = styleRef();
489 setHasBoxDecorationBackground(styleToUse.hasBoxDecorationBackground()); 489 setHasBoxDecorationBackground(styleToUse.hasBoxDecorationBackground());
490 setInline(styleToUse.isDisplayInlineType()); 490 setInline(styleToUse.isDisplayInlineType());
491 setPositionState(styleToUse.position()); 491 setPositionState(styleToUse.position());
492 setHorizontalWritingMode(styleToUse.isHorizontalWritingMode()); 492 setHorizontalWritingMode(styleToUse.isHorizontalWritingMode());
493 } 493 }
494 494
495 static bool isOutOfFlowPositionedWithImplicitHeight(LayoutBlock* child)
mstensho (USE GERRIT) 2016/08/29 16:02:26 static inline and const LayoutBlock?
496 {
497 return child->isOutOfFlowPositioned() && !child->style()->logicalTop().isAut o() && !child->style()->logicalBottom().isAuto();
498 }
499
495 LayoutBlock* LayoutBoxModelObject::containingBlockForAutoHeightDetection(Length logicalHeight) const 500 LayoutBlock* LayoutBoxModelObject::containingBlockForAutoHeightDetection(Length logicalHeight) const
496 { 501 {
497 // For percentage heights: The percentage is calculated with respect to the height of the generated box's 502 // For percentage heights: The percentage is calculated with respect to the height of the generated box's
498 // containing block. If the height of the containing block is not specified explicitly (i.e., it depends 503 // containing block. If the height of the containing block is not specified explicitly (i.e., it depends
499 // on content height), and this element is not absolutely positioned, the u sed height is calculated 504 // on content height), and this element is not absolutely positioned, the u sed height is calculated
500 // as if 'auto' was specified. 505 // as if 'auto' was specified.
501 if (!logicalHeight.hasPercent() || isOutOfFlowPositioned()) 506 if (!logicalHeight.hasPercent() || isOutOfFlowPositioned())
502 return nullptr; 507 return nullptr;
503 508
504 // Anonymous block boxes are ignored when resolving percentage values that w ould refer to it: 509 // Anonymous block boxes are ignored when resolving percentage values that w ould refer to it:
505 // the closest non-anonymous ancestor box is used instead. 510 // the closest non-anonymous ancestor box is used instead.
506 LayoutBlock* cb = containingBlock(); 511 LayoutBlock* cb = containingBlock();
507 while (cb->isAnonymous()) 512 while (cb->isAnonymous())
508 cb = cb->containingBlock(); 513 cb = cb->containingBlock();
509 514
510 // Matching LayoutBox::percentageLogicalHeightIsResolvableFromBlock() by 515 // Matching LayoutBox::percentageLogicalHeightIsResolvableFromBlock() by
511 // ignoring table cell's attribute value, where it says that table cells vio late 516 // ignoring table cell's attribute value, where it says that table cells vio late
512 // what the CSS spec says to do with heights. Basically we 517 // what the CSS spec says to do with heights. Basically we
513 // don't care if the cell specified a height or not. 518 // don't care if the cell specified a height or not.
514 if (cb->isTableCell()) 519 if (cb->isTableCell())
515 return nullptr; 520 return nullptr;
516 521
517 // Match LayoutBox::availableLogicalHeightUsing by special casing 522 // Match LayoutBox::availableLogicalHeightUsing by special casing
518 // the layout view. The available height is taken from the frame. 523 // the layout view. The available height is taken from the frame.
519 if (cb->isLayoutView()) 524 if (cb->isLayoutView())
520 return nullptr; 525 return nullptr;
521 526
522 if (cb->isOutOfFlowPositioned() && !cb->style()->logicalTop().isAuto() && !c b->style()->logicalBottom().isAuto()) 527 if (isOutOfFlowPositionedWithImplicitHeight(cb))
523 return nullptr; 528 return nullptr;
524 529
525 return cb; 530 return cb;
526 } 531 }
527 532
528 bool LayoutBoxModelObject::hasAutoHeightOrContainingBlockWithAutoHeight(bool che ckingContainingBlock) const 533 bool LayoutBoxModelObject::hasAutoHeightOrContainingBlockWithAutoHeight(bool che ckingContainingBlock) const
529 { 534 {
530 const LayoutBox* thisBox = isBox() ? toLayoutBox(this) : nullptr; 535 const LayoutBox* thisBox = isBox() ? toLayoutBox(this) : nullptr;
531 Length logicalHeightLength = style()->logicalHeight(); 536 Length logicalHeightLength = style()->logicalHeight();
532 LayoutBlock* cb = containingBlockForAutoHeightDetection(logicalHeightLength) ; 537 LayoutBlock* cb = containingBlockForAutoHeightDetection(logicalHeightLength) ;
533 if (logicalHeightLength.hasPercent() && cb && isBox()) 538 if (logicalHeightLength.hasPercent() && cb && isBox())
534 cb->addPercentHeightDescendant(const_cast<LayoutBox*>(toLayoutBox(this)) ); 539 cb->addPercentHeightDescendant(const_cast<LayoutBox*>(toLayoutBox(this)) );
535 if (thisBox && thisBox->isFlexItem()) { 540 if (thisBox && thisBox->isFlexItem()) {
536 LayoutFlexibleBox& flexBox = toLayoutFlexibleBox(*parent()); 541 LayoutFlexibleBox& flexBox = toLayoutFlexibleBox(*parent());
537 if (flexBox.childLogicalHeightForPercentageResolution(*thisBox) != Layou tUnit(-1)) 542 if (flexBox.childLogicalHeightForPercentageResolution(*thisBox) != Layou tUnit(-1))
538 return false; 543 return false;
539 } 544 }
540 if (thisBox && thisBox->isGridItem()) { 545 if (thisBox && thisBox->isGridItem()) {
541 if (checkingContainingBlock && thisBox->hasOverrideLogicalContentHeight( )) 546 if (checkingContainingBlock && thisBox->hasOverrideLogicalContentHeight( ))
542 return false; 547 return false;
543 if (!checkingContainingBlock && thisBox->hasOverrideContainingBlockLogic alHeight()) 548 if (!checkingContainingBlock && thisBox->hasOverrideContainingBlockLogic alHeight())
544 return false; 549 return false;
545 } 550 }
546 if (logicalHeightLength.isAuto()) 551 if (logicalHeightLength.isAuto() && !isOutOfFlowPositionedWithImplicitHeight (this))
547 return true; 552 return true;
548 553
549 if (document().inQuirksMode()) 554 if (document().inQuirksMode())
550 return false; 555 return false;
551 556
552 // If the height of the containing block computes to 'auto', then it hasn't been 'specified explicitly'. 557 // If the height of the containing block computes to 'auto', then it hasn't been 'specified explicitly'.
553 if (cb) 558 if (cb)
554 return cb->hasAutoHeightOrContainingBlockWithAutoHeight(true); 559 return cb->hasAutoHeightOrContainingBlockWithAutoHeight(true);
555 return false; 560 return false;
556 } 561 }
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 if (rootElementStyle->hasBackground()) 1110 if (rootElementStyle->hasBackground())
1106 return false; 1111 return false;
1107 1112
1108 if (node() != document().firstBodyElement()) 1113 if (node() != document().firstBodyElement())
1109 return false; 1114 return false;
1110 1115
1111 return true; 1116 return true;
1112 } 1117 }
1113 1118
1114 } // namespace blink 1119 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698