| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
| 6 #include "sky/engine/core/rendering/RenderParagraph.h" | 6 #include "sky/engine/core/rendering/RenderParagraph.h" |
| 7 | 7 |
| 8 #include "sky/engine/core/rendering/InlineIterator.h" |
| 9 |
| 8 namespace blink { | 10 namespace blink { |
| 9 | 11 |
| 10 RenderParagraph::RenderParagraph(ContainerNode* node) | 12 RenderParagraph::RenderParagraph(ContainerNode* node) |
| 11 : RenderBlockFlow(node) | 13 : RenderBlockFlow(node) |
| 12 { | 14 { |
| 13 } | 15 } |
| 14 | 16 |
| 15 RenderParagraph::~RenderParagraph() | 17 RenderParagraph::~RenderParagraph() |
| 16 { | 18 { |
| 17 } | 19 } |
| 18 | 20 |
| 19 RenderParagraph* RenderParagraph::createAnonymous(Document& document) | 21 RenderParagraph* RenderParagraph::createAnonymous(Document& document) |
| 20 { | 22 { |
| 21 RenderParagraph* renderer = new RenderParagraph(0); | 23 RenderParagraph* renderer = new RenderParagraph(0); |
| 22 renderer->setDocumentForAnonymous(&document); | 24 renderer->setDocumentForAnonymous(&document); |
| 23 return renderer; | 25 return renderer; |
| 24 } | 26 } |
| 25 | 27 |
| 28 void RenderParagraph::addOverflowFromChildren() |
| 29 { |
| 30 LayoutUnit endPadding = hasOverflowClip() ? paddingEnd() : LayoutUnit(); |
| 31 // FIXME: Need to find another way to do this, since scrollbars could show w
hen we don't want them to. |
| 32 if (hasOverflowClip() && !endPadding && node() && node()->isRootEditableElem
ent() && style()->isLeftToRightDirection()) |
| 33 endPadding = 1; |
| 34 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox())
{ |
| 35 addLayoutOverflow(curr->paddedLayoutOverflowRect(endPadding)); |
| 36 LayoutRect visualOverflow = curr->visualOverflowRect(curr->lineTop(), cu
rr->lineBottom()); |
| 37 addContentsVisualOverflow(visualOverflow); |
| 38 } |
| 39 } |
| 40 |
| 41 void RenderParagraph::simplifiedNormalFlowLayout() |
| 42 { |
| 43 ListHashSet<RootInlineBox*> lineBoxes; |
| 44 for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) { |
| 45 RenderObject* o = walker.current(); |
| 46 if (!o->isOutOfFlowPositioned() && o->isReplaced()) { |
| 47 o->layoutIfNeeded(); |
| 48 if (toRenderBox(o)->inlineBoxWrapper()) { |
| 49 RootInlineBox& box = toRenderBox(o)->inlineBoxWrapper()->root(
); |
| 50 lineBoxes.add(&box); |
| 51 } |
| 52 } else if (o->isText() || (o->isRenderInline() && !walker.atEndOfInlin
e())) { |
| 53 o->clearNeedsLayout(); |
| 54 } |
| 55 } |
| 56 |
| 57 // FIXME: Glyph overflow will get lost in this case, but not really a big
deal. |
| 58 GlyphOverflowAndFallbackFontsMap textBoxDataMap; |
| 59 for (ListHashSet<RootInlineBox*>::const_iterator it = lineBoxes.begin(); i
t != lineBoxes.end(); ++it) { |
| 60 RootInlineBox* box = *it; |
| 61 box->computeOverflow(box->lineTop(), box->lineBottom(), textBoxDataMap
); |
| 62 } |
| 63 } |
| 64 |
| 65 void RenderParagraph::paintContents(PaintInfo& paintInfo, const LayoutPoint& pai
ntOffset) |
| 66 { |
| 67 m_lineBoxes.paint(this, paintInfo, paintOffset); |
| 68 } |
| 69 |
| 70 bool RenderParagraph::hitTestContents(const HitTestRequest& request, HitTestResu
lt& result, const HitTestLocation& locationInContainer, const LayoutPoint& accum
ulatedOffset, HitTestAction hitTestAction) |
| 71 { |
| 72 return m_lineBoxes.hitTest(this, request, result, locationInContainer, accum
ulatedOffset, hitTestAction); |
| 73 } |
| 74 |
| 75 |
| 26 } // namespace blink | 76 } // namespace blink |
| OLD | NEW |