| 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 16 matching lines...) Expand all Loading... |
| 27 #include "core/rendering/GraphicsContextAnnotator.h" | 27 #include "core/rendering/GraphicsContextAnnotator.h" |
| 28 #include "core/rendering/LayoutRepainter.h" | 28 #include "core/rendering/LayoutRepainter.h" |
| 29 #include "core/rendering/RenderBlock.h" | 29 #include "core/rendering/RenderBlock.h" |
| 30 #include "core/rendering/RenderImage.h" | 30 #include "core/rendering/RenderImage.h" |
| 31 #include "core/rendering/RenderLayer.h" | 31 #include "core/rendering/RenderLayer.h" |
| 32 #include "core/rendering/RenderView.h" | 32 #include "core/rendering/RenderView.h" |
| 33 #include "platform/LengthFunctions.h" | 33 #include "platform/LengthFunctions.h" |
| 34 #include "platform/RuntimeEnabledFeatures.h" | 34 #include "platform/RuntimeEnabledFeatures.h" |
| 35 #include "platform/graphics/GraphicsContext.h" | 35 #include "platform/graphics/GraphicsContext.h" |
| 36 | 36 |
| 37 using namespace std; | |
| 38 | |
| 39 namespace WebCore { | 37 namespace WebCore { |
| 40 | 38 |
| 41 const int cDefaultWidth = 300; | 39 const int cDefaultWidth = 300; |
| 42 const int cDefaultHeight = 150; | 40 const int cDefaultHeight = 150; |
| 43 | 41 |
| 44 RenderReplaced::RenderReplaced(Element* element) | 42 RenderReplaced::RenderReplaced(Element* element) |
| 45 : RenderBox(element) | 43 : RenderBox(element) |
| 46 , m_intrinsicSize(cDefaultWidth, cDefaultHeight) | 44 , m_intrinsicSize(cDefaultWidth, cDefaultHeight) |
| 47 { | 45 { |
| 48 setReplaced(true); | 46 setReplaced(true); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 return false; | 189 return false; |
| 192 | 190 |
| 193 LayoutPoint adjustedPaintOffset = paintOffset + location(); | 191 LayoutPoint adjustedPaintOffset = paintOffset + location(); |
| 194 | 192 |
| 195 // Early exit if the element touches the edges. | 193 // Early exit if the element touches the edges. |
| 196 LayoutUnit top = adjustedPaintOffset.y() + visualOverflowRect().y(); | 194 LayoutUnit top = adjustedPaintOffset.y() + visualOverflowRect().y(); |
| 197 LayoutUnit bottom = adjustedPaintOffset.y() + visualOverflowRect().maxY(); | 195 LayoutUnit bottom = adjustedPaintOffset.y() + visualOverflowRect().maxY(); |
| 198 if (isSelected() && inlineBoxWrapper()) { | 196 if (isSelected() && inlineBoxWrapper()) { |
| 199 LayoutUnit selTop = paintOffset.y() + inlineBoxWrapper()->root().selecti
onTop(); | 197 LayoutUnit selTop = paintOffset.y() + inlineBoxWrapper()->root().selecti
onTop(); |
| 200 LayoutUnit selBottom = paintOffset.y() + selTop + inlineBoxWrapper()->ro
ot().selectionHeight(); | 198 LayoutUnit selBottom = paintOffset.y() + selTop + inlineBoxWrapper()->ro
ot().selectionHeight(); |
| 201 top = min(selTop, top); | 199 top = std::min(selTop, top); |
| 202 bottom = max(selBottom, bottom); | 200 bottom = std::max(selBottom, bottom); |
| 203 } | 201 } |
| 204 | 202 |
| 205 if (adjustedPaintOffset.x() + visualOverflowRect().x() >= paintInfo.rect.max
X() || adjustedPaintOffset.x() + visualOverflowRect().maxX() <= paintInfo.rect.x
()) | 203 if (adjustedPaintOffset.x() + visualOverflowRect().x() >= paintInfo.rect.max
X() || adjustedPaintOffset.x() + visualOverflowRect().maxX() <= paintInfo.rect.x
()) |
| 206 return false; | 204 return false; |
| 207 | 205 |
| 208 if (top >= paintInfo.rect.maxY() || bottom <= paintInfo.rect.y()) | 206 if (top >= paintInfo.rect.maxY() || bottom <= paintInfo.rect.y()) |
| 209 return false; | 207 return false; |
| 210 | 208 |
| 211 return true; | 209 return true; |
| 212 } | 210 } |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 logicalWidth = blockWithWidth->computeReplacedLogicalWidthRe
spectingMinMaxWidth(blockWithWidth->computeReplacedLogicalWidthUsing(blockWithWi
dth->style()->logicalWidth()), shouldComputePreferred); | 403 logicalWidth = blockWithWidth->computeReplacedLogicalWidthRe
spectingMinMaxWidth(blockWithWidth->computeReplacedLogicalWidthUsing(blockWithWi
dth->style()->logicalWidth()), shouldComputePreferred); |
| 406 } else { | 404 } else { |
| 407 // FIXME: If shouldComputePreferred == ComputePreferred, the
n we're reading this during preferred width | 405 // FIXME: If shouldComputePreferred == ComputePreferred, the
n we're reading this during preferred width |
| 408 // computation, at which point this is reading stale data fr
om a previous layout. | 406 // computation, at which point this is reading stale data fr
om a previous layout. |
| 409 logicalWidth = containingBlock()->availableLogicalWidth(); | 407 logicalWidth = containingBlock()->availableLogicalWidth(); |
| 410 } | 408 } |
| 411 | 409 |
| 412 // This solves above equation for 'width' (== logicalWidth). | 410 // This solves above equation for 'width' (== logicalWidth). |
| 413 LayoutUnit marginStart = minimumValueForLength(style()->marginSt
art(), logicalWidth); | 411 LayoutUnit marginStart = minimumValueForLength(style()->marginSt
art(), logicalWidth); |
| 414 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(
), logicalWidth); | 412 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(
), logicalWidth); |
| 415 logicalWidth = max<LayoutUnit>(0, logicalWidth - (marginStart +
marginEnd + (width() - clientWidth()))); | 413 logicalWidth = std::max<LayoutUnit>(0, logicalWidth - (marginSta
rt + marginEnd + (width() - clientWidth()))); |
| 416 return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalW
idth, shouldComputePreferred); | 414 return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalW
idth, shouldComputePreferred); |
| 417 } | 415 } |
| 418 } | 416 } |
| 419 | 417 |
| 420 // 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'. | 418 // 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'. |
| 421 if (hasIntrinsicWidth) | 419 if (hasIntrinsicWidth) |
| 422 return computeReplacedLogicalWidthRespectingMinMaxWidth(constrainedS
ize.width(), shouldComputePreferred); | 420 return computeReplacedLogicalWidthRespectingMinMaxWidth(constrainedS
ize.width(), shouldComputePreferred); |
| 423 | 421 |
| 424 // 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 | 422 // 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 |
| 425 // 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. | 423 // 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. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 if (style()->logicalWidth().isPercent()) | 477 if (style()->logicalWidth().isPercent()) |
| 480 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferred
LogicalWidth); | 478 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferred
LogicalWidth); |
| 481 else | 479 else |
| 482 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = computeReplace
dLogicalWidth(ComputePreferred); | 480 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = computeReplace
dLogicalWidth(ComputePreferred); |
| 483 | 481 |
| 484 RenderStyle* styleToUse = style(); | 482 RenderStyle* styleToUse = style(); |
| 485 if (styleToUse->logicalWidth().isPercent() || styleToUse->logicalMaxWidth().
isPercent()) | 483 if (styleToUse->logicalWidth().isPercent() || styleToUse->logicalMaxWidth().
isPercent()) |
| 486 m_minPreferredLogicalWidth = 0; | 484 m_minPreferredLogicalWidth = 0; |
| 487 | 485 |
| 488 if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth()
.value() > 0) { | 486 if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth()
.value() > 0) { |
| 489 m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustConte
ntBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); | 487 m_maxPreferredLogicalWidth = std::max(m_maxPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); |
| 490 m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustConte
ntBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); | 488 m_minPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value())); |
| 491 } | 489 } |
| 492 | 490 |
| 493 if (styleToUse->logicalMaxWidth().isFixed()) { | 491 if (styleToUse->logicalMaxWidth().isFixed()) { |
| 494 m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustConte
ntBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value())); | 492 m_maxPreferredLogicalWidth = std::min(m_maxPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value())); |
| 495 m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, adjustConte
ntBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value())); | 493 m_minPreferredLogicalWidth = std::min(m_minPreferredLogicalWidth, adjust
ContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value())); |
| 496 } | 494 } |
| 497 | 495 |
| 498 LayoutUnit borderAndPadding = borderAndPaddingLogicalWidth(); | 496 LayoutUnit borderAndPadding = borderAndPaddingLogicalWidth(); |
| 499 m_minPreferredLogicalWidth += borderAndPadding; | 497 m_minPreferredLogicalWidth += borderAndPadding; |
| 500 m_maxPreferredLogicalWidth += borderAndPadding; | 498 m_maxPreferredLogicalWidth += borderAndPadding; |
| 501 | 499 |
| 502 clearPreferredLogicalWidthsDirty(); | 500 clearPreferredLogicalWidthsDirty(); |
| 503 } | 501 } |
| 504 | 502 |
| 505 PositionWithAffinity RenderReplaced::positionForPoint(const LayoutPoint& point) | 503 PositionWithAffinity RenderReplaced::positionForPoint(const LayoutPoint& point) |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 // FIXME: layoutDelta needs to be applied in parts before/after transfor
ms and | 612 // FIXME: layoutDelta needs to be applied in parts before/after transfor
ms and |
| 615 // repaint containers. https://bugs.webkit.org/show_bug.cgi?id=23308 | 613 // repaint containers. https://bugs.webkit.org/show_bug.cgi?id=23308 |
| 616 r.move(v->layoutDelta()); | 614 r.move(v->layoutDelta()); |
| 617 } | 615 } |
| 618 | 616 |
| 619 mapRectToPaintInvalidationBacking(paintInvalidationContainer, r); | 617 mapRectToPaintInvalidationBacking(paintInvalidationContainer, r); |
| 620 return r; | 618 return r; |
| 621 } | 619 } |
| 622 | 620 |
| 623 } | 621 } |
| OLD | NEW |