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

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

Issue 197283025: Use new is*Element() helper functions more in rendering code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 { 401 {
402 Document& document = this->document(); 402 Document& document = this->document();
403 403
404 if (document.printing() || !document.frame()->selection().isFocusedAndActive ()) 404 if (document.printing() || !document.frame()->selection().isFocusedAndActive ())
405 return; 405 return;
406 406
407 if (paintInfo.context->paintingDisabled() && !paintInfo.context->updatingCon trolTints()) 407 if (paintInfo.context->paintingDisabled() && !paintInfo.context->updatingCon trolTints())
408 return; 408 return;
409 409
410 Element* focusedElement = document.focusedElement(); 410 Element* focusedElement = document.focusedElement();
411 if (!focusedElement || !focusedElement->hasTagName(areaTag)) 411 if (!isHTMLAreaElement(focusedElement))
412 return; 412 return;
413 413
414 HTMLAreaElement* areaElement = toHTMLAreaElement(focusedElement); 414 HTMLAreaElement& areaElement = toHTMLAreaElement(*focusedElement);
415 if (areaElement->imageElement() != node()) 415 if (areaElement.imageElement() != node())
416 return; 416 return;
417 417
418 // Even if the theme handles focus ring drawing for entire elements, it won' t do it for 418 // Even if the theme handles focus ring drawing for entire elements, it won' t do it for
419 // an area within an image, so we don't call RenderTheme::supportsFocusRing here. 419 // an area within an image, so we don't call RenderTheme::supportsFocusRing here.
420 420
421 Path path = areaElement->computePath(this); 421 Path path = areaElement.computePath(this);
422 if (path.isEmpty()) 422 if (path.isEmpty())
423 return; 423 return;
424 424
425 RenderStyle* areaElementStyle = areaElement->computedStyle(); 425 RenderStyle* areaElementStyle = areaElement.computedStyle();
426 unsigned short outlineWidth = areaElementStyle->outlineWidth(); 426 unsigned short outlineWidth = areaElementStyle->outlineWidth();
427 if (!outlineWidth) 427 if (!outlineWidth)
428 return; 428 return;
429 429
430 // FIXME: Clip path instead of context when Skia pathops is ready. 430 // FIXME: Clip path instead of context when Skia pathops is ready.
431 // https://crbug.com/251206 431 // https://crbug.com/251206
432 GraphicsContextStateSaver savedContext(*paintInfo.context); 432 GraphicsContextStateSaver savedContext(*paintInfo.context);
433 paintInfo.context->clip(absoluteContentBox()); 433 paintInfo.context->clip(absoluteContentBox());
434 paintInfo.context->drawFocusRing(path, outlineWidth, 434 paintInfo.context->drawFocusRing(path, outlineWidth,
435 areaElementStyle->outlineOffset(), 435 areaElementStyle->outlineOffset(),
(...skipping 21 matching lines...) Expand all
457 void RenderImage::paintIntoRect(GraphicsContext* context, const LayoutRect& rect ) 457 void RenderImage::paintIntoRect(GraphicsContext* context, const LayoutRect& rect )
458 { 458 {
459 IntRect alignedRect = pixelSnappedIntRect(rect); 459 IntRect alignedRect = pixelSnappedIntRect(rect);
460 if (!m_imageResource->hasImage() || m_imageResource->errorOccurred() || alig nedRect.width() <= 0 || alignedRect.height() <= 0) 460 if (!m_imageResource->hasImage() || m_imageResource->errorOccurred() || alig nedRect.width() <= 0 || alignedRect.height() <= 0)
461 return; 461 return;
462 462
463 RefPtr<Image> img = m_imageResource->image(alignedRect.width(), alignedRect. height()); 463 RefPtr<Image> img = m_imageResource->image(alignedRect.width(), alignedRect. height());
464 if (!img || img->isNull()) 464 if (!img || img->isNull())
465 return; 465 return;
466 466
467 HTMLImageElement* imageElt = (node() && node()->hasTagName(imgTag)) ? toHTML ImageElement(node()) : 0; 467 HTMLImageElement* imageElt = isHTMLImageElement(node()) ? toHTMLImageElement (node()) : 0;
468 CompositeOperator compositeOperator = imageElt ? imageElt->compositeOperator () : CompositeSourceOver; 468 CompositeOperator compositeOperator = imageElt ? imageElt->compositeOperator () : CompositeSourceOver;
469 Image* image = m_imageResource->image().get(); 469 Image* image = m_imageResource->image().get();
470 bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, image, a lignedRect.size()); 470 bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, image, a lignedRect.size());
471 471
472 InspectorInstrumentation::willPaintImage(this); 472 InspectorInstrumentation::willPaintImage(this);
473 context->drawImage(m_imageResource->image(alignedRect.width(), alignedRect.h eight()).get(), alignedRect, compositeOperator, shouldRespectImageOrientation(), useLowQualityScaling); 473 context->drawImage(m_imageResource->image(alignedRect.width(), alignedRect.h eight()).get(), alignedRect, compositeOperator, shouldRespectImageOrientation(), useLowQualityScaling);
474 InspectorInstrumentation::didPaintImage(this); 474 InspectorInstrumentation::didPaintImage(this);
475 } 475 }
476 476
477 bool RenderImage::boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox*) const 477 bool RenderImage::boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox*) const
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 return foregroundIsKnownToBeOpaqueInRect(backgroundPaintedExtent(), 0); 515 return foregroundIsKnownToBeOpaqueInRect(backgroundPaintedExtent(), 0);
516 } 516 }
517 517
518 LayoutUnit RenderImage::minimumReplacedHeight() const 518 LayoutUnit RenderImage::minimumReplacedHeight() const
519 { 519 {
520 return m_imageResource->errorOccurred() ? intrinsicSize().height() : LayoutU nit(); 520 return m_imageResource->errorOccurred() ? intrinsicSize().height() : LayoutU nit();
521 } 521 }
522 522
523 HTMLMapElement* RenderImage::imageMap() const 523 HTMLMapElement* RenderImage::imageMap() const
524 { 524 {
525 HTMLImageElement* i = node() && node()->hasTagName(imgTag) ? toHTMLImageElem ent(node()) : 0; 525 HTMLImageElement* i = isHTMLImageElement(node()) ? toHTMLImageElement(node() ) : 0;
526 return i ? i->treeScope().getImageMap(i->fastGetAttribute(usemapAttr)) : 0; 526 return i ? i->treeScope().getImageMap(i->fastGetAttribute(usemapAttr)) : 0;
527 } 527 }
528 528
529 bool RenderImage::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu lt, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOf fset, HitTestAction hitTestAction) 529 bool RenderImage::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu lt, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOf fset, HitTestAction hitTestAction)
530 { 530 {
531 HitTestResult tempResult(result.hitTestLocation()); 531 HitTestResult tempResult(result.hitTestLocation());
532 bool inside = RenderReplaced::nodeAtPoint(request, tempResult, locationInCon tainer, accumulatedOffset, hitTestAction); 532 bool inside = RenderReplaced::nodeAtPoint(request, tempResult, locationInCon tainer, accumulatedOffset, hitTestAction);
533 533
534 if (tempResult.innerNode() && node()) { 534 if (tempResult.innerNode() && node()) {
535 if (HTMLMapElement* map = imageMap()) { 535 if (HTMLMapElement* map = imageMap()) {
(...skipping 12 matching lines...) Expand all
548 if (inside) 548 if (inside)
549 result = tempResult; 549 result = tempResult;
550 return inside; 550 return inside;
551 } 551 }
552 552
553 void RenderImage::updateAltText() 553 void RenderImage::updateAltText()
554 { 554 {
555 if (!node()) 555 if (!node())
556 return; 556 return;
557 557
558 if (node()->hasTagName(inputTag)) 558 if (isHTMLInputElement(*node()))
559 m_altText = toHTMLInputElement(node())->altText(); 559 m_altText = toHTMLInputElement(node())->altText();
560 else if (node()->hasTagName(imgTag)) 560 else if (isHTMLImageElement(*node()))
561 m_altText = toHTMLImageElement(node())->altText(); 561 m_altText = toHTMLImageElement(node())->altText();
562 } 562 }
563 563
564 void RenderImage::layout() 564 void RenderImage::layout()
565 { 565 {
566 LayoutRectRecorder recorder(*this); 566 LayoutRectRecorder recorder(*this);
567 RenderReplaced::layout(); 567 RenderReplaced::layout();
568 updateInnerContentRect(); 568 updateInnerContentRect();
569 } 569 }
570 570
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 return 0; 626 return 0;
627 627
628 ImageResource* cachedImage = m_imageResource->cachedImage(); 628 ImageResource* cachedImage = m_imageResource->cachedImage();
629 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( )) 629 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( ))
630 return toSVGImage(cachedImage->image())->embeddedContentBox(); 630 return toSVGImage(cachedImage->image())->embeddedContentBox();
631 631
632 return 0; 632 return 0;
633 } 633 }
634 634
635 } // namespace WebCore 635 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderFileUploadControl.cpp ('k') | Source/core/rendering/RenderLayer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698