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

Unified Diff: third_party/WebKit/Source/core/editing/VisibleUnits.cpp

Issue 2776103002: Make RenderedRectsForMarkers() to ignore disconnected nodes. (Closed)
Patch Set: move to VisibleUnits Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/VisibleUnits.cpp
diff --git a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
index f1da75b0e408206c7b87a6ce891b67ed7c7005fc..24d9a73d88038e4e413c1ecc385d8934bd2ffe2d 100644
--- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -4040,6 +4040,48 @@ static PositionTemplate<Strategy> skipWhitespaceAlgorithm(
return runner;
}
+template <typename Strategy>
+void textRects(Vector<IntRect>& rects,
+ const EphemeralRangeTemplate<Strategy>& range) {
+ const PositionTemplate<Strategy> startPosition = range.startPosition();
+ const PositionTemplate<Strategy> endPosition = range.startPosition();
+ Node* startContainer = startPosition.computeContainerNode();
+ DCHECK(startContainer);
+ Node* endContainer = endPosition.computeContainerNode();
+ DCHECK(endContainer);
+
+ for (Node& node : range.nodes()) {
+ LayoutObject* layoutObject = node.layoutObject();
+ if (!layoutObject || !layoutObject->isText())
+ continue;
+ LayoutText* layoutText = toLayoutText(layoutObject);
+ unsigned startOffset =
+ node == startContainer ? startPosition.offsetInContainerNode() : 0;
+ unsigned endOffset = node == endContainer
+ ? endPosition.offsetInContainerNode()
+ : std::numeric_limits<unsigned>::max();
+ layoutText->absoluteRectsForRange(rects, startOffset, endOffset);
+ }
+}
+
+IntRect boundingBox(const EphemeralRange& range) {
+ IntRect result;
+ Vector<IntRect> rects;
+ textRects(rects, range);
+ for (const IntRect& rect : rects)
+ result.unite(rect);
+ return result;
+}
+
+IntRect boundingBox(const EphemeralRangeInFlatTree& range) {
+ IntRect result;
+ Vector<IntRect> rects;
+ textRects(rects, range);
+ for (const IntRect& rect : rects)
+ result.unite(rect);
+ return result;
+}
+
Position skipWhitespace(const Position& position) {
return skipWhitespaceAlgorithm(position);
}

Powered by Google App Engine
This is Rietveld 408576698