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

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: WIP Patch 3 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() && (type == TopPadding || type == BottomPadding || type == BeforePadding || type == AfterPadding))
ojan 2014/07/15 20:33:25 This isn't correct for vertical writing mode. TopP
harpreet.sk 2014/07/16 15:43:02 Done.
318 w = containingBlockLogicalHeightForContent();
319 else
320 w = containingBlockLogicalWidthForContent();
321 }
318 return minimumValueForLength(padding, w); 322 return minimumValueForLength(padding, w);
319 } 323 }
320 324
321 RoundedRect RenderBoxModelObject::getBackgroundRoundedRect(const LayoutRect& bor derRect, InlineFlowBox* box, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeig ht, 325 RoundedRect RenderBoxModelObject::getBackgroundRoundedRect(const LayoutRect& bor derRect, InlineFlowBox* box, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeig ht,
322 bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const 326 bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
323 { 327 {
324 RoundedRect border = style()->getRoundedBorderFor(borderRect, includeLogical LeftEdge, includeLogicalRightEdge); 328 RoundedRect border = style()->getRoundedBorderFor(borderRect, includeLogical LeftEdge, includeLogicalRightEdge);
325 if (box && (box->nextLineBox() || box->prevLineBox())) { 329 if (box && (box->nextLineBox() || box->prevLineBox())) {
326 RoundedRect segmentBorder = style()->getRoundedBorderFor(LayoutRect(0, 0 , inlineBoxWidth, inlineBoxHeight), includeLogicalLeftEdge, includeLogicalRightE dge); 330 RoundedRect segmentBorder = style()->getRoundedBorderFor(LayoutRect(0, 0 , inlineBoxWidth, inlineBoxHeight), includeLogicalLeftEdge, includeLogicalRightE dge);
327 border.setRadii(segmentBorder.radii()); 331 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); 2504 context->drawInnerShadow(border, shadowColor, flooredIntSize(shadowO ffset), shadowBlur, shadowSpread, clippedEdges);
2501 } 2505 }
2502 } 2506 }
2503 } 2507 }
2504 2508
2505 LayoutUnit RenderBoxModelObject::containingBlockLogicalWidthForContent() const 2509 LayoutUnit RenderBoxModelObject::containingBlockLogicalWidthForContent() const
2506 { 2510 {
2507 return containingBlock()->availableLogicalWidth(); 2511 return containingBlock()->availableLogicalWidth();
2508 } 2512 }
2509 2513
2514 LayoutUnit RenderBoxModelObject::containingBlockLogicalHeightForContent() const
leviw_travelin_and_unemployed 2014/07/15 20:08:29 This is different than RenderBox::containingBlockL
harpreet.sk 2014/07/16 15:43:01 Renamed.
2515 {
2516 if (containingBlock()->style()->logicalHeight().isIntrinsicOrAuto())
2517 return 0;
2518
2519 if (containingBlock()->style()->logicalHeight().isPercent())
2520 return containingBlock()->computePercentLogicalHeight();
2521
2522 return containingBlock()->style()->logicalHeight().value();
ojan 2014/07/15 20:33:25 Please ASSERT(containingBlock()->style()->logicalH
harpreet.sk 2014/07/16 15:43:01 Replaced if's with switch
2523 }
2524
2525 LayoutUnit RenderBoxModelObject::computePercentLogicalHeight() const
ojan 2014/07/15 20:33:25 This also is duplicating a method on RenderBox but
harpreet.sk 2014/07/16 15:43:01 Renamed the function. The reason why i am not usin
2526 {
2527 float percentHeightFactor = style()->logicalHeight().value() / 100;
ojan 2014/07/15 20:33:25 ASSERT(style()->logicalHeight().isPercent());
harpreet.sk 2014/07/16 15:43:01 Done.
2528 RenderBlock* cb = containingBlock();
2529 while (cb) {
2530 if (cb->style()->logicalHeight().isIntrinsicOrAuto())
2531 return 0;
2532 if (cb->style()->logicalHeight().isFixed() || cb->style()->logicalHeight ().isCalculated())
ojan 2014/07/15 20:33:25 This should use skipContainingBlockForPercentHeigh
harpreet.sk 2014/07/16 15:43:01 Done.
2533 break;
2534 percentHeightFactor *= cb->style()->logicalHeight().value() / 100;
2535 cb = cb->containingBlock();
2536 }
2537
2538 if (cb)
2539 return percentHeightFactor * cb->style()->logicalHeight().value();
2540
2541 return 0;
2542 }
2543
2510 RenderBoxModelObject* RenderBoxModelObject::continuation() const 2544 RenderBoxModelObject* RenderBoxModelObject::continuation() const
2511 { 2545 {
2512 if (!continuationMap) 2546 if (!continuationMap)
2513 return 0; 2547 return 0;
2514 return continuationMap->get(this); 2548 return continuationMap->get(this);
2515 } 2549 }
2516 2550
2517 void RenderBoxModelObject::setContinuation(RenderBoxModelObject* continuation) 2551 void RenderBoxModelObject::setContinuation(RenderBoxModelObject* continuation)
2518 { 2552 {
2519 if (continuation) { 2553 if (continuation) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2730 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 2764 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2731 for (RenderObject* child = startChild; child && child != endChild; ) { 2765 for (RenderObject* child = startChild; child && child != endChild; ) {
2732 // Save our next sibling as moveChildTo will clear it. 2766 // Save our next sibling as moveChildTo will clear it.
2733 RenderObject* nextSibling = child->nextSibling(); 2767 RenderObject* nextSibling = child->nextSibling();
2734 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 2768 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
2735 child = nextSibling; 2769 child = nextSibling;
2736 } 2770 }
2737 } 2771 }
2738 2772
2739 } // namespace WebCore 2773 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698