Chromium Code Reviews| 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 |