| 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) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com) |
| 6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
| 8 * Copyright (C) 2010 Google Inc. All rights reserved. | 8 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. | 9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. |
| 10 * | 10 * |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 invalidatePaintAndMarkForLayoutIfNeeded(); | 131 invalidatePaintAndMarkForLayoutIfNeeded(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void LayoutImage::updateIntrinsicSizeIfNeeded(const LayoutSize& newSize) | 134 void LayoutImage::updateIntrinsicSizeIfNeeded(const LayoutSize& newSize) |
| 135 { | 135 { |
| 136 if (m_imageResource->errorOccurred() || !m_imageResource->hasImage()) | 136 if (m_imageResource->errorOccurred() || !m_imageResource->hasImage()) |
| 137 return; | 137 return; |
| 138 setIntrinsicSize(newSize); | 138 setIntrinsicSize(newSize); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void LayoutImage::updateInnerContentRect() | |
| 142 { | |
| 143 // Propagate container size to the image resource. | |
| 144 LayoutRect containerRect = replacedContentRect(); | |
| 145 IntSize containerSize(containerRect.width(), containerRect.height()); | |
| 146 if (!containerSize.isEmpty()) | |
| 147 m_imageResource->setContainerSizeForLayoutObject(containerSize); | |
| 148 } | |
| 149 | |
| 150 void LayoutImage::invalidatePaintAndMarkForLayoutIfNeeded() | 141 void LayoutImage::invalidatePaintAndMarkForLayoutIfNeeded() |
| 151 { | 142 { |
| 152 LayoutSize oldIntrinsicSize = intrinsicSize(); | 143 LayoutSize oldIntrinsicSize = intrinsicSize(); |
| 153 LayoutSize newIntrinsicSize = m_imageResource->intrinsicSize(style()->effect
iveZoom()); | 144 LayoutSize newIntrinsicSize = m_imageResource->intrinsicSize(style()->effect
iveZoom()); |
| 154 updateIntrinsicSizeIfNeeded(newIntrinsicSize); | 145 updateIntrinsicSizeIfNeeded(newIntrinsicSize); |
| 155 | 146 |
| 156 // In the case of generated image content using :before/:after/content, we m
ight not be | 147 // In the case of generated image content using :before/:after/content, we m
ight not be |
| 157 // in the layout tree yet. In that case, we just need to update our intrinsi
c size. | 148 // in the layout tree yet. In that case, we just need to update our intrinsi
c size. |
| 158 // layout() will be called after we are inserted in the tree which will take
care of | 149 // layout() will be called after we are inserted in the tree which will take
care of |
| 159 // what we are doing here. | 150 // what we are doing here. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 170 // FIXME: We only need to recompute the containing block's preferred size if
the containing block's size | 161 // FIXME: We only need to recompute the containing block's preferred size if
the containing block's size |
| 171 // depends on the image's size (i.e., the container uses shrink-to-fit sizin
g). | 162 // depends on the image's size (i.e., the container uses shrink-to-fit sizin
g). |
| 172 // There's no easy way to detect that shrink-to-fit is needed, always force
a layout. | 163 // There's no easy way to detect that shrink-to-fit is needed, always force
a layout. |
| 173 bool containingBlockNeedsToRecomputePreferredSize = style()->logicalWidth().
hasPercent() || style()->logicalMaxWidth().hasPercent() || style()->logicalMinW
idth().hasPercent(); | 164 bool containingBlockNeedsToRecomputePreferredSize = style()->logicalWidth().
hasPercent() || style()->logicalMaxWidth().hasPercent() || style()->logicalMinW
idth().hasPercent(); |
| 174 | 165 |
| 175 if (imageSourceHasChangedSize && (!imageSizeIsConstrained || containingBlock
NeedsToRecomputePreferredSize)) { | 166 if (imageSourceHasChangedSize && (!imageSizeIsConstrained || containingBlock
NeedsToRecomputePreferredSize)) { |
| 176 setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::SizeCha
nged); | 167 setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::SizeCha
nged); |
| 177 return; | 168 return; |
| 178 } | 169 } |
| 179 | 170 |
| 180 // The image hasn't changed in size or its style constrains its size, so a p
aint invalidation will suffice. | |
| 181 if (everHadLayout() && !selfNeedsLayout()) { | |
| 182 // The inner content rectangle is calculated during layout, but may need
an update now | |
| 183 // (unless the box has already been scheduled for layout). In order to c
alculate it, we | |
| 184 // may need values from the containing block, though, so make sure that
we're not too | |
| 185 // early. It may be that layout hasn't even taken place once yet. | |
| 186 updateInnerContentRect(); | |
| 187 } | |
| 188 | |
| 189 if (imageResource() && imageResource()->image() && imageResource()->image()-
>maybeAnimated()) | 171 if (imageResource() && imageResource()->image() && imageResource()->image()-
>maybeAnimated()) |
| 190 setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull); | 172 setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull); |
| 191 else | 173 else |
| 192 setShouldDoFullPaintInvalidation(PaintInvalidationFull); | 174 setShouldDoFullPaintInvalidation(PaintInvalidationFull); |
| 193 | 175 |
| 194 // Tell any potential compositing layers that the image needs updating. | 176 // Tell any potential compositing layers that the image needs updating. |
| 195 contentChanged(ImageChanged); | 177 contentChanged(ImageChanged); |
| 196 } | 178 } |
| 197 | 179 |
| 198 void LayoutImage::notifyFinished(Resource* newImage) | 180 void LayoutImage::notifyFinished(Resource* newImage) |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation()); | 276 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation()); |
| 295 bool inside = LayoutReplaced::nodeAtPoint(tempResult, locationInContainer, a
ccumulatedOffset, hitTestAction); | 277 bool inside = LayoutReplaced::nodeAtPoint(tempResult, locationInContainer, a
ccumulatedOffset, hitTestAction); |
| 296 | 278 |
| 297 if (!inside && result.hitTestRequest().listBased()) | 279 if (!inside && result.hitTestRequest().listBased()) |
| 298 result.append(tempResult); | 280 result.append(tempResult); |
| 299 if (inside) | 281 if (inside) |
| 300 result = tempResult; | 282 result = tempResult; |
| 301 return inside; | 283 return inside; |
| 302 } | 284 } |
| 303 | 285 |
| 304 void LayoutImage::layout() | |
| 305 { | |
| 306 LayoutReplaced::layout(); | |
| 307 updateInnerContentRect(); | |
| 308 } | |
| 309 | |
| 310 bool LayoutImage::updateImageLoadingPriorities() | 286 bool LayoutImage::updateImageLoadingPriorities() |
| 311 { | 287 { |
| 312 if (!m_imageResource || !m_imageResource->cachedImage() || m_imageResource->
cachedImage()->isLoaded()) | 288 if (!m_imageResource || !m_imageResource->cachedImage() || m_imageResource->
cachedImage()->isLoaded()) |
| 313 return false; | 289 return false; |
| 314 | 290 |
| 315 LayoutRect viewBounds = viewRect(); | 291 LayoutRect viewBounds = viewRect(); |
| 316 LayoutRect objectBounds = LayoutRect(absoluteContentBox()); | 292 LayoutRect objectBounds = LayoutRect(absoluteContentBox()); |
| 317 | 293 |
| 318 // The object bounds might be empty right now, so intersects will fail since
it doesn't deal | 294 // The object bounds might be empty right now, so intersects will fail since
it doesn't deal |
| 319 // with empty rects. Use LayoutRect::contains in that case. | 295 // with empty rects. Use LayoutRect::contains in that case. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 return nullptr; | 347 return nullptr; |
| 372 | 348 |
| 373 ImageResource* cachedImage = m_imageResource->cachedImage(); | 349 ImageResource* cachedImage = m_imageResource->cachedImage(); |
| 374 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage(
)) | 350 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage(
)) |
| 375 return toSVGImage(cachedImage->image())->embeddedContentBox(); | 351 return toSVGImage(cachedImage->image())->embeddedContentBox(); |
| 376 | 352 |
| 377 return nullptr; | 353 return nullptr; |
| 378 } | 354 } |
| 379 | 355 |
| 380 } // namespace blink | 356 } // namespace blink |
| OLD | NEW |