| 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(),
|
|
|