OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2000 Dirk Mueller (mueller@kde.org) | 3 * Copyright (C) 2000 Dirk Mueller (mueller@kde.org) |
4 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
5 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 static inline RenderBlock* firstContainingBlockWithLogicalWidth(const RenderRepl
aced* replaced) | 218 static inline RenderBlock* firstContainingBlockWithLogicalWidth(const RenderRepl
aced* replaced) |
219 { | 219 { |
220 // We have to lookup the containing block, which has an explicit width, whic
h must not be equal to our direct containing block. | 220 // We have to lookup the containing block, which has an explicit width, whic
h must not be equal to our direct containing block. |
221 // If the embedded document appears _after_ we performed the initial layout,
our intrinsic size is 300x150. If our containing | 221 // If the embedded document appears _after_ we performed the initial layout,
our intrinsic size is 300x150. If our containing |
222 // block doesn't provide an explicit width, it's set to the 300 default, com
ing from the initial layout run. | 222 // block doesn't provide an explicit width, it's set to the 300 default, com
ing from the initial layout run. |
223 RenderBlock* containingBlock = replaced->containingBlock(); | 223 RenderBlock* containingBlock = replaced->containingBlock(); |
224 if (!containingBlock) | 224 if (!containingBlock) |
225 return 0; | 225 return 0; |
226 | 226 |
227 for (; !containingBlock->isRenderView() && !containingBlock->isBody(); conta
iningBlock = containingBlock->containingBlock()) { | 227 for (; !containingBlock->isRenderView() && !containingBlock->isBody(); conta
iningBlock = containingBlock->containingBlock()) { |
228 if (containingBlock->style()->logicalWidth().isSpecified()) | 228 if (containingBlock->style()->logicalWidth().isSpecified() |
| 229 && containingBlock->style()->logicalMinWidth().isSpecified() |
| 230 && (containingBlock->style()->logicalMaxWidth().isSpecified() || con
tainingBlock->style()->logicalMaxWidth().isUndefined())) |
229 return containingBlock; | 231 return containingBlock; |
230 } | 232 } |
231 | 233 |
232 return 0; | 234 return 0; |
233 } | 235 } |
234 | 236 |
235 bool RenderReplaced::hasReplacedLogicalWidth() const | 237 bool RenderReplaced::hasReplacedLogicalWidth() const |
236 { | 238 { |
237 if (style()->logicalWidth().isSpecified()) | 239 if (style()->logicalWidth().isSpecified()) |
238 return true; | 240 return true; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 return computeReplacedLogicalWidthRespectingMinMaxWidth(roundToI
nt(round(logicalHeight * intrinsicRatio)), shouldComputePreferred); | 413 return computeReplacedLogicalWidthRespectingMinMaxWidth(roundToI
nt(round(logicalHeight * intrinsicRatio)), shouldComputePreferred); |
412 } | 414 } |
413 | 415 |
414 // If 'height' and 'width' both have computed values of 'auto' and t
he element has an intrinsic ratio but no intrinsic height or width, then the use
d value of | 416 // If 'height' and 'width' both have computed values of 'auto' and t
he element has an intrinsic ratio but no intrinsic height or width, then the use
d value of |
415 // 'width' is undefined in CSS 2.1. However, it is suggested that, i
f the containing block's width does not itself depend on the replaced element's
width, then | 417 // 'width' is undefined in CSS 2.1. However, it is suggested that, i
f the containing block's width does not itself depend on the replaced element's
width, then |
416 // the used value of 'width' is calculated from the constraint equat
ion used for block-level, non-replaced elements in normal flow. | 418 // the used value of 'width' is calculated from the constraint equat
ion used for block-level, non-replaced elements in normal flow. |
417 if (heightIsAuto && !hasIntrinsicWidth && !hasIntrinsicHeight) { | 419 if (heightIsAuto && !hasIntrinsicWidth && !hasIntrinsicHeight) { |
418 // The aforementioned 'constraint equation' used for block-level
, non-replaced elements in normal flow: | 420 // The aforementioned 'constraint equation' used for block-level
, non-replaced elements in normal flow: |
419 // 'margin-left' + 'border-left-width' + 'padding-left' + 'width
' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containin
g block | 421 // 'margin-left' + 'border-left-width' + 'padding-left' + 'width
' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containin
g block |
420 LayoutUnit logicalWidth; | 422 LayoutUnit logicalWidth; |
421 if (RenderBlock* blockWithWidth = firstContainingBlockWithLogica
lWidth(this)) | 423 // FIXME: This walking up the containgBlock chain to find the fi
rst one with a specified width is bonkers. |
| 424 // If nothing else, it requires making sure that computeReplaced
LogicalWidthRespectingMinMaxWidth cannot |
| 425 // depend on the width of the replaced element or we infinite lo
op. Right now we do that in |
| 426 // firstContainingBlockWithLogicalWidth by checking that width/m
in-width/max-width are all specified. |
| 427 // |
| 428 // Firefox 27 seems to only do this if the <svg> has a viewbox. |
| 429 if (RenderBlock* blockWithWidth = firstContainingBlockWithLogica
lWidth(this)) { |
422 logicalWidth = blockWithWidth->computeReplacedLogicalWidthRe
spectingMinMaxWidth(blockWithWidth->computeReplacedLogicalWidthUsing(blockWithWi
dth->style()->logicalWidth()), shouldComputePreferred); | 430 logicalWidth = blockWithWidth->computeReplacedLogicalWidthRe
spectingMinMaxWidth(blockWithWidth->computeReplacedLogicalWidthUsing(blockWithWi
dth->style()->logicalWidth()), shouldComputePreferred); |
423 else | 431 } else { |
| 432 // FIXME: If shouldComputePreferred == ComputePreferred, the
n we're reading this during preferred width |
| 433 // computation, at which point this is reading stale data fr
om a previous layout. |
424 logicalWidth = containingBlock()->availableLogicalWidth(); | 434 logicalWidth = containingBlock()->availableLogicalWidth(); |
| 435 } |
425 | 436 |
426 // This solves above equation for 'width' (== logicalWidth). | 437 // This solves above equation for 'width' (== logicalWidth). |
427 LayoutUnit marginStart = minimumValueForLength(style()->marginSt
art(), logicalWidth); | 438 LayoutUnit marginStart = minimumValueForLength(style()->marginSt
art(), logicalWidth); |
428 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(
), logicalWidth); | 439 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(
), logicalWidth); |
429 logicalWidth = max<LayoutUnit>(0, logicalWidth - (marginStart +
marginEnd + (width() - clientWidth()))); | 440 logicalWidth = max<LayoutUnit>(0, logicalWidth - (marginStart +
marginEnd + (width() - clientWidth()))); |
430 if (isPercentageIntrinsicSize) | 441 if (isPercentageIntrinsicSize) |
431 logicalWidth = logicalWidth * constrainedSize.width() / 100; | 442 logicalWidth = logicalWidth * constrainedSize.width() / 100; |
432 return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalW
idth, shouldComputePreferred); | 443 return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalW
idth, shouldComputePreferred); |
433 } | 444 } |
434 } | 445 } |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 | 639 |
629 if (style()) { | 640 if (style()) { |
630 if (v) | 641 if (v) |
631 r.inflate(style()->outlineSize()); | 642 r.inflate(style()->outlineSize()); |
632 } | 643 } |
633 computeRectForRepaint(repaintContainer, r); | 644 computeRectForRepaint(repaintContainer, r); |
634 return r; | 645 return r; |
635 } | 646 } |
636 | 647 |
637 } | 648 } |
OLD | NEW |