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 14 matching lines...) Expand all Loading... |
25 #include "core/layout/LayoutReplaced.h" | 25 #include "core/layout/LayoutReplaced.h" |
26 | 26 |
27 #include "core/editing/PositionWithAffinity.h" | 27 #include "core/editing/PositionWithAffinity.h" |
28 #include "core/layout/LayoutAnalyzer.h" | 28 #include "core/layout/LayoutAnalyzer.h" |
29 #include "core/layout/LayoutBlock.h" | 29 #include "core/layout/LayoutBlock.h" |
30 #include "core/layout/LayoutImage.h" | 30 #include "core/layout/LayoutImage.h" |
31 #include "core/layout/LayoutView.h" | 31 #include "core/layout/LayoutView.h" |
32 #include "core/paint/PaintInfo.h" | 32 #include "core/paint/PaintInfo.h" |
33 #include "core/paint/PaintLayer.h" | 33 #include "core/paint/PaintLayer.h" |
34 #include "core/paint/ReplacedPainter.h" | 34 #include "core/paint/ReplacedPainter.h" |
| 35 #include "core/svg/SVGSVGElement.h" |
35 #include "platform/LengthFunctions.h" | 36 #include "platform/LengthFunctions.h" |
36 | 37 |
37 namespace blink { | 38 namespace blink { |
38 | 39 |
39 const int LayoutReplaced::defaultWidth = 300; | 40 const int LayoutReplaced::defaultWidth = 300; |
40 const int LayoutReplaced::defaultHeight = 150; | 41 const int LayoutReplaced::defaultHeight = 150; |
41 | 42 |
42 LayoutReplaced::LayoutReplaced(Element* element) | 43 LayoutReplaced::LayoutReplaced(Element* element) |
43 : LayoutBox(element) | 44 : LayoutBox(element) |
44 , m_intrinsicSize(defaultWidth, defaultHeight) | 45 , m_intrinsicSize(defaultWidth, defaultHeight) |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 ASSERT(!embeddedContentBox()); | 260 ASSERT(!embeddedContentBox()); |
260 intrinsicSize = FloatSize(intrinsicLogicalWidth().toFloat(), intrinsicLogica
lHeight().toFloat()); | 261 intrinsicSize = FloatSize(intrinsicLogicalWidth().toFloat(), intrinsicLogica
lHeight().toFloat()); |
261 | 262 |
262 // Figure out if we need to compute an intrinsic ratio. | 263 // Figure out if we need to compute an intrinsic ratio. |
263 if (intrinsicSize.isEmpty() || !layoutObjectHasAspectRatio(this)) | 264 if (intrinsicSize.isEmpty() || !layoutObjectHasAspectRatio(this)) |
264 return; | 265 return; |
265 | 266 |
266 intrinsicRatio = intrinsicSize.width() / intrinsicSize.height(); | 267 intrinsicRatio = intrinsicSize.width() / intrinsicSize.height(); |
267 } | 268 } |
268 | 269 |
| 270 static bool hasIntrinsicWidthForLayoutBox(LayoutBox* layoutObject) |
| 271 { |
| 272 if (layoutObject && layoutObject->isSVGRoot()) { |
| 273 SVGSVGElement* svg = toSVGSVGElement(layoutObject->node()); |
| 274 ASSERT(svg); |
| 275 return svg->hasIntrinsicWidth(); |
| 276 } |
| 277 |
| 278 return false; |
| 279 } |
| 280 |
| 281 static bool hasIntrinsicHeightForLayoutBox(LayoutBox* layoutObject) |
| 282 { |
| 283 if (layoutObject && layoutObject->isSVGRoot()) { |
| 284 SVGSVGElement* svg = toSVGSVGElement(layoutObject->node()); |
| 285 ASSERT(svg); |
| 286 return svg->hasIntrinsicHeight(); |
| 287 } |
| 288 |
| 289 return false; |
| 290 } |
| 291 |
269 LayoutUnit LayoutReplaced::computeReplacedLogicalWidth(ShouldComputePreferred sh
ouldComputePreferred) const | 292 LayoutUnit LayoutReplaced::computeReplacedLogicalWidth(ShouldComputePreferred sh
ouldComputePreferred) const |
270 { | 293 { |
271 if (style()->logicalWidth().isSpecified() || style()->logicalWidth().isIntri
nsic()) | 294 if (style()->logicalWidth().isSpecified() || style()->logicalWidth().isIntri
nsic()) |
272 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedL
ogicalWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePre
ferred); | 295 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedL
ogicalWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePre
ferred); |
273 | 296 |
274 LayoutBox* contentLayoutObject = embeddedContentBox(); | 297 LayoutBox* contentLayoutObject = embeddedContentBox(); |
275 | 298 |
276 // 10.3.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html
#inline-replaced-width | 299 // 10.3.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html
#inline-replaced-width |
277 double intrinsicRatio = 0; | 300 double intrinsicRatio = 0; |
278 FloatSize constrainedSize; | 301 FloatSize constrainedSize; |
279 computeAspectRatioInformationForLayoutBox(contentLayoutObject, constrainedSi
ze, intrinsicRatio); | 302 computeAspectRatioInformationForLayoutBox(contentLayoutObject, constrainedSi
ze, intrinsicRatio); |
280 | 303 |
281 if (style()->logicalWidth().isAuto()) { | 304 if (style()->logicalWidth().isAuto()) { |
282 bool computedHeightIsAuto = hasAutoHeightOrContainingBlockWithAutoHeight
(); | 305 bool computedHeightIsAuto = hasAutoHeightOrContainingBlockWithAutoHeight
(); |
283 bool hasIntrinsicWidth = constrainedSize.width() > 0; | 306 // TODO(shanmuga.m@samsung.com): hasIntrinsicWidth/Height information sh
ould be obtained |
| 307 // from LayoutBox::computeIntrinsicRatioInformation(). |
| 308 bool hasIntrinsicWidth = constrainedSize.width() > 0 || hasIntrinsicWidt
hForLayoutBox(contentLayoutObject); |
284 | 309 |
285 // 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'. | 310 // 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'. |
286 if (computedHeightIsAuto && hasIntrinsicWidth) | 311 if (computedHeightIsAuto && hasIntrinsicWidth) |
287 return computeReplacedLogicalWidthRespectingMinMaxWidth(constrainedS
ize.width(), shouldComputePreferred); | 312 return computeReplacedLogicalWidthRespectingMinMaxWidth(constrainedS
ize.width(), shouldComputePreferred); |
288 | 313 |
289 bool hasIntrinsicHeight = constrainedSize.height() > 0; | 314 bool hasIntrinsicHeight = constrainedSize.height() > 0 || hasIntrinsicHe
ightForLayoutBox(contentLayoutObject); |
| 315 |
290 if (intrinsicRatio) { | 316 if (intrinsicRatio) { |
291 // 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; | 317 // 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; |
292 // 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 | 318 // 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 |
293 // of 'width' is: (used height) * (intrinsic ratio) | 319 // of 'width' is: (used height) * (intrinsic ratio) |
294 if (intrinsicRatio && ((computedHeightIsAuto && !hasIntrinsicWidth &
& hasIntrinsicHeight) || !computedHeightIsAuto)) { | 320 if (intrinsicRatio && ((computedHeightIsAuto && !hasIntrinsicWidth &
& hasIntrinsicHeight) || !computedHeightIsAuto)) { |
295 LayoutUnit logicalHeight = computeReplacedLogicalHeight(); | 321 LayoutUnit logicalHeight = computeReplacedLogicalHeight(); |
296 return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalH
eight * intrinsicRatio, shouldComputePreferred); | 322 return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalH
eight * intrinsicRatio, shouldComputePreferred); |
297 } | 323 } |
298 | 324 |
299 // 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 | 325 // 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 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplace
dLogicalHeightUsing(MainOrPreferredSize, style()->logicalHeight())); | 361 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplace
dLogicalHeightUsing(MainOrPreferredSize, style()->logicalHeight())); |
336 | 362 |
337 LayoutBox* contentLayoutObject = embeddedContentBox(); | 363 LayoutBox* contentLayoutObject = embeddedContentBox(); |
338 | 364 |
339 // 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html
#inline-replaced-height | 365 // 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html
#inline-replaced-height |
340 double intrinsicRatio = 0; | 366 double intrinsicRatio = 0; |
341 FloatSize constrainedSize; | 367 FloatSize constrainedSize; |
342 computeAspectRatioInformationForLayoutBox(contentLayoutObject, constrainedSi
ze, intrinsicRatio); | 368 computeAspectRatioInformationForLayoutBox(contentLayoutObject, constrainedSi
ze, intrinsicRatio); |
343 | 369 |
344 bool widthIsAuto = style()->logicalWidth().isAuto(); | 370 bool widthIsAuto = style()->logicalWidth().isAuto(); |
345 bool hasIntrinsicHeight = constrainedSize.height() > 0; | 371 // TODO(shanmuga.m@samsung.com): hasIntrinsicWidth/Height information should
be obtained |
| 372 // from LayoutBox::computeIntrinsicRatioInformation(). |
| 373 bool hasIntrinsicHeight = constrainedSize.height() > 0 || hasIntrinsicHeight
ForLayoutBox(contentLayoutObject); |
346 | 374 |
347 // 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'. | 375 // 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'. |
348 if (widthIsAuto && hasIntrinsicHeight) | 376 if (widthIsAuto && hasIntrinsicHeight) |
349 return computeReplacedLogicalHeightRespectingMinMaxHeight(constrainedSiz
e.height()); | 377 return computeReplacedLogicalHeightRespectingMinMaxHeight(constrainedSiz
e.height()); |
350 | 378 |
351 // Otherwise, if 'height' has a computed value of 'auto', and the element ha
s an intrinsic ratio then the used value of 'height' is: | 379 // Otherwise, if 'height' has a computed value of 'auto', and the element ha
s an intrinsic ratio then the used value of 'height' is: |
352 // (used width) / (intrinsic ratio) | 380 // (used width) / (intrinsic ratio) |
353 if (intrinsicRatio) | 381 if (intrinsicRatio) |
354 return computeReplacedLogicalHeightRespectingMinMaxHeight(availableLogic
alWidth() / intrinsicRatio); | 382 return computeReplacedLogicalHeightRespectingMinMaxHeight(availableLogic
alWidth() / intrinsicRatio); |
355 | 383 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 // We only include the space below the baseline in our layer's cached paint
invalidation rect if the | 498 // We only include the space below the baseline in our layer's cached paint
invalidation rect if the |
471 // image is selected. Since the selection state has changed update the rect. | 499 // image is selected. Since the selection state has changed update the rect. |
472 if (hasLayer()) | 500 if (hasLayer()) |
473 setPreviousPaintInvalidationRect(boundsRectForPaintInvalidation(containe
rForPaintInvalidation())); | 501 setPreviousPaintInvalidationRect(boundsRectForPaintInvalidation(containe
rForPaintInvalidation())); |
474 | 502 |
475 if (canUpdateSelectionOnRootLineBoxes()) | 503 if (canUpdateSelectionOnRootLineBoxes()) |
476 inlineBoxWrapper()->root().setHasSelectedChildren(state != SelectionNone
); | 504 inlineBoxWrapper()->root().setHasSelectedChildren(state != SelectionNone
); |
477 } | 505 } |
478 | 506 |
479 } | 507 } |
OLD | NEW |