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

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

Issue 1709963002: [css-align] New CSS Value 'normal' for Self Alignment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed repaint tests. Created 4 years, 6 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, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. 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 2342 matching lines...) Expand 10 before | Expand all | Expand 10 after
2353 if (shrinkToAvoidFloats() && cb->isLayoutBlockFlow() && toLayoutBlockFlow(cb )->containsFloats()) 2353 if (shrinkToAvoidFloats() && cb->isLayoutBlockFlow() && toLayoutBlockFlow(cb )->containsFloats())
2354 logicalWidthResult = std::min(logicalWidthResult, shrinkLogicalWidthToAv oidFloats(marginStart, marginEnd, toLayoutBlockFlow(cb))); 2354 logicalWidthResult = std::min(logicalWidthResult, shrinkLogicalWidthToAv oidFloats(marginStart, marginEnd, toLayoutBlockFlow(cb)));
2355 2355
2356 if (widthType == MainOrPreferredSize && sizesLogicalWidthToFitContent(logica lWidth)) 2356 if (widthType == MainOrPreferredSize && sizesLogicalWidthToFitContent(logica lWidth))
2357 return std::max(minPreferredLogicalWidth(), std::min(maxPreferredLogical Width(), logicalWidthResult)); 2357 return std::max(minPreferredLogicalWidth(), std::min(maxPreferredLogical Width(), logicalWidthResult));
2358 return logicalWidthResult; 2358 return logicalWidthResult;
2359 } 2359 }
2360 2360
2361 static bool columnFlexItemHasStretchAlignment(const LayoutObject* flexitem) 2361 static bool columnFlexItemHasStretchAlignment(const LayoutObject* flexitem)
2362 { 2362 {
2363 LayoutObject* parent = flexitem->parent();
2364 // auto margins mean we don't stretch. Note that this function will only be used for 2363 // auto margins mean we don't stretch. Note that this function will only be used for
2365 // widths, so we don't have to check marginBefore/marginAfter. 2364 // widths, so we don't have to check marginBefore/marginAfter.
2366 ASSERT(parent->style()->isColumnFlexDirection()); 2365 DCHECK(flexitem->parent()->style()->isColumnFlexDirection());
2367 if (flexitem->style()->marginStart().isAuto() || flexitem->style()->marginEn d().isAuto()) 2366 if (flexitem->style()->marginStart().isAuto() || flexitem->style()->marginEn d().isAuto())
2368 return false; 2367 return false;
2369 return flexitem->style()->alignSelfPosition() == ItemPositionStretch || (fle xitem->style()->alignSelfPosition() == ItemPositionAuto && parent->style()->alig nItemsPosition() == ItemPositionStretch); 2368 return flexitem->styleRef().resolvedAlignSelf(ItemPositionStretch).position( ) == ItemPositionStretch;
2370 } 2369 }
2371 2370
2372 static bool isStretchingColumnFlexItem(const LayoutObject* flexitem) 2371 static bool isStretchingColumnFlexItem(const LayoutObject* flexitem)
2373 { 2372 {
2374 LayoutObject* parent = flexitem->parent(); 2373 LayoutObject* parent = flexitem->parent();
2375 if (parent->isDeprecatedFlexibleBox() && parent->style()->boxOrient() == VER TICAL && parent->style()->boxAlign() == BSTRETCH) 2374 if (parent->isDeprecatedFlexibleBox() && parent->style()->boxOrient() == VER TICAL && parent->style()->boxAlign() == BSTRETCH)
2376 return true; 2375 return true;
2377 2376
2378 // We don't stretch multiline flexboxes because they need to apply line spac ing (align-content) first. 2377 // We don't stretch multiline flexboxes because they need to apply line spac ing (align-content) first.
2379 if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexNoWrap && parent->style()->isColumnFlexDirection() && columnFlexItemHasStretchAlignment(fl exitem)) 2378 if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexNoWrap && parent->style()->isColumnFlexDirection() && columnFlexItemHasStretchAlignment(fl exitem))
2380 return true; 2379 return true;
2381 return false; 2380 return false;
2382 } 2381 }
2383 2382
2384 // TODO (lajava) Can/Should we move this inside specific layout classes (flex. g rid)? Can we refactor columnFlexItemHasStretchAlignment logic? 2383 // TODO (lajava) Can/Should we move this inside specific layout classes (flex. g rid)? Can we refactor columnFlexItemHasStretchAlignment logic?
2385 bool LayoutBox::hasStretchedLogicalWidth() const 2384 bool LayoutBox::hasStretchedLogicalWidth() const
2386 { 2385 {
2387 const ComputedStyle& style = styleRef(); 2386 const ComputedStyle& style = styleRef();
2388 if (!style.logicalWidth().isAuto() || style.marginStart().isAuto() || style. marginEnd().isAuto()) 2387 if (!style.logicalWidth().isAuto() || style.marginStart().isAuto() || style. marginEnd().isAuto())
2389 return false; 2388 return false;
2390 LayoutBlock* cb = containingBlock(); 2389 LayoutBlock* cb = containingBlock();
2391 if (!cb) { 2390 if (!cb) {
2392 // We are evaluating align-self/justify-self, which default to 'normal' for the root element. 2391 // We are evaluating align-self/justify-self, which default to 'normal' for the root element.
2393 // The 'normal' value behaves like 'start' except for Flexbox Items, whi ch obviously should have a container. 2392 // The 'normal' value behaves like 'start' except for Flexbox Items, whi ch obviously should have a container.
2394 return false; 2393 return false;
2395 } 2394 }
2396 if (cb->isHorizontalWritingMode() != isHorizontalWritingMode()) 2395 if (cb->isHorizontalWritingMode() != isHorizontalWritingMode())
2397 return ComputedStyle::resolveAlignment(cb->styleRef(), style, ItemPositi onStretch) == ItemPositionStretch; 2396 return style.resolvedAlignSelf(ItemPositionStretch).position() == ItemPo sitionStretch;
2398 return ComputedStyle::resolveJustification(cb->styleRef(), style, ItemPositi onStretch) == ItemPositionStretch; 2397 return style.resolvedJustifySelf(ItemPositionStretch).position() == ItemPosi tionStretch;
2399 } 2398 }
2400 2399
2401 bool LayoutBox::sizesLogicalWidthToFitContent(const Length& logicalWidth) const 2400 bool LayoutBox::sizesLogicalWidthToFitContent(const Length& logicalWidth) const
2402 { 2401 {
2403 if (isFloating() || isInlineBlockOrInlineTable()) 2402 if (isFloating() || isInlineBlockOrInlineTable())
2404 return true; 2403 return true;
2405 2404
2406 if (isGridItem()) 2405 if (isGridItem())
2407 return !hasStretchedLogicalWidth(); 2406 return !hasStretchedLogicalWidth();
2408 2407
(...skipping 2541 matching lines...) Expand 10 before | Expand all | Expand 10 after
4950 m_rareData->m_snapAreas->remove(&snapArea); 4949 m_rareData->m_snapAreas->remove(&snapArea);
4951 } 4950 }
4952 } 4951 }
4953 4952
4954 SnapAreaSet* LayoutBox::snapAreas() const 4953 SnapAreaSet* LayoutBox::snapAreas() const
4955 { 4954 {
4956 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; 4955 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr;
4957 } 4956 }
4958 4957
4959 } // namespace blink 4958 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698