~ubuntu-branches/ubuntu/lucid/webkit/lucid-updates

« back to all changes in this revision

Viewing changes to WebCore/rendering/RenderImage.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gustavo Noronha Silva
  • Date: 2010-02-04 19:30:57 UTC
  • mfrom: (1.2.8 upstream) (4.3.9 sid)
  • Revision ID: james.westby@ubuntu.com-20100204193057-d3018lm1fipb0703
* New upstream release
* debian/copyright:
- Updated with changes since 1.1.19.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include "config.h"
27
27
#include "RenderImage.h"
28
28
 
 
29
#include "Frame.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"
35
38
#include "Page.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>
39
44
 
425
430
    }
426
431
}
427
432
 
 
433
void RenderImage::paint(PaintInfo& paintInfo, int tx, int ty)
 
434
{
 
435
    RenderReplaced::paint(paintInfo, tx, ty);
 
436
    
 
437
    if (paintInfo.phase == PaintPhaseOutline)
 
438
        paintFocusRings(paintInfo, style());
 
439
}
 
440
    
 
441
void RenderImage::paintFocusRings(PaintInfo& paintInfo, const RenderStyle* style)
 
442
{
 
443
    // Don't draw focus rings if printing.
 
444
    if (document()->printing() || !document()->frame()->selection()->isFocusedAndActive())
 
445
        return;
 
446
    
 
447
    if (paintInfo.context->paintingDisabled() && !paintInfo.context->updatingControlTints())
 
448
        return;
 
449
 
 
450
    HTMLMapElement* mapElement = imageMap();
 
451
    if (!mapElement)
 
452
        return;
 
453
    
 
454
    Document* document = mapElement->document();
 
455
    if (!document)
 
456
        return;
 
457
    
 
458
    Node* focusedNode = document->focusedNode();
 
459
    if (!focusedNode)
 
460
        return;
 
461
    
 
462
    RefPtr<HTMLCollection> areas = mapElement->areas();
 
463
    unsigned numAreas = areas->length();
 
464
    
 
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)
 
469
            continue;
 
470
        
 
471
        Vector<Path> focusRingPaths;
 
472
        focusRingPaths.append(areaElement->getPath(this));
 
473
        paintInfo.context->drawFocusRing(focusRingPaths, style->outlineWidth(), style->outlineOffset(), style->outlineColor());
 
474
        break;
 
475
    }
 
476
}
 
477
    
428
478
void RenderImage::paintIntoRect(GraphicsContext* context, const IntRect& rect)
429
479
{
430
480
    if (!hasImage() || errorOccurred() || rect.width() <= 0 || rect.height() <= 0)
445
495
    return errorOccurred() ? intrinsicSize().height() : 0;
446
496
}
447
497
 
448
 
HTMLMapElement* RenderImage::imageMap()
 
498
HTMLMapElement* RenderImage::imageMap() const
449
499
{
450
500
    HTMLImageElement* i = node() && node()->hasTagName(imgTag) ? static_cast<HTMLImageElement*>(node()) : 0;
451
501
    return i ? i->document()->getImageMap(i->getAttribute(usemapAttr)) : 0;