diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/RenderTextLineBoxes.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/rendering/RenderTextLineBoxes.cpp')
-rw-r--r-- | Source/WebCore/rendering/RenderTextLineBoxes.cpp | 85 |
1 files changed, 50 insertions, 35 deletions
diff --git a/Source/WebCore/rendering/RenderTextLineBoxes.cpp b/Source/WebCore/rendering/RenderTextLineBoxes.cpp index 4ad4c156b..e59f3de61 100644 --- a/Source/WebCore/rendering/RenderTextLineBoxes.cpp +++ b/Source/WebCore/rendering/RenderTextLineBoxes.cpp @@ -64,7 +64,7 @@ void RenderTextLineBoxes::extract(InlineTextBox& box) if (box.prevTextBox()) box.prevTextBox()->setNextTextBox(nullptr); box.setPreviousTextBox(nullptr); - for (auto current = &box; current; current = current->nextTextBox()) + for (auto* current = &box; current; current = current->nextTextBox()) current->setExtracted(); checkConsistency(); @@ -80,7 +80,7 @@ void RenderTextLineBoxes::attach(InlineTextBox& box) } else m_first = &box; InlineTextBox* last = nullptr; - for (auto current = &box; current; current = current->nextTextBox()) { + for (auto* current = &box; current; current = current->nextTextBox()) { current->setExtracted(false); last = current; } @@ -109,10 +109,10 @@ void RenderTextLineBoxes::removeAllFromParent(RenderText& renderer) { if (!m_first) { if (renderer.parent()) - renderer.parent()->dirtyLinesFromChangedChild(&renderer); + renderer.parent()->dirtyLinesFromChangedChild(renderer); return; } - for (auto box = m_first; box; box = box->nextTextBox()) + for (auto* box = m_first; box; box = box->nextTextBox()) box->removeFromParent(); } @@ -121,7 +121,7 @@ void RenderTextLineBoxes::deleteAll() if (!m_first) return; InlineTextBox* next; - for (auto current = m_first; current; current = next) { + for (auto* current = m_first; current; current = next) { next = current->nextTextBox(); delete current; } @@ -153,7 +153,7 @@ IntRect RenderTextLineBoxes::boundingBox(const RenderText& renderer) const // Return the width of the minimal left side and the maximal right side. float logicalLeftSide = 0; float logicalRightSide = 0; - for (auto current = m_first; current; current = current->nextTextBox()) { + for (auto* current = m_first; current; current = current->nextTextBox()) { if (current == m_first || current->logicalLeft() < logicalLeftSide) logicalLeftSide = current->logicalLeft(); if (current == m_first || current->logicalRight() > logicalRightSide) @@ -169,6 +169,13 @@ IntRect RenderTextLineBoxes::boundingBox(const RenderText& renderer) const return enclosingIntRect(FloatRect(x, y, width, height)); } +IntPoint RenderTextLineBoxes::firstRunLocation() const +{ + if (!m_first) + return IntPoint(); + return IntPoint(m_first->topLeft()); +} + LayoutRect RenderTextLineBoxes::visualOverflowBoundingBox(const RenderText& renderer) const { if (!m_first) @@ -177,7 +184,7 @@ LayoutRect RenderTextLineBoxes::visualOverflowBoundingBox(const RenderText& rend // Return the width of the minimal left side and the maximal right side. auto logicalLeftSide = LayoutUnit::max(); auto logicalRightSide = LayoutUnit::min(); - for (auto current = m_first; current; current = current->nextTextBox()) { + for (auto* current = m_first; current; current = current->nextTextBox()) { logicalLeftSide = std::min(logicalLeftSide, current->logicalLeftVisualOverflow()); logicalRightSide = std::max(logicalRightSide, current->logicalRightVisualOverflow()); } @@ -194,7 +201,7 @@ LayoutRect RenderTextLineBoxes::visualOverflowBoundingBox(const RenderText& rend bool RenderTextLineBoxes::hasRenderedText() const { - for (auto box = m_first; box; box = box->nextTextBox()) { + for (auto* box = m_first; box; box = box->nextTextBox()) { if (box->len()) return true; } @@ -226,7 +233,7 @@ int RenderTextLineBoxes::caretMaxOffset(const RenderText& renderer) const bool RenderTextLineBoxes::containsOffset(const RenderText& renderer, unsigned offset, OffsetType type) const { - for (auto box = m_first; box; box = box->nextTextBox()) { + for (auto* box = m_first; box; box = box->nextTextBox()) { if (offset < box->start() && !renderer.containsReversedText()) return false; unsigned boxEnd = box->start() + box->len(); @@ -245,7 +252,7 @@ bool RenderTextLineBoxes::containsOffset(const RenderText& renderer, unsigned of unsigned RenderTextLineBoxes::countCharacterOffsetsUntil(unsigned offset) const { unsigned result = 0; - for (auto box = m_first; box; box = box->nextTextBox()) { + for (auto* box = m_first; box; box = box->nextTextBox()) { if (offset < box->start()) return result; if (offset <= box->start() + box->len()) { @@ -395,7 +402,7 @@ VisiblePosition RenderTextLineBoxes::positionForPoint(const RenderText& renderer bool blocksAreFlipped = renderer.style().isFlippedBlocksWritingMode(); InlineTextBox* lastBox = nullptr; - for (auto box = m_first; box; box = box->nextTextBox()) { + for (auto* box = m_first; box; box = box->nextTextBox()) { if (box->isLineBreak() && !box->prevLeafChild() && box->nextLeafChild() && !box->nextLeafChild()->isLineBreak()) box = box->nextTextBox(); @@ -433,12 +440,12 @@ VisiblePosition RenderTextLineBoxes::positionForPoint(const RenderText& renderer void RenderTextLineBoxes::setSelectionState(RenderText& renderer, RenderObject::SelectionState state) { if (state == RenderObject::SelectionInside || state == RenderObject::SelectionNone) { - for (auto box = m_first; box; box = box->nextTextBox()) + for (auto* box = m_first; box; box = box->nextTextBox()) box->root().setHasSelectedChildren(state == RenderObject::SelectionInside); return; } - int start, end; + unsigned start, end; renderer.selectionStartEnd(start, end); if (state == RenderObject::SelectionStart) { end = renderer.textLength(); @@ -449,7 +456,7 @@ void RenderTextLineBoxes::setSelectionState(RenderText& renderer, RenderObject:: } else if (state == RenderObject::SelectionEnd) start = 0; - for (auto box = m_first; box; box = box->nextTextBox()) { + for (auto* box = m_first; box; box = box->nextTextBox()) { if (box->isSelected(start, end)) box->root().setHasSelectedChildren(true); } @@ -480,17 +487,28 @@ static IntRect ellipsisRectForBox(const InlineTextBox& box, unsigned start, unsi LayoutRect RenderTextLineBoxes::selectionRectForRange(unsigned start, unsigned end) { LayoutRect rect; - for (auto box = m_first; box; box = box->nextTextBox()) { + for (auto* box = m_first; box; box = box->nextTextBox()) { rect.unite(box->localSelectionRect(start, end)); rect.unite(ellipsisRectForBox(*box, start, end)); } return rect; } +void RenderTextLineBoxes::collectSelectionRectsForRange(unsigned start, unsigned end, Vector<LayoutRect>& rects) +{ + for (auto* box = m_first; box; box = box->nextTextBox()) { + LayoutRect rect; + rect.unite(box->localSelectionRect(start, end)); + rect.unite(ellipsisRectForBox(*box, start, end)); + if (!rect.size().isEmpty()) + rects.append(rect); + } +} + Vector<IntRect> RenderTextLineBoxes::absoluteRects(const LayoutPoint& accumulatedOffset) const { Vector<IntRect> rects; - for (auto box = m_first; box; box = box->nextTextBox()) + for (auto* box = m_first; box; box = box->nextTextBox()) rects.append(enclosingIntRect(FloatRect(accumulatedOffset + box->topLeft(), box->size()))); return rects; } @@ -518,7 +536,7 @@ static FloatRect localQuadForTextBox(const InlineTextBox& box, unsigned start, u Vector<IntRect> RenderTextLineBoxes::absoluteRectsForRange(const RenderText& renderer, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const { Vector<IntRect> rects; - for (auto box = m_first; box; box = box->nextTextBox()) { + for (auto* box = m_first; box; box = box->nextTextBox()) { // Note: box->end() returns the index of the last character, not the index past it if (start <= box->start() && box->end() < end) { FloatRect boundaries = box->calculateBoundaries(); @@ -532,13 +550,13 @@ Vector<IntRect> RenderTextLineBoxes::absoluteRectsForRange(const RenderText& ren boundaries.setX(selectionRect.x()); } } - rects.append(renderer.localToAbsoluteQuad(boundaries, 0, wasFixed).enclosingBoundingBox()); + rects.append(renderer.localToAbsoluteQuad(boundaries, UseTransforms, wasFixed).enclosingBoundingBox()); continue; } // FIXME: This code is wrong. It's converting local to absolute twice. http://webkit.org/b/65722 FloatRect rect = localQuadForTextBox(*box, start, end, useSelectionHeight); if (!rect.isZero()) - rects.append(renderer.localToAbsoluteQuad(rect, 0, wasFixed).enclosingBoundingBox()); + rects.append(renderer.localToAbsoluteQuad(rect, UseTransforms, wasFixed).enclosingBoundingBox()); } return rects; } @@ -546,7 +564,7 @@ Vector<IntRect> RenderTextLineBoxes::absoluteRectsForRange(const RenderText& ren Vector<FloatQuad> RenderTextLineBoxes::absoluteQuads(const RenderText& renderer, bool* wasFixed, ClippingOption option) const { Vector<FloatQuad> quads; - for (auto box = m_first; box; box = box->nextTextBox()) { + for (auto* box = m_first; box; box = box->nextTextBox()) { FloatRect boundaries = box->calculateBoundaries(); // Shorten the width of this text box if it ends in an ellipsis. @@ -558,7 +576,7 @@ Vector<FloatQuad> RenderTextLineBoxes::absoluteQuads(const RenderText& renderer, else boundaries.setHeight(ellipsisRect.maxY() - boundaries.y()); } - quads.append(renderer.localToAbsoluteQuad(boundaries, 0, wasFixed)); + quads.append(renderer.localToAbsoluteQuad(boundaries, UseTransforms, wasFixed)); } return quads; } @@ -566,7 +584,7 @@ Vector<FloatQuad> RenderTextLineBoxes::absoluteQuads(const RenderText& renderer, Vector<FloatQuad> RenderTextLineBoxes::absoluteQuadsForRange(const RenderText& renderer, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const { Vector<FloatQuad> quads; - for (auto box = m_first; box; box = box->nextTextBox()) { + for (auto* box = m_first; box; box = box->nextTextBox()) { // Note: box->end() returns the index of the last character, not the index past it if (start <= box->start() && box->end() < end) { FloatRect boundaries = box->calculateBoundaries(); @@ -580,19 +598,19 @@ Vector<FloatQuad> RenderTextLineBoxes::absoluteQuadsForRange(const RenderText& r boundaries.setX(selectionRect.x()); } } - quads.append(renderer.localToAbsoluteQuad(boundaries, 0, wasFixed)); + quads.append(renderer.localToAbsoluteQuad(boundaries, UseTransforms, wasFixed)); continue; } FloatRect rect = localQuadForTextBox(*box, start, end, useSelectionHeight); if (!rect.isZero()) - quads.append(renderer.localToAbsoluteQuad(rect, 0, wasFixed)); + quads.append(renderer.localToAbsoluteQuad(rect, UseTransforms, wasFixed)); } return quads; } void RenderTextLineBoxes::dirtyAll() { - for (auto box = m_first; box; box = box->nextTextBox()) + for (auto* box = m_first; box; box = box->nextTextBox()) box->dirtyLineBoxes(); } @@ -603,7 +621,7 @@ bool RenderTextLineBoxes::dirtyRange(RenderText& renderer, unsigned start, unsig // Dirty all text boxes that include characters in between offset and offset+len. bool dirtiedLines = false; - for (auto current = m_first; current; current = current->nextTextBox()) { + for (auto* current = m_first; current; current = current->nextTextBox()) { // FIXME: This shouldn't rely on the end of a dirty line box. See https://bugs.webkit.org/show_bug.cgi?id=97264 // Text run is entirely before the affected range. if (current->end() < start) @@ -615,8 +633,7 @@ bool RenderTextLineBoxes::dirtyRange(RenderText& renderer, unsigned start, unsig if (!firstRootBox) { firstRootBox = &rootBox; if (!dirtiedLines) { - // The affected area was in between two runs. Go ahead and mark the root box of - // the run after the affected area as dirty. + // The affected area was in between two runs. Mark the root box of the run after the affected area as dirty. firstRootBox->markDirty(); dirtiedLines = true; } @@ -658,14 +675,14 @@ bool RenderTextLineBoxes::dirtyRange(RenderText& renderer, unsigned start, unsig firstRootBox->markDirty(); dirtiedLines = true; } - for (auto current = firstRootBox; current && current != lastRootBox; current = current->nextRootBox()) { + for (auto* current = firstRootBox; current && current != lastRootBox; current = current->nextRootBox()) { if (current->lineBreakObj() == &renderer && current->lineBreakPos() > end) current->setLineBreakPos(current->lineBreakPos() + lengthDelta); } // If the text node is empty, dirty the line where new text will be inserted. if (!m_first && renderer.parent()) { - renderer.parent()->dirtyLinesFromChangedChild(&renderer); + renderer.parent()->dirtyLinesFromChangedChild(renderer); dirtiedLines = true; } return dirtiedLines; @@ -676,7 +693,7 @@ inline void RenderTextLineBoxes::checkConsistency() const #if !ASSERT_DISABLED #ifdef CHECK_CONSISTENCY const InlineTextBox* prev = nullptr; - for (auto child = m_first; child; child = child->nextTextBox()) { + for (auto* child = m_first; child; child = child->nextTextBox()) { ASSERT(child->renderer() == this); ASSERT(child->prevTextBox() == prev); prev = child; @@ -697,10 +714,8 @@ RenderTextLineBoxes::~RenderTextLineBoxes() #if !ASSERT_WITH_SECURITY_IMPLICATION_DISABLED void RenderTextLineBoxes::invalidateParentChildLists() { - for (auto box = m_first; box; box = box->nextTextBox()) { - if (auto parent = box->parent()) - parent->setHasBadChildList(); - } + for (auto* box = m_first; box; box = box->nextTextBox()) + box->invalidateParentChildList(); } #endif |