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

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

Issue 21430003: Implement interfaces in PaintInfo and make it a class. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@getterPaintInfo01
Patch Set: Second try Created 7 years, 4 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
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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 void RenderImage::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOf fset) 276 void RenderImage::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOf fset)
277 { 277 {
278 LayoutUnit cWidth = contentWidth(); 278 LayoutUnit cWidth = contentWidth();
279 LayoutUnit cHeight = contentHeight(); 279 LayoutUnit cHeight = contentHeight();
280 LayoutUnit leftBorder = borderLeft(); 280 LayoutUnit leftBorder = borderLeft();
281 LayoutUnit topBorder = borderTop(); 281 LayoutUnit topBorder = borderTop();
282 LayoutUnit leftPad = paddingLeft(); 282 LayoutUnit leftPad = paddingLeft();
283 LayoutUnit topPad = paddingTop(); 283 LayoutUnit topPad = paddingTop();
284 284
285 GraphicsContext* context = paintInfo.context; 285 GraphicsContext* context = paintInfo.getContext();
286 286
287 Page* page = 0; 287 Page* page = 0;
288 if (Frame* frame = this->frame()) 288 if (Frame* frame = this->frame())
289 page = frame->page(); 289 page = frame->page();
290 290
291 if (!m_imageResource->hasImage() || m_imageResource->errorOccurred()) { 291 if (!m_imageResource->hasImage() || m_imageResource->errorOccurred()) {
292 if (paintInfo.phase == PaintPhaseSelection) 292 if (paintInfo.getPhase() == PaintPhaseSelection)
293 return; 293 return;
294 294
295 if (page && paintInfo.phase == PaintPhaseForeground) 295 if (page && paintInfo.getPhase() == PaintPhaseForeground)
296 page->addRelevantUnpaintedObject(this, visualOverflowRect()); 296 page->addRelevantUnpaintedObject(this, visualOverflowRect());
297 297
298 if (cWidth > 2 && cHeight > 2) { 298 if (cWidth > 2 && cHeight > 2) {
299 const int borderWidth = 1; 299 const int borderWidth = 1;
300 300
301 // Draw an outline rect where the image should be. 301 // Draw an outline rect where the image should be.
302 context->setStrokeStyle(SolidStroke); 302 context->setStrokeStyle(SolidStroke);
303 context->setStrokeColor(Color::lightGray); 303 context->setStrokeColor(Color::lightGray);
304 context->setFillColor(Color::transparent); 304 context->setFillColor(Color::transparent);
305 context->drawRect(pixelSnappedIntRect(LayoutRect(paintOffset.x() + l eftBorder + leftPad, paintOffset.y() + topBorder + topPad, cWidth, cHeight))); 305 context->drawRect(pixelSnappedIntRect(LayoutRect(paintOffset.x() + l eftBorder + leftPad, paintOffset.y() + topBorder + topPad, cWidth, cHeight)));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 if (errorPictureDrawn) { 351 if (errorPictureDrawn) {
352 if (usableWidth >= textWidth && fontMetrics.height() <= imag eOffset.height()) 352 if (usableWidth >= textWidth && fontMetrics.height() <= imag eOffset.height())
353 context->drawText(font, textRunPaintInfo, textOrigin); 353 context->drawText(font, textRunPaintInfo, textOrigin);
354 } else if (usableWidth >= textWidth && usableHeight >= fontMetri cs.height()) 354 } else if (usableWidth >= textWidth && usableHeight >= fontMetri cs.height())
355 context->drawText(font, textRunPaintInfo, textOrigin); 355 context->drawText(font, textRunPaintInfo, textOrigin);
356 } 356 }
357 } 357 }
358 } else if (m_imageResource->hasImage() && cWidth > 0 && cHeight > 0) { 358 } else if (m_imageResource->hasImage() && cWidth > 0 && cHeight > 0) {
359 RefPtr<Image> img = m_imageResource->image(cWidth, cHeight); 359 RefPtr<Image> img = m_imageResource->image(cWidth, cHeight);
360 if (!img || img->isNull()) { 360 if (!img || img->isNull()) {
361 if (page && paintInfo.phase == PaintPhaseForeground) 361 if (page && paintInfo.getPhase() == PaintPhaseForeground)
362 page->addRelevantUnpaintedObject(this, visualOverflowRect()); 362 page->addRelevantUnpaintedObject(this, visualOverflowRect());
363 return; 363 return;
364 } 364 }
365 365
366 LayoutSize contentSize(cWidth, cHeight); 366 LayoutSize contentSize(cWidth, cHeight);
367 LayoutPoint contentLocation = paintOffset; 367 LayoutPoint contentLocation = paintOffset;
368 contentLocation.move(leftBorder + leftPad, topBorder + topPad); 368 contentLocation.move(leftBorder + leftPad, topBorder + topPad);
369 paintIntoRect(context, LayoutRect(contentLocation, contentSize)); 369 paintIntoRect(context, LayoutRect(contentLocation, contentSize));
370 370
371 if (cachedImage() && page && paintInfo.phase == PaintPhaseForeground) { 371 if (cachedImage() && page && paintInfo.getPhase() == PaintPhaseForegroun d) {
372 // For now, count images as unpainted if they are still progressivel y loading. We may want 372 // For now, count images as unpainted if they are still progressivel y loading. We may want
373 // to refine this in the future to account for the portion of the im age that has painted. 373 // to refine this in the future to account for the portion of the im age that has painted.
374 if (cachedImage()->isLoading()) 374 if (cachedImage()->isLoading())
375 page->addRelevantUnpaintedObject(this, LayoutRect(contentLocatio n, contentSize)); 375 page->addRelevantUnpaintedObject(this, LayoutRect(contentLocatio n, contentSize));
376 else 376 else
377 page->addRelevantRepaintedObject(this, LayoutRect(contentLocatio n, contentSize)); 377 page->addRelevantRepaintedObject(this, LayoutRect(contentLocatio n, contentSize));
378 } 378 }
379 } 379 }
380 } 380 }
381 381
382 void RenderImage::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 382 void RenderImage::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
383 { 383 {
384 RenderReplaced::paint(paintInfo, paintOffset); 384 RenderReplaced::paint(paintInfo, paintOffset);
385 385
386 if (paintInfo.phase == PaintPhaseOutline) 386 if (paintInfo.getPhase() == PaintPhaseOutline)
387 paintAreaElementFocusRing(paintInfo); 387 paintAreaElementFocusRing(paintInfo);
388 } 388 }
389 389
390 void RenderImage::paintAreaElementFocusRing(PaintInfo& paintInfo) 390 void RenderImage::paintAreaElementFocusRing(PaintInfo& paintInfo)
391 { 391 {
392 Document* document = this->document(); 392 Document* document = this->document();
393 393
394 if (document->printing() || !document->frame()->selection()->isFocusedAndAct ive()) 394 if (document->printing() || !document->frame()->selection()->isFocusedAndAct ive())
395 return; 395 return;
396 396
397 if (paintInfo.context->paintingDisabled() && !paintInfo.context->updatingCon trolTints()) 397 if (paintInfo.getContext()->paintingDisabled() && !paintInfo.getContext()->u pdatingControlTints())
398 return; 398 return;
399 399
400 Element* focusedElement = document->focusedElement(); 400 Element* focusedElement = document->focusedElement();
401 if (!focusedElement || !isHTMLAreaElement(focusedElement)) 401 if (!focusedElement || !isHTMLAreaElement(focusedElement))
402 return; 402 return;
403 403
404 HTMLAreaElement* areaElement = toHTMLAreaElement(focusedElement); 404 HTMLAreaElement* areaElement = toHTMLAreaElement(focusedElement);
405 if (areaElement->imageElement() != node()) 405 if (areaElement->imageElement() != node())
406 return; 406 return;
407 407
408 // Even if the theme handles focus ring drawing for entire elements, it won' t do it for 408 // Even if the theme handles focus ring drawing for entire elements, it won' t do it for
409 // an area within an image, so we don't call RenderTheme::supportsFocusRing here. 409 // an area within an image, so we don't call RenderTheme::supportsFocusRing here.
410 410
411 Path path = areaElement->computePath(this); 411 Path path = areaElement->computePath(this);
412 if (path.isEmpty()) 412 if (path.isEmpty())
413 return; 413 return;
414 414
415 RenderStyle* areaElementStyle = areaElement->computedStyle(); 415 RenderStyle* areaElementStyle = areaElement->computedStyle();
416 unsigned short outlineWidth = areaElementStyle->outlineWidth(); 416 unsigned short outlineWidth = areaElementStyle->outlineWidth();
417 if (!outlineWidth) 417 if (!outlineWidth)
418 return; 418 return;
419 419
420 // FIXME: Clip path instead of context when Skia pathops is ready. 420 // FIXME: Clip path instead of context when Skia pathops is ready.
421 // https://crbug.com/251206 421 // https://crbug.com/251206
422 GraphicsContextStateSaver savedContext(*paintInfo.context); 422 GraphicsContextStateSaver savedContext(*(paintInfo.getContext()));
423 paintInfo.context->clip(absoluteContentBox()); 423 paintInfo.getContext()->clip(absoluteContentBox());
424 paintInfo.context->drawFocusRing(path, outlineWidth, 424 paintInfo.getContext()->drawFocusRing(path, outlineWidth,
425 areaElementStyle->outlineOffset(), 425 areaElementStyle->outlineOffset(),
426 resolveColor(areaElementStyle, CSSPropertyOutlineColor)); 426 resolveColor(areaElementStyle, CSSPropertyOutlineColor));
427 } 427 }
428 428
429 void RenderImage::areaElementFocusChanged(HTMLAreaElement* areaElement) 429 void RenderImage::areaElementFocusChanged(HTMLAreaElement* areaElement)
430 { 430 {
431 ASSERT(areaElement->imageElement() == node()); 431 ASSERT(areaElement->imageElement() == node());
432 432
433 Path path = areaElement->computePath(this); 433 Path path = areaElement->computePath(this);
434 if (path.isEmpty()) 434 if (path.isEmpty())
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 return 0; 586 return 0;
587 587
588 CachedImage* cachedImage = m_imageResource->cachedImage(); 588 CachedImage* cachedImage = m_imageResource->cachedImage();
589 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( )) 589 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( ))
590 return static_cast<SVGImage*>(cachedImage->image())->embeddedContentBox( ); 590 return static_cast<SVGImage*>(cachedImage->image())->embeddedContentBox( );
591 591
592 return 0; 592 return 0;
593 } 593 }
594 594
595 } // namespace WebCore 595 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698