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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // this node to change it's preferred width because it maintains aspect rati
o. | 264 // this node to change it's preferred width because it maintains aspect rati
o. |
265 return hasRelativeLogicalHeight() && style()->logicalWidth().isAuto() && !ha
sAutoHeightOrContainingBlockWithAutoHeight(); | 265 return hasRelativeLogicalHeight() && style()->logicalWidth().isAuto() && !ha
sAutoHeightOrContainingBlockWithAutoHeight(); |
266 } | 266 } |
267 | 267 |
268 static inline bool rendererHasAspectRatio(const RenderObject* renderer) | 268 static inline bool rendererHasAspectRatio(const RenderObject* renderer) |
269 { | 269 { |
270 ASSERT(renderer); | 270 ASSERT(renderer); |
271 return renderer->isImage() || renderer->isCanvas() || renderer->isVideo(); | 271 return renderer->isImage() || renderer->isCanvas() || renderer->isVideo(); |
272 } | 272 } |
273 | 273 |
274 void RenderReplaced::computeAspectRatioInformationForRenderBox(RenderBox* conten
tRenderer, FloatSize& constrainedSize, double& intrinsicRatio, bool& isPercentag
eIntrinsicSize) const | 274 void RenderReplaced::computeAspectRatioInformationForRenderBox(RenderBox* conten
tRenderer, FloatSize& constrainedSize, double& intrinsicRatio) const |
275 { | 275 { |
276 FloatSize intrinsicSize; | 276 FloatSize intrinsicSize; |
277 if (contentRenderer) { | 277 if (contentRenderer) { |
278 contentRenderer->computeIntrinsicRatioInformation(intrinsicSize, intrins
icRatio, isPercentageIntrinsicSize); | 278 contentRenderer->computeIntrinsicRatioInformation(intrinsicSize, intrins
icRatio); |
279 if (intrinsicRatio) | |
280 ASSERT(!isPercentageIntrinsicSize); | |
281 | 279 |
282 // Handle zoom & vertical writing modes here, as the embedded document d
oesn't know about them. | 280 // Handle zoom & vertical writing modes here, as the embedded document d
oesn't know about them. |
283 if (!isPercentageIntrinsicSize) { | 281 intrinsicSize.scale(style()->effectiveZoom()); |
284 intrinsicSize.scale(style()->effectiveZoom()); | 282 if (isRenderImage()) |
285 if (isRenderImage()) | 283 intrinsicSize.scale(toRenderImage(this)->imageDevicePixelRatio()); |
286 intrinsicSize.scale(toRenderImage(this)->imageDevicePixelRatio()
); | |
287 } | |
288 | |
289 if (rendererHasAspectRatio(this) && isPercentageIntrinsicSize) | |
290 intrinsicRatio = 1; | |
291 | 284 |
292 // Update our intrinsic size to match what the content renderer has comp
uted, so that when we | 285 // Update our intrinsic size to match what the content renderer has comp
uted, so that when we |
293 // constrain the size below, the correct intrinsic size will be obtained
for comparison against | 286 // constrain the size below, the correct intrinsic size will be obtained
for comparison against |
294 // min and max widths. | 287 // min and max widths. |
295 if (intrinsicRatio && !isPercentageIntrinsicSize && !intrinsicSize.isEmp
ty()) | 288 if (intrinsicRatio && !intrinsicSize.isEmpty()) |
296 m_intrinsicSize = LayoutSize(intrinsicSize); | 289 m_intrinsicSize = LayoutSize(intrinsicSize); |
297 | 290 |
298 if (!isHorizontalWritingMode()) { | 291 if (!isHorizontalWritingMode()) { |
299 if (intrinsicRatio) | 292 if (intrinsicRatio) |
300 intrinsicRatio = 1 / intrinsicRatio; | 293 intrinsicRatio = 1 / intrinsicRatio; |
301 intrinsicSize = intrinsicSize.transposedSize(); | 294 intrinsicSize = intrinsicSize.transposedSize(); |
302 } | 295 } |
303 } else { | 296 } else { |
304 computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercen
tageIntrinsicSize); | 297 computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio); |
305 if (intrinsicRatio) { | 298 if (intrinsicRatio && !intrinsicSize.isEmpty()) |
306 ASSERT(!isPercentageIntrinsicSize); | 299 m_intrinsicSize = LayoutSize(isHorizontalWritingMode() ? intrinsicSi
ze : intrinsicSize.transposedSize()); |
307 if (!intrinsicSize.isEmpty()) | |
308 m_intrinsicSize = LayoutSize(isHorizontalWritingMode() ? intrins
icSize : intrinsicSize.transposedSize()); | |
309 } | |
310 } | 300 } |
311 | 301 |
312 // Now constrain the intrinsic size along each axis according to minimum and
maximum width/heights along the | 302 // Now constrain the intrinsic size along each axis according to minimum and
maximum width/heights along the |
313 // opposite axis. So for example a maximum width that shrinks our width will
result in the height we compute here | 303 // opposite axis. So for example a maximum width that shrinks our width will
result in the height we compute here |
314 // having to shrink in order to preserve the aspect ratio. Because we comput
e these values independently along | 304 // having to shrink in order to preserve the aspect ratio. Because we comput
e these values independently along |
315 // each axis, the final returned size may in fact not preserve the aspect ra
tio. | 305 // each axis, the final returned size may in fact not preserve the aspect ra
tio. |
316 // FIXME: In the long term, it might be better to just return this code more
to the way it used to be before this | 306 // FIXME: In the long term, it might be better to just return this code more
to the way it used to be before this |
317 // function was added, since all it has done is make the code more unclear. | 307 // function was added, since all it has done is make the code more unclear. |
318 constrainedSize = intrinsicSize; | 308 constrainedSize = intrinsicSize; |
319 if (intrinsicRatio && !isPercentageIntrinsicSize && !intrinsicSize.isEmpty()
&& style()->logicalWidth().isAuto() && style()->logicalHeight().isAuto()) { | 309 if (intrinsicRatio && !intrinsicSize.isEmpty() && style()->logicalWidth().is
Auto() && style()->logicalHeight().isAuto()) { |
320 // We can't multiply or divide by 'intrinsicRatio' here, it breaks tests
, like fast/images/zoomed-img-size.html, which | 310 // We can't multiply or divide by 'intrinsicRatio' here, it breaks tests
, like fast/images/zoomed-img-size.html, which |
321 // can only be fixed once subpixel precision is available for things lik
e intrinsicWidth/Height - which include zoom! | 311 // can only be fixed once subpixel precision is available for things lik
e intrinsicWidth/Height - which include zoom! |
322 constrainedSize.setWidth(RenderBox::computeReplacedLogicalHeight() * int
rinsicSize.width() / intrinsicSize.height()); | 312 constrainedSize.setWidth(RenderBox::computeReplacedLogicalHeight() * int
rinsicSize.width() / intrinsicSize.height()); |
323 constrainedSize.setHeight(RenderBox::computeReplacedLogicalWidth() * int
rinsicSize.height() / intrinsicSize.width()); | 313 constrainedSize.setHeight(RenderBox::computeReplacedLogicalWidth() * int
rinsicSize.height() / intrinsicSize.width()); |
324 } | 314 } |
325 } | 315 } |
326 | 316 |
327 LayoutRect RenderReplaced::replacedContentRect(const LayoutSize* overriddenIntri
nsicSize) const | 317 LayoutRect RenderReplaced::replacedContentRect(const LayoutSize* overriddenIntri
nsicSize) const |
328 { | 318 { |
329 LayoutRect contentRect = contentBoxRect(); | 319 LayoutRect contentRect = contentBoxRect(); |
(...skipping 27 matching lines...) Expand all Loading... |
357 ASSERT_NOT_REACHED(); | 347 ASSERT_NOT_REACHED(); |
358 } | 348 } |
359 | 349 |
360 LayoutUnit xOffset = minimumValueForLength(style()->objectPosition().x(), co
ntentRect.width() - finalRect.width()); | 350 LayoutUnit xOffset = minimumValueForLength(style()->objectPosition().x(), co
ntentRect.width() - finalRect.width()); |
361 LayoutUnit yOffset = minimumValueForLength(style()->objectPosition().y(), co
ntentRect.height() - finalRect.height()); | 351 LayoutUnit yOffset = minimumValueForLength(style()->objectPosition().y(), co
ntentRect.height() - finalRect.height()); |
362 finalRect.move(xOffset, yOffset); | 352 finalRect.move(xOffset, yOffset); |
363 | 353 |
364 return finalRect; | 354 return finalRect; |
365 } | 355 } |
366 | 356 |
367 void RenderReplaced::computeIntrinsicRatioInformation(FloatSize& intrinsicSize,
double& intrinsicRatio, bool& isPercentageIntrinsicSize) const | 357 void RenderReplaced::computeIntrinsicRatioInformation(FloatSize& intrinsicSize,
double& intrinsicRatio) const |
368 { | 358 { |
369 // If there's an embeddedContentBox() of a remote, referenced document avail
able, this code-path should never be used. | 359 // If there's an embeddedContentBox() of a remote, referenced document avail
able, this code-path should never be used. |
370 ASSERT(!embeddedContentBox()); | 360 ASSERT(!embeddedContentBox()); |
371 isPercentageIntrinsicSize = false; | |
372 intrinsicSize = FloatSize(intrinsicLogicalWidth().toFloat(), intrinsicLogica
lHeight().toFloat()); | 361 intrinsicSize = FloatSize(intrinsicLogicalWidth().toFloat(), intrinsicLogica
lHeight().toFloat()); |
373 | 362 |
374 // Figure out if we need to compute an intrinsic ratio. | 363 // Figure out if we need to compute an intrinsic ratio. |
375 if (intrinsicSize.isEmpty() || !rendererHasAspectRatio(this)) | 364 if (intrinsicSize.isEmpty() || !rendererHasAspectRatio(this)) |
376 return; | 365 return; |
377 | 366 |
378 intrinsicRatio = intrinsicSize.width() / intrinsicSize.height(); | 367 intrinsicRatio = intrinsicSize.width() / intrinsicSize.height(); |
379 } | 368 } |
380 | 369 |
381 LayoutUnit RenderReplaced::computeReplacedLogicalWidth(ShouldComputePreferred sh
ouldComputePreferred) const | 370 LayoutUnit RenderReplaced::computeReplacedLogicalWidth(ShouldComputePreferred sh
ouldComputePreferred) const |
382 { | 371 { |
383 if (style()->logicalWidth().isSpecified() || style()->logicalWidth().isIntri
nsic()) | 372 if (style()->logicalWidth().isSpecified() || style()->logicalWidth().isIntri
nsic()) |
384 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedL
ogicalWidthUsing(style()->logicalWidth()), shouldComputePreferred); | 373 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedL
ogicalWidthUsing(style()->logicalWidth()), shouldComputePreferred); |
385 | 374 |
386 RenderBox* contentRenderer = embeddedContentBox(); | 375 RenderBox* contentRenderer = embeddedContentBox(); |
387 | 376 |
388 // 10.3.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html
#inline-replaced-width | 377 // 10.3.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html
#inline-replaced-width |
389 bool isPercentageIntrinsicSize = false; | |
390 double intrinsicRatio = 0; | 378 double intrinsicRatio = 0; |
391 FloatSize constrainedSize; | 379 FloatSize constrainedSize; |
392 computeAspectRatioInformationForRenderBox(contentRenderer, constrainedSize,
intrinsicRatio, isPercentageIntrinsicSize); | 380 computeAspectRatioInformationForRenderBox(contentRenderer, constrainedSize,
intrinsicRatio); |
393 | 381 |
394 if (style()->logicalWidth().isAuto()) { | 382 if (style()->logicalWidth().isAuto()) { |
395 bool heightIsAuto = style()->logicalHeight().isAuto(); | 383 bool computedHeightIsAuto = hasAutoHeightOrContainingBlockWithAutoHeight
(); |
396 bool hasIntrinsicWidth = !isPercentageIntrinsicSize && constrainedSize.w
idth() > 0; | 384 bool hasIntrinsicWidth = constrainedSize.width() > 0; |
397 | 385 |
398 // If 'height' and 'width' both have computed values of 'auto' and the e
lement also has an intrinsic width, then that intrinsic width is the used value
of 'width'. | 386 // If 'height' and 'width' both have computed values of 'auto' and the e
lement also has an intrinsic width, then that intrinsic width is the used value
of 'width'. |
399 if (heightIsAuto && hasIntrinsicWidth) | 387 if (computedHeightIsAuto && hasIntrinsicWidth) |
400 return computeReplacedLogicalWidthRespectingMinMaxWidth(constrainedS
ize.width(), shouldComputePreferred); | 388 return computeReplacedLogicalWidthRespectingMinMaxWidth(constrainedS
ize.width(), shouldComputePreferred); |
401 | 389 |
402 bool hasIntrinsicHeight = !isPercentageIntrinsicSize && constrainedSize.
height() > 0; | 390 bool hasIntrinsicHeight = constrainedSize.height() > 0; |
403 if (intrinsicRatio || isPercentageIntrinsicSize) { | 391 if (intrinsicRatio) { |
404 // If 'height' and 'width' both have computed values of 'auto' and t
he element has no intrinsic width, but does have an intrinsic height and intrins
ic ratio; | 392 // If 'height' and 'width' both have computed values of 'auto' and t
he element has no intrinsic width, but does have an intrinsic height and intrins
ic ratio; |
405 // or if 'width' has a computed value of 'auto', 'height' has some o
ther computed value, and the element does have an intrinsic ratio; then the used
value | 393 // or if 'width' has a computed value of 'auto', 'height' has some o
ther computed value, and the element does have an intrinsic ratio; then the used
value |
406 // of 'width' is: (used height) * (intrinsic ratio) | 394 // of 'width' is: (used height) * (intrinsic ratio) |
407 if (intrinsicRatio && ((heightIsAuto && !hasIntrinsicWidth && hasInt
rinsicHeight) || !heightIsAuto)) { | 395 if (intrinsicRatio && ((computedHeightIsAuto && !hasIntrinsicWidth &
& hasIntrinsicHeight) || !computedHeightIsAuto)) { |
408 LayoutUnit logicalHeight = computeReplacedLogicalHeight(); | 396 LayoutUnit logicalHeight = computeReplacedLogicalHeight(); |
409 return computeReplacedLogicalWidthRespectingMinMaxWidth(roundToI
nt(round(logicalHeight * intrinsicRatio)), shouldComputePreferred); | 397 return computeReplacedLogicalWidthRespectingMinMaxWidth(roundToI
nt(round(logicalHeight * intrinsicRatio)), shouldComputePreferred); |
410 } | 398 } |
411 | 399 |
412 // 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 | 400 // 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 |
413 // '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 | 401 // '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 |
414 // the used value of 'width' is calculated from the constraint equat
ion used for block-level, non-replaced elements in normal flow. | 402 // the used value of 'width' is calculated from the constraint equat
ion used for block-level, non-replaced elements in normal flow. |
415 if (heightIsAuto && !hasIntrinsicWidth && !hasIntrinsicHeight) { | 403 if (computedHeightIsAuto && !hasIntrinsicWidth && !hasIntrinsicHeigh
t) { |
416 // The aforementioned 'constraint equation' used for block-level
, non-replaced elements in normal flow: | 404 // The aforementioned 'constraint equation' used for block-level
, non-replaced elements in normal flow: |
417 // 'margin-left' + 'border-left-width' + 'padding-left' + 'width
' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containin
g block | 405 // 'margin-left' + 'border-left-width' + 'padding-left' + 'width
' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containin
g block |
418 LayoutUnit logicalWidth; | 406 LayoutUnit logicalWidth; |
419 // FIXME: This walking up the containgBlock chain to find the fi
rst one with a specified width is bonkers. | 407 // FIXME: This walking up the containgBlock chain to find the fi
rst one with a specified width is bonkers. |
420 // If nothing else, it requires making sure that computeReplaced
LogicalWidthRespectingMinMaxWidth cannot | 408 // If nothing else, it requires making sure that computeReplaced
LogicalWidthRespectingMinMaxWidth cannot |
421 // depend on the width of the replaced element or we infinite lo
op. Right now we do that in | 409 // depend on the width of the replaced element or we infinite lo
op. Right now we do that in |
422 // firstContainingBlockWithLogicalWidth by checking that width/m
in-width/max-width are all specified. | 410 // firstContainingBlockWithLogicalWidth by checking that width/m
in-width/max-width are all specified. |
423 // | 411 // |
424 // Firefox 27 seems to only do this if the <svg> has a viewbox. | 412 // Firefox 27 seems to only do this if the <svg> has a viewbox. |
425 if (RenderBlock* blockWithWidth = firstContainingBlockWithLogica
lWidth(this)) { | 413 if (RenderBlock* blockWithWidth = firstContainingBlockWithLogica
lWidth(this)) { |
426 logicalWidth = blockWithWidth->computeReplacedLogicalWidthRe
spectingMinMaxWidth(blockWithWidth->computeReplacedLogicalWidthUsing(blockWithWi
dth->style()->logicalWidth()), shouldComputePreferred); | 414 logicalWidth = blockWithWidth->computeReplacedLogicalWidthRe
spectingMinMaxWidth(blockWithWidth->computeReplacedLogicalWidthUsing(blockWithWi
dth->style()->logicalWidth()), shouldComputePreferred); |
427 } else { | 415 } else { |
428 // FIXME: If shouldComputePreferred == ComputePreferred, the
n we're reading this during preferred width | 416 // FIXME: If shouldComputePreferred == ComputePreferred, the
n we're reading this during preferred width |
429 // computation, at which point this is reading stale data fr
om a previous layout. | 417 // computation, at which point this is reading stale data fr
om a previous layout. |
430 logicalWidth = containingBlock()->availableLogicalWidth(); | 418 logicalWidth = containingBlock()->availableLogicalWidth(); |
431 } | 419 } |
432 | 420 |
433 // This solves above equation for 'width' (== logicalWidth). | 421 // This solves above equation for 'width' (== logicalWidth). |
434 LayoutUnit marginStart = minimumValueForLength(style()->marginSt
art(), logicalWidth); | 422 LayoutUnit marginStart = minimumValueForLength(style()->marginSt
art(), logicalWidth); |
435 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(
), logicalWidth); | 423 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(
), logicalWidth); |
436 logicalWidth = max<LayoutUnit>(0, logicalWidth - (marginStart +
marginEnd + (width() - clientWidth()))); | 424 logicalWidth = max<LayoutUnit>(0, logicalWidth - (marginStart +
marginEnd + (width() - clientWidth()))); |
437 if (isPercentageIntrinsicSize) | |
438 logicalWidth = logicalWidth * constrainedSize.width() / 100; | |
439 return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalW
idth, shouldComputePreferred); | 425 return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalW
idth, shouldComputePreferred); |
440 } | 426 } |
441 } | 427 } |
442 | 428 |
443 // Otherwise, if 'width' has a computed value of 'auto', and the element
has an intrinsic width, then that intrinsic width is the used value of 'width'. | 429 // Otherwise, if 'width' has a computed value of 'auto', and the element
has an intrinsic width, then that intrinsic width is the used value of 'width'. |
444 if (hasIntrinsicWidth) | 430 if (hasIntrinsicWidth) |
445 return computeReplacedLogicalWidthRespectingMinMaxWidth(constrainedS
ize.width(), shouldComputePreferred); | 431 return computeReplacedLogicalWidthRespectingMinMaxWidth(constrainedS
ize.width(), shouldComputePreferred); |
446 | 432 |
447 // Otherwise, if 'width' has a computed value of 'auto', but none of the
conditions above are met, then the used value of 'width' becomes 300px. If 300p
x is too | 433 // Otherwise, if 'width' has a computed value of 'auto', but none of the
conditions above are met, then the used value of 'width' becomes 300px. If 300p
x is too |
448 // wide to fit the device, UAs should use the width of the largest recta
ngle that has a 2:1 ratio and fits the device instead. | 434 // wide to fit the device, UAs should use the width of the largest recta
ngle that has a 2:1 ratio and fits the device instead. |
449 // Note: We fall through and instead return intrinsicLogicalWidth() here
- to preserve existing WebKit behavior, which might or might not be correct, or
desired. | 435 // Note: We fall through and instead return intrinsicLogicalWidth() here
- to preserve existing WebKit behavior, which might or might not be correct, or
desired. |
450 // Changing this to return cDefaultWidth, will affect lots of test resul
ts. Eg. some tests assume that a blank <img> tag (which implies width/height=aut
o) | 436 // Changing this to return cDefaultWidth, will affect lots of test resul
ts. Eg. some tests assume that a blank <img> tag (which implies width/height=aut
o) |
451 // has no intrinsic size, which is wrong per CSS 2.1, but matches our be
havior since a long time. | 437 // has no intrinsic size, which is wrong per CSS 2.1, but matches our be
havior since a long time. |
452 } | 438 } |
453 | 439 |
454 return computeReplacedLogicalWidthRespectingMinMaxWidth(intrinsicLogicalWidt
h(), shouldComputePreferred); | 440 return computeReplacedLogicalWidthRespectingMinMaxWidth(intrinsicLogicalWidt
h(), shouldComputePreferred); |
455 } | 441 } |
456 | 442 |
457 LayoutUnit RenderReplaced::computeReplacedLogicalHeight() const | 443 LayoutUnit RenderReplaced::computeReplacedLogicalHeight() const |
458 { | 444 { |
459 // 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/vi
sudet.html#propdef-height | 445 // 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/vi
sudet.html#propdef-height |
460 if (hasReplacedLogicalHeight()) | 446 if (hasReplacedLogicalHeight()) |
461 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplace
dLogicalHeightUsing(style()->logicalHeight())); | 447 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplace
dLogicalHeightUsing(style()->logicalHeight())); |
462 | 448 |
463 RenderBox* contentRenderer = embeddedContentBox(); | 449 RenderBox* contentRenderer = embeddedContentBox(); |
464 | 450 |
465 // 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html
#inline-replaced-height | 451 // 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html
#inline-replaced-height |
466 bool isPercentageIntrinsicSize = false; | |
467 double intrinsicRatio = 0; | 452 double intrinsicRatio = 0; |
468 FloatSize constrainedSize; | 453 FloatSize constrainedSize; |
469 computeAspectRatioInformationForRenderBox(contentRenderer, constrainedSize,
intrinsicRatio, isPercentageIntrinsicSize); | 454 computeAspectRatioInformationForRenderBox(contentRenderer, constrainedSize,
intrinsicRatio); |
470 | 455 |
471 bool widthIsAuto = style()->logicalWidth().isAuto(); | 456 bool widthIsAuto = style()->logicalWidth().isAuto(); |
472 bool hasIntrinsicHeight = !isPercentageIntrinsicSize && constrainedSize.heig
ht() > 0; | 457 bool hasIntrinsicHeight = constrainedSize.height() > 0; |
473 | 458 |
474 // If 'height' and 'width' both have computed values of 'auto' and the eleme
nt also has an intrinsic height, then that intrinsic height is the used value of
'height'. | 459 // If 'height' and 'width' both have computed values of 'auto' and the eleme
nt also has an intrinsic height, then that intrinsic height is the used value of
'height'. |
475 if (widthIsAuto && hasIntrinsicHeight) | 460 if (widthIsAuto && hasIntrinsicHeight) |
476 return computeReplacedLogicalHeightRespectingMinMaxHeight(constrainedSiz
e.height()); | 461 return computeReplacedLogicalHeightRespectingMinMaxHeight(constrainedSiz
e.height()); |
477 | 462 |
478 // Otherwise, if 'height' has a computed value of 'auto', and the element ha
s an intrinsic ratio then the used value of 'height' is: | 463 // Otherwise, if 'height' has a computed value of 'auto', and the element ha
s an intrinsic ratio then the used value of 'height' is: |
479 // (used width) / (intrinsic ratio) | 464 // (used width) / (intrinsic ratio) |
480 if (intrinsicRatio) | 465 if (intrinsicRatio) |
481 return computeReplacedLogicalHeightRespectingMinMaxHeight(roundToInt(rou
nd(availableLogicalWidth() / intrinsicRatio))); | 466 return computeReplacedLogicalHeightRespectingMinMaxHeight(roundToInt(rou
nd(availableLogicalWidth() / intrinsicRatio))); |
482 | 467 |
(...skipping 16 matching lines...) Expand all Loading... |
499 ASSERT(preferredLogicalWidthsDirty()); | 484 ASSERT(preferredLogicalWidthsDirty()); |
500 | 485 |
501 // We cannot resolve any percent logical width here as the available logical | 486 // We cannot resolve any percent logical width here as the available logical |
502 // width may not be set on our containing block. | 487 // width may not be set on our containing block. |
503 if (style()->logicalWidth().isPercent()) | 488 if (style()->logicalWidth().isPercent()) |
504 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferred
LogicalWidth); | 489 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferred
LogicalWidth); |
505 else | 490 else |
506 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = computeReplace
dLogicalWidth(ComputePreferred); | 491 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = computeReplace
dLogicalWidth(ComputePreferred); |
507 | 492 |
508 RenderStyle* styleToUse = style(); | 493 RenderStyle* styleToUse = style(); |
509 if (styleToUse->logicalWidth().isPercent() || styleToUse->logicalMaxWidth().
isPercent() || hasRelativeIntrinsicLogicalWidth()) | 494 if (styleToUse->logicalWidth().isPercent() || styleToUse->logicalMaxWidth().
isPercent()) |
510 m_minPreferredLogicalWidth = 0; | 495 m_minPreferredLogicalWidth = 0; |
511 | 496 |
512 if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth()
.value() > 0) { | 497 if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth()
.value() > 0) { |
513 m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustConte
ntBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); | 498 m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustConte
ntBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); |
514 m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustConte
ntBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); | 499 m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustConte
ntBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); |
515 } | 500 } |
516 | 501 |
517 if (styleToUse->logicalMaxWidth().isFixed()) { | 502 if (styleToUse->logicalMaxWidth().isFixed()) { |
518 m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustConte
ntBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value())); | 503 m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustConte
ntBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value())); |
519 m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, adjustConte
ntBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value())); | 504 m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, adjustConte
ntBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value())); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 // FIXME: layoutDelta needs to be applied in parts before/after transfor
ms and | 616 // FIXME: layoutDelta needs to be applied in parts before/after transfor
ms and |
632 // repaint containers. https://bugs.webkit.org/show_bug.cgi?id=23308 | 617 // repaint containers. https://bugs.webkit.org/show_bug.cgi?id=23308 |
633 r.move(v->layoutDelta()); | 618 r.move(v->layoutDelta()); |
634 } | 619 } |
635 | 620 |
636 computeRectForRepaint(repaintContainer, r); | 621 computeRectForRepaint(repaintContainer, r); |
637 return r; | 622 return r; |
638 } | 623 } |
639 | 624 |
640 } | 625 } |
OLD | NEW |