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

Side by Side Diff: Source/core/rendering/RenderBoxModelObject.cpp

Issue 385583005: For flex items, percent paddings should resolve against their respective dimension Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 5 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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 int RenderBoxModelObject::pixelSnappedOffsetWidth() const 303 int RenderBoxModelObject::pixelSnappedOffsetWidth() const
304 { 304 {
305 return snapSizeToPixel(offsetWidth(), offsetLeft()); 305 return snapSizeToPixel(offsetWidth(), offsetLeft());
306 } 306 }
307 307
308 int RenderBoxModelObject::pixelSnappedOffsetHeight() const 308 int RenderBoxModelObject::pixelSnappedOffsetHeight() const
309 { 309 {
310 return snapSizeToPixel(offsetHeight(), offsetTop()); 310 return snapSizeToPixel(offsetHeight(), offsetTop());
311 } 311 }
312 312
313 LayoutUnit RenderBoxModelObject::computedCSSPadding(const Length& padding) const 313 LayoutUnit RenderBoxModelObject::computedCSSPadding(const Length& padding, Paddi ngType type) const
314 { 314 {
315 LayoutUnit w = 0; 315 LayoutUnit w = 0;
316 if (padding.isPercent()) 316 if (padding.isPercent()) {
317 w = containingBlockLogicalWidthForContent(); 317 if (containingBlock()->isFlexibleBox() && RuntimeEnabledFeatures::vertic alPaddingEnabled()) {
318 if (type == TopPadding || type == BottomPadding || type == BeforePad ding || type == AfterPadding)
319 w = isHorizontalWritingMode() ? containingBlockLogicalHeightForP adding() : containingBlockLogicalWidthForContent();
320 else
321 w = isHorizontalWritingMode() ? containingBlockLogicalWidthForCo ntent() : containingBlockLogicalHeightForPadding();
322 } else {
323 w = containingBlockLogicalWidthForContent();
324 }
325 }
318 return minimumValueForLength(padding, w); 326 return minimumValueForLength(padding, w);
319 } 327 }
320 328
321 RoundedRect RenderBoxModelObject::getBackgroundRoundedRect(const LayoutRect& bor derRect, InlineFlowBox* box, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeig ht, 329 RoundedRect RenderBoxModelObject::getBackgroundRoundedRect(const LayoutRect& bor derRect, InlineFlowBox* box, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeig ht,
322 bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const 330 bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
323 { 331 {
324 RoundedRect border = style()->getRoundedBorderFor(borderRect, includeLogical LeftEdge, includeLogicalRightEdge); 332 RoundedRect border = style()->getRoundedBorderFor(borderRect, includeLogical LeftEdge, includeLogicalRightEdge);
325 if (box && (box->nextLineBox() || box->prevLineBox())) { 333 if (box && (box->nextLineBox() || box->prevLineBox())) {
326 RoundedRect segmentBorder = style()->getRoundedBorderFor(LayoutRect(0, 0 , inlineBoxWidth, inlineBoxHeight), includeLogicalLeftEdge, includeLogicalRightE dge); 334 RoundedRect segmentBorder = style()->getRoundedBorderFor(LayoutRect(0, 0 , inlineBoxWidth, inlineBoxHeight), includeLogicalLeftEdge, includeLogicalRightE dge);
327 border.setRadii(segmentBorder.radii()); 335 border.setRadii(segmentBorder.radii());
(...skipping 2172 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 context->drawInnerShadow(border, shadowColor, flooredIntSize(shadowO ffset), shadowBlur, shadowSpread, clippedEdges); 2508 context->drawInnerShadow(border, shadowColor, flooredIntSize(shadowO ffset), shadowBlur, shadowSpread, clippedEdges);
2501 } 2509 }
2502 } 2510 }
2503 } 2511 }
2504 2512
2505 LayoutUnit RenderBoxModelObject::containingBlockLogicalWidthForContent() const 2513 LayoutUnit RenderBoxModelObject::containingBlockLogicalWidthForContent() const
2506 { 2514 {
2507 return containingBlock()->availableLogicalWidth(); 2515 return containingBlock()->availableLogicalWidth();
2508 } 2516 }
2509 2517
2518 LayoutUnit RenderBoxModelObject::containingBlockLogicalHeightForPadding() const
2519 {
2520 switch (containingBlock()->style()->logicalHeight().type()) {
2521 case Auto:
2522 case MinContent:
2523 case MaxContent:
2524 case FitContent:
2525 case FillAvailable:
2526 return 0;
2527 case Fixed:
2528 case Calculated:
2529 return containingBlock()->style()->logicalHeight().value();
2530 case Percent:
2531 return computePercentLogicalHeightForPadding(containingBlock());
2532 default:
tony 2014/07/16 16:57:23 One of the reasons to use a switch statement is so
harpreet.sk 2014/07/17 14:36:53 Done.
2533 return 0;
2534 }
2535 }
2536
2537 LayoutUnit RenderBoxModelObject::computePercentLogicalHeightForPadding(RenderBlo ck* block) const
2538 {
2539 ASSERT(block->style()->logicalHeight().isPercent());
2540
2541 float percentHeightFactor = block->style()->logicalHeight().value() / 100;
2542 RenderBlock* cb = block->containingBlock();
2543 while (cb) {
2544 if (cb->style()->logicalHeight().isIntrinsicOrAuto())
2545 return 0;
2546 if (!block->skipContainingBlockForPercentHeightCalculation(cb) && (cb->s tyle()->logicalHeight().isFixed() || cb->style()->logicalHeight().isCalculated() ))
2547 break;
2548 if (cb->style()->logicalHeight().isPercent())
2549 percentHeightFactor *= cb->style()->logicalHeight().value() / 100;
2550 cb = cb->containingBlock();
2551 }
2552
2553 if (cb)
2554 return percentHeightFactor * cb->style()->logicalHeight().value();
2555
2556 return 0;
2557 }
2558
2510 RenderBoxModelObject* RenderBoxModelObject::continuation() const 2559 RenderBoxModelObject* RenderBoxModelObject::continuation() const
2511 { 2560 {
2512 if (!continuationMap) 2561 if (!continuationMap)
2513 return 0; 2562 return 0;
2514 return continuationMap->get(this); 2563 return continuationMap->get(this);
2515 } 2564 }
2516 2565
2517 void RenderBoxModelObject::setContinuation(RenderBoxModelObject* continuation) 2566 void RenderBoxModelObject::setContinuation(RenderBoxModelObject* continuation)
2518 { 2567 {
2519 if (continuation) { 2568 if (continuation) {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
2727 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 2776 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2728 for (RenderObject* child = startChild; child && child != endChild; ) { 2777 for (RenderObject* child = startChild; child && child != endChild; ) {
2729 // Save our next sibling as moveChildTo will clear it. 2778 // Save our next sibling as moveChildTo will clear it.
2730 RenderObject* nextSibling = child->nextSibling(); 2779 RenderObject* nextSibling = child->nextSibling();
2731 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 2780 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
2732 child = nextSibling; 2781 child = nextSibling;
2733 } 2782 }
2734 } 2783 }
2735 2784
2736 } // namespace WebCore 2785 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBoxModelObject.h ('k') | Source/core/rendering/RenderThemeChromiumSkia.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698