OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 */ | 19 */ |
20 | 20 |
21 #include "config.h" | 21 #include "config.h" |
22 #include "core/rendering/RenderView.h" | 22 #include "core/rendering/RenderView.h" |
23 | 23 |
24 #include "core/dom/Document.h" | 24 #include "core/dom/Document.h" |
25 #include "core/dom/Element.h" | 25 #include "core/dom/Element.h" |
26 #include "core/frame/LocalFrame.h" | 26 #include "core/frame/LocalFrame.h" |
27 #include "core/html/HTMLFrameOwnerElement.h" | 27 #include "core/html/HTMLFrameOwnerElement.h" |
28 #include "core/html/HTMLIFrameElement.h" | 28 #include "core/html/HTMLIFrameElement.h" |
29 #include "core/page/Page.h" | 29 #include "core/page/Page.h" |
| 30 #include "core/paint/ViewPainter.h" |
30 #include "core/rendering/ColumnInfo.h" | 31 #include "core/rendering/ColumnInfo.h" |
31 #include "core/rendering/FlowThreadController.h" | 32 #include "core/rendering/FlowThreadController.h" |
32 #include "core/rendering/GraphicsContextAnnotator.h" | 33 #include "core/rendering/GraphicsContextAnnotator.h" |
33 #include "core/rendering/HitTestResult.h" | 34 #include "core/rendering/HitTestResult.h" |
34 #include "core/rendering/RenderFlowThread.h" | 35 #include "core/rendering/RenderFlowThread.h" |
35 #include "core/rendering/RenderGeometryMap.h" | 36 #include "core/rendering/RenderGeometryMap.h" |
36 #include "core/rendering/RenderLayer.h" | 37 #include "core/rendering/RenderLayer.h" |
37 #include "core/rendering/RenderPart.h" | 38 #include "core/rendering/RenderPart.h" |
38 #include "core/rendering/RenderQuote.h" | 39 #include "core/rendering/RenderQuote.h" |
39 #include "core/rendering/RenderSelectionInfo.h" | 40 #include "core/rendering/RenderSelectionInfo.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 void RenderView::computeSelfHitTestRects(Vector<LayoutRect>& rects, const Layout
Point&) const | 307 void RenderView::computeSelfHitTestRects(Vector<LayoutRect>& rects, const Layout
Point&) const |
307 { | 308 { |
308 // Record the entire size of the contents of the frame. Note that we don't j
ust | 309 // Record the entire size of the contents of the frame. Note that we don't j
ust |
309 // use the viewport size (containing block) here because we want to ensure t
his includes | 310 // use the viewport size (containing block) here because we want to ensure t
his includes |
310 // all children (so we can avoid walking them explicitly). | 311 // all children (so we can avoid walking them explicitly). |
311 rects.append(LayoutRect(LayoutPoint::zero(), frameView()->contentsSize())); | 312 rects.append(LayoutRect(LayoutPoint::zero(), frameView()->contentsSize())); |
312 } | 313 } |
313 | 314 |
314 void RenderView::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) | 315 void RenderView::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
315 { | 316 { |
316 // If we ever require layout but receive a paint anyway, something has gone
horribly wrong. | 317 ViewPainter(*this).paint(paintInfo, paintOffset); |
317 ASSERT(!needsLayout()); | |
318 // RenderViews should never be called to paint with an offset not on device
pixels. | |
319 ASSERT(LayoutPoint(IntPoint(paintOffset.x(), paintOffset.y())) == paintOffse
t); | |
320 | |
321 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); | |
322 | |
323 // This avoids painting garbage between columns if there is a column gap. | |
324 if (m_frameView && style()->isOverflowPaged()) | |
325 paintInfo.context->fillRect(paintInfo.rect, m_frameView->baseBackgroundC
olor()); | |
326 | |
327 paintObject(paintInfo, paintOffset); | |
328 } | |
329 | |
330 static inline bool rendererObscuresBackground(RenderBox* rootBox) | |
331 { | |
332 ASSERT(rootBox); | |
333 RenderStyle* style = rootBox->style(); | |
334 if (style->visibility() != VISIBLE | |
335 || style->opacity() != 1 | |
336 || style->hasFilter() | |
337 || style->hasTransform()) | |
338 return false; | |
339 | |
340 if (rootBox->compositingState() == PaintsIntoOwnBacking) | |
341 return false; | |
342 | |
343 const RenderObject* rootRenderer = rootBox->rendererForRootBackground(); | |
344 if (rootRenderer->style()->backgroundClip() == TextFillBox) | |
345 return false; | |
346 | |
347 return true; | |
348 } | |
349 | |
350 bool RenderView::rootFillsViewportBackground(RenderBox* rootBox) const | |
351 { | |
352 ASSERT(rootBox); | |
353 // CSS Boxes always fill the viewport background (see paintRootBoxFillLayers
) | |
354 if (!rootBox->isSVG()) | |
355 return true; | |
356 | |
357 return rootBox->frameRect().contains(frameRect()); | |
358 } | 318 } |
359 | 319 |
360 void RenderView::paintBoxDecorationBackground(PaintInfo& paintInfo, const Layout
Point&) | 320 void RenderView::paintBoxDecorationBackground(PaintInfo& paintInfo, const Layout
Point&) |
361 { | 321 { |
362 if (document().ownerElement() || !view()) | 322 ViewPainter(*this).paintBoxDecorationBackground(paintInfo); |
363 return; | |
364 | |
365 if (paintInfo.skipRootBackground()) | |
366 return; | |
367 | |
368 bool shouldPaintBackground = true; | |
369 Node* documentElement = document().documentElement(); | |
370 if (RenderBox* rootBox = documentElement ? toRenderBox(documentElement->rend
erer()) : 0) | |
371 shouldPaintBackground = !rootFillsViewportBackground(rootBox) || !render
erObscuresBackground(rootBox); | |
372 | |
373 // If painting will entirely fill the view, no need to fill the background. | |
374 if (!shouldPaintBackground) | |
375 return; | |
376 | |
377 // This code typically only executes if the root element's visibility has be
en set to hidden, | |
378 // if there is a transform on the <html>, or if there is a page scale factor
less than 1. | |
379 // Only fill with the base background color (typically white) if we're the r
oot document, | |
380 // since iframes/frames with no background in the child document should show
the parent's background. | |
381 if (!frameView()->isTransparent()) { | |
382 Color baseColor = frameView()->baseBackgroundColor(); | |
383 if (baseColor.alpha()) { | |
384 CompositeOperator previousOperator = paintInfo.context->compositeOpe
ration(); | |
385 paintInfo.context->setCompositeOperation(CompositeCopy); | |
386 paintInfo.context->fillRect(paintInfo.rect, baseColor); | |
387 paintInfo.context->setCompositeOperation(previousOperator); | |
388 } else { | |
389 paintInfo.context->clearRect(paintInfo.rect); | |
390 } | |
391 } | |
392 } | 323 } |
393 | 324 |
394 void RenderView::invalidateTreeIfNeeded(const PaintInvalidationState& paintInval
idationState) | 325 void RenderView::invalidateTreeIfNeeded(const PaintInvalidationState& paintInval
idationState) |
395 { | 326 { |
396 ASSERT(!needsLayout()); | 327 ASSERT(!needsLayout()); |
397 | 328 |
398 // We specifically need to issue paint invalidations for the viewRect since
other renderers | 329 // We specifically need to issue paint invalidations for the viewRect since
other renderers |
399 // short-circuit on full-paint invalidation. | 330 // short-circuit on full-paint invalidation. |
400 LayoutRect dirtyRect = viewRect(); | 331 LayoutRect dirtyRect = viewRect(); |
401 if (doingFullPaintInvalidation() && !dirtyRect.isEmpty()) { | 332 if (doingFullPaintInvalidation() && !dirtyRect.isEmpty()) { |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 return viewWidth(IncludeScrollbars) / scale; | 897 return viewWidth(IncludeScrollbars) / scale; |
967 } | 898 } |
968 | 899 |
969 double RenderView::layoutViewportHeight() const | 900 double RenderView::layoutViewportHeight() const |
970 { | 901 { |
971 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; | 902 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; |
972 return viewHeight(IncludeScrollbars) / scale; | 903 return viewHeight(IncludeScrollbars) / scale; |
973 } | 904 } |
974 | 905 |
975 } // namespace blink | 906 } // namespace blink |
OLD | NEW |