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

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

Issue 2059663002: Make RenderedPosition constructor to work on flat tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-06-10T18:14:53 Update for review comments Created 4 years, 6 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 | « third_party/WebKit/LayoutTests/editing/selection/select_all/select_all_details_crash.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/RenderedPosition.cpp
diff --git a/third_party/WebKit/Source/core/editing/RenderedPosition.cpp b/third_party/WebKit/Source/core/editing/RenderedPosition.cpp
index 951cddccf10ca1f91d4d152e6dc97e40d6b175dc..400978b016fad92c6a8bf0678575e41c3fdd2e27 100644
--- a/third_party/WebKit/Source/core/editing/RenderedPosition.cpp
+++ b/third_party/WebKit/Source/core/editing/RenderedPosition.cpp
@@ -39,7 +39,8 @@
namespace blink {
-static inline LayoutObject* layoutObjectFromPosition(const Position& position)
+template <typename Strategy>
+static inline LayoutObject* layoutObjectFromPosition(const PositionTemplate<Strategy>& position)
{
DCHECK(position.isNotNull());
Node* layoutObjectNode = nullptr;
@@ -55,10 +56,10 @@ static inline LayoutObject* layoutObjectFromPosition(const Position& position)
break;
case PositionAnchorType::BeforeChildren:
- layoutObjectNode = position.anchorNode()->firstChild();
+ layoutObjectNode = Strategy::firstChild(*position.anchorNode());
break;
case PositionAnchorType::AfterChildren:
- layoutObjectNode = position.anchorNode()->lastChild();
+ layoutObjectNode = Strategy::lastChild(*position.anchorNode());
break;
}
if (!layoutObjectNode || !layoutObjectNode->layoutObject())
@@ -95,8 +96,21 @@ RenderedPosition::RenderedPosition(const Position& position, TextAffinity affini
}
RenderedPosition::RenderedPosition(const PositionInFlatTree& position, TextAffinity affinity)
- : RenderedPosition(toPositionInDOMTree(position), affinity)
+ : m_layoutObject(nullptr)
+ , m_inlineBox(nullptr)
+ , m_offset(0)
+ , m_prevLeafChild(uncachedInlineBox())
+ , m_nextLeafChild(uncachedInlineBox())
{
+ if (position.isNull())
+ return;
+ InlineBoxPosition boxPosition = computeInlineBoxPosition(position, affinity);
+ m_inlineBox = boxPosition.inlineBox;
+ m_offset = boxPosition.offsetInBox;
+ if (m_inlineBox)
+ m_layoutObject = LineLayoutAPIShim::layoutObjectFrom(m_inlineBox->getLineLayoutItem());
+ else
+ m_layoutObject = layoutObjectFromPosition(position);
}
InlineBox* RenderedPosition::prevLeafChild() const
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/selection/select_all/select_all_details_crash.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698