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

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

Issue 686633002: First pass at removing position:fixed. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 offset += layer()->offsetForInFlowPosition(); 1549 offset += layer()->offsetForInFlowPosition();
1550 transformState.move(offset); 1550 transformState.move(offset);
1551 return; 1551 return;
1552 } 1552 }
1553 1553
1554 bool containerSkipped; 1554 bool containerSkipped;
1555 RenderObject* o = container(paintInvalidationContainer, &containerSkipped); 1555 RenderObject* o = container(paintInvalidationContainer, &containerSkipped);
1556 if (!o) 1556 if (!o)
1557 return; 1557 return;
1558 1558
1559 bool isFixedPos = style()->position() == FixedPosition;
1560 bool hasTransform = hasLayer() && layer()->transform(); 1559 bool hasTransform = hasLayer() && layer()->transform();
1561 // If this box has a transform, it acts as a fixed position container for fi xed descendants, 1560 // If this box has a transform, it acts as a fixed position container for fi xed descendants,
1562 // and may itself also be fixed position. So propagate 'fixed' up only if th is box is fixed position. 1561 // and may itself also be fixed position. So propagate 'fixed' up only if th is box is fixed position.
1563 if (hasTransform && !isFixedPos) 1562 if (hasTransform)
1564 mode &= ~IsFixed; 1563 mode &= ~IsFixed;
1565 else if (isFixedPos)
1566 mode |= IsFixed;
1567 1564
1568 if (wasFixed) 1565 if (wasFixed)
1569 *wasFixed = mode & IsFixed; 1566 *wasFixed = mode & IsFixed;
1570 1567
1571 LayoutSize containerOffset = offsetFromContainer(o, roundedLayoutPoint(trans formState.mappedPoint())); 1568 LayoutSize containerOffset = offsetFromContainer(o, roundedLayoutPoint(trans formState.mappedPoint()));
1572 1569
1573 bool preserve3D = mode & UseTransforms && (o->style()->preserves3D() || styl e()->preserves3D()); 1570 bool preserve3D = mode & UseTransforms && (o->style()->preserves3D() || styl e()->preserves3D());
1574 if (mode & UseTransforms && shouldUseTransformFromContainer(o)) { 1571 if (mode & UseTransforms && shouldUseTransformFromContainer(o)) {
1575 TransformationMatrix t; 1572 TransformationMatrix t;
1576 getTransformFromContainer(o, containerOffset, t); 1573 getTransformFromContainer(o, containerOffset, t);
1577 transformState.applyTransform(t, preserve3D ? TransformState::Accumulate Transform : TransformState::FlattenTransform); 1574 transformState.applyTransform(t, preserve3D ? TransformState::Accumulate Transform : TransformState::FlattenTransform);
1578 } else 1575 } else
1579 transformState.move(containerOffset.width(), containerOffset.height(), p reserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransfo rm); 1576 transformState.move(containerOffset.width(), containerOffset.height(), p reserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransfo rm);
1580 1577
1581 if (containerSkipped) { 1578 if (containerSkipped) {
1582 // There can't be a transform between paintInvalidationContainer and o, because transforms create containers, so it should be safe 1579 // There can't be a transform between paintInvalidationContainer and o, because transforms create containers, so it should be safe
1583 // to just subtract the delta between the paintInvalidationContainer and o. 1580 // to just subtract the delta between the paintInvalidationContainer and o.
1584 LayoutSize containerOffset = paintInvalidationContainer->offsetFromAnces torContainer(o); 1581 LayoutSize containerOffset = paintInvalidationContainer->offsetFromAnces torContainer(o);
1585 transformState.move(-containerOffset.width(), -containerOffset.height(), preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTrans form); 1582 transformState.move(-containerOffset.width(), -containerOffset.height(), preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTrans form);
1586 return; 1583 return;
1587 } 1584 }
1588 1585
1589 mode &= ~ApplyContainerFlip; 1586 mode &= ~ApplyContainerFlip;
1590 1587
1591 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode, was Fixed); 1588 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode, was Fixed);
1592 } 1589 }
1593 1590
1594 void RenderBox::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformState & transformState) const 1591 void RenderBox::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformState & transformState) const
1595 { 1592 {
1596 bool isFixedPos = style()->position() == FixedPosition;
1597 bool hasTransform = hasLayer() && layer()->transform(); 1593 bool hasTransform = hasLayer() && layer()->transform();
1598 if (hasTransform && !isFixedPos) { 1594 if (hasTransform) {
1599 // If this box has a transform, it acts as a fixed position container fo r fixed descendants, 1595 // If this box has a transform, it acts as a fixed position container fo r fixed descendants,
1600 // and may itself also be fixed position. So propagate 'fixed' up only i f this box is fixed position. 1596 // and may itself also be fixed position. So propagate 'fixed' up only i f this box is fixed position.
1601 mode &= ~IsFixed; 1597 mode &= ~IsFixed;
1602 } else if (isFixedPos) 1598 }
1603 mode |= IsFixed;
1604 1599
1605 RenderBoxModelObject::mapAbsoluteToLocalPoint(mode, transformState); 1600 RenderBoxModelObject::mapAbsoluteToLocalPoint(mode, transformState);
1606 } 1601 }
1607 1602
1608 LayoutSize RenderBox::offsetFromContainer(const RenderObject* o, const LayoutPoi nt& point, bool* offsetDependsOnPoint) const 1603 LayoutSize RenderBox::offsetFromContainer(const RenderObject* o, const LayoutPoi nt& point, bool* offsetDependsOnPoint) const
1609 { 1604 {
1610 ASSERT(o == container()); 1605 ASSERT(o == container());
1611 1606
1612 LayoutSize offset; 1607 LayoutSize offset;
1613 if (isRelPositioned()) 1608 if (isRelPositioned())
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 // physical coordinate space of the paintInvalidationContainer. 1714 // physical coordinate space of the paintInvalidationContainer.
1720 RenderStyle* styleToUse = style(); 1715 RenderStyle* styleToUse = style();
1721 1716
1722 EPosition position = styleToUse->position(); 1717 EPosition position = styleToUse->position();
1723 1718
1724 // We need to inflate the paint invalidation rect before we use paintInvalid ationState, 1719 // We need to inflate the paint invalidation rect before we use paintInvalid ationState,
1725 // else we would forget to inflate it for the current renderer. FIXME: If th ese were 1720 // else we would forget to inflate it for the current renderer. FIXME: If th ese were
1726 // included into the visual overflow for repaint, we wouldn't have this issu e. 1721 // included into the visual overflow for repaint, we wouldn't have this issu e.
1727 inflatePaintInvalidationRectForReflectionAndFilter(rect); 1722 inflatePaintInvalidationRectForReflectionAndFilter(rect);
1728 1723
1729 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain tInvalidationContainer) && position != FixedPosition) { 1724 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain tInvalidationContainer)) {
1730 if (layer() && layer()->transform()) 1725 if (layer() && layer()->transform())
1731 rect = layer()->transform()->mapRect(pixelSnappedIntRect(rect)); 1726 rect = layer()->transform()->mapRect(pixelSnappedIntRect(rect));
1732 1727
1733 // We can't trust the bits on RenderObject, because this might be called while re-resolving style. 1728 // We can't trust the bits on RenderObject, because this might be called while re-resolving style.
1734 if (styleToUse->hasInFlowPosition() && layer()) 1729 if (styleToUse->hasInFlowPosition() && layer())
1735 rect.move(layer()->offsetForInFlowPosition()); 1730 rect.move(layer()->offsetForInFlowPosition());
1736 1731
1737 rect.moveBy(location()); 1732 rect.moveBy(location());
1738 rect.move(paintInvalidationState->paintOffset()); 1733 rect.move(paintInvalidationState->paintOffset());
1739 if (paintInvalidationState->isClipped()) 1734 if (paintInvalidationState->isClipped())
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 // See http://www.w3.org/TR/2014/CR-css-writing-modes-3-20140320/#orthogonal -flows 2443 // See http://www.w3.org/TR/2014/CR-css-writing-modes-3-20140320/#orthogonal -flows
2449 containingBlock->setMarginBeforeForChild(this, marginBefore); 2444 containingBlock->setMarginBeforeForChild(this, marginBefore);
2450 containingBlock->setMarginAfterForChild(this, marginAfter); 2445 containingBlock->setMarginAfterForChild(this, marginAfter);
2451 } 2446 }
2452 2447
2453 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo delObject* containingBlock, bool checkForPerpendicularWritingMode) const 2448 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo delObject* containingBlock, bool checkForPerpendicularWritingMode) const
2454 { 2449 {
2455 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting Mode() != isHorizontalWritingMode()) 2450 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting Mode() != isHorizontalWritingMode())
2456 return containingBlockLogicalHeightForPositioned(containingBlock, false) ; 2451 return containingBlockLogicalHeightForPositioned(containingBlock, false) ;
2457 2452
2458 // Use viewport as container for top-level fixed-position elements.
2459 if (style()->position() == FixedPosition && containingBlock->isRenderView()) {
2460 const RenderView* view = toRenderView(containingBlock);
2461 if (FrameView* frameView = view->frameView()) {
2462 LayoutRect viewportRect = frameView->visibleContentRect();
2463 return containingBlock->isHorizontalWritingMode() ? viewportRect.wid th() : viewportRect.height();
2464 }
2465 }
2466
2467 if (containingBlock->isBox()) 2453 if (containingBlock->isBox())
2468 return toRenderBox(containingBlock)->clientLogicalWidth(); 2454 return toRenderBox(containingBlock)->clientLogicalWidth();
2469 2455
2470 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ()); 2456 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ());
2471 2457
2472 const RenderInline* flow = toRenderInline(containingBlock); 2458 const RenderInline* flow = toRenderInline(containingBlock);
2473 InlineFlowBox* first = flow->firstLineBox(); 2459 InlineFlowBox* first = flow->firstLineBox();
2474 InlineFlowBox* last = flow->lastLineBox(); 2460 InlineFlowBox* last = flow->lastLineBox();
2475 2461
2476 // If the containing block is empty, return a width of 0. 2462 // If the containing block is empty, return a width of 0.
(...skipping 11 matching lines...) Expand all
2488 } 2474 }
2489 2475
2490 return std::max<LayoutUnit>(0, fromRight - fromLeft); 2476 return std::max<LayoutUnit>(0, fromRight - fromLeft);
2491 } 2477 }
2492 2478
2493 LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxM odelObject* containingBlock, bool checkForPerpendicularWritingMode) const 2479 LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxM odelObject* containingBlock, bool checkForPerpendicularWritingMode) const
2494 { 2480 {
2495 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting Mode() != isHorizontalWritingMode()) 2481 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting Mode() != isHorizontalWritingMode())
2496 return containingBlockLogicalWidthForPositioned(containingBlock, false); 2482 return containingBlockLogicalWidthForPositioned(containingBlock, false);
2497 2483
2498 // Use viewport as container for top-level fixed-position elements.
2499 if (style()->position() == FixedPosition && containingBlock->isRenderView()) {
2500 const RenderView* view = toRenderView(containingBlock);
2501 if (FrameView* frameView = view->frameView()) {
2502 LayoutRect viewportRect = frameView->visibleContentRect();
2503 return containingBlock->isHorizontalWritingMode() ? viewportRect.hei ght() : viewportRect.width();
2504 }
2505 }
2506
2507 if (containingBlock->isBox()) { 2484 if (containingBlock->isBox()) {
2508 const RenderBlock* cb = containingBlock->isRenderBlock() ? 2485 const RenderBlock* cb = containingBlock->isRenderBlock() ?
2509 toRenderBlock(containingBlock) : containingBlock->containingBlock(); 2486 toRenderBlock(containingBlock) : containingBlock->containingBlock();
2510 return cb->clientLogicalHeight(); 2487 return cb->clientLogicalHeight();
2511 } 2488 }
2512 2489
2513 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ()); 2490 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ());
2514 2491
2515 const RenderInline* flow = toRenderInline(containingBlock); 2492 const RenderInline* flow = toRenderInline(containingBlock);
2516 InlineFlowBox* first = flow->firstLineBox(); 2493 InlineFlowBox* first = flow->firstLineBox();
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after
4208 4185
4209 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) 4186 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style)
4210 { 4187 {
4211 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor); 4188 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor);
4212 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); 4189 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage();
4213 ASSERT(hasBackground == style.hasBackground()); 4190 ASSERT(hasBackground == style.hasBackground());
4214 hasBorder = style.hasBorder(); 4191 hasBorder = style.hasBorder();
4215 } 4192 }
4216 4193
4217 } // namespace blink 4194 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderBlock.cpp ('k') | sky/engine/core/rendering/RenderBoxModelObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698