OLD | NEW |
---|---|
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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 int RenderBox::pixelSnappedOffsetWidth() const | 401 int RenderBox::pixelSnappedOffsetWidth() const |
402 { | 402 { |
403 return snapSizeToPixel(offsetWidth(), x() + clientLeft()); | 403 return snapSizeToPixel(offsetWidth(), x() + clientLeft()); |
404 } | 404 } |
405 | 405 |
406 int RenderBox::pixelSnappedOffsetHeight() const | 406 int RenderBox::pixelSnappedOffsetHeight() const |
407 { | 407 { |
408 return snapSizeToPixel(offsetHeight(), y() + clientTop()); | 408 return snapSizeToPixel(offsetHeight(), y() + clientTop()); |
409 } | 409 } |
410 | 410 |
411 bool RenderBox::requiresLayoutToDetermineWidth() const | 411 bool RenderBox::canDetermineWidthWithoutLayout() const |
412 { | 412 { |
413 // FIXME: There are likely many subclasses of RenderBlockFlow which | |
Julien - ping for review
2013/09/30 16:28:06
Maybe also classes outside RenderBlockFlow?
| |
414 // cannot determine their layout just from style! | |
415 // Perhaps we should create a "PlainRenderBlockFlow" | |
416 // and move this optimization there? | |
417 if (!isRenderBlockFlow() | |
418 // Flexbox items can be expanded beyond their width. | |
419 || isFlexItemIncludingDeprecated() | |
420 // Table Layout controls cell size, width is ignored. | |
Julien - ping for review
2013/09/30 16:28:06
width is not ignored when doing a table layout. On
| |
421 || isTableCell()) | |
422 return false; | |
423 | |
413 RenderStyle* style = this->style(); | 424 RenderStyle* style = this->style(); |
414 return !style->width().isFixed() | 425 return style->width().isFixed() |
415 || !style->minWidth().isFixed() | 426 && style->minWidth().isFixed() |
416 || (!style->maxWidth().isUndefined() && !style->maxWidth().isFixed()) | 427 && (style->maxWidth().isUndefined() || style->maxWidth().isFixed()) |
417 || !style->paddingLeft().isFixed() | 428 && style->paddingLeft().isFixed() |
418 || !style->paddingRight().isFixed() | 429 && style->paddingRight().isFixed() |
419 || style->resize() != RESIZE_NONE | 430 && style->boxSizing() == CONTENT_BOX; |
420 || style->boxSizing() == BORDER_BOX | |
421 || !isRenderBlock() | |
422 || !isRenderBlockFlow() | |
423 || isFlexItemIncludingDeprecated() | |
424 // TableCells can expand beyond a specified width. | |
425 || isTableCell(); | |
426 } | 431 } |
427 | 432 |
428 LayoutUnit RenderBox::fixedOffsetWidth() const | 433 LayoutUnit RenderBox::fixedOffsetWidth() const |
429 { | 434 { |
430 ASSERT(!requiresLayoutToDetermineWidth()); | 435 ASSERT(canDetermineWidthWithoutLayout()); |
431 | 436 |
432 RenderStyle* style = this->style(); | 437 RenderStyle* style = this->style(); |
433 | 438 |
434 LayoutUnit width = std::max(LayoutUnit(style->minWidth().value()), LayoutUni t(style->width().value())); | 439 LayoutUnit width = std::max(LayoutUnit(style->minWidth().value()), LayoutUni t(style->width().value())); |
435 if (style->maxWidth().isFixed()) | 440 if (style->maxWidth().isFixed()) |
436 width = std::min(LayoutUnit(style->maxWidth().value()), width); | 441 width = std::min(LayoutUnit(style->maxWidth().value()), width); |
437 | 442 |
438 LayoutUnit borderLeft = style->borderLeft().nonZero() ? style->borderLeft(). width() : 0; | 443 LayoutUnit borderLeft = style->borderLeft().nonZero() ? style->borderLeft(). width() : 0; |
439 LayoutUnit borderRight = style->borderRight().nonZero() ? style->borderRight ().width() : 0; | 444 LayoutUnit borderRight = style->borderRight().nonZero() ? style->borderRight ().width() : 0; |
440 | 445 |
(...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2081 float maxWidth = 0; | 2086 float maxWidth = 0; |
2082 for (RenderObject* child = renderer->firstChild(); child; child = child->nex tSibling()) { | 2087 for (RenderObject* child = renderer->firstChild(); child; child = child->nex tSibling()) { |
2083 if (!child->isListItem()) | 2088 if (!child->isListItem()) |
2084 continue; | 2089 continue; |
2085 | 2090 |
2086 RenderBox* listItem = toRenderBox(child); | 2091 RenderBox* listItem = toRenderBox(child); |
2087 for (RenderObject* itemChild = listItem->firstChild(); itemChild; itemCh ild = itemChild->nextSibling()) { | 2092 for (RenderObject* itemChild = listItem->firstChild(); itemChild; itemCh ild = itemChild->nextSibling()) { |
2088 if (!itemChild->isListMarker()) | 2093 if (!itemChild->isListMarker()) |
2089 continue; | 2094 continue; |
2090 RenderBox* itemMarker = toRenderBox(itemChild); | 2095 RenderBox* itemMarker = toRenderBox(itemChild); |
2091 if (itemMarker->requiresLayoutToDetermineWidth() && itemMarker->need sLayout()) { | 2096 // FIXME: canDetermineWidthWithoutLayout expects us to use fixedOffs etWidth, which this code |
2097 // does not do! This check is likely wrong. | |
2098 if (!itemMarker->canDetermineWidthWithoutLayout() && itemMarker->nee dsLayout()) { | |
2092 // Make sure to compute the autosized width. | 2099 // Make sure to compute the autosized width. |
2093 itemMarker->layout(); | 2100 itemMarker->layout(); |
Julien - ping for review
2013/09/30 16:28:06
layoutIfNeeded()?
| |
2094 } | 2101 } |
2095 maxWidth = max<float>(maxWidth, toRenderListMarker(itemMarker)->logi calWidth().toFloat()); | 2102 maxWidth = max<float>(maxWidth, toRenderListMarker(itemMarker)->logi calWidth().toFloat()); |
2096 break; | 2103 break; |
2097 } | 2104 } |
2098 } | 2105 } |
2099 return maxWidth; | 2106 return maxWidth; |
2100 } | 2107 } |
2101 | 2108 |
2102 void RenderBox::computeLogicalWidthInRegion(LogicalExtentComputedValues& compute dValues, RenderRegion* region) const | 2109 void RenderBox::computeLogicalWidthInRegion(LogicalExtentComputedValues& compute dValues, RenderRegion* region) const |
2103 { | 2110 { |
(...skipping 2663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4767 return 0; | 4774 return 0; |
4768 | 4775 |
4769 if (!layoutState && !flowThreadContainingBlock()) | 4776 if (!layoutState && !flowThreadContainingBlock()) |
4770 return 0; | 4777 return 0; |
4771 | 4778 |
4772 RenderBlock* containerBlock = containingBlock(); | 4779 RenderBlock* containerBlock = containingBlock(); |
4773 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); | 4780 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); |
4774 } | 4781 } |
4775 | 4782 |
4776 } // namespace WebCore | 4783 } // namespace WebCore |
OLD | NEW |