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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutObject.cpp

Issue 1647793002: Use ScrollAnchor in FrameView and PaintLayerScrollableArea. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@anchor-skeleton
Patch Set: move save/restore from LayoutBlockFlow into LayoutBlock Created 4 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) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 2626 matching lines...) Expand 10 before | Expand all | Expand 10 after
2637 layer->dirtyVisibleContentStatus(); 2637 layer->dirtyVisibleContentStatus();
2638 } 2638 }
2639 2639
2640 if (parent()->childrenInline()) 2640 if (parent()->childrenInline())
2641 parent()->dirtyLinesFromChangedChild(this); 2641 parent()->dirtyLinesFromChangedChild(this);
2642 2642
2643 if (LayoutFlowThread* flowThread = flowThreadContainingBlock()) 2643 if (LayoutFlowThread* flowThread = flowThreadContainingBlock())
2644 flowThread->flowThreadDescendantWasInserted(this); 2644 flowThread->flowThreadDescendantWasInserted(this);
2645 } 2645 }
2646 2646
2647 enum FindReferencingScrollAnchorsBehavior {
2648 DontClear,
2649 Clear
2650 };
2651
2652 static bool findReferencingScrollAnchors(LayoutObject* layoutObject, FindReferen cingScrollAnchorsBehavior behavior)
2653 {
2654 PaintLayer* layer = layoutObject->enclosingLayer();
2655 bool found = false;
2656
2657 // Walk up the layer tree to clear any scroll anchors that reference us.
2658 while (layer) {
2659 if (PaintLayerScrollableArea* scrollableArea = layer->scrollableArea()) {
2660 ScrollAnchor& anchor = scrollableArea->scrollAnchor();
2661 if (anchor.anchorObject() == layoutObject) {
2662 found = true;
2663 if (behavior == Clear)
2664 anchor.clear();
2665 else
2666 return true;
2667 }
2668 }
2669 layer = layer->parent();
2670 }
2671 if (FrameView* view = layoutObject->frameView()) {
2672 ScrollAnchor& anchor = view->scrollAnchor();
2673 if (anchor.anchorObject() == layoutObject) {
2674 found = true;
2675 if (behavior == Clear)
2676 anchor.clear();
2677 }
2678 }
2679 return found;
2680 }
2681
2647 void LayoutObject::willBeRemovedFromTree() 2682 void LayoutObject::willBeRemovedFromTree()
2648 { 2683 {
2649 // FIXME: We should ASSERT(isRooted()) but we have some out-of-order removal s which would need to be fixed first. 2684 // FIXME: We should ASSERT(isRooted()) but we have some out-of-order removal s which would need to be fixed first.
2650 2685
2651 // If we remove a visible child from an invisible parent, we don't know the layer visibility any more. 2686 // If we remove a visible child from an invisible parent, we don't know the layer visibility any more.
2652 PaintLayer* layer = nullptr; 2687 PaintLayer* layer = nullptr;
2653 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V ISIBLE && !hasLayer()) { 2688 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V ISIBLE && !hasLayer()) {
2654 layer = parent()->enclosingLayer(); 2689 layer = parent()->enclosingLayer();
2655 if (layer) 2690 if (layer)
2656 layer->dirtyVisibleContentStatus(); 2691 layer->dirtyVisibleContentStatus();
2657 } 2692 }
2658 2693
2659 // Keep our layer hierarchy updated. 2694 // Keep our layer hierarchy updated.
2660 if (slowFirstChild() || hasLayer()) { 2695 if (slowFirstChild() || hasLayer()) {
2661 if (!layer) 2696 if (!layer)
2662 layer = parent()->enclosingLayer(); 2697 layer = parent()->enclosingLayer();
2663 removeLayers(layer); 2698 removeLayers(layer);
2664 } 2699 }
2665 2700
2666 if (isOutOfFlowPositioned() && parent()->childrenInline()) 2701 if (isOutOfFlowPositioned() && parent()->childrenInline())
2667 parent()->dirtyLinesFromChangedChild(this); 2702 parent()->dirtyLinesFromChangedChild(this);
2668 2703
2669 removeFromLayoutFlowThread(); 2704 removeFromLayoutFlowThread();
2670 2705
2671 // Update cached boundaries in SVG layoutObjects if a child is removed. 2706 // Update cached boundaries in SVG layoutObjects if a child is removed.
2672 if (parent()->isSVG()) 2707 if (parent()->isSVG())
2673 parent()->setNeedsBoundariesUpdate(); 2708 parent()->setNeedsBoundariesUpdate();
2709
2710 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && m_bitfields.isScroll AnchorObject()) {
2711 // Clear the bit first so that anchor.clear() doesn't recurse into findR eferencingScrollAnchors.
2712 m_bitfields.setIsScrollAnchorObject(false);
2713 findReferencingScrollAnchors(this, Clear);
2714 }
2715 }
2716
2717 void LayoutObject::maybeClearIsScrollAnchorObject()
2718 {
2719 if (m_bitfields.isScrollAnchorObject())
2720 m_bitfields.setIsScrollAnchorObject(findReferencingScrollAnchors(this, D ontClear));
2674 } 2721 }
2675 2722
2676 void LayoutObject::removeFromLayoutFlowThread() 2723 void LayoutObject::removeFromLayoutFlowThread()
2677 { 2724 {
2678 if (!isInsideFlowThread()) 2725 if (!isInsideFlowThread())
2679 return; 2726 return;
2680 2727
2681 // Sometimes we remove the element from the flow, but it's not destroyed at that time. 2728 // Sometimes we remove the element from the flow, but it's not destroyed at that time.
2682 // It's only until later when we actually destroy it and remove all the chil dren from it. 2729 // It's only until later when we actually destroy it and remove all the chil dren from it.
2683 // Currently, that happens for firstLetter elements and list markers. 2730 // Currently, that happens for firstLetter elements and list markers.
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
3568 const blink::LayoutObject* root = object1; 3615 const blink::LayoutObject* root = object1;
3569 while (root->parent()) 3616 while (root->parent())
3570 root = root->parent(); 3617 root = root->parent();
3571 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3618 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3572 } else { 3619 } else {
3573 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); 3620 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n");
3574 } 3621 }
3575 } 3622 }
3576 3623
3577 #endif 3624 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698