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

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: Unskipped some repaint tests and rebaselined. Created 4 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) 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 2349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 } 2360 }
2361 2361
2362 static bool columnFlexItemHasStretchAlignment(const LayoutObject* flexitem) 2362 static bool columnFlexItemHasStretchAlignment(const LayoutObject* flexitem)
2363 { 2363 {
2364 LayoutObject* parent = flexitem->parent(); 2364 LayoutObject* parent = flexitem->parent();
2365 // auto margins mean we don't stretch. Note that this function will only be used for 2365 // auto margins mean we don't stretch. Note that this function will only be used for
2366 // widths, so we don't have to check marginBefore/marginAfter. 2366 // widths, so we don't have to check marginBefore/marginAfter.
2367 ASSERT(parent->style()->isColumnFlexDirection()); 2367 ASSERT(parent->style()->isColumnFlexDirection());
2368 if (flexitem->style()->marginStart().isAuto() || flexitem->style()->marginEn d().isAuto()) 2368 if (flexitem->style()->marginStart().isAuto() || flexitem->style()->marginEn d().isAuto())
2369 return false; 2369 return false;
2370 return flexitem->style()->alignSelfPosition() == ItemPositionStretch || (fle xitem->style()->alignSelfPosition() == ItemPositionAuto && parent->style()->alig nItemsPosition() == ItemPositionStretch); 2370 return flexitem->styleRef().resolvedAlignSelf(parent->styleRef(), ItemPositi onStretch).position() == ItemPositionStretch;
2371 } 2371 }
2372 2372
2373 static bool isStretchingColumnFlexItem(const LayoutObject* flexitem) 2373 static bool isStretchingColumnFlexItem(const LayoutObject* flexitem)
2374 { 2374 {
2375 LayoutObject* parent = flexitem->parent(); 2375 LayoutObject* parent = flexitem->parent();
2376 if (parent->isDeprecatedFlexibleBox() && parent->style()->boxOrient() == VER TICAL && parent->style()->boxAlign() == BSTRETCH) 2376 if (parent->isDeprecatedFlexibleBox() && parent->style()->boxOrient() == VER TICAL && parent->style()->boxAlign() == BSTRETCH)
2377 return true; 2377 return true;
2378 2378
2379 // We don't stretch multiline flexboxes because they need to apply line spac ing (align-content) first. 2379 // We don't stretch multiline flexboxes because they need to apply line spac ing (align-content) first.
2380 if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexNoWrap && parent->style()->isColumnFlexDirection() && columnFlexItemHasStretchAlignment(fl exitem)) 2380 if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexNoWrap && parent->style()->isColumnFlexDirection() && columnFlexItemHasStretchAlignment(fl exitem))
2381 return true; 2381 return true;
2382 return false; 2382 return false;
2383 } 2383 }
2384 2384
2385 // TODO (lajava) Can/Should we move this inside specific layout classes (flex. g rid)? Can we refactor columnFlexItemHasStretchAlignment logic? 2385 // TODO (lajava) Can/Should we move this inside specific layout classes (flex. g rid)? Can we refactor columnFlexItemHasStretchAlignment logic?
2386 bool LayoutBox::hasStretchedLogicalWidth() const 2386 bool LayoutBox::hasStretchedLogicalWidth() const
2387 { 2387 {
2388 const ComputedStyle& style = styleRef(); 2388 const ComputedStyle& style = styleRef();
2389 if (!style.logicalWidth().isAuto() || style.marginStart().isAuto() || style. marginEnd().isAuto()) 2389 if (!style.logicalWidth().isAuto() || style.marginStart().isAuto() || style. marginEnd().isAuto())
2390 return false; 2390 return false;
2391 LayoutBlock* cb = containingBlock(); 2391 LayoutBlock* cb = containingBlock();
2392 if (!cb) { 2392 if (!cb) {
2393 // We are evaluating align-self/justify-self, which default to 'normal' for the root element. 2393 // We are evaluating align-self/justify-self, which default to 'normal' for the root element.
2394 // The 'normal' value behaves like 'start' except for Flexbox Items, whi ch obviously should have a container. 2394 // The 'normal' value behaves like 'start' except for Flexbox Items, whi ch obviously should have a container.
2395 return false; 2395 return false;
2396 } 2396 }
2397 if (cb->isHorizontalWritingMode() != isHorizontalWritingMode()) 2397 if (cb->isHorizontalWritingMode() != isHorizontalWritingMode())
2398 return ComputedStyle::resolveAlignment(cb->styleRef(), style, ItemPositi onStretch) == ItemPositionStretch; 2398 return style.resolvedAlignSelf(cb->styleRef(), ItemPositionStretch).posi tion() == ItemPositionStretch;
2399 return ComputedStyle::resolveJustification(cb->styleRef(), style, ItemPositi onStretch) == ItemPositionStretch; 2399 return style.resolvedJustifySelf(cb->styleRef(), ItemPositionStretch).positi on() == ItemPositionStretch;
2400 } 2400 }
2401 2401
2402 bool LayoutBox::sizesLogicalWidthToFitContent(const Length& logicalWidth) const 2402 bool LayoutBox::sizesLogicalWidthToFitContent(const Length& logicalWidth) const
2403 { 2403 {
2404 if (isFloating() || isInlineBlockOrInlineTable()) 2404 if (isFloating() || isInlineBlockOrInlineTable())
2405 return true; 2405 return true;
2406 2406
2407 if (isGridItem()) 2407 if (isGridItem())
2408 return !hasStretchedLogicalWidth(); 2408 return !hasStretchedLogicalWidth();
2409 2409
(...skipping 2543 matching lines...) Expand 10 before | Expand all | Expand 10 after
4953 m_rareData->m_snapAreas->remove(&snapArea); 4953 m_rareData->m_snapAreas->remove(&snapArea);
4954 } 4954 }
4955 } 4955 }
4956 4956
4957 SnapAreaSet* LayoutBox::snapAreas() const 4957 SnapAreaSet* LayoutBox::snapAreas() const
4958 { 4958 {
4959 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; 4959 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr;
4960 } 4960 }
4961 4961
4962 } // namespace blink 4962 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698