OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Simon Hausmann <hausmann@kde.org> | 3 * (C) 2000 Simon Hausmann <hausmann@kde.org> |
4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) | 4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) |
5 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. |
6 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 11 matching lines...) Expand all Loading... |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #include "config.h" | 25 #include "config.h" |
26 #include "core/rendering/RenderPart.h" | 26 #include "core/rendering/RenderPart.h" |
27 | 27 |
28 #include "core/accessibility/AXObjectCache.h" | 28 #include "core/accessibility/AXObjectCache.h" |
29 #include "core/frame/FrameView.h" | 29 #include "core/frame/FrameView.h" |
30 #include "core/frame/LocalFrame.h" | 30 #include "core/frame/LocalFrame.h" |
31 #include "core/html/HTMLFrameElementBase.h" | 31 #include "core/html/HTMLFrameElementBase.h" |
32 #include "core/paint/BoxPainter.h" | 32 #include "core/paint/PartPainter.h" |
33 #include "core/plugins/PluginView.h" | 33 #include "core/plugins/PluginView.h" |
34 #include "core/rendering/GraphicsContextAnnotator.h" | |
35 #include "core/rendering/HitTestResult.h" | 34 #include "core/rendering/HitTestResult.h" |
36 #include "core/rendering/RenderLayer.h" | 35 #include "core/rendering/RenderLayer.h" |
37 #include "core/rendering/RenderView.h" | 36 #include "core/rendering/RenderView.h" |
38 #include "core/rendering/svg/RenderSVGRoot.h" | 37 #include "core/rendering/svg/RenderSVGRoot.h" |
39 | 38 |
40 namespace blink { | 39 namespace blink { |
41 | 40 |
42 RenderPart::RenderPart(Element* element) | 41 RenderPart::RenderPart(Element* element) |
43 : RenderReplaced(element) | 42 : RenderReplaced(element) |
44 #if !ENABLE(OILPAN) | 43 #if !ENABLE(OILPAN) |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 217 |
219 void RenderPart::layout() | 218 void RenderPart::layout() |
220 { | 219 { |
221 ASSERT(needsLayout()); | 220 ASSERT(needsLayout()); |
222 | 221 |
223 clearNeedsLayout(); | 222 clearNeedsLayout(); |
224 } | 223 } |
225 | 224 |
226 void RenderPart::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) | 225 void RenderPart::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
227 { | 226 { |
228 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); | 227 PartPainter(*this).paint(paintInfo, paintOffset); |
229 | |
230 if (!shouldPaint(paintInfo, paintOffset)) | |
231 return; | |
232 | |
233 LayoutPoint adjustedPaintOffset = paintOffset + location(); | |
234 | |
235 if (hasBoxDecorationBackground() && (paintInfo.phase == PaintPhaseForeground
|| paintInfo.phase == PaintPhaseSelection)) | |
236 paintBoxDecorationBackground(paintInfo, adjustedPaintOffset); | |
237 | |
238 if (paintInfo.phase == PaintPhaseMask) { | |
239 paintMask(paintInfo, adjustedPaintOffset); | |
240 return; | |
241 } | |
242 | |
243 if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSe
lfOutline) && style()->hasOutline()) | |
244 paintOutline(paintInfo, LayoutRect(adjustedPaintOffset, size())); | |
245 | |
246 if (paintInfo.phase != PaintPhaseForeground) | |
247 return; | |
248 | |
249 if (style()->hasBorderRadius()) { | |
250 LayoutRect borderRect = LayoutRect(adjustedPaintOffset, size()); | |
251 | |
252 if (borderRect.isEmpty()) | |
253 return; | |
254 | |
255 // Push a clip if we have a border radius, since we want to round the fo
reground content that gets painted. | |
256 paintInfo.context->save(); | |
257 RoundedRect roundedInnerRect = style()->getRoundedInnerBorderFor(borderR
ect, | |
258 paddingTop() + borderTop(), paddingBottom() + borderBottom(), paddin
gLeft() + borderLeft(), paddingRight() + borderRight(), true, true); | |
259 BoxPainter::clipRoundedInnerRect(paintInfo.context, borderRect, roundedI
nnerRect); | |
260 } | |
261 | |
262 if (this->widget()) | |
263 paintContents(paintInfo, paintOffset); | |
264 | |
265 if (style()->hasBorderRadius()) | |
266 paintInfo.context->restore(); | |
267 | |
268 // Paint a partially transparent wash over selected widgets. | |
269 if (isSelected() && !document().printing()) { | |
270 LayoutRect rect = localSelectionRect(); | |
271 rect.moveBy(adjustedPaintOffset); | |
272 paintInfo.context->fillRect(pixelSnappedIntRect(rect), selectionBackgrou
ndColor()); | |
273 } | |
274 | |
275 if (canResize()) | |
276 layer()->scrollableArea()->paintResizer(paintInfo.context, roundedIntPoi
nt(adjustedPaintOffset), paintInfo.rect); | |
277 } | |
278 | |
279 void RenderPart::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOff
set) | |
280 { | |
281 LayoutPoint adjustedPaintOffset = paintOffset + location(); | |
282 | |
283 Widget* widget = this->widget(); | |
284 RELEASE_ASSERT(widget); | |
285 | |
286 // Tell the widget to paint now. This is the only time the widget is allowed | |
287 // to paint itself. That way it will composite properly with z-indexed layer
s. | |
288 IntPoint widgetLocation = widget->frameRect().location(); | |
289 IntPoint paintLocation(roundToInt(adjustedPaintOffset.x() + borderLeft() + p
addingLeft()), | |
290 roundToInt(adjustedPaintOffset.y() + borderTop() + paddingTop())); | |
291 IntRect paintRect = paintInfo.rect; | |
292 | |
293 IntSize widgetPaintOffset = paintLocation - widgetLocation; | |
294 // When painting widgets into compositing layers, tx and ty are relative to
the enclosing compositing layer, | |
295 // not the root. In this case, shift the CTM and adjust the paintRect to be
root-relative to fix plug-in drawing. | |
296 if (!widgetPaintOffset.isZero()) { | |
297 paintInfo.context->translate(widgetPaintOffset.width(), widgetPaintOffse
t.height()); | |
298 paintRect.move(-widgetPaintOffset); | |
299 } | |
300 widget->paint(paintInfo.context, paintRect); | |
301 | |
302 if (!widgetPaintOffset.isZero()) | |
303 paintInfo.context->translate(-widgetPaintOffset.width(), -widgetPaintOff
set.height()); | |
304 } | 228 } |
305 | 229 |
306 CursorDirective RenderPart::getCursor(const LayoutPoint& point, Cursor& cursor)
const | 230 CursorDirective RenderPart::getCursor(const LayoutPoint& point, Cursor& cursor)
const |
307 { | 231 { |
308 if (widget() && widget()->isPluginView()) { | 232 if (widget() && widget()->isPluginView()) { |
309 // A plug-in is responsible for setting the cursor when the pointer is o
ver it. | 233 // A plug-in is responsible for setting the cursor when the pointer is o
ver it. |
310 return DoNotSetCursor; | 234 return DoNotSetCursor; |
311 } | 235 } |
312 return RenderReplaced::getCursor(point, cursor); | 236 return RenderReplaced::getCursor(point, cursor); |
313 } | 237 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 if (widget->frameRect() == newFrame) | 319 if (widget->frameRect() == newFrame) |
396 return false; | 320 return false; |
397 | 321 |
398 RefPtrWillBeRawPtr<RenderPart> protector(this); | 322 RefPtrWillBeRawPtr<RenderPart> protector(this); |
399 RefPtrWillBeRawPtr<Node> protectedNode(node()); | 323 RefPtrWillBeRawPtr<Node> protectedNode(node()); |
400 widget->setFrameRect(newFrame); | 324 widget->setFrameRect(newFrame); |
401 return widget->frameRect().size() != newFrame.size(); | 325 return widget->frameRect().size() != newFrame.size(); |
402 } | 326 } |
403 | 327 |
404 } | 328 } |
OLD | NEW |