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

Side by Side Diff: Source/core/layout/LayoutBlock.cpp

Issue 1121173002: Fix shrink-to-fit when children's writing-mode is orthogonal (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: float tests added + cleanup a bit Created 5 years, 7 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) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 LayoutBlock::LayoutBlock(ContainerNode* node) 148 LayoutBlock::LayoutBlock(ContainerNode* node)
149 : LayoutBox(node) 149 : LayoutBox(node)
150 , m_hasMarginBeforeQuirk(false) 150 , m_hasMarginBeforeQuirk(false)
151 , m_hasMarginAfterQuirk(false) 151 , m_hasMarginAfterQuirk(false)
152 , m_beingDestroyed(false) 152 , m_beingDestroyed(false)
153 , m_hasMarkupTruncation(false) 153 , m_hasMarkupTruncation(false)
154 , m_widthAvailableToChildrenChanged(false) 154 , m_widthAvailableToChildrenChanged(false)
155 , m_hasOnlySelfCollapsingChildren(false) 155 , m_hasOnlySelfCollapsingChildren(false)
156 , m_descendantsWithFloatsMarkedForLayout(false) 156 , m_descendantsWithFloatsMarkedForLayout(false)
157 , m_needsRecalcLogicalWidthAfterLayoutChildren(false)
157 { 158 {
158 // LayoutBlockFlow calls setChildrenInline(true). 159 // LayoutBlockFlow calls setChildrenInline(true).
159 // By default, subclasses do not have inline children. 160 // By default, subclasses do not have inline children.
160 } 161 }
161 162
162 static void removeBlockFromDescendantAndContainerMaps(LayoutBlock* block, Tracke dDescendantsMap*& descendantMap, TrackedContainerMap*& containerMap) 163 static void removeBlockFromDescendantAndContainerMaps(LayoutBlock* block, Tracke dDescendantsMap*& descendantMap, TrackedContainerMap*& containerMap)
163 { 164 {
164 if (OwnPtr<TrackedLayoutBoxListHashSet> descendantSet = descendantMap->take( block)) { 165 if (OwnPtr<TrackedLayoutBoxListHashSet> descendantSet = descendantMap->take( block)) {
165 for (auto& descendant : *descendantSet) { 166 for (auto& descendant : *descendantSet) {
166 TrackedContainerMap::iterator it = containerMap->find(descendant); 167 TrackedContainerMap::iterator it = containerMap->find(descendant);
(...skipping 2889 matching lines...) Expand 10 before | Expand all | Expand 10 after
3056 LayoutUnit margin = 0; 3057 LayoutUnit margin = 0;
3057 LayoutUnit marginStart = 0; 3058 LayoutUnit marginStart = 0;
3058 LayoutUnit marginEnd = 0; 3059 LayoutUnit marginEnd = 0;
3059 if (startMarginLength.isFixed()) 3060 if (startMarginLength.isFixed())
3060 marginStart += startMarginLength.value(); 3061 marginStart += startMarginLength.value();
3061 if (endMarginLength.isFixed()) 3062 if (endMarginLength.isFixed())
3062 marginEnd += endMarginLength.value(); 3063 marginEnd += endMarginLength.value();
3063 margin = marginStart + marginEnd; 3064 margin = marginStart + marginEnd;
3064 3065
3065 LayoutUnit childMinPreferredLogicalWidth, childMaxPreferredLogicalWidth; 3066 LayoutUnit childMinPreferredLogicalWidth, childMaxPreferredLogicalWidth;
3066 if (child->isBox() && child->isHorizontalWritingMode() != isHorizontalWr itingMode()) { 3067 minMaxPreferredLogicalWidthOfChild(*child, childMinPreferredLogicalWidth , childMaxPreferredLogicalWidth);
3067 childMinPreferredLogicalWidth = childMaxPreferredLogicalWidth = toLa youtBox(child)->computeLogicalHeightWithoutLayout();
3068 } else {
3069 childMinPreferredLogicalWidth = child->minPreferredLogicalWidth();
3070 childMaxPreferredLogicalWidth = child->maxPreferredLogicalWidth();
3071 }
3072 3068
3073 LayoutUnit w = childMinPreferredLogicalWidth + margin; 3069 LayoutUnit w = childMinPreferredLogicalWidth + margin;
3074 minLogicalWidth = std::max(w, minLogicalWidth); 3070 minLogicalWidth = std::max(w, minLogicalWidth);
3075 3071
3076 // IE ignores tables for calculation of nowrap. Makes some sense. 3072 // IE ignores tables for calculation of nowrap. Makes some sense.
3077 if (nowrap && !child->isTable()) 3073 if (nowrap && !child->isTable())
3078 maxLogicalWidth = std::max(w, maxLogicalWidth); 3074 maxLogicalWidth = std::max(w, maxLogicalWidth);
3079 3075
3080 w = childMaxPreferredLogicalWidth + margin; 3076 w = childMaxPreferredLogicalWidth + margin;
3081 3077
(...skipping 27 matching lines...) Expand all
3109 child = child->nextSibling(); 3105 child = child->nextSibling();
3110 } 3106 }
3111 3107
3112 // Always make sure these values are non-negative. 3108 // Always make sure these values are non-negative.
3113 minLogicalWidth = std::max<LayoutUnit>(0, minLogicalWidth); 3109 minLogicalWidth = std::max<LayoutUnit>(0, minLogicalWidth);
3114 maxLogicalWidth = std::max<LayoutUnit>(0, maxLogicalWidth); 3110 maxLogicalWidth = std::max<LayoutUnit>(0, maxLogicalWidth);
3115 3111
3116 maxLogicalWidth = std::max(floatLeftWidth + floatRightWidth, maxLogicalWidth ); 3112 maxLogicalWidth = std::max(floatLeftWidth + floatRightWidth, maxLogicalWidth );
3117 } 3113 }
3118 3114
3115 void LayoutBlock::minMaxPreferredLogicalWidthOfChild(LayoutObject& child, Layout Unit& minPreferredLogicalWidth, LayoutUnit& maxPreferredLogicalWidth) const
3116 {
3117 ASSERT(child.parent() == this);
3118
3119 if (!(child.isBox() && toLayoutBox(child).isWritingModeOrthogonalToParent()) ) {
3120 minPreferredLogicalWidth = child.minPreferredLogicalWidth();
3121 maxPreferredLogicalWidth = child.maxPreferredLogicalWidth();
3122 return;
3123 }
3124
3125 #ifdef CRBUG410320_APPROACH_1
3126 child.layoutIfNeeded();
3127 #else
3128 // If the child is an orthogonal flow, child's height determines the width, but the height is not available until layout.
3129 // http://dev.w3.org/csswg/css-writing-modes-3/#orthogonal-shrink-to-fit
3130 if (child.needsLayout()) {
3131 minPreferredLogicalWidth = maxPreferredLogicalWidth = toLayoutBox(child) .computeLogicalHeightWithoutLayout();
3132 m_needsRecalcLogicalWidthAfterLayoutChildren = true;
3133 return;
3134 }
3135 #endif
3136 minPreferredLogicalWidth = maxPreferredLogicalWidth = toLayoutBox(child).log icalHeight();
3137 }
3138
3119 bool LayoutBlock::hasLineIfEmpty() const 3139 bool LayoutBlock::hasLineIfEmpty() const
3120 { 3140 {
3121 if (!node()) 3141 if (!node())
3122 return false; 3142 return false;
3123 3143
3124 if (node()->isRootEditableElement()) 3144 if (node()->isRootEditableElement())
3125 return true; 3145 return true;
3126 3146
3127 if (node()->isShadowRoot() && isHTMLInputElement(*toShadowRoot(node())->host ())) 3147 if (node()->isShadowRoot() && isHTMLInputElement(*toShadowRoot(node())->host ()))
3128 return true; 3148 return true;
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
3920 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const 3940 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const
3921 { 3941 {
3922 showLayoutObject(); 3942 showLayoutObject();
3923 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 3943 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
3924 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 3944 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
3925 } 3945 }
3926 3946
3927 #endif 3947 #endif
3928 3948
3929 } // namespace blink 3949 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698