| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 if (!m_didIncrementVisuallyNonEmptyPixelCount) { | 165 if (!m_didIncrementVisuallyNonEmptyPixelCount) { |
| 166 // At a zoom level of 1 the image is guaranteed to have an integer size. | 166 // At a zoom level of 1 the image is guaranteed to have an integer size. |
| 167 view()->frameView()->incrementVisuallyNonEmptyPixelCount(flooredIntSize(
m_imageResource->imageSize(1.0f))); | 167 view()->frameView()->incrementVisuallyNonEmptyPixelCount(flooredIntSize(
m_imageResource->imageSize(1.0f))); |
| 168 m_didIncrementVisuallyNonEmptyPixelCount = true; | 168 m_didIncrementVisuallyNonEmptyPixelCount = true; |
| 169 } | 169 } |
| 170 | 170 |
| 171 bool imageSizeChanged = false; | 171 bool imageSizeChanged = false; |
| 172 | 172 |
| 173 // Set image dimensions, taking into account the size of the alt text. | 173 // Set image dimensions, taking into account the size of the alt text. |
| 174 if (m_imageResource->errorOccurred() || !newImage) { | 174 if (m_imageResource->errorOccurred() || !newImage) { |
| 175 if (!m_altText.isEmpty() && document()->hasPendingStyleRecalc()) { | 175 if (!m_altText.isEmpty() && document().hasPendingStyleRecalc()) { |
| 176 ASSERT(node()); | 176 ASSERT(node()); |
| 177 if (node()) { | 177 if (node()) { |
| 178 m_needsToSetSizeForAltText = true; | 178 m_needsToSetSizeForAltText = true; |
| 179 node()->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRen
derer); | 179 node()->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRen
derer); |
| 180 } | 180 } |
| 181 return; | 181 return; |
| 182 } | 182 } |
| 183 imageSizeChanged = setImageSizeForAltText(m_imageResource->cachedImage()
); | 183 imageSizeChanged = setImageSizeForAltText(m_imageResource->cachedImage()
); |
| 184 } | 184 } |
| 185 | 185 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 centerX = 0; | 346 centerX = 0; |
| 347 LayoutUnit centerY = (usableHeight - imageSize.height()) / 2; | 347 LayoutUnit centerY = (usableHeight - imageSize.height()) / 2; |
| 348 if (centerY < 0) | 348 if (centerY < 0) |
| 349 centerY = 0; | 349 centerY = 0; |
| 350 imageOffset = LayoutSize(leftBorder + leftPad + centerX + border
Width, topBorder + topPad + centerY + borderWidth); | 350 imageOffset = LayoutSize(leftBorder + leftPad + centerX + border
Width, topBorder + topPad + centerY + borderWidth); |
| 351 context->drawImage(image.get(), pixelSnappedIntRect(LayoutRect(p
aintOffset + imageOffset, imageSize)), CompositeSourceOver, shouldRespectImageOr
ientation()); | 351 context->drawImage(image.get(), pixelSnappedIntRect(LayoutRect(p
aintOffset + imageOffset, imageSize)), CompositeSourceOver, shouldRespectImageOr
ientation()); |
| 352 errorPictureDrawn = true; | 352 errorPictureDrawn = true; |
| 353 } | 353 } |
| 354 | 354 |
| 355 if (!m_altText.isEmpty()) { | 355 if (!m_altText.isEmpty()) { |
| 356 String text = document()->displayStringModifiedByEncoding(m_altT
ext); | 356 String text = document().displayStringModifiedByEncoding(m_altTe
xt); |
| 357 const Font& font = style()->font(); | 357 const Font& font = style()->font(); |
| 358 const FontMetrics& fontMetrics = font.fontMetrics(); | 358 const FontMetrics& fontMetrics = font.fontMetrics(); |
| 359 LayoutUnit ascent = fontMetrics.ascent(); | 359 LayoutUnit ascent = fontMetrics.ascent(); |
| 360 LayoutPoint textRectOrigin = paintOffset; | 360 LayoutPoint textRectOrigin = paintOffset; |
| 361 textRectOrigin.move(leftBorder + leftPad + (paddingWidth / 2) -
borderWidth, topBorder + topPad + (paddingHeight / 2) - borderWidth); | 361 textRectOrigin.move(leftBorder + leftPad + (paddingWidth / 2) -
borderWidth, topBorder + topPad + (paddingHeight / 2) - borderWidth); |
| 362 LayoutPoint textOrigin(textRectOrigin.x(), textRectOrigin.y() +
ascent); | 362 LayoutPoint textOrigin(textRectOrigin.x(), textRectOrigin.y() +
ascent); |
| 363 | 363 |
| 364 // Only draw the alt text if it'll fit within the content box, | 364 // Only draw the alt text if it'll fit within the content box, |
| 365 // and only if it fits above the error image. | 365 // and only if it fits above the error image. |
| 366 TextRun textRun = RenderBlock::constructTextRun(this, font, text
, style()); | 366 TextRun textRun = RenderBlock::constructTextRun(this, font, text
, style()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 void RenderImage::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) | 413 void RenderImage::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
| 414 { | 414 { |
| 415 RenderReplaced::paint(paintInfo, paintOffset); | 415 RenderReplaced::paint(paintInfo, paintOffset); |
| 416 | 416 |
| 417 if (paintInfo.phase == PaintPhaseOutline) | 417 if (paintInfo.phase == PaintPhaseOutline) |
| 418 paintAreaElementFocusRing(paintInfo); | 418 paintAreaElementFocusRing(paintInfo); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void RenderImage::paintAreaElementFocusRing(PaintInfo& paintInfo) | 421 void RenderImage::paintAreaElementFocusRing(PaintInfo& paintInfo) |
| 422 { | 422 { |
| 423 Document* document = this->document(); | 423 Document& document = this->document(); |
| 424 | 424 |
| 425 if (document->printing() || !document->frame()->selection()->isFocusedAndAct
ive()) | 425 if (document.printing() || !document.frame()->selection()->isFocusedAndActiv
e()) |
| 426 return; | 426 return; |
| 427 | 427 |
| 428 if (paintInfo.context->paintingDisabled() && !paintInfo.context->updatingCon
trolTints()) | 428 if (paintInfo.context->paintingDisabled() && !paintInfo.context->updatingCon
trolTints()) |
| 429 return; | 429 return; |
| 430 | 430 |
| 431 Element* focusedElement = document->focusedElement(); | 431 Element* focusedElement = document.focusedElement(); |
| 432 if (!focusedElement || !isHTMLAreaElement(focusedElement)) | 432 if (!focusedElement || !isHTMLAreaElement(focusedElement)) |
| 433 return; | 433 return; |
| 434 | 434 |
| 435 HTMLAreaElement* areaElement = toHTMLAreaElement(focusedElement); | 435 HTMLAreaElement* areaElement = toHTMLAreaElement(focusedElement); |
| 436 if (areaElement->imageElement() != node()) | 436 if (areaElement->imageElement() != node()) |
| 437 return; | 437 return; |
| 438 | 438 |
| 439 // Even if the theme handles focus ring drawing for entire elements, it won'
t do it for | 439 // Even if the theme handles focus ring drawing for entire elements, it won'
t do it for |
| 440 // an area within an image, so we don't call RenderTheme::supportsFocusRing
here. | 440 // an area within an image, so we don't call RenderTheme::supportsFocusRing
here. |
| 441 | 441 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 return 0; | 616 return 0; |
| 617 | 617 |
| 618 ImageResource* cachedImage = m_imageResource->cachedImage(); | 618 ImageResource* cachedImage = m_imageResource->cachedImage(); |
| 619 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage(
)) | 619 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage(
)) |
| 620 return static_cast<SVGImage*>(cachedImage->image())->embeddedContentBox(
); | 620 return static_cast<SVGImage*>(cachedImage->image())->embeddedContentBox(
); |
| 621 | 621 |
| 622 return 0; | 622 return 0; |
| 623 } | 623 } |
| 624 | 624 |
| 625 } // namespace WebCore | 625 } // namespace WebCore |
| OLD | NEW |