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

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

Issue 159863002: 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 1920 matching lines...) Expand 10 before | Expand all | Expand 10 after
2549 if (AXObjectCache* cache = document().existingAXObjectCache()) 2539 if (AXObjectCache* cache = document().existingAXObjectCache())
2550 cache->childrenChanged(this->parent()); 2540 cache->childrenChanged(this->parent());
2551 2541
2552 remove(); 2542 remove();
2553 2543
2554 // The remove() call above may invoke axObjectCache()->childrenChanged() on the parent, which may require the AX render 2544 // The remove() call above may invoke axObjectCache()->childrenChanged() on the parent, which may require the AX render
2555 // object for this renderer. So we remove the AX render object now, after th e renderer is removed. 2545 // object for this renderer. So we remove the AX render object now, after th e renderer is removed.
2556 if (AXObjectCache* cache = document().existingAXObjectCache()) 2546 if (AXObjectCache* cache = document().existingAXObjectCache())
2557 cache->remove(this); 2547 cache->remove(this);
2558 2548
2559 #ifndef NDEBUG
2560 if (!documentBeingDestroyed() && view() && view()->hasRenderNamedFlowThreads ()) {
2561 // After remove, the object and the associated information should not be in any flow thread.
2562 const RenderNamedFlowThreadList* flowThreadList = view()->flowThreadCont roller()->renderNamedFlowThreadList();
2563 for (RenderNamedFlowThreadList::const_iterator iter = flowThreadList->be gin(); iter != flowThreadList->end(); ++iter) {
2564 const RenderNamedFlowThread* renderFlowThread = *iter;
2565 ASSERT(!renderFlowThread->hasChild(this));
2566 ASSERT(!renderFlowThread->hasChildInfo(this));
2567 }
2568 }
2569 #endif
2570
2571 // If this renderer had a parent, remove should have destroyed any counters 2549 // If this renderer had a parent, remove should have destroyed any counters
2572 // attached to this renderer and marked the affected other counters for 2550 // attached to this renderer and marked the affected other counters for
2573 // reevaluation. This apparently redundant check is here for the case when 2551 // reevaluation. This apparently redundant check is here for the case when
2574 // this renderer had no parent at the time remove() was called. 2552 // this renderer had no parent at the time remove() was called.
2575 2553
2576 if (hasCounterNodeMap()) 2554 if (hasCounterNodeMap())
2577 RenderCounter::destroyCounterNodes(*this); 2555 RenderCounter::destroyCounterNodes(*this);
2578 2556
2579 setAncestorLineBoxDirty(false); 2557 setAncestorLineBoxDirty(false);
2580 2558
(...skipping 16 matching lines...) Expand all
2597 // that needs to be drawn and layer visibility optimization can't be used 2575 // that needs to be drawn and layer visibility optimization can't be used
2598 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V ISIBLE && !hasLayer()) { 2576 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V ISIBLE && !hasLayer()) {
2599 if (!layer) 2577 if (!layer)
2600 layer = parent()->enclosingLayer(); 2578 layer = parent()->enclosingLayer();
2601 if (layer) 2579 if (layer)
2602 layer->setHasVisibleContent(); 2580 layer->setHasVisibleContent();
2603 } 2581 }
2604 2582
2605 if (!isFloating() && parent()->childrenInline()) 2583 if (!isFloating() && parent()->childrenInline())
2606 parent()->dirtyLinesFromChangedChild(this); 2584 parent()->dirtyLinesFromChangedChild(this);
2607
2608 if (RenderNamedFlowThread* containerFlowThread = parent()->renderNamedFlowTh readWrapper())
2609 containerFlowThread->addFlowChild(this);
2610 } 2585 }
2611 2586
2612 void RenderObject::willBeRemovedFromTree() 2587 void RenderObject::willBeRemovedFromTree()
2613 { 2588 {
2614 // FIXME: We should ASSERT(isRooted()) but we have some out-of-order removal s which would need to be fixed first. 2589 // FIXME: We should ASSERT(isRooted()) but we have some out-of-order removal s which would need to be fixed first.
2615 2590
2616 // If we remove a visible child from an invisible parent, we don't know the layer visibility any more. 2591 // If we remove a visible child from an invisible parent, we don't know the layer visibility any more.
2617 RenderLayer* layer = 0; 2592 RenderLayer* layer = 0;
2618 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V ISIBLE && !hasLayer()) { 2593 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V ISIBLE && !hasLayer()) {
2619 if ((layer = parent()->enclosingLayer())) 2594 if ((layer = parent()->enclosingLayer()))
2620 layer->dirtyVisibleContentStatus(); 2595 layer->dirtyVisibleContentStatus();
2621 } 2596 }
2622 2597
2623 // Keep our layer hierarchy updated. 2598 // Keep our layer hierarchy updated.
2624 if (firstChild() || hasLayer()) { 2599 if (firstChild() || hasLayer()) {
2625 if (!layer) 2600 if (!layer)
2626 layer = parent()->enclosingLayer(); 2601 layer = parent()->enclosingLayer();
2627 removeLayers(layer); 2602 removeLayers(layer);
2628 } 2603 }
2629 2604
2630 if (isOutOfFlowPositioned() && parent()->childrenInline()) 2605 if (isOutOfFlowPositioned() && parent()->childrenInline())
2631 parent()->dirtyLinesFromChangedChild(this); 2606 parent()->dirtyLinesFromChangedChild(this);
2632 2607
2633 removeFromRenderFlowThread(); 2608 removeFromRenderFlowThread();
2634 2609
2635 if (RenderNamedFlowThread* containerFlowThread = parent()->renderNamedFlowTh readWrapper())
2636 containerFlowThread->removeFlowChild(this);
2637
2638 // Update cached boundaries in SVG renderers if a child is removed. 2610 // Update cached boundaries in SVG renderers if a child is removed.
2639 if (parent()->isSVG()) 2611 if (parent()->isSVG())
2640 parent()->setNeedsBoundariesUpdate(); 2612 parent()->setNeedsBoundariesUpdate();
2641 } 2613 }
2642 2614
2643 void RenderObject::removeFromRenderFlowThread() 2615 void RenderObject::removeFromRenderFlowThread()
2644 { 2616 {
2645 if (flowThreadState() == NotInsideFlowThread) 2617 if (flowThreadState() == NotInsideFlowThread)
2646 return; 2618 return;
2647 2619
2648 // Sometimes we remove the element from the flow, but it's not destroyed at that time. 2620 // Sometimes we remove the element from the flow, but it's not destroyed at that time.
2649 // It's only until later when we actually destroy it and remove all the chil dren from it. 2621 // It's only until later when we actually destroy it and remove all the chil dren from it.
2650 // Currently, that happens for firstLetter elements and list markers. 2622 // Currently, that happens for firstLetter elements and list markers.
2651 // Pass in the flow thread so that we don't have to look it up for all the c hildren. 2623 // Pass in the flow thread so that we don't have to look it up for all the c hildren.
2652 removeFromRenderFlowThreadRecursive(flowThreadContainingBlock()); 2624 removeFromRenderFlowThreadRecursive(flowThreadContainingBlock());
2653 } 2625 }
2654 2626
2655 void RenderObject::removeFromRenderFlowThreadRecursive(RenderFlowThread* renderF lowThread) 2627 void RenderObject::removeFromRenderFlowThreadRecursive(RenderFlowThread* renderF lowThread)
2656 { 2628 {
2657 if (const RenderObjectChildList* children = virtualChildren()) { 2629 if (const RenderObjectChildList* children = virtualChildren()) {
2658 for (RenderObject* child = children->firstChild(); child; child = child- >nextSibling()) 2630 for (RenderObject* child = children->firstChild(); child; child = child- >nextSibling())
2659 child->removeFromRenderFlowThreadRecursive(renderFlowThread); 2631 child->removeFromRenderFlowThreadRecursive(renderFlowThread);
2660 } 2632 }
2661 2633
2662 RenderFlowThread* localFlowThread = renderFlowThread;
2663 if (flowThreadState() == InsideInFlowThread)
2664 localFlowThread = flowThreadContainingBlock(); // We have to ask. We can 't just assume we are in the same flow thread.
2665 if (localFlowThread)
2666 localFlowThread->removeFlowChildInfo(this);
2667 setFlowThreadState(NotInsideFlowThread); 2634 setFlowThreadState(NotInsideFlowThread);
2668 } 2635 }
2669 2636
2670 void RenderObject::destroyAndCleanupAnonymousWrappers() 2637 void RenderObject::destroyAndCleanupAnonymousWrappers()
2671 { 2638 {
2672 // If the tree is destroyed, there is no need for a clean-up phase. 2639 // If the tree is destroyed, there is no need for a clean-up phase.
2673 if (documentBeingDestroyed()) { 2640 if (documentBeingDestroyed()) {
2674 destroy(); 2641 destroy();
2675 return; 2642 return;
2676 } 2643 }
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
3118 while (!renderer->node()) 3085 while (!renderer->node())
3119 renderer = renderer->parent(); 3086 renderer = renderer->parent();
3120 return renderer->node()->isInert(); 3087 return renderer->node()->isInert();
3121 } 3088 }
3122 3089
3123 void RenderObject::imageChanged(ImageResource* image, const IntRect* rect) 3090 void RenderObject::imageChanged(ImageResource* image, const IntRect* rect)
3124 { 3091 {
3125 imageChanged(static_cast<WrappedImagePtr>(image), rect); 3092 imageChanged(static_cast<WrappedImagePtr>(image), rect);
3126 } 3093 }
3127 3094
3128 RenderObject* RenderObject::hoverAncestor() const
3129 {
3130 // When searching for the hover ancestor and encountering a named flow threa d,
3131 // the search will continue with the DOM ancestor of the top-most element
3132 // in the named flow thread.
3133 // See https://code.google.com/p/chromium/issues/detail?id=243278
3134 RenderObject* hoverAncestor = parent();
3135
3136 // Skip anonymous blocks directly flowed into flow threads as it would
3137 // prevent us from continuing the search on the DOM tree when reaching the n amed flow thread.
3138 if (hoverAncestor && hoverAncestor->isAnonymousBlock() && hoverAncestor->par ent() && hoverAncestor->parent()->isRenderNamedFlowThread())
3139 hoverAncestor = hoverAncestor->parent();
3140
3141 if (hoverAncestor && hoverAncestor->isRenderNamedFlowThread()) {
3142 hoverAncestor = 0;
3143
3144 Node* node = this->node();
3145 if (node) {
3146 Node* domAncestorNode = node->parentNode();
3147 if (domAncestorNode)
3148 hoverAncestor = domAncestorNode->renderer();
3149 }
3150 }
3151
3152 return hoverAncestor;
3153 }
3154
3155 Element* RenderObject::offsetParent() const 3095 Element* RenderObject::offsetParent() const
3156 { 3096 {
3157 if (isRoot() || isBody()) 3097 if (isRoot() || isBody())
3158 return 0; 3098 return 0;
3159 3099
3160 if (isOutOfFlowPositioned() && style()->position() == FixedPosition) 3100 if (isOutOfFlowPositioned() && style()->position() == FixedPosition)
3161 return 0; 3101 return 0;
3162 3102
3163 // If A is an area HTML element which has a map HTML element somewhere in th e ancestor 3103 // If A is an area HTML element which has a map HTML element somewhere in th e ancestor
3164 // chain return the nearest ancestor map HTML element and stop this algorith m. 3104 // chain return the nearest ancestor map HTML element and stop this algorith m.
3165 // FIXME: Implement! 3105 // FIXME: Implement!
3166 3106
3167 float effectiveZoom = style()->effectiveZoom(); 3107 float effectiveZoom = style()->effectiveZoom();
3168 Node* node = 0; 3108 Node* node = 0;
3169 for (RenderObject* ancestor = parent(); ancestor; ancestor = ancestor->paren t()) { 3109 for (RenderObject* ancestor = parent(); ancestor; ancestor = ancestor->paren t()) {
3170 // Spec: http://www.w3.org/TR/cssom-view/#offset-attributes 3110 // Spec: http://www.w3.org/TR/cssom-view/#offset-attributes
3171 3111
3172 // CSS regions specification says that region flows should return the bo dy element as their offsetParent.
3173 if (ancestor->isRenderNamedFlowThread())
3174 return document().body();
3175
3176 node = ancestor->node(); 3112 node = ancestor->node();
3177 3113
3178 if (!node) 3114 if (!node)
3179 continue; 3115 continue;
3180 3116
3181 if (ancestor->isPositioned()) 3117 if (ancestor->isPositioned())
3182 break; 3118 break;
3183 3119
3184 if (node->hasTagName(bodyTag)) 3120 if (node->hasTagName(bodyTag))
3185 break; 3121 break;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
3323 { 3259 {
3324 ASSERT_NOT_REACHED(); 3260 ASSERT_NOT_REACHED();
3325 return false; 3261 return false;
3326 } 3262 }
3327 3263
3328 bool RenderObject::isRelayoutBoundaryForInspector() const 3264 bool RenderObject::isRelayoutBoundaryForInspector() const
3329 { 3265 {
3330 return objectIsRelayoutBoundary(this); 3266 return objectIsRelayoutBoundary(this);
3331 } 3267 }
3332 3268
3333 bool RenderObject::isRenderNamedFlowFragmentContainer() const
3334 {
3335 return isRenderBlockFlow() && toRenderBlockFlow(this)->renderNamedFlowFragme nt();
3336 }
3337
3338 } // namespace WebCore 3269 } // namespace WebCore
3339 3270
3340 #ifndef NDEBUG 3271 #ifndef NDEBUG
3341 3272
3342 void showTree(const WebCore::RenderObject* object) 3273 void showTree(const WebCore::RenderObject* object)
3343 { 3274 {
3344 if (object) 3275 if (object)
3345 object->showTreeForThis(); 3276 object->showTreeForThis();
3346 } 3277 }
3347 3278
(...skipping 12 matching lines...) Expand all
3360 { 3291 {
3361 if (object1) { 3292 if (object1) {
3362 const WebCore::RenderObject* root = object1; 3293 const WebCore::RenderObject* root = object1;
3363 while (root->parent()) 3294 while (root->parent())
3364 root = root->parent(); 3295 root = root->parent();
3365 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3296 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3366 } 3297 }
3367 } 3298 }
3368 3299
3369 #endif 3300 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698