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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2145823002: Implement the overflow-anchor CSS property as an opt-out for ScrollAnchoring (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 // and then trigger a full document recalc. We also need to clear it here si nce the 1575 // and then trigger a full document recalc. We also need to clear it here si nce the
1576 // call to styleForElement on the body above can cache bad values for rem un its if the 1576 // call to styleForElement on the body above can cache bad values for rem un its if the
1577 // documentElement's style was dirty. We could keep track of which elements depend on 1577 // documentElement's style was dirty. We could keep track of which elements depend on
1578 // rem units like we do for viewport styles, but we assume root font size ch anges are 1578 // rem units like we do for viewport styles, but we assume root font size ch anges are
1579 // rare and just invalidate the cache for now. 1579 // rare and just invalidate the cache for now.
1580 if (styleEngine().usesRemUnits() && (documentElement()->needsAttach() || !do cumentElement()->computedStyle() || documentElement()->computedStyle()->fontSize () != documentElementStyle->fontSize())) { 1580 if (styleEngine().usesRemUnits() && (documentElement()->needsAttach() || !do cumentElement()->computedStyle() || documentElement()->computedStyle()->fontSize () != documentElementStyle->fontSize())) {
1581 ensureStyleResolver().invalidateMatchedPropertiesCache(); 1581 ensureStyleResolver().invalidateMatchedPropertiesCache();
1582 documentElement()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeRe asonForTracing::create(StyleChangeReason::FontSizeChange)); 1582 documentElement()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeRe asonForTracing::create(StyleChangeReason::FontSizeChange));
1583 } 1583 }
1584 1584
1585 EOverflowAnchor overflowAnchor = AnchorAuto;
1585 EOverflow overflowX = OverflowAuto; 1586 EOverflow overflowX = OverflowAuto;
1586 EOverflow overflowY = OverflowAuto; 1587 EOverflow overflowY = OverflowAuto;
1587 float columnGap = 0; 1588 float columnGap = 0;
1588 if (overflowStyle) { 1589 if (overflowStyle) {
1590 overflowAnchor = overflowStyle->overflowAnchor();
1589 overflowX = overflowStyle->overflowX(); 1591 overflowX = overflowStyle->overflowX();
1590 overflowY = overflowStyle->overflowY(); 1592 overflowY = overflowStyle->overflowY();
1591 // Visible overflow on the viewport is meaningless, and the spec says to treat it as 'auto': 1593 // Visible overflow on the viewport is meaningless, and the spec says to treat it as 'auto':
1592 if (overflowX == OverflowVisible) 1594 if (overflowX == OverflowVisible)
1593 overflowX = OverflowAuto; 1595 overflowX = OverflowAuto;
1594 if (overflowY == OverflowVisible) 1596 if (overflowY == OverflowVisible)
1595 overflowY = OverflowAuto; 1597 overflowY = OverflowAuto;
1598 if (overflowAnchor == AnchorVisible)
1599 overflowAnchor = AnchorAuto;
1596 // Column-gap is (ab)used by the current paged overflow implementation ( in lack of other 1600 // Column-gap is (ab)used by the current paged overflow implementation ( in lack of other
1597 // ways to specify gaps between pages), so we have to propagate it too. 1601 // ways to specify gaps between pages), so we have to propagate it too.
1598 columnGap = overflowStyle->columnGap(); 1602 columnGap = overflowStyle->columnGap();
1599 } 1603 }
1600 1604
1601 ScrollSnapType snapType = overflowStyle->getScrollSnapType(); 1605 ScrollSnapType snapType = overflowStyle->getScrollSnapType();
1602 const LengthPoint& snapDestination = overflowStyle->scrollSnapDestination(); 1606 const LengthPoint& snapDestination = overflowStyle->scrollSnapDestination();
1603 1607
1604 RefPtr<ComputedStyle> documentStyle = layoutView()->mutableStyle(); 1608 RefPtr<ComputedStyle> documentStyle = layoutView()->mutableStyle();
1605 if (documentStyle->getWritingMode() != rootWritingMode 1609 if (documentStyle->getWritingMode() != rootWritingMode
1606 || documentStyle->direction() != rootDirection 1610 || documentStyle->direction() != rootDirection
1607 || documentStyle->visitedDependentColor(CSSPropertyBackgroundColor) != b ackgroundColor 1611 || documentStyle->visitedDependentColor(CSSPropertyBackgroundColor) != b ackgroundColor
1608 || documentStyle->backgroundLayers() != backgroundLayers 1612 || documentStyle->backgroundLayers() != backgroundLayers
1609 || documentStyle->imageRendering() != imageRendering 1613 || documentStyle->imageRendering() != imageRendering
1614 || documentStyle->overflowAnchor() != overflowAnchor
1610 || documentStyle->overflowX() != overflowX 1615 || documentStyle->overflowX() != overflowX
1611 || documentStyle->overflowY() != overflowY 1616 || documentStyle->overflowY() != overflowY
1612 || documentStyle->columnGap() != columnGap 1617 || documentStyle->columnGap() != columnGap
1613 || documentStyle->getScrollSnapType() != snapType 1618 || documentStyle->getScrollSnapType() != snapType
1614 || documentStyle->scrollSnapDestination() != snapDestination) { 1619 || documentStyle->scrollSnapDestination() != snapDestination) {
1615 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*documentStyle); 1620 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*documentStyle);
1616 newStyle->setWritingMode(rootWritingMode); 1621 newStyle->setWritingMode(rootWritingMode);
1617 newStyle->setDirection(rootDirection); 1622 newStyle->setDirection(rootDirection);
1618 newStyle->setBackgroundColor(backgroundColor); 1623 newStyle->setBackgroundColor(backgroundColor);
1619 newStyle->accessBackgroundLayers() = backgroundLayers; 1624 newStyle->accessBackgroundLayers() = backgroundLayers;
1620 newStyle->setImageRendering(imageRendering); 1625 newStyle->setImageRendering(imageRendering);
1626 newStyle->setOverflowAnchor(overflowAnchor);
1621 newStyle->setOverflowX(overflowX); 1627 newStyle->setOverflowX(overflowX);
1622 newStyle->setOverflowY(overflowY); 1628 newStyle->setOverflowY(overflowY);
1623 newStyle->setColumnGap(columnGap); 1629 newStyle->setColumnGap(columnGap);
1624 newStyle->setScrollSnapType(snapType); 1630 newStyle->setScrollSnapType(snapType);
1625 newStyle->setScrollSnapDestination(snapDestination); 1631 newStyle->setScrollSnapDestination(snapDestination);
1626 layoutView()->setStyle(newStyle); 1632 layoutView()->setStyle(newStyle);
1627 setupFontBuilder(*newStyle); 1633 setupFontBuilder(*newStyle);
1628 } 1634 }
1629 1635
1630 if (body) { 1636 if (body) {
(...skipping 4413 matching lines...) Expand 10 before | Expand all | Expand 10 after
6044 } 6050 }
6045 6051
6046 void showLiveDocumentInstances() 6052 void showLiveDocumentInstances()
6047 { 6053 {
6048 WeakDocumentSet& set = liveDocumentSet(); 6054 WeakDocumentSet& set = liveDocumentSet();
6049 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6055 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6050 for (Document* document : set) 6056 for (Document* document : set)
6051 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 6057 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
6052 } 6058 }
6053 #endif 6059 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698