| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 if (newImage->willPaintBrokenImage()) { | 100 if (newImage->willPaintBrokenImage()) { |
| 101 float deviceScaleFactor = blink::deviceScaleFactor(frame()); | 101 float deviceScaleFactor = blink::deviceScaleFactor(frame()); |
| 102 pair<Image*, float> brokenImageAndImageScaleFactor = ImageResource::brok
enImage(deviceScaleFactor); | 102 pair<Image*, float> brokenImageAndImageScaleFactor = ImageResource::brok
enImage(deviceScaleFactor); |
| 103 imageSize = brokenImageAndImageScaleFactor.first->size(); | 103 imageSize = brokenImageAndImageScaleFactor.first->size(); |
| 104 imageSize.scale(1 / brokenImageAndImageScaleFactor.second); | 104 imageSize.scale(1 / brokenImageAndImageScaleFactor.second); |
| 105 } else | 105 } else |
| 106 imageSize = newImage->imageForRenderer(this)->size(); | 106 imageSize = newImage->imageForRenderer(this)->size(); |
| 107 | 107 |
| 108 // imageSize() returns 0 for the error image. We need the true size of the | 108 // imageSize() returns 0 for the error image. We need the true size of the |
| 109 // error image, so we have to get it by grabbing image() directly. | 109 // error image, so we have to get it by grabbing image() directly. |
| 110 return IntSize(paddingWidth + imageSize.width() * style()->effectiveZoom(),
paddingHeight + imageSize.height() * style()->effectiveZoom()); | 110 return IntSize(paddingWidth + imageSize.width(), paddingHeight + imageSize.h
eight()); |
| 111 } | 111 } |
| 112 | 112 |
| 113 // Sets the image height and width to fit the alt text. Returns true if the | 113 // Sets the image height and width to fit the alt text. Returns true if the |
| 114 // image size changed. | 114 // image size changed. |
| 115 bool RenderImage::setImageSizeForAltText(ImageResource* newImage /* = 0 */) | 115 bool RenderImage::setImageSizeForAltText(ImageResource* newImage /* = 0 */) |
| 116 { | 116 { |
| 117 IntSize imageSize; | 117 IntSize imageSize; |
| 118 if (newImage && newImage->imageForRenderer(this)) | 118 if (newImage && newImage->imageForRenderer(this)) |
| 119 imageSize = imageSizeForError(newImage); | 119 imageSize = imageSizeForError(newImage); |
| 120 else if (!m_altText.isEmpty() || newImage) { | 120 else if (!m_altText.isEmpty() || newImage) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // Propagate container size to the image resource. | 178 // Propagate container size to the image resource. |
| 179 LayoutRect containerRect = replacedContentRect(); | 179 LayoutRect containerRect = replacedContentRect(); |
| 180 IntSize containerSize(containerRect.width(), containerRect.height()); | 180 IntSize containerSize(containerRect.width(), containerRect.height()); |
| 181 if (!containerSize.isEmpty()) | 181 if (!containerSize.isEmpty()) |
| 182 m_imageResource->setContainerSizeForRenderer(containerSize); | 182 m_imageResource->setContainerSizeForRenderer(containerSize); |
| 183 } | 183 } |
| 184 | 184 |
| 185 void RenderImage::paintInvalidationOrMarkForLayout(bool imageSizeChangedToAccomo
dateAltText, const IntRect* rect) | 185 void RenderImage::paintInvalidationOrMarkForLayout(bool imageSizeChangedToAccomo
dateAltText, const IntRect* rect) |
| 186 { | 186 { |
| 187 LayoutSize oldIntrinsicSize = intrinsicSize(); | 187 LayoutSize oldIntrinsicSize = intrinsicSize(); |
| 188 LayoutSize newIntrinsicSize = m_imageResource->intrinsicSize(style()->effect
iveZoom()); | 188 LayoutSize newIntrinsicSize = m_imageResource->intrinsicSize(); |
| 189 updateIntrinsicSizeIfNeeded(newIntrinsicSize); | 189 updateIntrinsicSizeIfNeeded(newIntrinsicSize); |
| 190 | 190 |
| 191 // In the case of generated image content using :before/:after/content, we m
ight not be | 191 // In the case of generated image content using :before/:after/content, we m
ight not be |
| 192 // in the render tree yet. In that case, we just need to update our intrinsi
c size. | 192 // in the render tree yet. In that case, we just need to update our intrinsi
c size. |
| 193 // layout() will be called after we are inserted in the tree which will take
care of | 193 // layout() will be called after we are inserted in the tree which will take
care of |
| 194 // what we are doing here. | 194 // what we are doing here. |
| 195 if (!containingBlock()) | 195 if (!containingBlock()) |
| 196 return; | 196 return; |
| 197 | 197 |
| 198 bool imageSourceHasChangedSize = oldIntrinsicSize != newIntrinsicSize || ima
geSizeChangedToAccomodateAltText; | 198 bool imageSourceHasChangedSize = oldIntrinsicSize != newIntrinsicSize || ima
geSizeChangedToAccomodateAltText; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 218 // (unless the box has already been scheduled for layout). In order to c
alculate it, we | 218 // (unless the box has already been scheduled for layout). In order to c
alculate it, we |
| 219 // may need values from the containing block, though, so make sure that
we're not too | 219 // may need values from the containing block, though, so make sure that
we're not too |
| 220 // early. It may be that layout hasn't even taken place once yet. | 220 // early. It may be that layout hasn't even taken place once yet. |
| 221 updateInnerContentRect(); | 221 updateInnerContentRect(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 LayoutRect paintInvalidationRect; | 224 LayoutRect paintInvalidationRect; |
| 225 if (rect) { | 225 if (rect) { |
| 226 // The image changed rect is in source image coordinates (without zoom), | 226 // The image changed rect is in source image coordinates (without zoom), |
| 227 // so map from the bounds of the image to the contentsBox. | 227 // so map from the bounds of the image to the contentsBox. |
| 228 const LayoutSize imageSizeWithoutZoom = m_imageResource->imageSize(1 / s
tyle()->effectiveZoom()); | 228 const LayoutSize imageSizeWithoutZoom = m_imageResource->imageSize(); |
| 229 paintInvalidationRect = enclosingIntRect(mapRect(*rect, FloatRect(FloatP
oint(), imageSizeWithoutZoom), contentBoxRect())); | 229 paintInvalidationRect = enclosingIntRect(mapRect(*rect, FloatRect(FloatP
oint(), imageSizeWithoutZoom), contentBoxRect())); |
| 230 // Guard against too-large changed rects. | 230 // Guard against too-large changed rects. |
| 231 paintInvalidationRect.intersect(contentBoxRect()); | 231 paintInvalidationRect.intersect(contentBoxRect()); |
| 232 } else { | 232 } else { |
| 233 paintInvalidationRect = contentBoxRect(); | 233 paintInvalidationRect = contentBoxRect(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 { | 236 { |
| 237 // FIXME: We should not be allowing paint invalidations during layout. c
rbug.com/339584 | 237 // FIXME: We should not be allowing paint invalidations during layout. c
rbug.com/339584 |
| 238 AllowPaintInvalidationScope scoper(frameView()); | 238 AllowPaintInvalidationScope scoper(frameView()); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 return; | 522 return; |
| 523 } | 523 } |
| 524 } | 524 } |
| 525 | 525 |
| 526 bool RenderImage::needsPreferredWidthsRecalculation() const | 526 bool RenderImage::needsPreferredWidthsRecalculation() const |
| 527 { | 527 { |
| 528 return RenderReplaced::needsPreferredWidthsRecalculation(); | 528 return RenderReplaced::needsPreferredWidthsRecalculation(); |
| 529 } | 529 } |
| 530 | 530 |
| 531 } // namespace blink | 531 } // namespace blink |
| OLD | NEW |