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

Unified Diff: Source/core/editing/VisibleUnits.cpp

Issue 1309673002: Move inRenderedText() to VisibleUnits.cpp from Position.cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-21T17:53:03 Created 5 years, 4 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
« no previous file with comments | « Source/core/editing/Position.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/VisibleUnits.cpp
diff --git a/Source/core/editing/VisibleUnits.cpp b/Source/core/editing/VisibleUnits.cpp
index 2dcb4ccc9b144a57733b0bffe9090e20957762b0..b5a1ca773da0f0cd50dc74803adeede3d88e1201 100644
--- a/Source/core/editing/VisibleUnits.cpp
+++ b/Source/core/editing/VisibleUnits.cpp
@@ -1763,6 +1763,35 @@ VisiblePosition visiblePositionForContentsPoint(const IntPoint& contentsPoint, L
return VisiblePosition();
}
+template <typename Strategy>
+static bool inRenderedText(const PositionAlgorithm<Strategy>& position)
+{
+ Node* const anchorNode = position.anchorNode();
+ if (!anchorNode || !anchorNode->isTextNode())
+ return false;
+
+ LayoutObject* layoutObject = anchorNode->layoutObject();
+ if (!layoutObject)
+ return false;
+
+ const int offsetInNode = position.computeEditingOffset();
+ LayoutText* textLayoutObject = toLayoutText(layoutObject);
+ for (InlineTextBox *box = textLayoutObject->firstTextBox(); box; box = box->nextTextBox()) {
+ if (offsetInNode < static_cast<int>(box->start()) && !textLayoutObject->containsReversedText()) {
+ // The offset we're looking for is before this node
+ // this means the offset must be in content that is
+ // not laid out. Return false.
+ return false;
+ }
+ if (box->containsCaretOffset(offsetInNode)) {
+ // Return false for offsets inside composed characters.
+ return offsetInNode == 0 || offsetInNode == textLayoutObject->nextOffset(textLayoutObject->previousOffset(offsetInNode));
+ }
+ }
+
+ return false;
+}
+
static Node* nextRenderedEditable(Node* node)
{
for (node = nextAtomicLeafNode(*node); node; node = nextAtomicLeafNode(*node)) {
« no previous file with comments | « Source/core/editing/Position.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698