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

Side by Side Diff: third_party/WebKit/Source/web/WebSurroundingText.cpp

Issue 2350303003: Prune CreateVisiblePositionDeprecated from SurroundingText-related callers (Closed)
Patch Set: Address comments 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/testing/Internals.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 { 42 {
43 } 43 }
44 44
45 WebSurroundingText::~WebSurroundingText() 45 WebSurroundingText::~WebSurroundingText()
46 { 46 {
47 } 47 }
48 48
49 void WebSurroundingText::initialize(const WebNode& webNode, const WebPoint& node Point, size_t maxLength) 49 void WebSurroundingText::initialize(const WebNode& webNode, const WebPoint& node Point, size_t maxLength)
50 { 50 {
51 const Node* node = webNode.constUnwrap<Node>(); 51 const Node* node = webNode.constUnwrap<Node>();
52 if (!node || !node->layoutObject()) 52 if (!node)
53 return; 53 return;
54 54
55 m_private.reset(new SurroundingText(createVisiblePositionDeprecated(node->la youtObject()->positionForPoint(static_cast<IntPoint>(nodePoint))).deepEquivalent ().parentAnchoredEquivalent(), maxLength)); 55 // VisiblePosition and SurroundingText must be created with clean layout.
56 node->document().updateStyleAndLayoutIgnorePendingStylesheets();
57 DocumentLifecycle::DisallowTransitionScope disallowTransition(node->document ().lifecycle());
58
59 if (!node->layoutObject())
60 return;
61
62 m_private.reset(new SurroundingText(createVisiblePosition(node->layoutObject ()->positionForPoint(static_cast<IntPoint>(nodePoint))).deepEquivalent().parentA nchoredEquivalent(), maxLength));
56 } 63 }
57 64
58 void WebSurroundingText::initializeFromCurrentSelection(WebLocalFrame* frame, si ze_t maxLength) 65 void WebSurroundingText::initializeFromCurrentSelection(WebLocalFrame* frame, si ze_t maxLength)
59 { 66 {
60 LocalFrame* webFrame = toWebLocalFrameImpl(frame)->frame(); 67 LocalFrame* webFrame = toWebLocalFrameImpl(frame)->frame();
61 if (Range* range = createRange(webFrame->selection().selection().toNormalize dEphemeralRange())) 68 if (Range* range = createRange(webFrame->selection().selection().toNormalize dEphemeralRange()))
62 m_private.reset(new SurroundingText(*range, maxLength)); 69 m_private.reset(new SurroundingText(*range, maxLength));
63 } 70 }
64 71
65 WebString WebSurroundingText::textContent() const 72 WebString WebSurroundingText::textContent() const
(...skipping 16 matching lines...) Expand all
82 { 89 {
83 return m_private->endOffsetInContent(); 90 return m_private->endOffsetInContent();
84 } 91 }
85 92
86 bool WebSurroundingText::isNull() const 93 bool WebSurroundingText::isNull() const
87 { 94 {
88 return !m_private.get(); 95 return !m_private.get();
89 } 96 }
90 97
91 } // namespace blink 98 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/testing/Internals.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698