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

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

Issue 2776103002: Make RenderedRectsForMarkers() to ignore disconnected nodes. (Closed)
Patch Set: upload test file 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/EphemeralRange.cpp
diff --git a/third_party/WebKit/Source/core/editing/EphemeralRange.cpp b/third_party/WebKit/Source/core/editing/EphemeralRange.cpp
index 2767484862f96592db1f214fa106e2e365b7abd3..bc12c06648a4a6bd204df3462b2ea574965849c8 100644
--- a/third_party/WebKit/Source/core/editing/EphemeralRange.cpp
+++ b/third_party/WebKit/Source/core/editing/EphemeralRange.cpp
@@ -8,6 +8,8 @@
#include "core/dom/Element.h"
#include "core/dom/Range.h"
#include "core/dom/Text.h"
+#include "core/layout/LayoutObject.h"
+#include "core/layout/LayoutText.h"
namespace blink {
@@ -119,6 +121,40 @@ PositionTemplate<Strategy> EphemeralRangeTemplate<Strategy>::endPosition()
}
template <typename Strategy>
+IntRect EphemeralRangeTemplate<Strategy>::boundingBox() const {
+ IntRect result;
+ Vector<IntRect> rects;
+ textRects(rects);
+ for (const IntRect& rect : rects)
+ result.unite(rect);
+ return result;
+}
+
+template <typename Strategy>
+void EphemeralRangeTemplate<Strategy>::textRects(
+ Vector<IntRect>& rects,
+ bool useSelectionHeight) const {
+ Node* startContainer = m_startPosition.computeContainerNode();
+ DCHECK(startContainer);
+ Node* endContainer = m_endPosition.computeContainerNode();
+ DCHECK(endContainer);
+
+ for (Node& node : nodes()) {
+ LayoutObject* layoutObject = node.layoutObject();
+ if (!layoutObject || !layoutObject->isText())
+ continue;
+ LayoutText* layoutText = toLayoutText(layoutObject);
+ unsigned startOffset =
+ node == startContainer ? m_startPosition.offsetInContainerNode() : 0;
+ unsigned endOffset = node == endContainer
+ ? m_endPosition.offsetInContainerNode()
+ : std::numeric_limits<unsigned>::max();
+ layoutText->absoluteRectsForRange(rects, startOffset, endOffset,
+ useSelectionHeight);
+ }
+}
+
+template <typename Strategy>
Node* EphemeralRangeTemplate<Strategy>::commonAncestorContainer() const {
return commonAncestorContainerNode<Strategy>(
m_startPosition.computeContainerNode(),

Powered by Google App Engine
This is Rietveld 408576698