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

Side by Side Diff: Source/core/rendering/RenderObject.cpp

Issue 134473008: Remove CSS regions support, keeping a bare minimum to support "region-based" multicol. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "core/page/Page.h" 48 #include "core/page/Page.h"
49 #include "core/frame/Settings.h" 49 #include "core/frame/Settings.h"
50 #include "core/frame/UseCounter.h" 50 #include "core/frame/UseCounter.h"
51 #include "core/rendering/CompositedLayerMapping.h" 51 #include "core/rendering/CompositedLayerMapping.h"
52 #include "core/rendering/FlowThreadController.h" 52 #include "core/rendering/FlowThreadController.h"
53 #include "core/rendering/HitTestResult.h" 53 #include "core/rendering/HitTestResult.h"
54 #include "core/rendering/LayoutRectRecorder.h" 54 #include "core/rendering/LayoutRectRecorder.h"
55 #include "core/rendering/RenderCounter.h" 55 #include "core/rendering/RenderCounter.h"
56 #include "core/rendering/RenderDeprecatedFlexibleBox.h" 56 #include "core/rendering/RenderDeprecatedFlexibleBox.h"
57 #include "core/rendering/RenderFlexibleBox.h" 57 #include "core/rendering/RenderFlexibleBox.h"
58 #include "core/rendering/RenderFlowThread.h"
58 #include "core/rendering/RenderGeometryMap.h" 59 #include "core/rendering/RenderGeometryMap.h"
59 #include "core/rendering/RenderGrid.h" 60 #include "core/rendering/RenderGrid.h"
60 #include "core/rendering/RenderImage.h" 61 #include "core/rendering/RenderImage.h"
61 #include "core/rendering/RenderImageResourceStyleImage.h" 62 #include "core/rendering/RenderImageResourceStyleImage.h"
62 #include "core/rendering/RenderInline.h" 63 #include "core/rendering/RenderInline.h"
63 #include "core/rendering/RenderLayer.h" 64 #include "core/rendering/RenderLayer.h"
64 #include "core/rendering/RenderLayerCompositor.h" 65 #include "core/rendering/RenderLayerCompositor.h"
65 #include "core/rendering/RenderListItem.h" 66 #include "core/rendering/RenderListItem.h"
66 #include "core/rendering/RenderMarquee.h" 67 #include "core/rendering/RenderMarquee.h"
67 #include "core/rendering/RenderMultiColumnBlock.h" 68 #include "core/rendering/RenderMultiColumnBlock.h"
68 #include "core/rendering/RenderNamedFlowThread.h"
69 #include "core/rendering/RenderRegion.h"
70 #include "core/rendering/RenderScrollbarPart.h" 69 #include "core/rendering/RenderScrollbarPart.h"
71 #include "core/rendering/RenderTableCaption.h" 70 #include "core/rendering/RenderTableCaption.h"
72 #include "core/rendering/RenderTableCell.h" 71 #include "core/rendering/RenderTableCell.h"
73 #include "core/rendering/RenderTableCol.h" 72 #include "core/rendering/RenderTableCol.h"
74 #include "core/rendering/RenderTableRow.h" 73 #include "core/rendering/RenderTableRow.h"
75 #include "core/rendering/RenderTheme.h" 74 #include "core/rendering/RenderTheme.h"
76 #include "core/rendering/RenderView.h" 75 #include "core/rendering/RenderView.h"
77 #include "core/rendering/style/ContentData.h" 76 #include "core/rendering/style/ContentData.h"
78 #include "core/rendering/style/CursorList.h" 77 #include "core/rendering/style/CursorList.h"
79 #include "core/rendering/style/ShadowList.h" 78 #include "core/rendering/style/ShadowList.h"
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 // Not in the middle of layout so have to find the thread the slow way. 599 // Not in the middle of layout so have to find the thread the slow way.
601 RenderObject* curr = const_cast<RenderObject*>(this); 600 RenderObject* curr = const_cast<RenderObject*>(this);
602 while (curr) { 601 while (curr) {
603 if (curr->isRenderFlowThread()) 602 if (curr->isRenderFlowThread())
604 return toRenderFlowThread(curr); 603 return toRenderFlowThread(curr);
605 curr = curr->containingBlock(); 604 curr = curr->containingBlock();
606 } 605 }
607 return 0; 606 return 0;
608 } 607 }
609 608
610 RenderNamedFlowThread* RenderObject::renderNamedFlowThreadWrapper() const
611 {
612 RenderObject* object = const_cast<RenderObject*>(this);
613 while (object && object->isAnonymousBlock() && !object->isRenderNamedFlowThr ead())
614 object = object->parent();
615
616 return object && object->isRenderNamedFlowThread() ? toRenderNamedFlowThread (object) : 0;
617 }
618
619 RenderBlock* RenderObject::firstLineBlock() const 609 RenderBlock* RenderObject::firstLineBlock() const
620 { 610 {
621 return 0; 611 return 0;
622 } 612 }
623 613
624 static inline bool objectIsRelayoutBoundary(const RenderObject* object) 614 static inline bool objectIsRelayoutBoundary(const RenderObject* object)
625 { 615 {
626 // FIXME: In future it may be possible to broaden these conditions in order to improve performance. 616 // FIXME: In future it may be possible to broaden these conditions in order to improve performance.
627 if (object->isTextControl()) 617 if (object->isTextControl())
628 return true; 618 return true;
(...skipping 1928 matching lines...) Expand 10 before | Expand all | Expand 10 after
2557 if (AXObjectCache* cache = document().existingAXObjectCache()) 2547 if (AXObjectCache* cache = document().existingAXObjectCache())
2558 cache->childrenChanged(this->parent()); 2548 cache->childrenChanged(this->parent());
2559 2549
2560 remove(); 2550 remove();
2561 2551
2562 // The remove() call above may invoke axObjectCache()->childrenChanged() on the parent, which may require the AX render 2552 // The remove() call above may invoke axObjectCache()->childrenChanged() on the parent, which may require the AX render
2563 // object for this renderer. So we remove the AX render object now, after th e renderer is removed. 2553 // object for this renderer. So we remove the AX render object now, after th e renderer is removed.
2564 if (AXObjectCache* cache = document().existingAXObjectCache()) 2554 if (AXObjectCache* cache = document().existingAXObjectCache())
2565 cache->remove(this); 2555 cache->remove(this);
2566 2556
2567 #ifndef NDEBUG
2568 if (!documentBeingDestroyed() && view() && view()->hasRenderNamedFlowThreads ()) {
2569 // After remove, the object and the associated information should not be in any flow thread.
2570 const RenderNamedFlowThreadList* flowThreadList = view()->flowThreadCont roller()->renderNamedFlowThreadList();
2571 for (RenderNamedFlowThreadList::const_iterator iter = flowThreadList->be gin(); iter != flowThreadList->end(); ++iter) {
2572 const RenderNamedFlowThread* renderFlowThread = *iter;
2573 ASSERT(!renderFlowThread->hasChild(this));
2574 ASSERT(!renderFlowThread->hasChildInfo(this));
2575 }
2576 }
2577 #endif
2578
2579 // If this renderer had a parent, remove should have destroyed any counters 2557 // If this renderer had a parent, remove should have destroyed any counters
2580 // attached to this renderer and marked the affected other counters for 2558 // attached to this renderer and marked the affected other counters for
2581 // reevaluation. This apparently redundant check is here for the case when 2559 // reevaluation. This apparently redundant check is here for the case when
2582 // this renderer had no parent at the time remove() was called. 2560 // this renderer had no parent at the time remove() was called.
2583 2561
2584 if (hasCounterNodeMap()) 2562 if (hasCounterNodeMap())
2585 RenderCounter::destroyCounterNodes(*this); 2563 RenderCounter::destroyCounterNodes(*this);
2586 2564
2587 setAncestorLineBoxDirty(false); 2565 setAncestorLineBoxDirty(false);
2588 2566
(...skipping 16 matching lines...) Expand all
2605 // that needs to be drawn and layer visibility optimization can't be used 2583 // that needs to be drawn and layer visibility optimization can't be used
2606 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V ISIBLE && !hasLayer()) { 2584 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V ISIBLE && !hasLayer()) {
2607 if (!layer) 2585 if (!layer)
2608 layer = parent()->enclosingLayer(); 2586 layer = parent()->enclosingLayer();
2609 if (layer) 2587 if (layer)
2610 layer->setHasVisibleContent(); 2588 layer->setHasVisibleContent();
2611 } 2589 }
2612 2590
2613 if (!isFloating() && parent()->childrenInline()) 2591 if (!isFloating() && parent()->childrenInline())
2614 parent()->dirtyLinesFromChangedChild(this); 2592 parent()->dirtyLinesFromChangedChild(this);
2615
2616 if (RenderNamedFlowThread* containerFlowThread = parent()->renderNamedFlowTh readWrapper())
2617 containerFlowThread->addFlowChild(this);
2618 } 2593 }
2619 2594
2620 void RenderObject::willBeRemovedFromTree() 2595 void RenderObject::willBeRemovedFromTree()
2621 { 2596 {
2622 // FIXME: We should ASSERT(isRooted()) but we have some out-of-order removal s which would need to be fixed first. 2597 // FIXME: We should ASSERT(isRooted()) but we have some out-of-order removal s which would need to be fixed first.
2623 2598
2624 // If we remove a visible child from an invisible parent, we don't know the layer visibility any more. 2599 // If we remove a visible child from an invisible parent, we don't know the layer visibility any more.
2625 RenderLayer* layer = 0; 2600 RenderLayer* layer = 0;
2626 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V ISIBLE && !hasLayer()) { 2601 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V ISIBLE && !hasLayer()) {
2627 if ((layer = parent()->enclosingLayer())) 2602 if ((layer = parent()->enclosingLayer()))
2628 layer->dirtyVisibleContentStatus(); 2603 layer->dirtyVisibleContentStatus();
2629 } 2604 }
2630 2605
2631 // Keep our layer hierarchy updated. 2606 // Keep our layer hierarchy updated.
2632 if (firstChild() || hasLayer()) { 2607 if (firstChild() || hasLayer()) {
2633 if (!layer) 2608 if (!layer)
2634 layer = parent()->enclosingLayer(); 2609 layer = parent()->enclosingLayer();
2635 removeLayers(layer); 2610 removeLayers(layer);
2636 } 2611 }
2637 2612
2638 if (isOutOfFlowPositioned() && parent()->childrenInline()) 2613 if (isOutOfFlowPositioned() && parent()->childrenInline())
2639 parent()->dirtyLinesFromChangedChild(this); 2614 parent()->dirtyLinesFromChangedChild(this);
2640 2615
2641 removeFromRenderFlowThread(); 2616 removeFromRenderFlowThread();
2642 2617
2643 if (RenderNamedFlowThread* containerFlowThread = parent()->renderNamedFlowTh readWrapper())
2644 containerFlowThread->removeFlowChild(this);
2645
2646 // Update cached boundaries in SVG renderers if a child is removed. 2618 // Update cached boundaries in SVG renderers if a child is removed.
2647 if (parent()->isSVG()) 2619 if (parent()->isSVG())
2648 parent()->setNeedsBoundariesUpdate(); 2620 parent()->setNeedsBoundariesUpdate();
2649 } 2621 }
2650 2622
2651 void RenderObject::removeFromRenderFlowThread() 2623 void RenderObject::removeFromRenderFlowThread()
2652 { 2624 {
2653 if (flowThreadState() == NotInsideFlowThread) 2625 if (flowThreadState() == NotInsideFlowThread)
2654 return; 2626 return;
2655 2627
2656 // Sometimes we remove the element from the flow, but it's not destroyed at that time. 2628 // Sometimes we remove the element from the flow, but it's not destroyed at that time.
2657 // It's only until later when we actually destroy it and remove all the chil dren from it. 2629 // It's only until later when we actually destroy it and remove all the chil dren from it.
2658 // Currently, that happens for firstLetter elements and list markers. 2630 // Currently, that happens for firstLetter elements and list markers.
2659 // Pass in the flow thread so that we don't have to look it up for all the c hildren. 2631 // Pass in the flow thread so that we don't have to look it up for all the c hildren.
2660 removeFromRenderFlowThreadRecursive(flowThreadContainingBlock()); 2632 removeFromRenderFlowThreadRecursive(flowThreadContainingBlock());
2661 } 2633 }
2662 2634
2663 void RenderObject::removeFromRenderFlowThreadRecursive(RenderFlowThread* renderF lowThread) 2635 void RenderObject::removeFromRenderFlowThreadRecursive(RenderFlowThread* renderF lowThread)
2664 { 2636 {
2665 if (const RenderObjectChildList* children = virtualChildren()) { 2637 if (const RenderObjectChildList* children = virtualChildren()) {
2666 for (RenderObject* child = children->firstChild(); child; child = child- >nextSibling()) 2638 for (RenderObject* child = children->firstChild(); child; child = child- >nextSibling())
2667 child->removeFromRenderFlowThreadRecursive(renderFlowThread); 2639 child->removeFromRenderFlowThreadRecursive(renderFlowThread);
2668 } 2640 }
2669 2641
2670 RenderFlowThread* localFlowThread = renderFlowThread;
2671 if (flowThreadState() == InsideInFlowThread)
2672 localFlowThread = flowThreadContainingBlock(); // We have to ask. We can 't just assume we are in the same flow thread.
2673 if (localFlowThread)
2674 localFlowThread->removeFlowChildInfo(this);
2675 setFlowThreadState(NotInsideFlowThread); 2642 setFlowThreadState(NotInsideFlowThread);
2676 } 2643 }
2677 2644
2678 void RenderObject::destroyAndCleanupAnonymousWrappers() 2645 void RenderObject::destroyAndCleanupAnonymousWrappers()
2679 { 2646 {
2680 // If the tree is destroyed, there is no need for a clean-up phase. 2647 // If the tree is destroyed, there is no need for a clean-up phase.
2681 if (documentBeingDestroyed()) { 2648 if (documentBeingDestroyed()) {
2682 destroy(); 2649 destroy();
2683 return; 2650 return;
2684 } 2651 }
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
3126 while (!renderer->node()) 3093 while (!renderer->node())
3127 renderer = renderer->parent(); 3094 renderer = renderer->parent();
3128 return renderer->node()->isInert(); 3095 return renderer->node()->isInert();
3129 } 3096 }
3130 3097
3131 void RenderObject::imageChanged(ImageResource* image, const IntRect* rect) 3098 void RenderObject::imageChanged(ImageResource* image, const IntRect* rect)
3132 { 3099 {
3133 imageChanged(static_cast<WrappedImagePtr>(image), rect); 3100 imageChanged(static_cast<WrappedImagePtr>(image), rect);
3134 } 3101 }
3135 3102
3136 RenderObject* RenderObject::hoverAncestor() const
3137 {
3138 // When searching for the hover ancestor and encountering a named flow threa d,
3139 // the search will continue with the DOM ancestor of the top-most element
3140 // in the named flow thread.
3141 // See https://code.google.com/p/chromium/issues/detail?id=243278
3142 RenderObject* hoverAncestor = parent();
3143
3144 // Skip anonymous blocks directly flowed into flow threads as it would
3145 // prevent us from continuing the search on the DOM tree when reaching the n amed flow thread.
3146 if (hoverAncestor && hoverAncestor->isAnonymousBlock() && hoverAncestor->par ent() && hoverAncestor->parent()->isRenderNamedFlowThread())
3147 hoverAncestor = hoverAncestor->parent();
3148
3149 if (hoverAncestor && hoverAncestor->isRenderNamedFlowThread()) {
3150 hoverAncestor = 0;
3151
3152 Node* node = this->node();
3153 if (node) {
3154 Node* domAncestorNode = node->parentNode();
3155 if (domAncestorNode)
3156 hoverAncestor = domAncestorNode->renderer();
3157 }
3158 }
3159
3160 return hoverAncestor;
3161 }
3162
3163 Element* RenderObject::offsetParent() const 3103 Element* RenderObject::offsetParent() const
3164 { 3104 {
3165 if (isRoot() || isBody()) 3105 if (isRoot() || isBody())
3166 return 0; 3106 return 0;
3167 3107
3168 if (isOutOfFlowPositioned() && style()->position() == FixedPosition) 3108 if (isOutOfFlowPositioned() && style()->position() == FixedPosition)
3169 return 0; 3109 return 0;
3170 3110
3171 // If A is an area HTML element which has a map HTML element somewhere in th e ancestor 3111 // If A is an area HTML element which has a map HTML element somewhere in th e ancestor
3172 // chain return the nearest ancestor map HTML element and stop this algorith m. 3112 // chain return the nearest ancestor map HTML element and stop this algorith m.
3173 // FIXME: Implement! 3113 // FIXME: Implement!
3174 3114
3175 float effectiveZoom = style()->effectiveZoom(); 3115 float effectiveZoom = style()->effectiveZoom();
3176 Node* node = 0; 3116 Node* node = 0;
3177 for (RenderObject* ancestor = parent(); ancestor; ancestor = ancestor->paren t()) { 3117 for (RenderObject* ancestor = parent(); ancestor; ancestor = ancestor->paren t()) {
3178 // Spec: http://www.w3.org/TR/cssom-view/#offset-attributes 3118 // Spec: http://www.w3.org/TR/cssom-view/#offset-attributes
3179 3119
3180 // CSS regions specification says that region flows should return the bo dy element as their offsetParent.
3181 if (ancestor->isRenderNamedFlowThread())
3182 return document().body();
3183
3184 node = ancestor->node(); 3120 node = ancestor->node();
3185 3121
3186 if (!node) 3122 if (!node)
3187 continue; 3123 continue;
3188 3124
3189 if (ancestor->isPositioned()) 3125 if (ancestor->isPositioned())
3190 break; 3126 break;
3191 3127
3192 if (node->hasTagName(bodyTag)) 3128 if (node->hasTagName(bodyTag))
3193 break; 3129 break;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
3331 { 3267 {
3332 ASSERT_NOT_REACHED(); 3268 ASSERT_NOT_REACHED();
3333 return false; 3269 return false;
3334 } 3270 }
3335 3271
3336 bool RenderObject::isRelayoutBoundaryForInspector() const 3272 bool RenderObject::isRelayoutBoundaryForInspector() const
3337 { 3273 {
3338 return objectIsRelayoutBoundary(this); 3274 return objectIsRelayoutBoundary(this);
3339 } 3275 }
3340 3276
3341 bool RenderObject::isRenderNamedFlowFragmentContainer() const
3342 {
3343 return isRenderBlockFlow() && toRenderBlockFlow(this)->renderNamedFlowFragme nt();
3344 }
3345
3346 } // namespace WebCore 3277 } // namespace WebCore
3347 3278
3348 #ifndef NDEBUG 3279 #ifndef NDEBUG
3349 3280
3350 void showTree(const WebCore::RenderObject* object) 3281 void showTree(const WebCore::RenderObject* object)
3351 { 3282 {
3352 if (object) 3283 if (object)
3353 object->showTreeForThis(); 3284 object->showTreeForThis();
3354 } 3285 }
3355 3286
(...skipping 12 matching lines...) Expand all
3368 { 3299 {
3369 if (object1) { 3300 if (object1) {
3370 const WebCore::RenderObject* root = object1; 3301 const WebCore::RenderObject* root = object1;
3371 while (root->parent()) 3302 while (root->parent())
3372 root = root->parent(); 3303 root = root->parent();
3373 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3304 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3374 } 3305 }
3375 } 3306 }
3376 3307
3377 #endif 3308 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698