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 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 7 * Copyright (C) 2010 Google Inc. All rights reserved. | 7 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| 11 * License as published by the Free Software Foundation; either | 11 * License as published by the Free Software Foundation; either |
| 12 * version 2 of the License, or (at your option) any later version. | 12 * version 2 of the License, or (at your option) any later version. |
| 13 * | 13 * |
| 14 * This library is distributed in the hope that it will be useful, | 14 * This library is distributed in the hope that it will be useful, |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 * Library General Public License for more details. | 17 * Library General Public License for more details. |
| 18 * | 18 * |
| 19 * You should have received a copy of the GNU Library General Public License | 19 * You should have received a copy of the GNU Library General Public License |
| 20 * along with this library; see the file COPYING.LIB. If not, write to | 20 * along with this library; see the file COPYING.LIB. If not, write to |
| 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 22 * Boston, MA 02110-1301, USA. | 22 * Boston, MA 02110-1301, USA. |
| 23 * | 23 * |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/layout/LayoutBoxModelObject.h" | 27 #include "core/layout/LayoutBoxModelObject.h" |
| 28 | 28 |
| 29 #include "core/dom/NodeComputedStyle.h" | |
| 29 #include "core/layout/ImageQualityController.h" | 30 #include "core/layout/ImageQualityController.h" |
| 30 #include "core/layout/LayoutBlock.h" | 31 #include "core/layout/LayoutBlock.h" |
| 31 #include "core/layout/LayoutFlowThread.h" | 32 #include "core/layout/LayoutFlowThread.h" |
| 32 #include "core/layout/LayoutGeometryMap.h" | 33 #include "core/layout/LayoutGeometryMap.h" |
| 33 #include "core/layout/LayoutInline.h" | 34 #include "core/layout/LayoutInline.h" |
| 34 #include "core/layout/LayoutObject.h" | 35 #include "core/layout/LayoutObject.h" |
| 35 #include "core/layout/LayoutTextFragment.h" | 36 #include "core/layout/LayoutTextFragment.h" |
| 36 #include "core/layout/LayoutView.h" | 37 #include "core/layout/LayoutView.h" |
| 37 #include "core/layout/compositing/CompositedDeprecatedPaintLayerMapping.h" | 38 #include "core/layout/compositing/CompositedDeprecatedPaintLayerMapping.h" |
| 38 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" | 39 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 // gets the same layout after changing position property, although no | 243 // gets the same layout after changing position property, although no |
| 243 // re-raster (rect-based invalidation) is needed, display items should | 244 // re-raster (rect-based invalidation) is needed, display items should |
| 244 // still update their paint offset. | 245 // still update their paint offset. |
| 245 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && oldStyle) { | 246 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && oldStyle) { |
| 246 bool newStyleIsFixedPosition = style()->position() == FixedPosition; | 247 bool newStyleIsFixedPosition = style()->position() == FixedPosition; |
| 247 bool oldStyleIsFixedPosition = oldStyle->position() == FixedPosition; | 248 bool oldStyleIsFixedPosition = oldStyle->position() == FixedPosition; |
| 248 if (newStyleIsFixedPosition != oldStyleIsFixedPosition) | 249 if (newStyleIsFixedPosition != oldStyleIsFixedPosition) |
| 249 invalidateDisplayItemClientForNonCompositingDescendants(); | 250 invalidateDisplayItemClientForNonCompositingDescendants(); |
| 250 } | 251 } |
| 251 | 252 |
| 253 if (isDocumentElement() && isHTMLHtmlElement(node())) { | |
| 254 // Refers to backgroundStolenForBeingBody(). | |
| 255 bool newStyleHasBackground = style()->hasBackground(); | |
| 256 bool oldStyleHasBackground = oldStyle && oldStyle->hasBackground(); | |
| 257 if (newStyleHasBackground != oldStyleHasBackground) { | |
| 258 Element* body = document().body(); | |
| 259 LayoutObject* bodyLayout = isHTMLBodyElement(body) ? body->layoutObj ect() : nullptr; | |
| 260 if (bodyLayout) { | |
| 261 const ComputedStyle* bodyStyle = bodyLayout->style(); | |
| 262 if (bodyStyle && bodyStyle->hasBackground()) | |
| 263 bodyLayout-> setShouldDoFullPaintInvalidation(); | |
|
Xianzhu
2015/06/02 23:34:35
s/-> /->/
trchen
2015/06/03 00:06:59
Acknowledged.
| |
| 264 } | |
| 265 } | |
| 266 } | |
| 267 | |
| 252 if (FrameView *frameView = view()->frameView()) { | 268 if (FrameView *frameView = view()->frameView()) { |
| 253 bool newStyleIsViewportConstained = style()->hasViewportConstrainedPosit ion(); | 269 bool newStyleIsViewportConstained = style()->hasViewportConstrainedPosit ion(); |
| 254 bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportCo nstrainedPosition(); | 270 bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportCo nstrainedPosition(); |
| 255 if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) { | 271 if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) { |
| 256 if (newStyleIsViewportConstained && layer()) | 272 if (newStyleIsViewportConstained && layer()) |
| 257 frameView->addViewportConstrainedObject(this); | 273 frameView->addViewportConstrainedObject(this); |
| 258 else | 274 else |
| 259 frameView->removeViewportConstrainedObject(this); | 275 frameView->removeViewportConstrainedObject(this); |
| 260 } | 276 } |
| 261 } | 277 } |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 702 return false; | 718 return false; |
| 703 } | 719 } |
| 704 | 720 |
| 705 if (!hasOneNormalBoxShadow) | 721 if (!hasOneNormalBoxShadow) |
| 706 return false; | 722 return false; |
| 707 | 723 |
| 708 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor); | 724 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor); |
| 709 if (backgroundColor.hasAlpha()) | 725 if (backgroundColor.hasAlpha()) |
| 710 return false; | 726 return false; |
| 711 | 727 |
| 728 // TODO(trchen): Mask layers are painted with the same code path as backgrou nd layers. | |
| 729 // We shouldn't paint shadow to the mask by accident. | |
| 730 if (style()->maskImage()) | |
| 731 return false; | |
| 732 | |
| 712 const FillLayer* lastBackgroundLayer = &style()->backgroundLayers(); | 733 const FillLayer* lastBackgroundLayer = &style()->backgroundLayers(); |
| 713 for (const FillLayer* next = lastBackgroundLayer->next(); next; next = lastB ackgroundLayer->next()) | 734 for (const FillLayer* next = lastBackgroundLayer->next(); next; next = lastB ackgroundLayer->next()) |
| 714 lastBackgroundLayer = next; | 735 lastBackgroundLayer = next; |
| 715 | 736 |
| 716 if (lastBackgroundLayer->clip() != BorderFillBox) | 737 if (lastBackgroundLayer->clip() != BorderFillBox) |
| 717 return false; | 738 return false; |
| 718 | 739 |
| 719 if (lastBackgroundLayer->image() && style()->hasBorderRadius()) | 740 if (lastBackgroundLayer->image() && style()->hasBorderRadius()) |
| 720 return false; | 741 return false; |
| 721 | 742 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 937 | 958 |
| 938 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); | 959 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); |
| 939 for (LayoutObject* child = startChild; child && child != endChild; ) { | 960 for (LayoutObject* child = startChild; child && child != endChild; ) { |
| 940 // Save our next sibling as moveChildTo will clear it. | 961 // Save our next sibling as moveChildTo will clear it. |
| 941 LayoutObject* nextSibling = child->nextSibling(); | 962 LayoutObject* nextSibling = child->nextSibling(); |
| 942 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); | 963 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); |
| 943 child = nextSibling; | 964 child = nextSibling; |
| 944 } | 965 } |
| 945 } | 966 } |
| 946 | 967 |
| 968 bool LayoutBoxModelObject::backgroundStolenForBeingBody() const | |
| 969 { | |
| 970 // http://www.w3.org/TR/css3-background/#body-background | |
| 971 // If the root element is <html> with no background, and a <body> child elem ent exists, | |
| 972 // the root element steals the first <body> child element's background. | |
| 973 if (!isBody()) | |
| 974 return false; | |
| 975 | |
| 976 Element* rootElement = document().documentElement(); | |
| 977 if (!isHTMLHtmlElement(rootElement) || rootElement->ensureComputedStyle()->h asBackground()) | |
| 978 return false; | |
| 979 | |
| 980 if (node() != document().body()) | |
| 981 return false; | |
| 982 | |
| 983 return true; | |
| 984 } | |
| 985 | |
| 947 } // namespace blink | 986 } // namespace blink |
| OLD | NEW |