OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 37 matching lines...) Loading... |
48 { | 48 { |
49 if (RenderReplaced::requiresLayer()) | 49 if (RenderReplaced::requiresLayer()) |
50 return true; | 50 return true; |
51 | 51 |
52 HTMLCanvasElement* canvas = toHTMLCanvasElement(node()); | 52 HTMLCanvasElement* canvas = toHTMLCanvasElement(node()); |
53 return canvas && canvas->renderingContext() && canvas->renderingContext()->i
sAccelerated(); | 53 return canvas && canvas->renderingContext() && canvas->renderingContext()->i
sAccelerated(); |
54 } | 54 } |
55 | 55 |
56 void RenderHTMLCanvas::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) | 56 void RenderHTMLCanvas::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) |
57 { | 57 { |
58 LayoutRect rect = contentBoxRect(); | 58 GraphicsContext* context = paintInfo.context; |
59 rect.moveBy(paintOffset); | 59 |
| 60 LayoutRect contentRect = contentBoxRect(); |
| 61 contentRect.moveBy(paintOffset); |
| 62 LayoutRect paintRect = replacedContentRect(); |
| 63 paintRect.moveBy(paintOffset); |
| 64 |
| 65 bool clip = !contentRect.contains(paintRect); |
| 66 if (clip) { |
| 67 // Not allowed to overflow the content box. |
| 68 paintInfo.context->save(); |
| 69 paintInfo.context->clip(pixelSnappedIntRect(contentRect)); |
| 70 } |
60 | 71 |
61 if (Frame* frame = this->frame()) { | 72 if (Frame* frame = this->frame()) { |
62 if (Page* page = frame->page()) { | 73 if (Page* page = frame->page()) { |
63 if (paintInfo.phase == PaintPhaseForeground) | 74 if (paintInfo.phase == PaintPhaseForeground) |
64 page->addRelevantRepaintedObject(this, rect); | 75 page->addRelevantRepaintedObject(this, intersection(paintRect, c
ontentRect)); |
65 } | 76 } |
66 } | 77 } |
67 | 78 |
68 bool useLowQualityScale = style()->imageRendering() == ImageRenderingOptimiz
eContrast; | 79 bool useLowQualityScale = style()->imageRendering() == ImageRenderingOptimiz
eContrast; |
69 toHTMLCanvasElement(node())->paint(paintInfo.context, rect, useLowQualitySca
le); | 80 toHTMLCanvasElement(node())->paint(context, paintRect, useLowQualityScale); |
| 81 |
| 82 if (clip) |
| 83 context->restore(); |
70 } | 84 } |
71 | 85 |
72 void RenderHTMLCanvas::canvasSizeChanged() | 86 void RenderHTMLCanvas::canvasSizeChanged() |
73 { | 87 { |
74 IntSize canvasSize = toHTMLCanvasElement(node())->size(); | 88 IntSize canvasSize = toHTMLCanvasElement(node())->size(); |
75 LayoutSize zoomedSize(canvasSize.width() * style()->effectiveZoom(), canvasS
ize.height() * style()->effectiveZoom()); | 89 LayoutSize zoomedSize(canvasSize.width() * style()->effectiveZoom(), canvasS
ize.height() * style()->effectiveZoom()); |
76 | 90 |
77 if (zoomedSize == intrinsicSize()) | 91 if (zoomedSize == intrinsicSize()) |
78 return; | 92 return; |
79 | 93 |
80 setIntrinsicSize(zoomedSize); | 94 setIntrinsicSize(zoomedSize); |
81 | 95 |
82 if (!parent()) | 96 if (!parent()) |
83 return; | 97 return; |
84 | 98 |
85 if (!preferredLogicalWidthsDirty()) | 99 if (!preferredLogicalWidthsDirty()) |
86 setPreferredLogicalWidthsDirty(true); | 100 setPreferredLogicalWidthsDirty(true); |
87 | 101 |
88 LayoutSize oldSize = size(); | 102 LayoutSize oldSize = size(); |
89 updateLogicalWidth(); | 103 updateLogicalWidth(); |
90 updateLogicalHeight(); | 104 updateLogicalHeight(); |
91 if (oldSize == size()) | 105 if (oldSize == size()) |
92 return; | 106 return; |
93 | 107 |
94 if (!selfNeedsLayout()) | 108 if (!selfNeedsLayout()) |
95 setNeedsLayout(true); | 109 setNeedsLayout(true); |
96 } | 110 } |
97 | 111 |
98 } // namespace WebCore | 112 } // namespace WebCore |
OLD | NEW |