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

Unified Diff: Source/core/editing/iterators/TextIterator.cpp

Issue 1213213004: Introduce use counters for shadow DOM handling in plainText() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-07-02T15:13:50 Add comment for |m_handleShadowRoot| Created 5 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
Index: Source/core/editing/iterators/TextIterator.cpp
diff --git a/Source/core/editing/iterators/TextIterator.cpp b/Source/core/editing/iterators/TextIterator.cpp
index 712b154bb315954e4f15eab2f8ae8e3bb0c42f27..4087b91e9fdaf0fc23745111028c2a6c489efa6c 100644
--- a/Source/core/editing/iterators/TextIterator.cpp
+++ b/Source/core/editing/iterators/TextIterator.cpp
@@ -39,6 +39,7 @@
#include "core/editing/iterators/CharacterIterator.h"
#include "core/editing/iterators/WordAwareIterator.h"
#include "core/frame/FrameView.h"
+#include "core/frame/UseCounter.h"
#include "core/html/HTMLElement.h"
#include "core/html/HTMLImageElement.h"
#include "core/html/HTMLInputElement.h"
@@ -133,6 +134,7 @@ TextIteratorAlgorithm<Strategy>::TextIteratorAlgorithm(const typename Strategy::
, m_behavior(adjustBehaviorFlags<Strategy>(behavior))
, m_handledFirstLetter(false)
, m_shouldStop(false)
+ , m_handleShadowRoot(false)
// The call to emitsOriginalText() must occur after m_behavior is initialized.
, m_textState(emitsOriginalText())
{
@@ -188,6 +190,15 @@ void TextIteratorAlgorithm<Strategy>::initialize(Node* startContainer, int start
template<typename Strategy>
TextIteratorAlgorithm<Strategy>::~TextIteratorAlgorithm()
{
+ if (!m_handleShadowRoot)
+ return;
+ Document* document = ownerDocument();
+ if (!document)
+ return;
+ if (m_behavior & TextIteratorForInnerText)
+ UseCounter::count(document, UseCounter::InnerTextWithShadowTree);
+ if (m_behavior & TextIteratorForSelectionToString)
+ UseCounter::count(document, UseCounter::SelectionToStringWithShadowTree);
}
template<typename Strategy>
@@ -257,6 +268,7 @@ void TextIteratorAlgorithm<Strategy>::advance()
if (m_node->isShadowRoot()) {
// A shadow root doesn't have a layoutObject, but we want to visit children anyway.
m_iterationProgress = m_iterationProgress < HandledNode ? HandledNode : m_iterationProgress;
+ m_handleShadowRoot = true;
} else {
m_iterationProgress = HandledChildren;
}

Powered by Google App Engine
This is Rietveld 408576698