26
26
#include "config.h"
27
27
#include "RenderImage.h"
29
30
#include "GraphicsContext.h"
31
#include "HTMLAreaElement.h"
32
#include "HTMLCollection.h"
30
33
#include "HTMLImageElement.h"
31
34
#include "HTMLInputElement.h"
32
35
#include "HTMLMapElement.h"
33
36
#include "HTMLNames.h"
34
37
#include "HitTestResult.h"
39
#include "RenderTheme.h"
36
40
#include "RenderView.h"
41
#include "SelectionController.h"
37
42
#include <wtf/CurrentTime.h>
38
43
#include <wtf/UnusedParam.h>
433
void RenderImage::paint(PaintInfo& paintInfo, int tx, int ty)
435
RenderReplaced::paint(paintInfo, tx, ty);
437
if (paintInfo.phase == PaintPhaseOutline)
438
paintFocusRings(paintInfo, style());
441
void RenderImage::paintFocusRings(PaintInfo& paintInfo, const RenderStyle* style)
443
// Don't draw focus rings if printing.
444
if (document()->printing() || !document()->frame()->selection()->isFocusedAndActive())
447
if (paintInfo.context->paintingDisabled() && !paintInfo.context->updatingControlTints())
450
HTMLMapElement* mapElement = imageMap();
454
Document* document = mapElement->document();
458
Node* focusedNode = document->focusedNode();
462
RefPtr<HTMLCollection> areas = mapElement->areas();
463
unsigned numAreas = areas->length();
465
// FIXME: Clip the paths to the image bounding box.
466
for (unsigned k = 0; k < numAreas; ++k) {
467
HTMLAreaElement* areaElement = static_cast<HTMLAreaElement*>(areas->item(k));
468
if (focusedNode != areaElement)
471
Vector<Path> focusRingPaths;
472
focusRingPaths.append(areaElement->getPath(this));
473
paintInfo.context->drawFocusRing(focusRingPaths, style->outlineWidth(), style->outlineOffset(), style->outlineColor());
428
478
void RenderImage::paintIntoRect(GraphicsContext* context, const IntRect& rect)
430
480
if (!hasImage() || errorOccurred() || rect.width() <= 0 || rect.height() <= 0)
445
495
return errorOccurred() ? intrinsicSize().height() : 0;
448
HTMLMapElement* RenderImage::imageMap()
498
HTMLMapElement* RenderImage::imageMap() const
450
500
HTMLImageElement* i = node() && node()->hasTagName(imgTag) ? static_cast<HTMLImageElement*>(node()) : 0;
451
501
return i ? i->document()->getImageMap(i->getAttribute(usemapAttr)) : 0;