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

Unified Diff: third_party/WebKit/Source/core/editing/EditingUtilities.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/EditingUtilities.cpp
diff --git a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
index 13c6a5b8679447efc7e81ef71e8d57c5eab35147..9523b077c1d8f38a19c8c9275824e3e8eaf2fd65 100644
--- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
+++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
@@ -53,6 +53,7 @@
#include "core/html/HTMLUListElement.h"
#include "core/layout/LayoutObject.h"
#include "core/layout/LayoutTableCell.h"
+#include "core/layout/LayoutText.h"
#include "wtf/Assertions.h"
#include "wtf/StdLibExtras.h"
#include "wtf/text/StringBuilder.h"
@@ -1680,4 +1681,59 @@ Position adjustedSelectionStartForStyleComputation(const VisibleSelection& selec
return mostForwardCaretPosition(visiblePosition.deepEquivalent());
}
+static void absoluteTextBoundsForRange(LayoutText* layoutText, Vector<IntRect>& rects, unsigned startOffset, unsigned endOffset, bool useSelectionHeight, bool* wasFixed)
+{
+ layoutText->absoluteRectsForRange(rects, startOffset, endOffset, useSelectionHeight, wasFixed);
+}
+
+static void absoluteTextBoundsForRange(LayoutText* layoutText, Vector<FloatQuad>& quads, unsigned startOffset, unsigned endOffset, bool useSelectionHeight, bool* wasFixed)
+{
+ layoutText->absoluteQuadsForRange(quads, startOffset, endOffset, useSelectionHeight, wasFixed);
+}
+
+template <typename BoundsType>
+void collectTextBoundsInRangeAlgorithm(
yosin_UTC9 2015/11/04 07:11:06 nit: Please add |static|, just in case.
+ Node* start, int startOffset, Node* end, int endOffset, Node* firstNode, Node* stopNode, Node* (*next)(const Node&),
+ Vector<BoundsType>& textBounds, bool useSelectionHeight, bool* allFixed, bool* someFixed)
+{
+ ASSERT(start);
+ ASSERT(end);
+ ASSERT(next);
+
+ bool allFixedLocal = true;
+ bool someFixedLocal = false;
+ for (Node* node = firstNode; node != stopNode; node = next(*node)) {
+ LayoutObject* layoutObject = node->layoutObject();
+ if (!layoutObject || !layoutObject->isText())
+ continue;
+
+ int textStartOffset = node == start ? startOffset : 0;
+ int textEndOffset = node == end ? endOffset : std::numeric_limits<int>::max();
+ bool isFixed = false;
+ absoluteTextBoundsForRange(toLayoutText(layoutObject), textBounds, textStartOffset, textEndOffset, useSelectionHeight, &isFixed);
+ allFixedLocal &= isFixed;
+ someFixedLocal |= isFixed;
+ }
+
+ if (allFixed)
+ *allFixed = allFixedLocal;
+
+ if (someFixed)
+ *someFixed = someFixedLocal;
+}
+
+void collectTextBoundsInRange(
+ Node* start, int startOffset, Node* end, int endOffset, Node* firstNode, Node* stopNode, Node* (*next)(const Node&),
+ Vector<IntRect>& rects, bool useSelectionHeight, bool* allFixed, bool* someFixed)
+{
+ collectTextBoundsInRangeAlgorithm(start, startOffset, end, endOffset, firstNode, stopNode, next, rects, useSelectionHeight, allFixed, someFixed);
+}
+
+void collectTextBoundsInRange(
+ Node* start, int startOffset, Node* end, int endOffset, Node* firstNode, Node* stopNode, Node* (*next)(const Node&),
+ Vector<FloatQuad>& quads, bool useSelectionHeight, bool* allFixed, bool* someFixed)
+{
+ collectTextBoundsInRangeAlgorithm(start, startOffset, end, endOffset, firstNode, stopNode, next, quads, useSelectionHeight, allFixed, someFixed);
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698