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

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

Issue 1409073004: Return EphemeralRange from Editor::findRangeOfString. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Extract text bounds collecting to a function Created 5 years, 1 month 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 a578146ae9e2cb48ea7aad6e06331b761e872981..7cc6901290b29b8928672926562965432e4b7f12 100644
--- a/third_party/WebKit/Source/core/editing/EphemeralRange.cpp
+++ b/third_party/WebKit/Source/core/editing/EphemeralRange.cpp
@@ -9,6 +9,8 @@
#include "core/dom/Element.h"
#include "core/dom/Range.h"
#include "core/dom/Text.h"
+#include "core/editing/EditingUtilities.h"
+#include "core/layout/LayoutText.h"
namespace blink {
@@ -123,6 +125,29 @@ EphemeralRangeTemplate<Strategy> EphemeralRangeTemplate<Strategy>::rangeOfConten
return EphemeralRangeTemplate<Strategy>(PositionTemplate<Strategy>::firstPositionInNode(&const_cast<Node&>(node)), PositionTemplate<Strategy>::lastPositionInNode(&const_cast<Node&>(node)));
}
+static IntRect uniteRects(const Vector<IntRect>& rects)
+{
+ IntRect result;
+ for (const auto& rect : rects)
+ result.unite(rect);
+ return result;
+}
+
+template <typename Strategy>
+IntRect EphemeralRangeTemplate<Strategy>::textBoundingBox() const
+{
+ if (isCollapsed())
+ return IntRect();
+
+ Vector<IntRect> rects;
+ collectTextBoundsInRange(
+ m_startPosition, m_endPosition,
+ m_startPosition.nodeAsRangeFirstNode(), m_endPosition.nodeAsRangePastLastNode(),
+ rects);
+
+ return uniteRects(rects);
+}
+
#if ENABLE(ASSERT)
template <typename Strategy>
bool EphemeralRangeTemplate<Strategy>::isValid() const

Powered by Google App Engine
This is Rietveld 408576698