Chromium Code Reviews| 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, |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 if (!style()->isHorizontalWritingMode()) | 188 if (!style()->isHorizontalWritingMode()) |
| 189 return true; | 189 return true; |
| 190 | 190 |
| 191 // The width/height checks below assume horizontal writing mode. | 191 // The width/height checks below assume horizontal writing mode. |
| 192 ASSERT(style()->isHorizontalWritingMode()); | 192 ASSERT(style()->isHorizontalWritingMode()); |
| 193 | 193 |
| 194 if (size().width() != viewLogicalWidthForBoxSizing()) | 194 if (size().width() != viewLogicalWidthForBoxSizing()) |
| 195 return true; | 195 return true; |
| 196 | 196 |
| 197 if (size().height() != viewLogicalHeightForBoxSizing()) { | 197 if (size().height() != viewLogicalHeightForBoxSizing()) { |
| 198 if (LayoutObject* backgroundLayoutObject = this->backgroundLayoutObject( )) { | 198 // When background-attachment is 'fixed', we treat the viewport (instead of the 'root' |
| 199 // When background-attachment is 'fixed', we treat the viewport (ins tead of the 'root' | 199 // i.e. html or body) as the background positioning area, and we should full paint invalidation |
| 200 // i.e. html or body) as the background positioning area, and we sho uld full paint invalidation | 200 // viewport resize if the background image is not composited and needs f ull paint invalidation on |
| 201 // viewport resize if the background image is not composited and nee ds full paint invalidation on | 201 // background positioning area resize. |
| 202 // background positioning area resize. | 202 if (!m_compositor || !m_compositor->needsFixedRootBackgroundLayer(layer( ))) { |
| 203 if (!m_compositor || !m_compositor->needsFixedRootBackgroundLayer(la yer())) { | 203 if (style()->hasFixedBackgroundImage() |
| 204 if (backgroundLayoutObject->style()->hasFixedBackgroundImage() | 204 && mustInvalidateFillLayersPaintOnHeightChange(style()->backgrou ndLayers())) |
| 205 && mustInvalidateFillLayersPaintOnHeightChange(backgroundLay outObject->style()->backgroundLayers())) | 205 return true; |
| 206 return true; | |
| 207 } | |
| 208 } | 206 } |
| 209 } | 207 } |
| 210 | 208 |
| 211 return false; | 209 return false; |
| 212 } | 210 } |
| 213 | 211 |
| 214 void LayoutView::layout() | 212 void LayoutView::layout() |
| 215 { | 213 { |
| 216 if (!document().paginated()) | 214 if (!document().paginated()) |
| 217 setPageLogicalHeight(0); | 215 setPageLogicalHeight(0); |
| 218 | 216 |
| 219 if (shouldUsePrintingLayout()) | 217 if (shouldUsePrintingLayout()) |
| 220 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth() ; | 218 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth() ; |
| 221 | 219 |
| 222 SubtreeLayoutScope layoutScope(*this); | 220 SubtreeLayoutScope layoutScope(*this); |
| 223 | 221 |
| 224 LayoutRect oldLayoutOverflowRect = layoutOverflowRect(); | |
| 225 | |
| 226 // Use calcWidth/Height to get the new width/height, since this will take th e full page zoom factor into account. | 222 // Use calcWidth/Height to get the new width/height, since this will take th e full page zoom factor into account. |
| 227 bool relayoutChildren = !shouldUsePrintingLayout() && (!m_frameView | 223 bool relayoutChildren = !shouldUsePrintingLayout() && (!m_frameView |
| 228 || logicalWidth() != viewLogicalWidthForBoxSizing() | 224 || logicalWidth() != viewLogicalWidthForBoxSizing() |
| 229 || logicalHeight() != viewLogicalHeightForBoxSizing()); | 225 || logicalHeight() != viewLogicalHeightForBoxSizing()); |
| 230 if (relayoutChildren) { | 226 if (relayoutChildren) { |
| 231 layoutScope.setChildNeedsLayout(this); | 227 layoutScope.setChildNeedsLayout(this); |
| 232 for (LayoutObject* child = firstChild(); child; child = child->nextSibli ng()) { | 228 for (LayoutObject* child = firstChild(); child; child = child->nextSibli ng()) { |
| 233 if (child->isSVGRoot()) | 229 if (child->isSVGRoot()) |
| 234 continue; | 230 continue; |
| 235 | 231 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 247 ASSERT(!m_layoutState); | 243 ASSERT(!m_layoutState); |
| 248 if (!needsLayout()) | 244 if (!needsLayout()) |
| 249 return; | 245 return; |
| 250 | 246 |
| 251 LayoutState rootLayoutState(pageLogicalHeight(), pageLogicalHeightChanged(), *this); | 247 LayoutState rootLayoutState(pageLogicalHeight(), pageLogicalHeightChanged(), *this); |
| 252 | 248 |
| 253 m_pageLogicalHeightChanged = false; | 249 m_pageLogicalHeightChanged = false; |
| 254 | 250 |
| 255 layoutContent(); | 251 layoutContent(); |
| 256 | 252 |
| 257 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && layoutOverflowRect() ! = oldLayoutOverflowRect) { | |
| 258 // The document element paints the viewport background, so we need to in validate it when | |
| 259 // layout overflow changes. | |
| 260 // FIXME: Improve viewport background styling/invalidation/painting. crb ug.com/475115 | |
| 261 if (Element* documentElement = document().documentElement()) { | |
| 262 if (LayoutObject* rootObject = documentElement->layoutObject()) | |
| 263 rootObject->setShouldDoFullPaintInvalidation(); | |
| 264 } | |
| 265 } | |
| 266 | |
| 267 #if ENABLE(ASSERT) | 253 #if ENABLE(ASSERT) |
| 268 checkLayoutState(); | 254 checkLayoutState(); |
| 269 #endif | 255 #endif |
| 270 clearNeedsLayout(); | 256 clearNeedsLayout(); |
| 271 } | 257 } |
| 272 | 258 |
| 259 void LayoutView::styleDidChange(StyleDifference diff, const ComputedStyle* oldSt yle) | |
| 260 { | |
| 261 const ComputedStyle& newStyle = styleRef(); | |
| 262 | |
| 263 if (oldStyle && oldStyle->hasEntirelyFixedBackground() != newStyle.hasEntire lyFixedBackground()) | |
| 264 compositor()->setNeedsUpdateFixedBackground(); | |
| 265 | |
| 266 LayoutBlockFlow::styleDidChange(diff, oldStyle); | |
| 267 } | |
| 268 | |
| 269 PaintInvalidationReason LayoutView::invalidatePaintIfNeeded(PaintInvalidationSta te& paintInvalidationState, const LayoutBoxModelObject& newPaintInvalidationCont ainer) | |
| 270 { | |
| 271 const LayoutObject* rootObject = document().documentElement() ? document().d ocumentElement()->layoutObject() : nullptr; | |
| 272 TransformationMatrix newTransform; | |
| 273 LayoutSize newBorderBoxSize; | |
| 274 LayoutRect newPaddingBoxRect; | |
| 275 LayoutRect newContentBoxRect; | |
| 276 | |
| 277 if (rootObject && rootObject->isBox()) { | |
| 278 const LayoutBox& rootBox = toLayoutBox(*rootObject); | |
| 279 if (rootBox.hasLayer()) { | |
| 280 const DeprecatedPaintLayer& rootLayer = *rootBox.layer(); | |
| 281 LayoutPoint offset; | |
| 282 rootLayer.convertToLayerCoords(nullptr, offset); | |
| 283 newTransform.translate(offset.x(), offset.y()); | |
| 284 newTransform.multiply(rootLayer.currentTransform()); | |
| 285 } | |
| 286 newBorderBoxSize = rootBox.size(); | |
| 287 newPaddingBoxRect = rootBox.paddingBoxRect(); | |
| 288 newContentBoxRect = rootBox.contentBoxRect(); | |
| 289 } | |
| 290 | |
| 291 if (m_previousRootBackgroundPositioning.transform != newTransform) | |
| 292 setShouldDoFullPaintInvalidation(PaintInvalidationLocationChange); | |
| 293 | |
| 294 const FillLayer& backgroundLayers = style()->backgroundLayers(); | |
| 295 if (mustInvalidateFillLayersPaintOnWidthChange(backgroundLayers) || mustInva lidateFillLayersPaintOnHeightChange(backgroundLayers)) { | |
| 296 if (m_previousRootBackgroundPositioning.borderBoxSize != newBorderBoxSiz e | |
| 297 || m_previousRootBackgroundPositioning.paddingBoxRect != newPaddingB oxRect | |
| 298 || m_previousRootBackgroundPositioning.contentBoxRect != newContentB oxRect) { | |
| 299 setShouldDoFullPaintInvalidation(PaintInvalidationBorderBoxChange); | |
| 300 } | |
| 301 } | |
|
Xianzhu
2015/06/05 03:44:51
We don't allow setShouldDoFullPaintInvalidation()
| |
| 302 | |
| 303 m_previousRootBackgroundPositioning.transform = newTransform; | |
| 304 m_previousRootBackgroundPositioning.borderBoxSize = newBorderBoxSize; | |
| 305 m_previousRootBackgroundPositioning.paddingBoxRect = newPaddingBoxRect; | |
| 306 m_previousRootBackgroundPositioning.contentBoxRect = newContentBoxRect; | |
| 307 | |
| 308 return LayoutBox::invalidatePaintIfNeeded(paintInvalidationState, newPaintIn validationContainer); | |
| 309 } | |
| 310 | |
| 273 void LayoutView::mapLocalToContainer(const LayoutBoxModelObject* paintInvalidati onContainer, TransformState& transformState, MapCoordinatesFlags mode, bool* was Fixed, const PaintInvalidationState* paintInvalidationState) const | 311 void LayoutView::mapLocalToContainer(const LayoutBoxModelObject* paintInvalidati onContainer, TransformState& transformState, MapCoordinatesFlags mode, bool* was Fixed, const PaintInvalidationState* paintInvalidationState) const |
| 274 { | 312 { |
| 275 ASSERT_UNUSED(wasFixed, !wasFixed || *wasFixed == static_cast<bool>(mode & I sFixed)); | 313 ASSERT_UNUSED(wasFixed, !wasFixed || *wasFixed == static_cast<bool>(mode & I sFixed)); |
| 276 | 314 |
| 277 if (!paintInvalidationContainer && mode & UseTransforms && shouldUseTransfor mFromContainer(0)) { | 315 if (!paintInvalidationContainer && mode & UseTransforms && shouldUseTransfor mFromContainer(0)) { |
| 278 TransformationMatrix t; | 316 TransformationMatrix t; |
| 279 getTransformFromContainer(0, LayoutSize(), t); | 317 getTransformFromContainer(0, LayoutSize(), t); |
| 280 transformState.applyTransform(t); | 318 transformState.applyTransform(t); |
| 281 } | 319 } |
| 282 | 320 |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 837 | 875 |
| 838 IntRect LayoutView::unscaledDocumentRect() const | 876 IntRect LayoutView::unscaledDocumentRect() const |
| 839 { | 877 { |
| 840 LayoutRect overflowRect(layoutOverflowRect()); | 878 LayoutRect overflowRect(layoutOverflowRect()); |
| 841 flipForWritingMode(overflowRect); | 879 flipForWritingMode(overflowRect); |
| 842 return pixelSnappedIntRect(overflowRect); | 880 return pixelSnappedIntRect(overflowRect); |
| 843 } | 881 } |
| 844 | 882 |
| 845 bool LayoutView::rootBackgroundIsEntirelyFixed() const | 883 bool LayoutView::rootBackgroundIsEntirelyFixed() const |
| 846 { | 884 { |
| 847 if (LayoutObject* backgroundLayoutObject = this->backgroundLayoutObject()) | 885 return style()->hasEntirelyFixedBackground(); |
| 848 return backgroundLayoutObject->style()->hasEntirelyFixedBackground(); | |
| 849 return false; | |
| 850 } | |
| 851 | |
| 852 LayoutObject* LayoutView::backgroundLayoutObject() const | |
| 853 { | |
| 854 if (Element* documentElement = document().documentElement()) { | |
| 855 if (LayoutObject* rootObject = documentElement->layoutObject()) | |
| 856 return rootObject->layoutObjectForRootBackground(); | |
| 857 } | |
| 858 return 0; | |
| 859 } | 886 } |
| 860 | 887 |
| 861 LayoutRect LayoutView::backgroundRect(LayoutBox* backgroundLayoutObject) const | 888 LayoutRect LayoutView::backgroundRect(LayoutBox* backgroundLayoutObject) const |
| 862 { | 889 { |
| 863 return LayoutRect(unscaledDocumentRect()); | 890 return LayoutRect(unscaledDocumentRect()); |
| 864 } | 891 } |
| 865 | 892 |
| 866 IntRect LayoutView::documentRect() const | 893 IntRect LayoutView::documentRect() const |
| 867 { | 894 { |
| 868 FloatRect overflowRect(unscaledDocumentRect()); | 895 FloatRect overflowRect(unscaledDocumentRect()); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 974 return viewHeight(IncludeScrollbars) / scale; | 1001 return viewHeight(IncludeScrollbars) / scale; |
| 975 } | 1002 } |
| 976 | 1003 |
| 977 void LayoutView::willBeDestroyed() | 1004 void LayoutView::willBeDestroyed() |
| 978 { | 1005 { |
| 979 LayoutBlockFlow::willBeDestroyed(); | 1006 LayoutBlockFlow::willBeDestroyed(); |
| 980 m_compositor.clear(); | 1007 m_compositor.clear(); |
| 981 } | 1008 } |
| 982 | 1009 |
| 983 } // namespace blink | 1010 } // namespace blink |
| OLD | NEW |