Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: sky/engine/core/rendering/RenderBox.cpp

Issue 928393003: Remove the concept of document.documentElement (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. 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
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 && parent() && !parent()->normalChildNeedsLayout()) 110 && parent() && !parent()->normalChildNeedsLayout())
111 parent()->setChildNeedsLayout(); 111 parent()->setChildNeedsLayout();
112 } 112 }
113 } 113 }
114 114
115 void RenderBox::updateFromStyle() 115 void RenderBox::updateFromStyle()
116 { 116 {
117 RenderBoxModelObject::updateFromStyle(); 117 RenderBoxModelObject::updateFromStyle();
118 118
119 RenderStyle* styleToUse = style(); 119 RenderStyle* styleToUse = style();
120 bool isRootObject = isDocumentElement();
121 bool isViewObject = isRenderView();
122 120
123 // The root and the RenderView always paint their backgrounds/borders. 121 if (isRenderView()) {
124 if (isRootObject || isViewObject)
125 setHasBoxDecorationBackground(true); 122 setHasBoxDecorationBackground(true);
126 123 } else if (isRenderBlock()) {
127 // TODO(esprehn): Why do we not want to set this on the RenderView? 124 // TODO(esprehn): Why do we not want to set this on the RenderView?
128 if (isRenderBlock() && !isViewObject)
129 setHasOverflowClip(!styleToUse->isOverflowVisible()); 125 setHasOverflowClip(!styleToUse->isOverflowVisible());
126 }
130 127
131 setHasTransform(styleToUse->hasTransformRelatedProperty()); 128 setHasTransform(styleToUse->hasTransformRelatedProperty());
132 } 129 }
133 130
134 void RenderBox::layout() 131 void RenderBox::layout()
135 { 132 {
136 ASSERT(needsLayout()); 133 ASSERT(needsLayout());
137 134
138 RenderObject* child = slowFirstChild(); 135 RenderObject* child = slowFirstChild();
139 if (!child) { 136 if (!child) {
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 paintBackground(paintInfo, paintRect, boxDecorationData.backgroundColor, ble edAvoidance); 668 paintBackground(paintInfo, paintRect, boxDecorationData.backgroundColor, ble edAvoidance);
672 paintBoxShadow(paintInfo, paintRect, style, Inset); 669 paintBoxShadow(paintInfo, paintRect, style, Inset);
673 670
674 // The theme will tell us whether or not we should also paint the CSS border . 671 // The theme will tell us whether or not we should also paint the CSS border .
675 if (boxDecorationData.hasBorder && bleedAvoidance != BackgroundBleedBackgrou ndOverBorder) 672 if (boxDecorationData.hasBorder && bleedAvoidance != BackgroundBleedBackgrou ndOverBorder)
676 paintBorder(paintInfo, paintRect, style, bleedAvoidance); 673 paintBorder(paintInfo, paintRect, style, bleedAvoidance);
677 } 674 }
678 675
679 void RenderBox::paintBackground(const PaintInfo& paintInfo, const LayoutRect& pa intRect, const Color& backgroundColor, BackgroundBleedAvoidance bleedAvoidance) 676 void RenderBox::paintBackground(const PaintInfo& paintInfo, const LayoutRect& pa intRect, const Color& backgroundColor, BackgroundBleedAvoidance bleedAvoidance)
680 { 677 {
681 if (isDocumentElement()) {
682 paintRootBoxFillLayers(paintInfo);
683 return;
684 }
685 paintFillLayers(paintInfo, backgroundColor, style()->backgroundLayers(), pai ntRect, bleedAvoidance); 678 paintFillLayers(paintInfo, backgroundColor, style()->backgroundLayers(), pai ntRect, bleedAvoidance);
686 } 679 }
687 680
688 bool RenderBox::backgroundHasOpaqueTopLayer() const 681 bool RenderBox::backgroundHasOpaqueTopLayer() const
689 { 682 {
690 const FillLayer& fillLayer = style()->backgroundLayers(); 683 const FillLayer& fillLayer = style()->backgroundLayers();
691 if (fillLayer.clip() != BorderFillBox) 684 if (fillLayer.clip() != BorderFillBox)
692 return false; 685 return false;
693 686
694 if (fillLayer.hasOpaqueImage(this) && fillLayer.hasRepeatXY() && fillLayer.i mage()->canRender(*this)) 687 if (fillLayer.hasOpaqueImage(this) && fillLayer.hasRepeatXY() && fillLayer.i mage()->canRender(*this))
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 curLayer = curLayer->next(); 723 curLayer = curLayer->next();
731 } 724 }
732 725
733 if (layers.size() > 0 && (**layers.rbegin()).next()) 726 if (layers.size() > 0 && (**layers.rbegin()).next())
734 isBottomLayerOccluded = true; 727 isBottomLayerOccluded = true;
735 728
736 GraphicsContext* context = paintInfo.context; 729 GraphicsContext* context = paintInfo.context;
737 if (!context) 730 if (!context)
738 shouldDrawBackgroundInSeparateBuffer = false; 731 shouldDrawBackgroundInSeparateBuffer = false;
739 732
733 // FIXME(sky): Propagate this constant.
740 bool skipBaseColor = false; 734 bool skipBaseColor = false;
741 if (shouldDrawBackgroundInSeparateBuffer) { 735 if (shouldDrawBackgroundInSeparateBuffer)
742 bool isBaseColorVisible = !isBottomLayerOccluded && c.hasAlpha();
743
744 // Paint the document's base background color outside the transparency l ayer,
745 // so that the background images don't blend with this color: http://crb ug.com/389039.
746 if (isBaseColorVisible && isDocumentElementWithOpaqueBackground()) {
747 paintRootBackgroundColor(paintInfo, rect, Color());
748 skipBaseColor = true;
749 }
750 context->beginTransparencyLayer(1); 736 context->beginTransparencyLayer(1);
751 }
752 737
753 Vector<const FillLayer*>::const_reverse_iterator topLayer = layers.rend(); 738 Vector<const FillLayer*>::const_reverse_iterator topLayer = layers.rend();
754 for (Vector<const FillLayer*>::const_reverse_iterator it = layers.rbegin(); it != topLayer; ++it) 739 for (Vector<const FillLayer*>::const_reverse_iterator it = layers.rbegin(); it != topLayer; ++it)
755 paintFillLayer(paintInfo, c, **it, rect, bleedAvoidance, backgroundObjec t, skipBaseColor); 740 paintFillLayer(paintInfo, c, **it, rect, bleedAvoidance, backgroundObjec t, skipBaseColor);
756 741
757 if (shouldDrawBackgroundInSeparateBuffer) 742 if (shouldDrawBackgroundInSeparateBuffer)
758 context->endLayer(); 743 context->endLayer();
759 } 744 }
760 745
761 void RenderBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const FillLayer& fillLayer, const LayoutRect& rect, 746 void RenderBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const FillLayer& fillLayer, const LayoutRect& rect,
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 1298
1314 LayoutUnit RenderBox::computePercentageLogicalHeight(const Length& height) const 1299 LayoutUnit RenderBox::computePercentageLogicalHeight(const Length& height) const
1315 { 1300 {
1316 LayoutUnit availableHeight = -1; 1301 LayoutUnit availableHeight = -1;
1317 1302
1318 bool skippedAutoHeightContainingBlock = false; 1303 bool skippedAutoHeightContainingBlock = false;
1319 RenderBlock* cb = containingBlock(); 1304 RenderBlock* cb = containingBlock();
1320 const RenderBox* containingBlockChild = this; 1305 const RenderBox* containingBlockChild = this;
1321 LayoutUnit rootMarginBorderPaddingHeight = 0; 1306 LayoutUnit rootMarginBorderPaddingHeight = 0;
1322 while (!cb->isRenderView() && skipContainingBlockForPercentHeightCalculation (cb)) { 1307 while (!cb->isRenderView() && skipContainingBlockForPercentHeightCalculation (cb)) {
1323 if (cb->isDocumentElement())
1324 rootMarginBorderPaddingHeight += cb->marginBefore() + cb->marginAfte r() + cb->borderAndPaddingLogicalHeight();
1325 skippedAutoHeightContainingBlock = true; 1308 skippedAutoHeightContainingBlock = true;
1326 containingBlockChild = cb; 1309 containingBlockChild = cb;
1327 cb = cb->containingBlock(); 1310 cb = cb->containingBlock();
1328 } 1311 }
1329 cb->addPercentHeightDescendant(const_cast<RenderBox*>(this)); 1312 cb->addPercentHeightDescendant(const_cast<RenderBox*>(this));
1330 1313
1331 RenderStyle* cbstyle = cb->style(); 1314 RenderStyle* cbstyle = cb->style();
1332 1315
1333 // A positioned element that specified both top/bottom or that specifies hei ght should be treated as though it has a height 1316 // A positioned element that specified both top/bottom or that specifies hei ght should be treated as though it has a height
1334 // explicitly specified that can be used for any percentage computations. 1317 // explicitly specified that can be used for any percentage computations.
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after
2805 bool isOutOfFlowPositionedWithSpecifiedHeight = cb->isOutOfFlowPositioned() && (!cb->style()->logicalHeight().isAuto() || (!cb->style()->top().isAuto() && ! cb->style()->bottom().isAuto())); 2788 bool isOutOfFlowPositionedWithSpecifiedHeight = cb->isOutOfFlowPositioned() && (!cb->style()->logicalHeight().isAuto() || (!cb->style()->top().isAuto() && ! cb->style()->bottom().isAuto()));
2806 2789
2807 // Otherwise we only use our percentage height if our containing block had a specified 2790 // Otherwise we only use our percentage height if our containing block had a specified
2808 // height. 2791 // height.
2809 if (cb->style()->logicalHeight().isFixed()) 2792 if (cb->style()->logicalHeight().isFixed())
2810 return true; 2793 return true;
2811 if (cb->style()->logicalHeight().isPercent() && !isOutOfFlowPositionedWithSp ecifiedHeight) 2794 if (cb->style()->logicalHeight().isPercent() && !isOutOfFlowPositionedWithSp ecifiedHeight)
2812 return percentageLogicalHeightIsResolvableFromBlock(cb->containingBlock( ), cb->isOutOfFlowPositioned()); 2795 return percentageLogicalHeightIsResolvableFromBlock(cb->containingBlock( ), cb->isOutOfFlowPositioned());
2813 if (cb->isRenderView() || isOutOfFlowPositionedWithSpecifiedHeight) 2796 if (cb->isRenderView() || isOutOfFlowPositionedWithSpecifiedHeight)
2814 return true; 2797 return true;
2815 if (cb->isDocumentElement() && isOutOfFlowPositioned) {
2816 // Match the positioned objects behavior, which is that positioned objec ts will fill their viewport
2817 // always. Note we could only hit this case by recurring into computePe rcentageLogicalHeight on a positioned containing block.
2818 return true;
2819 }
2820
2821 return false; 2798 return false;
2822 } 2799 }
2823 2800
2824 LayoutUnit RenderBox::lineHeight(bool /*firstLine*/, LineDirectionMode direction , LinePositionMode /*linePositionMode*/) const 2801 LayoutUnit RenderBox::lineHeight(bool /*firstLine*/, LineDirectionMode direction , LinePositionMode /*linePositionMode*/) const
2825 { 2802 {
2826 if (isReplaced()) 2803 if (isReplaced())
2827 return direction == HorizontalLine ? m_marginBox.top() + height() + m_ma rginBox.bottom() : m_marginBox.right() + width() + m_marginBox.left(); 2804 return direction == HorizontalLine ? m_marginBox.top() + height() + m_ma rginBox.bottom() : m_marginBox.right() + width() + m_marginBox.left();
2828 return 0; 2805 return 0;
2829 } 2806 }
2830 2807
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2893 2870
2894 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) 2871 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style)
2895 { 2872 {
2896 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor); 2873 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor);
2897 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); 2874 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage();
2898 ASSERT(hasBackground == style.hasBackground()); 2875 ASSERT(hasBackground == style.hasBackground());
2899 hasBorder = style.hasBorder(); 2876 hasBorder = style.hasBorder();
2900 } 2877 }
2901 2878
2902 } // namespace blink 2879 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderBlockFlow.cpp ('k') | sky/engine/core/rendering/RenderBoxModelObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698