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

Unified Diff: third_party/WebKit/Source/web/WebSurroundingText.cpp

Issue 2350303003: Prune CreateVisiblePositionDeprecated from SurroundingText-related callers (Closed)
Patch Set: Created 4 years, 3 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
Index: third_party/WebKit/Source/web/WebSurroundingText.cpp
diff --git a/third_party/WebKit/Source/web/WebSurroundingText.cpp b/third_party/WebKit/Source/web/WebSurroundingText.cpp
index 0ecd970dd407a7f6bb2cd220843beee4e755199f..3d0380daea6d1d7544852f80cdc226428b48fae8 100644
--- a/third_party/WebKit/Source/web/WebSurroundingText.cpp
+++ b/third_party/WebKit/Source/web/WebSurroundingText.cpp
@@ -49,10 +49,17 @@ WebSurroundingText::~WebSurroundingText()
void WebSurroundingText::initialize(const WebNode& webNode, const WebPoint& nodePoint, size_t maxLength)
{
const Node* node = webNode.constUnwrap<Node>();
- if (!node || !node->layoutObject())
+ if (!node)
return;
- m_private.reset(new SurroundingText(createVisiblePositionDeprecated(node->layoutObject()->positionForPoint(static_cast<IntPoint>(nodePoint))).deepEquivalent().parentAnchoredEquivalent(), maxLength));
+ // SurroundingText must be created in clean layout.
+ node->document().updateStyleAndLayoutIgnorePendingStylesheets();
+ DocumentLifecycle::DisallowTransitionScope disallowTransition(node->document().lifecycle());
+
+ if (!node->layoutObject())
+ return;
+
+ m_private.reset(new SurroundingText(createVisiblePosition(node->layoutObject()->positionForPoint(static_cast<IntPoint>(nodePoint))).deepEquivalent().parentAnchoredEquivalent(), maxLength));
}
void WebSurroundingText::initializeFromCurrentSelection(WebLocalFrame* frame, size_t maxLength)

Powered by Google App Engine
This is Rietveld 408576698