| 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 context->drawImage(image.get(), style()->colorSpace(), pixelSnap
pedIntRect(LayoutRect(paintOffset + imageOffset, imageSize)), CompositeSourceOve
r, shouldRespectImageOrientation()); | 334 context->drawImage(image.get(), style()->colorSpace(), pixelSnap
pedIntRect(LayoutRect(paintOffset + imageOffset, imageSize)), CompositeSourceOve
r, shouldRespectImageOrientation()); |
| 335 errorPictureDrawn = true; | 335 errorPictureDrawn = true; |
| 336 } | 336 } |
| 337 | 337 |
| 338 if (!m_altText.isEmpty()) { | 338 if (!m_altText.isEmpty()) { |
| 339 String text = document()->displayStringModifiedByEncoding(m_altT
ext); | 339 String text = document()->displayStringModifiedByEncoding(m_altT
ext); |
| 340 context->setFillColor(style()->visitedDependentColor(CSSProperty
Color), style()->colorSpace()); | 340 context->setFillColor(style()->visitedDependentColor(CSSProperty
Color), style()->colorSpace()); |
| 341 const Font& font = style()->font(); | 341 const Font& font = style()->font(); |
| 342 const FontMetrics& fontMetrics = font.fontMetrics(); | 342 const FontMetrics& fontMetrics = font.fontMetrics(); |
| 343 LayoutUnit ascent = fontMetrics.ascent(); | 343 LayoutUnit ascent = fontMetrics.ascent(); |
| 344 LayoutPoint altTextOffset = paintOffset; | 344 LayoutPoint textRectOrigin = paintOffset; |
| 345 altTextOffset.move(leftBorder + leftPad + (paddingWidth / 2) - b
orderWidth, topBorder + topPad + ascent + (paddingHeight / 2) - borderWidth); | 345 textRectOrigin.move(leftBorder + leftPad + (paddingWidth / 2) -
borderWidth, topBorder + topPad + (paddingHeight / 2) - borderWidth); |
| 346 LayoutPoint textOrigin(textRectOrigin.x(), textRectOrigin.y() +
ascent); |
| 346 | 347 |
| 347 // Only draw the alt text if it'll fit within the content box, | 348 // Only draw the alt text if it'll fit within the content box, |
| 348 // and only if it fits above the error image. | 349 // and only if it fits above the error image. |
| 349 TextRun textRun = RenderBlock::constructTextRun(this, font, text
, style()); | 350 TextRun textRun = RenderBlock::constructTextRun(this, font, text
, style()); |
| 350 LayoutUnit textWidth = font.width(textRun); | 351 LayoutUnit textWidth = font.width(textRun); |
| 352 FloatRect textRect(textRectOrigin, FloatSize(textWidth, fontMetr
ics.height())); |
| 351 if (errorPictureDrawn) { | 353 if (errorPictureDrawn) { |
| 352 if (usableWidth >= textWidth && fontMetrics.height() <= imag
eOffset.height()) | 354 if (usableWidth >= textWidth && fontMetrics.height() <= imag
eOffset.height()) |
| 353 context->drawText(font, textRun, altTextOffset); | 355 context->drawText(font, textRun, textOrigin, textRect); |
| 354 } else if (usableWidth >= textWidth && usableHeight >= fontMetri
cs.height()) | 356 } else if (usableWidth >= textWidth && usableHeight >= fontMetri
cs.height()) |
| 355 context->drawText(font, textRun, altTextOffset); | 357 context->drawText(font, textRun, textOrigin, textRect); |
| 356 } | 358 } |
| 357 } | 359 } |
| 358 } else if (m_imageResource->hasImage() && cWidth > 0 && cHeight > 0) { | 360 } else if (m_imageResource->hasImage() && cWidth > 0 && cHeight > 0) { |
| 359 RefPtr<Image> img = m_imageResource->image(cWidth, cHeight); | 361 RefPtr<Image> img = m_imageResource->image(cWidth, cHeight); |
| 360 if (!img || img->isNull()) { | 362 if (!img || img->isNull()) { |
| 361 if (page && paintInfo.phase == PaintPhaseForeground) | 363 if (page && paintInfo.phase == PaintPhaseForeground) |
| 362 page->addRelevantUnpaintedObject(this, visualOverflowRect()); | 364 page->addRelevantUnpaintedObject(this, visualOverflowRect()); |
| 363 return; | 365 return; |
| 364 } | 366 } |
| 365 | 367 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 #if ENABLE(SVG) | 580 #if ENABLE(SVG) |
| 579 CachedImage* cachedImage = m_imageResource->cachedImage(); | 581 CachedImage* cachedImage = m_imageResource->cachedImage(); |
| 580 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage(
)) | 582 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage(
)) |
| 581 return static_cast<SVGImage*>(cachedImage->image())->embeddedContentBox(
); | 583 return static_cast<SVGImage*>(cachedImage->image())->embeddedContentBox(
); |
| 582 #endif | 584 #endif |
| 583 | 585 |
| 584 return 0; | 586 return 0; |
| 585 } | 587 } |
| 586 | 588 |
| 587 } // namespace WebCore | 589 } // namespace WebCore |
| OLD | NEW |