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

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

Issue 734813004: Get rid of continuations. (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 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2010 Google Inc. All rights reserved. 7 * Copyright (C) 2010 Google Inc. 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 28 matching lines...) Expand all
39 #include "core/rendering/style/ShadowList.h" 39 #include "core/rendering/style/ShadowList.h"
40 #include "platform/LengthFunctions.h" 40 #include "platform/LengthFunctions.h"
41 #include "platform/geometry/TransformState.h" 41 #include "platform/geometry/TransformState.h"
42 #include "platform/graphics/DrawLooperBuilder.h" 42 #include "platform/graphics/DrawLooperBuilder.h"
43 #include "platform/graphics/GraphicsContextStateSaver.h" 43 #include "platform/graphics/GraphicsContextStateSaver.h"
44 #include "platform/graphics/Path.h" 44 #include "platform/graphics/Path.h"
45 #include "wtf/CurrentTime.h" 45 #include "wtf/CurrentTime.h"
46 46
47 namespace blink { 47 namespace blink {
48 48
49 // The HashMap for storing continuation pointers.
50 // An inline can be split with blocks occuring in between the inline content.
51 // When this occurs we need a pointer to the next object. We can basically be
52 // split into a sequence of inlines and blocks. The continuation will either be
53 // an anonymous block (that houses other blocks) or it will be an inline flow.
54 // <b><i><p>Hello</p></i></b>. In this example the <i> will have a block as
55 // its continuation but the <b> will just have an inline as its continuation.
56 typedef HashMap<RawPtr<const RenderBoxModelObject>, RawPtr<RenderBoxModelObject> > ContinuationMap;
57 static OwnPtr<ContinuationMap>* continuationMap = 0;
58
59 void RenderBoxModelObject::setSelectionState(SelectionState state) 49 void RenderBoxModelObject::setSelectionState(SelectionState state)
60 { 50 {
61 if (state == SelectionInside && selectionState() != SelectionNone) 51 if (state == SelectionInside && selectionState() != SelectionNone)
62 return; 52 return;
63 53
64 if ((state == SelectionStart && selectionState() == SelectionEnd) 54 if ((state == SelectionStart && selectionState() == SelectionEnd)
65 || (state == SelectionEnd && selectionState() == SelectionStart)) 55 || (state == SelectionEnd && selectionState() == SelectionStart))
66 RenderObject::setSelectionState(SelectionBoth); 56 RenderObject::setSelectionState(SelectionBoth);
67 else 57 else
68 RenderObject::setSelectionState(state); 58 RenderObject::setSelectionState(state);
(...skipping 29 matching lines...) Expand all
98 { 88 {
99 } 89 }
100 90
101 RenderBoxModelObject::~RenderBoxModelObject() 91 RenderBoxModelObject::~RenderBoxModelObject()
102 { 92 {
103 } 93 }
104 94
105 void RenderBoxModelObject::willBeDestroyed() 95 void RenderBoxModelObject::willBeDestroyed()
106 { 96 {
107 ImageQualityController::remove(this); 97 ImageQualityController::remove(this);
108
109 // A continuation of this RenderObject should be destroyed at subclasses.
110 ASSERT(!continuation());
111
112 RenderLayerModelObject::willBeDestroyed(); 98 RenderLayerModelObject::willBeDestroyed();
113 } 99 }
114 100
115 bool RenderBoxModelObject::calculateHasBoxDecorations() const 101 bool RenderBoxModelObject::calculateHasBoxDecorations() const
116 { 102 {
117 RenderStyle* styleToUse = style(); 103 RenderStyle* styleToUse = style();
118 ASSERT(styleToUse); 104 ASSERT(styleToUse);
119 return hasBackground() || styleToUse->hasBorder() || styleToUse->boxShadow() ; 105 return hasBackground() || styleToUse->hasBorder() || styleToUse->boxShadow() ;
120 } 106 }
121 107
122 void RenderBoxModelObject::updateFromStyle() 108 void RenderBoxModelObject::updateFromStyle()
123 { 109 {
124 RenderLayerModelObject::updateFromStyle(); 110 RenderLayerModelObject::updateFromStyle();
125 111
126 RenderStyle* styleToUse = style(); 112 RenderStyle* styleToUse = style();
127 setHasBoxDecorationBackground(calculateHasBoxDecorations()); 113 setHasBoxDecorationBackground(calculateHasBoxDecorations());
128 setInline(styleToUse->isDisplayInlineType()); 114 setInline(styleToUse->isDisplayInlineType());
129 setPositionState(styleToUse->position()); 115 setPositionState(styleToUse->position());
130 } 116 }
131 117
132 static LayoutSize accumulateInFlowPositionOffsets(const RenderObject* child)
133 {
134 if (!child->isAnonymousBlock() || !child->isRelPositioned())
135 return LayoutSize();
136 LayoutSize offset;
137 RenderObject* p = toRenderBlock(child)->inlineElementContinuation();
138 while (p && p->isRenderInline()) {
139 if (p->isRelPositioned()) {
140 RenderInline* renderInline = toRenderInline(p);
141 offset += renderInline->offsetForInFlowPosition();
142 }
143 p = p->parent();
144 }
145 return offset;
146 }
147
148 bool RenderBoxModelObject::hasAutoHeightOrContainingBlockWithAutoHeight() const 118 bool RenderBoxModelObject::hasAutoHeightOrContainingBlockWithAutoHeight() const
149 { 119 {
150 Length logicalHeightLength = style()->logicalHeight(); 120 Length logicalHeightLength = style()->logicalHeight();
151 if (logicalHeightLength.isAuto()) 121 if (logicalHeightLength.isAuto())
152 return true; 122 return true;
153 123
154 // For percentage heights: The percentage is calculated with respect to the height of the generated box's 124 // For percentage heights: The percentage is calculated with respect to the height of the generated box's
155 // containing block. If the height of the containing block is not specified explicitly (i.e., it depends 125 // containing block. If the height of the containing block is not specified explicitly (i.e., it depends
156 // on content height), and this element is not absolutely positioned, the va lue computes to 'auto'. 126 // on content height), and this element is not absolutely positioned, the va lue computes to 'auto'.
157 // FIXME(sky): We might want to make height: 100% be sensible. 127 // FIXME(sky): We might want to make height: 100% be sensible.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 context->fillRect(backgroundRect, baseColor, operation); 182 context->fillRect(backgroundRect, baseColor, operation);
213 } else if (bgColor.alpha()) { 183 } else if (bgColor.alpha()) {
214 context->fillRect(backgroundRect, bgColor, operation); 184 context->fillRect(backgroundRect, bgColor, operation);
215 } else if (shouldClearDocumentBackground) { 185 } else if (shouldClearDocumentBackground) {
216 context->clearRect(backgroundRect); 186 context->clearRect(backgroundRect);
217 } 187 }
218 } 188 }
219 189
220 LayoutSize RenderBoxModelObject::relativePositionOffset() const 190 LayoutSize RenderBoxModelObject::relativePositionOffset() const
221 { 191 {
222 LayoutSize offset = accumulateInFlowPositionOffsets(this); 192 LayoutSize offset;
223 193
224 RenderBlock* containingBlock = this->containingBlock(); 194 RenderBlock* containingBlock = this->containingBlock();
225 195
226 // Objects that shrink to avoid floats normally use available line width whe n computing containing block width. However 196 // Objects that shrink to avoid floats normally use available line width whe n computing containing block width. However
227 // in the case of relative positioning using percentages, we can't do this. The offset should always be resolved using the 197 // in the case of relative positioning using percentages, we can't do this. The offset should always be resolved using the
228 // available width of the containing block. Therefore we don't use containi ngBlockLogicalWidthForContent() here, but instead explicitly 198 // available width of the containing block. Therefore we don't use containi ngBlockLogicalWidthForContent() here, but instead explicitly
229 // call availableWidth on our containing block. 199 // call availableWidth on our containing block.
230 if (!style()->left().isAuto()) { 200 if (!style()->left().isAuto()) {
231 if (!style()->right().isAuto() && !containingBlock->style()->isLeftToRig htDirection()) 201 if (!style()->right().isAuto() && !containingBlock->style()->isLeftToRig htDirection())
232 offset.setWidth(-valueForLength(style()->right(), containingBlock->a vailableWidth())); 202 offset.setWidth(-valueForLength(style()->right(), containingBlock->a vailableWidth()));
(...skipping 2188 matching lines...) Expand 10 before | Expand all | Expand 10 after
2421 context->drawInnerShadow(border, shadowColor, flooredIntSize(shadowO ffset), shadowBlur, shadowSpread, clippedEdges); 2391 context->drawInnerShadow(border, shadowColor, flooredIntSize(shadowO ffset), shadowBlur, shadowSpread, clippedEdges);
2422 } 2392 }
2423 } 2393 }
2424 } 2394 }
2425 2395
2426 LayoutUnit RenderBoxModelObject::containingBlockLogicalWidthForContent() const 2396 LayoutUnit RenderBoxModelObject::containingBlockLogicalWidthForContent() const
2427 { 2397 {
2428 return containingBlock()->availableLogicalWidth(); 2398 return containingBlock()->availableLogicalWidth();
2429 } 2399 }
2430 2400
2431 RenderBoxModelObject* RenderBoxModelObject::continuation() const
2432 {
2433 if (!continuationMap)
2434 return 0;
2435 return (*continuationMap)->get(this);
2436 }
2437
2438 void RenderBoxModelObject::setContinuation(RenderBoxModelObject* continuation)
2439 {
2440 if (continuation) {
2441 if (!continuationMap)
2442 continuationMap = new OwnPtr<ContinuationMap>(adoptPtr(new Continuat ionMap));
2443 (*continuationMap)->set(this, continuation);
2444 } else {
2445 if (continuationMap)
2446 (*continuationMap)->remove(this);
2447 }
2448 }
2449
2450 LayoutRect RenderBoxModelObject::localCaretRectForEmptyElement(LayoutUnit width, LayoutUnit textIndentOffset) 2401 LayoutRect RenderBoxModelObject::localCaretRectForEmptyElement(LayoutUnit width, LayoutUnit textIndentOffset)
2451 { 2402 {
2452 ASSERT(!slowFirstChild()); 2403 ASSERT(!slowFirstChild());
2453 2404
2454 // FIXME: This does not take into account either :first-line or :first-lette r 2405 // FIXME: This does not take into account either :first-line or :first-lette r
2455 // However, as soon as some content is entered, the line boxes will be 2406 // However, as soon as some content is entered, the line boxes will be
2456 // constructed and this kludge is not called any more. So only the caret siz e 2407 // constructed and this kludge is not called any more. So only the caret siz e
2457 // of an empty :first-line'd block is wrong. I think we can live with that. 2408 // of an empty :first-line'd block is wrong. I think we can live with that.
2458 RenderStyle* currentStyle = firstLineStyle(); 2409 RenderStyle* currentStyle = firstLineStyle();
2459 2410
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
2583 ASSERT(this == child->parent()); 2534 ASSERT(this == child->parent());
2584 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 2535 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2585 if (fullRemoveInsert && (toBoxModelObject->isRenderBlock() || toBoxModelObje ct->isRenderInline())) { 2536 if (fullRemoveInsert && (toBoxModelObject->isRenderBlock() || toBoxModelObje ct->isRenderInline())) {
2586 // Takes care of adding the new child correctly if toBlock and fromBlock 2537 // Takes care of adding the new child correctly if toBlock and fromBlock
2587 // have different kind of children (block vs inline). 2538 // have different kind of children (block vs inline).
2588 toBoxModelObject->addChild(virtualChildren()->removeChildNode(this, chil d), beforeChild); 2539 toBoxModelObject->addChild(virtualChildren()->removeChildNode(this, chil d), beforeChild);
2589 } else 2540 } else
2590 toBoxModelObject->virtualChildren()->insertChildNode(toBoxModelObject, v irtualChildren()->removeChildNode(this, child, fullRemoveInsert), beforeChild, f ullRemoveInsert); 2541 toBoxModelObject->virtualChildren()->insertChildNode(toBoxModelObject, v irtualChildren()->removeChildNode(this, child, fullRemoveInsert), beforeChild, f ullRemoveInsert);
2591 } 2542 }
2592 2543
2593 void RenderBoxModelObject::moveChildrenTo(RenderBoxModelObject* toBoxModelObject , RenderObject* startChild, RenderObject* endChild, RenderObject* beforeChild, b ool fullRemoveInsert) 2544 void RenderBoxModelObject::moveAllChildrenTo(RenderBoxModelObject* toBoxModelObj ect, RenderObject* beforeChild, bool fullRemoveInsert)
2594 { 2545 {
2595 // This condition is rarely hit since this function is usually called on 2546 // This condition is rarely hit since this function is usually called on
2596 // anonymous blocks which can no longer carry positioned objects (see r12076 1) 2547 // anonymous blocks which can no longer carry positioned objects (see r12076 1)
2597 // or when fullRemoveInsert is false. 2548 // or when fullRemoveInsert is false.
2598 if (fullRemoveInsert && isRenderBlock()) { 2549 if (fullRemoveInsert && isRenderBlock()) {
2599 RenderBlock* block = toRenderBlock(this); 2550 RenderBlock* block = toRenderBlock(this);
2600 block->removePositionedObjects(0); 2551 block->removePositionedObjects(0);
2601 } 2552 }
2602 2553
2603 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 2554 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2604 for (RenderObject* child = startChild; child && child != endChild; ) { 2555 for (RenderObject* child = slowFirstChild(); child; ) {
2605 // Save our next sibling as moveChildTo will clear it. 2556 // Save our next sibling as moveChildTo will clear it.
2606 RenderObject* nextSibling = child->nextSibling(); 2557 RenderObject* nextSibling = child->nextSibling();
2607 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 2558 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
2608 child = nextSibling; 2559 child = nextSibling;
2609 } 2560 }
2610 } 2561 }
2611 2562
2612 } // namespace blink 2563 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderBoxModelObject.h ('k') | sky/engine/core/rendering/RenderInline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698