| 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 return; | 292 return; |
| 293 | 293 |
| 294 if (page && paintInfo.phase == PaintPhaseForeground) | 294 if (page && paintInfo.phase == PaintPhaseForeground) |
| 295 page->addRelevantUnpaintedObject(this, visualOverflowRect()); | 295 page->addRelevantUnpaintedObject(this, visualOverflowRect()); |
| 296 | 296 |
| 297 if (cWidth > 2 && cHeight > 2) { | 297 if (cWidth > 2 && cHeight > 2) { |
| 298 const int borderWidth = 1; | 298 const int borderWidth = 1; |
| 299 | 299 |
| 300 // Draw an outline rect where the image should be. | 300 // Draw an outline rect where the image should be. |
| 301 context->setStrokeStyle(SolidStroke); | 301 context->setStrokeStyle(SolidStroke); |
| 302 context->setStrokeColor(Color::lightGray, style()->colorSpace()); | 302 context->setStrokeColor(Color::lightGray); |
| 303 context->setFillColor(Color::transparent, style()->colorSpace()); | 303 context->setFillColor(Color::transparent); |
| 304 context->drawRect(pixelSnappedIntRect(LayoutRect(paintOffset.x() + l
eftBorder + leftPad, paintOffset.y() + topBorder + topPad, cWidth, cHeight))); | 304 context->drawRect(pixelSnappedIntRect(LayoutRect(paintOffset.x() + l
eftBorder + leftPad, paintOffset.y() + topBorder + topPad, cWidth, cHeight))); |
| 305 | 305 |
| 306 bool errorPictureDrawn = false; | 306 bool errorPictureDrawn = false; |
| 307 LayoutSize imageOffset; | 307 LayoutSize imageOffset; |
| 308 // When calculating the usable dimensions, exclude the pixels of | 308 // When calculating the usable dimensions, exclude the pixels of |
| 309 // the ouline rect so the error image/alt text doesn't draw on it. | 309 // the ouline rect so the error image/alt text doesn't draw on it. |
| 310 LayoutUnit usableWidth = cWidth - 2 * borderWidth; | 310 LayoutUnit usableWidth = cWidth - 2 * borderWidth; |
| 311 LayoutUnit usableHeight = cHeight - 2 * borderWidth; | 311 LayoutUnit usableHeight = cHeight - 2 * borderWidth; |
| 312 | 312 |
| 313 RefPtr<Image> image = m_imageResource->image(); | 313 RefPtr<Image> image = m_imageResource->image(); |
| 314 | 314 |
| 315 if (m_imageResource->errorOccurred() && !image->isNull() && usableWi
dth >= image->width() && usableHeight >= image->height()) { | 315 if (m_imageResource->errorOccurred() && !image->isNull() && usableWi
dth >= image->width() && usableHeight >= image->height()) { |
| 316 float deviceScaleFactor = WebCore::deviceScaleFactor(frame()); | 316 float deviceScaleFactor = WebCore::deviceScaleFactor(frame()); |
| 317 // Call brokenImage() explicitly to ensure we get the broken ima
ge icon at the appropriate resolution. | 317 // Call brokenImage() explicitly to ensure we get the broken ima
ge icon at the appropriate resolution. |
| 318 pair<Image*, float> brokenImageAndImageScaleFactor = m_imageReso
urce->cachedImage()->brokenImage(deviceScaleFactor); | 318 pair<Image*, float> brokenImageAndImageScaleFactor = m_imageReso
urce->cachedImage()->brokenImage(deviceScaleFactor); |
| 319 image = brokenImageAndImageScaleFactor.first; | 319 image = brokenImageAndImageScaleFactor.first; |
| 320 IntSize imageSize = image->size(); | 320 IntSize imageSize = image->size(); |
| 321 imageSize.scale(1 / brokenImageAndImageScaleFactor.second); | 321 imageSize.scale(1 / brokenImageAndImageScaleFactor.second); |
| 322 // Center the error image, accounting for border and padding. | 322 // Center the error image, accounting for border and padding. |
| 323 LayoutUnit centerX = (usableWidth - imageSize.width()) / 2; | 323 LayoutUnit centerX = (usableWidth - imageSize.width()) / 2; |
| 324 if (centerX < 0) | 324 if (centerX < 0) |
| 325 centerX = 0; | 325 centerX = 0; |
| 326 LayoutUnit centerY = (usableHeight - imageSize.height()) / 2; | 326 LayoutUnit centerY = (usableHeight - imageSize.height()) / 2; |
| 327 if (centerY < 0) | 327 if (centerY < 0) |
| 328 centerY = 0; | 328 centerY = 0; |
| 329 imageOffset = LayoutSize(leftBorder + leftPad + centerX + border
Width, topBorder + topPad + centerY + borderWidth); | 329 imageOffset = LayoutSize(leftBorder + leftPad + centerX + border
Width, topBorder + topPad + centerY + borderWidth); |
| 330 context->drawImage(image.get(), style()->colorSpace(), pixelSnap
pedIntRect(LayoutRect(paintOffset + imageOffset, imageSize)), CompositeSourceOve
r, shouldRespectImageOrientation()); | 330 context->drawImage(image.get(), pixelSnappedIntRect(LayoutRect(p
aintOffset + imageOffset, imageSize)), CompositeSourceOver, shouldRespectImageOr
ientation()); |
| 331 errorPictureDrawn = true; | 331 errorPictureDrawn = true; |
| 332 } | 332 } |
| 333 | 333 |
| 334 if (!m_altText.isEmpty()) { | 334 if (!m_altText.isEmpty()) { |
| 335 String text = document()->displayStringModifiedByEncoding(m_altT
ext); | 335 String text = document()->displayStringModifiedByEncoding(m_altT
ext); |
| 336 const Font& font = style()->font(); | 336 const Font& font = style()->font(); |
| 337 const FontMetrics& fontMetrics = font.fontMetrics(); | 337 const FontMetrics& fontMetrics = font.fontMetrics(); |
| 338 LayoutUnit ascent = fontMetrics.ascent(); | 338 LayoutUnit ascent = fontMetrics.ascent(); |
| 339 LayoutPoint textRectOrigin = paintOffset; | 339 LayoutPoint textRectOrigin = paintOffset; |
| 340 textRectOrigin.move(leftBorder + leftPad + (paddingWidth / 2) -
borderWidth, topBorder + topPad + (paddingHeight / 2) - borderWidth); | 340 textRectOrigin.move(leftBorder + leftPad + (paddingWidth / 2) -
borderWidth, topBorder + topPad + (paddingHeight / 2) - borderWidth); |
| 341 LayoutPoint textOrigin(textRectOrigin.x(), textRectOrigin.y() +
ascent); | 341 LayoutPoint textOrigin(textRectOrigin.x(), textRectOrigin.y() +
ascent); |
| 342 | 342 |
| 343 // Only draw the alt text if it'll fit within the content box, | 343 // Only draw the alt text if it'll fit within the content box, |
| 344 // and only if it fits above the error image. | 344 // and only if it fits above the error image. |
| 345 TextRun textRun = RenderBlock::constructTextRun(this, font, text
, style()); | 345 TextRun textRun = RenderBlock::constructTextRun(this, font, text
, style()); |
| 346 LayoutUnit textWidth = font.width(textRun); | 346 LayoutUnit textWidth = font.width(textRun); |
| 347 TextRunPaintInfo textRunPaintInfo(textRun); | 347 TextRunPaintInfo textRunPaintInfo(textRun); |
| 348 textRunPaintInfo.bounds = FloatRect(textRectOrigin, FloatSize(te
xtWidth, fontMetrics.height())); | 348 textRunPaintInfo.bounds = FloatRect(textRectOrigin, FloatSize(te
xtWidth, fontMetrics.height())); |
| 349 context->setFillColor(style()->visitedDependentColor(CSSProperty
Color), style()->colorSpace()); | 349 context->setFillColor(style()->visitedDependentColor(CSSProperty
Color)); |
| 350 if (errorPictureDrawn) { | 350 if (errorPictureDrawn) { |
| 351 if (usableWidth >= textWidth && fontMetrics.height() <= imag
eOffset.height()) | 351 if (usableWidth >= textWidth && fontMetrics.height() <= imag
eOffset.height()) |
| 352 context->drawText(font, textRunPaintInfo, textOrigin); | 352 context->drawText(font, textRunPaintInfo, textOrigin); |
| 353 } else if (usableWidth >= textWidth && usableHeight >= fontMetri
cs.height()) | 353 } else if (usableWidth >= textWidth && usableHeight >= fontMetri
cs.height()) |
| 354 context->drawText(font, textRunPaintInfo, textOrigin); | 354 context->drawText(font, textRunPaintInfo, textOrigin); |
| 355 } | 355 } |
| 356 } | 356 } |
| 357 } else if (m_imageResource->hasImage() && cWidth > 0 && cHeight > 0) { | 357 } else if (m_imageResource->hasImage() && cWidth > 0 && cHeight > 0) { |
| 358 RefPtr<Image> img = m_imageResource->image(cWidth, cHeight); | 358 RefPtr<Image> img = m_imageResource->image(cWidth, cHeight); |
| 359 if (!img || img->isNull()) { | 359 if (!img || img->isNull()) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 return; | 440 return; |
| 441 | 441 |
| 442 RefPtr<Image> img = m_imageResource->image(alignedRect.width(), alignedRect.
height()); | 442 RefPtr<Image> img = m_imageResource->image(alignedRect.width(), alignedRect.
height()); |
| 443 if (!img || img->isNull()) | 443 if (!img || img->isNull()) |
| 444 return; | 444 return; |
| 445 | 445 |
| 446 HTMLImageElement* imageElt = (node() && node()->hasTagName(imgTag)) ? static
_cast<HTMLImageElement*>(node()) : 0; | 446 HTMLImageElement* imageElt = (node() && node()->hasTagName(imgTag)) ? static
_cast<HTMLImageElement*>(node()) : 0; |
| 447 CompositeOperator compositeOperator = imageElt ? imageElt->compositeOperator
() : CompositeSourceOver; | 447 CompositeOperator compositeOperator = imageElt ? imageElt->compositeOperator
() : CompositeSourceOver; |
| 448 Image* image = m_imageResource->image().get(); | 448 Image* image = m_imageResource->image().get(); |
| 449 bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, image, a
lignedRect.size()); | 449 bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, image, a
lignedRect.size()); |
| 450 context->drawImage(m_imageResource->image(alignedRect.width(), alignedRect.h
eight()).get(), style()->colorSpace(), alignedRect, compositeOperator, shouldRes
pectImageOrientation(), useLowQualityScaling); | 450 context->drawImage(m_imageResource->image(alignedRect.width(), alignedRect.h
eight()).get(), alignedRect, compositeOperator, shouldRespectImageOrientation(),
useLowQualityScaling); |
| 451 } | 451 } |
| 452 | 452 |
| 453 bool RenderImage::boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance
bleedAvoidance, InlineFlowBox*) const | 453 bool RenderImage::boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance
bleedAvoidance, InlineFlowBox*) const |
| 454 { | 454 { |
| 455 if (!RenderBoxModelObject::boxShadowShouldBeAppliedToBackground(bleedAvoidan
ce)) | 455 if (!RenderBoxModelObject::boxShadowShouldBeAppliedToBackground(bleedAvoidan
ce)) |
| 456 return false; | 456 return false; |
| 457 | 457 |
| 458 return !const_cast<RenderImage*>(this)->backgroundIsKnownToBeObscured(); | 458 return !const_cast<RenderImage*>(this)->backgroundIsKnownToBeObscured(); |
| 459 } | 459 } |
| 460 | 460 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 return 0; | 575 return 0; |
| 576 | 576 |
| 577 CachedImage* cachedImage = m_imageResource->cachedImage(); | 577 CachedImage* cachedImage = m_imageResource->cachedImage(); |
| 578 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage(
)) | 578 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage(
)) |
| 579 return static_cast<SVGImage*>(cachedImage->image())->embeddedContentBox(
); | 579 return static_cast<SVGImage*>(cachedImage->image())->embeddedContentBox(
); |
| 580 | 580 |
| 581 return 0; | 581 return 0; |
| 582 } | 582 } |
| 583 | 583 |
| 584 } // namespace WebCore | 584 } // namespace WebCore |
| OLD | NEW |