| 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 12 matching lines...) Expand all Loading... |
| 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/BoxPainter.h" |
| 33 #include "core/paint/PartPainter.h" |
| 33 #include "core/plugins/PluginView.h" | 34 #include "core/plugins/PluginView.h" |
| 34 #include "core/rendering/GraphicsContextAnnotator.h" | |
| 35 #include "core/rendering/HitTestResult.h" | 35 #include "core/rendering/HitTestResult.h" |
| 36 #include "core/rendering/RenderLayer.h" | 36 #include "core/rendering/RenderLayer.h" |
| 37 #include "core/rendering/RenderView.h" | 37 #include "core/rendering/RenderView.h" |
| 38 #include "core/rendering/svg/RenderSVGRoot.h" | 38 #include "core/rendering/svg/RenderSVGRoot.h" |
| 39 | 39 |
| 40 namespace blink { | 40 namespace blink { |
| 41 | 41 |
| 42 RenderPart::RenderPart(Element* element) | 42 RenderPart::RenderPart(Element* element) |
| 43 : RenderReplaced(element) | 43 : RenderReplaced(element) |
| 44 #if !ENABLE(OILPAN) | 44 #if !ENABLE(OILPAN) |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 | 218 |
| 219 void RenderPart::layout() | 219 void RenderPart::layout() |
| 220 { | 220 { |
| 221 ASSERT(needsLayout()); | 221 ASSERT(needsLayout()); |
| 222 | 222 |
| 223 clearNeedsLayout(); | 223 clearNeedsLayout(); |
| 224 } | 224 } |
| 225 | 225 |
| 226 // FIXME: factor into PartPainter. | |
| 227 void RenderPart::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) | 226 void RenderPart::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
| 228 { | 227 { |
| 229 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); | 228 PartPainter(*this).paint(paintInfo, paintOffset); |
| 230 | |
| 231 if (!shouldPaint(paintInfo, paintOffset)) | |
| 232 return; | |
| 233 | |
| 234 LayoutPoint adjustedPaintOffset = paintOffset + location(); | |
| 235 | |
| 236 if (hasBoxDecorationBackground() && (paintInfo.phase == PaintPhaseForeground
|| paintInfo.phase == PaintPhaseSelection)) | |
| 237 paintBoxDecorationBackground(paintInfo, adjustedPaintOffset); | |
| 238 | |
| 239 if (paintInfo.phase == PaintPhaseMask) { | |
| 240 paintMask(paintInfo, adjustedPaintOffset); | |
| 241 return; | |
| 242 } | |
| 243 | |
| 244 if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSe
lfOutline) && style()->hasOutline()) | |
| 245 ObjectPainter(*this).paintOutline(paintInfo, LayoutRect(adjustedPaintOff
set, size())); | |
| 246 | |
| 247 if (paintInfo.phase != PaintPhaseForeground) | |
| 248 return; | |
| 249 | |
| 250 if (style()->hasBorderRadius()) { | |
| 251 LayoutRect borderRect = LayoutRect(adjustedPaintOffset, size()); | |
| 252 | |
| 253 if (borderRect.isEmpty()) | |
| 254 return; | |
| 255 | |
| 256 // Push a clip if we have a border radius, since we want to round the fo
reground content that gets painted. | |
| 257 paintInfo.context->save(); | |
| 258 RoundedRect roundedInnerRect = style()->getRoundedInnerBorderFor(borderR
ect, | |
| 259 paddingTop() + borderTop(), paddingBottom() + borderBottom(), paddin
gLeft() + borderLeft(), paddingRight() + borderRight(), true, true); | |
| 260 BoxPainter::clipRoundedInnerRect(paintInfo.context, borderRect, roundedI
nnerRect); | |
| 261 } | |
| 262 | |
| 263 if (this->widget()) | |
| 264 paintContents(paintInfo, paintOffset); | |
| 265 | |
| 266 if (style()->hasBorderRadius()) | |
| 267 paintInfo.context->restore(); | |
| 268 | |
| 269 // Paint a partially transparent wash over selected widgets. | |
| 270 if (isSelected() && !document().printing()) { | |
| 271 LayoutRect rect = localSelectionRect(); | |
| 272 rect.moveBy(adjustedPaintOffset); | |
| 273 paintInfo.context->fillRect(pixelSnappedIntRect(rect), selectionBackgrou
ndColor()); | |
| 274 } | |
| 275 | |
| 276 if (canResize()) | |
| 277 layer()->scrollableArea()->paintResizer(paintInfo.context, roundedIntPoi
nt(adjustedPaintOffset), paintInfo.rect); | |
| 278 } | 229 } |
| 279 | 230 |
| 280 void RenderPart::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOff
set) | 231 void RenderPart::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOff
set) |
| 281 { | 232 { |
| 282 LayoutPoint adjustedPaintOffset = paintOffset + location(); | 233 PartPainter(*this).paintContents(paintInfo, paintOffset); |
| 283 | |
| 284 Widget* widget = this->widget(); | |
| 285 RELEASE_ASSERT(widget); | |
| 286 | |
| 287 // Tell the widget to paint now. This is the only time the widget is allowed | |
| 288 // to paint itself. That way it will composite properly with z-indexed layer
s. | |
| 289 IntPoint widgetLocation = widget->frameRect().location(); | |
| 290 IntPoint paintLocation(roundToInt(adjustedPaintOffset.x() + borderLeft() + p
addingLeft()), | |
| 291 roundToInt(adjustedPaintOffset.y() + borderTop() + paddingTop())); | |
| 292 IntRect paintRect = paintInfo.rect; | |
| 293 | |
| 294 IntSize widgetPaintOffset = paintLocation - widgetLocation; | |
| 295 // When painting widgets into compositing layers, tx and ty are relative to
the enclosing compositing layer, | |
| 296 // not the root. In this case, shift the CTM and adjust the paintRect to be
root-relative to fix plug-in drawing. | |
| 297 if (!widgetPaintOffset.isZero()) { | |
| 298 paintInfo.context->translate(widgetPaintOffset.width(), widgetPaintOffse
t.height()); | |
| 299 paintRect.move(-widgetPaintOffset); | |
| 300 } | |
| 301 widget->paint(paintInfo.context, paintRect); | |
| 302 | |
| 303 if (!widgetPaintOffset.isZero()) | |
| 304 paintInfo.context->translate(-widgetPaintOffset.width(), -widgetPaintOff
set.height()); | |
| 305 } | 234 } |
| 306 | 235 |
| 307 CursorDirective RenderPart::getCursor(const LayoutPoint& point, Cursor& cursor)
const | 236 CursorDirective RenderPart::getCursor(const LayoutPoint& point, Cursor& cursor)
const |
| 308 { | 237 { |
| 309 if (widget() && widget()->isPluginView()) { | 238 if (widget() && widget()->isPluginView()) { |
| 310 // A plug-in is responsible for setting the cursor when the pointer is o
ver it. | 239 // A plug-in is responsible for setting the cursor when the pointer is o
ver it. |
| 311 return DoNotSetCursor; | 240 return DoNotSetCursor; |
| 312 } | 241 } |
| 313 return RenderReplaced::getCursor(point, cursor); | 242 return RenderReplaced::getCursor(point, cursor); |
| 314 } | 243 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 if (widget->frameRect() == newFrame) | 325 if (widget->frameRect() == newFrame) |
| 397 return false; | 326 return false; |
| 398 | 327 |
| 399 RefPtrWillBeRawPtr<RenderPart> protector(this); | 328 RefPtrWillBeRawPtr<RenderPart> protector(this); |
| 400 RefPtrWillBeRawPtr<Node> protectedNode(node()); | 329 RefPtrWillBeRawPtr<Node> protectedNode(node()); |
| 401 widget->setFrameRect(newFrame); | 330 widget->setFrameRect(newFrame); |
| 402 return widget->frameRect().size() != newFrame.size(); | 331 return widget->frameRect().size() != newFrame.size(); |
| 403 } | 332 } |
| 404 | 333 |
| 405 } | 334 } |
| OLD | NEW |