Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: Source/core/rendering/RenderImage.cpp

Issue 520803004: Remove redundant stack variables from RenderImage. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 // tell any potential compositing layers 272 // tell any potential compositing layers
273 // that the image is done and they can reference it directly. 273 // that the image is done and they can reference it directly.
274 contentChanged(ImageChanged); 274 contentChanged(ImageChanged);
275 } 275 }
276 } 276 }
277 277
278 void RenderImage::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOf fset) 278 void RenderImage::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOf fset)
279 { 279 {
280 LayoutUnit cWidth = contentWidth(); 280 LayoutUnit cWidth = contentWidth();
281 LayoutUnit cHeight = contentHeight(); 281 LayoutUnit cHeight = contentHeight();
282 LayoutUnit leftBorder = borderLeft();
283 LayoutUnit topBorder = borderTop();
284 LayoutUnit leftPad = paddingLeft();
285 LayoutUnit topPad = paddingTop();
286 282
287 GraphicsContext* context = paintInfo.context; 283 GraphicsContext* context = paintInfo.context;
288 284
289 if (!m_imageResource->hasImage() || m_imageResource->errorOccurred()) { 285 if (!m_imageResource->hasImage() || m_imageResource->errorOccurred()) {
290 if (paintInfo.phase == PaintPhaseSelection) 286 if (paintInfo.phase == PaintPhaseSelection)
291 return; 287 return;
292 288
293 if (cWidth > 2 && cHeight > 2) { 289 if (cWidth > 2 && cHeight > 2) {
294 const int borderWidth = 1; 290 const int borderWidth = 1;
295 291
292 LayoutUnit leftBorder = borderLeft();
293 LayoutUnit topBorder = borderTop();
294 LayoutUnit leftPad = paddingLeft();
295 LayoutUnit topPad = paddingTop();
296
296 // Draw an outline rect where the image should be. 297 // Draw an outline rect where the image should be.
297 context->setStrokeStyle(SolidStroke); 298 context->setStrokeStyle(SolidStroke);
298 context->setStrokeColor(Color::lightGray); 299 context->setStrokeColor(Color::lightGray);
299 context->setFillColor(Color::transparent); 300 context->setFillColor(Color::transparent);
300 context->drawRect(pixelSnappedIntRect(LayoutRect(paintOffset.x() + l eftBorder + leftPad, paintOffset.y() + topBorder + topPad, cWidth, cHeight))); 301 context->drawRect(pixelSnappedIntRect(LayoutRect(paintOffset.x() + l eftBorder + leftPad, paintOffset.y() + topBorder + topPad, cWidth, cHeight)));
301 302
302 bool errorPictureDrawn = false; 303 bool errorPictureDrawn = false;
303 LayoutSize imageOffset; 304 LayoutSize imageOffset;
304 // When calculating the usable dimensions, exclude the pixels of 305 // When calculating the usable dimensions, exclude the pixels of
305 // the ouline rect so the error image/alt text doesn't draw on it. 306 // the ouline rect so the error image/alt text doesn't draw on it.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 349 }
349 if (errorPictureDrawn) { 350 if (errorPictureDrawn) {
350 if (usableWidth >= textWidth && fontMetrics.height() <= imag eOffset.height()) 351 if (usableWidth >= textWidth && fontMetrics.height() <= imag eOffset.height())
351 context->drawBidiText(font, textRunPaintInfo, textOrigin ); 352 context->drawBidiText(font, textRunPaintInfo, textOrigin );
352 } else if (usableWidth >= textWidth && usableHeight >= fontMetri cs.height()) { 353 } else if (usableWidth >= textWidth && usableHeight >= fontMetri cs.height()) {
353 context->drawBidiText(font, textRunPaintInfo, textOrigin); 354 context->drawBidiText(font, textRunPaintInfo, textOrigin);
354 } 355 }
355 } 356 }
356 } 357 }
357 } else if (m_imageResource->hasImage() && cWidth > 0 && cHeight > 0) { 358 } else if (m_imageResource->hasImage() && cWidth > 0 && cHeight > 0) {
358 RefPtr<Image> img = m_imageResource->image(cWidth, cHeight);
359 if (!img || img->isNull())
360 return;
361
362 LayoutRect contentRect = contentBoxRect(); 359 LayoutRect contentRect = contentBoxRect();
363 contentRect.moveBy(paintOffset); 360 contentRect.moveBy(paintOffset);
364 LayoutRect paintRect = replacedContentRect(); 361 LayoutRect paintRect = replacedContentRect();
365 paintRect.moveBy(paintOffset); 362 paintRect.moveBy(paintOffset);
366 bool clip = !contentRect.contains(paintRect); 363 bool clip = !contentRect.contains(paintRect);
367 if (clip) { 364 if (clip) {
368 context->save(); 365 context->save();
369 context->clip(contentRect); 366 context->clip(contentRect);
370 } 367 }
371 368
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 IntRect alignedRect = pixelSnappedIntRect(rect); 440 IntRect alignedRect = pixelSnappedIntRect(rect);
444 if (!m_imageResource->hasImage() || m_imageResource->errorOccurred() || alig nedRect.width() <= 0 || alignedRect.height() <= 0) 441 if (!m_imageResource->hasImage() || m_imageResource->errorOccurred() || alig nedRect.width() <= 0 || alignedRect.height() <= 0)
445 return; 442 return;
446 443
447 RefPtr<Image> img = m_imageResource->image(alignedRect.width(), alignedRect. height()); 444 RefPtr<Image> img = m_imageResource->image(alignedRect.width(), alignedRect. height());
448 if (!img || img->isNull()) 445 if (!img || img->isNull())
449 return; 446 return;
450 447
451 HTMLImageElement* imageElt = isHTMLImageElement(node()) ? toHTMLImageElement (node()) : 0; 448 HTMLImageElement* imageElt = isHTMLImageElement(node()) ? toHTMLImageElement (node()) : 0;
452 CompositeOperator compositeOperator = imageElt ? imageElt->compositeOperator () : CompositeSourceOver; 449 CompositeOperator compositeOperator = imageElt ? imageElt->compositeOperator () : CompositeSourceOver;
453 Image* image = m_imageResource->image().get(); 450 Image* image = img.get();
454 InterpolationQuality interpolationQuality = chooseInterpolationQuality(conte xt, image, image, alignedRect.size()); 451 InterpolationQuality interpolationQuality = chooseInterpolationQuality(conte xt, image, image, alignedRect.size());
455 452
456 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", " data", InspectorPaintImageEvent::data(*this)); 453 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", " data", InspectorPaintImageEvent::data(*this));
457 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing. 454 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing.
458 InspectorInstrumentation::willPaintImage(this); 455 InspectorInstrumentation::willPaintImage(this);
459 InterpolationQuality previousInterpolationQuality = context->imageInterpolat ionQuality(); 456 InterpolationQuality previousInterpolationQuality = context->imageInterpolat ionQuality();
460 context->setImageInterpolationQuality(interpolationQuality); 457 context->setImageInterpolationQuality(interpolationQuality);
461 context->drawImage(m_imageResource->image(alignedRect.width(), alignedRect.h eight()).get(), alignedRect, compositeOperator, shouldRespectImageOrientation()) ; 458 context->drawImage(image, alignedRect, compositeOperator, shouldRespectImage Orientation());
462 context->setImageInterpolationQuality(previousInterpolationQuality); 459 context->setImageInterpolationQuality(previousInterpolationQuality);
463 InspectorInstrumentation::didPaintImage(this); 460 InspectorInstrumentation::didPaintImage(this);
464 } 461 }
465 462
466 bool RenderImage::boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox*) const 463 bool RenderImage::boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox*) const
467 { 464 {
468 if (!RenderBoxModelObject::boxShadowShouldBeAppliedToBackground(bleedAvoidan ce)) 465 if (!RenderBoxModelObject::boxShadowShouldBeAppliedToBackground(bleedAvoidan ce))
469 return false; 466 return false;
470 467
471 return !const_cast<RenderImage*>(this)->boxDecorationBackgroundIsKnownToBeOb scured(); 468 return !const_cast<RenderImage*>(this)->boxDecorationBackgroundIsKnownToBeOb scured();
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 return 0; 625 return 0;
629 626
630 ImageResource* cachedImage = m_imageResource->cachedImage(); 627 ImageResource* cachedImage = m_imageResource->cachedImage();
631 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( )) 628 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( ))
632 return toSVGImage(cachedImage->image())->embeddedContentBox(); 629 return toSVGImage(cachedImage->image())->embeddedContentBox();
633 630
634 return 0; 631 return 0;
635 } 632 }
636 633
637 } // namespace blink 634 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698