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

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

Issue 327323005: Introduce use counters for Blink specific CSS classes for editing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 | « no previous file | Source/core/editing/htmlediting.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/ReplaceSelectionCommand.cpp
diff --git a/Source/core/editing/ReplaceSelectionCommand.cpp b/Source/core/editing/ReplaceSelectionCommand.cpp
index 896c57d5bda63276ab218c75d64ed7ceb6d69823..ff95f762f4f00f5aee2e906e09d7f1eff6edd1af 100644
--- a/Source/core/editing/ReplaceSelectionCommand.cpp
+++ b/Source/core/editing/ReplaceSelectionCommand.cpp
@@ -48,6 +48,7 @@
#include "core/editing/markup.h"
#include "core/events/BeforeTextInsertedEvent.h"
#include "core/frame/LocalFrame.h"
+#include "core/frame/UseCounter.h"
#include "core/html/HTMLElement.h"
#include "core/html/HTMLInputElement.h"
#include "core/rendering/RenderObject.h"
@@ -289,6 +290,7 @@ void ReplacementFragment::removeInterchangeNodes(Node* container)
Node* node = container->firstChild();
while (node) {
if (isInterchangeNewlineNode(node)) {
+ UseCounter::count(node->document(), UseCounter::EditingAppleInterchangeNewline);
Yuta Kitamura 2014/06/12 07:55:23 You add some count() calls in predicate functions
yosin_UTC9 2014/06/12 08:46:06 You're right. I move count() call to predicate.
m_hasInterchangeNewlineAtStart = true;
removeNode(node);
break;
@@ -302,6 +304,7 @@ void ReplacementFragment::removeInterchangeNodes(Node* container)
node = container->lastChild();
while (node) {
if (isInterchangeNewlineNode(node)) {
+ UseCounter::count(node->document(), UseCounter::EditingAppleInterchangeNewline);
m_hasInterchangeNewlineAtEnd = true;
removeNode(node);
break;
@@ -418,7 +421,10 @@ bool ReplaceSelectionCommand::shouldMergeEnd(bool selectionEndWasEndOfParagraph)
static bool isMailPasteAsQuotationNode(const Node* node)
{
- return node && node->hasTagName(blockquoteTag) && toElement(node)->getAttribute(classAttr) == ApplePasteAsQuotation;
+ if (!node || !node->hasTagName(blockquoteTag) || toElement(node)->getAttribute(classAttr) != ApplePasteAsQuotation)
+ return false;
+ UseCounter::count(node->document(), UseCounter::EditingApplePasteAsQuotation);
+ return true;
}
static bool isHeaderElement(const Node* a)
@@ -532,6 +538,7 @@ void ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline(Insert
// WebKit used to not add display: inline and float: none on copy.
// Keep this code around for backward compatibility
if (isLegacyAppleStyleSpan(element)) {
+ UseCounter::count(document(), UseCounter::EditingAppleStyleSpanClass);
if (!element->firstChild()) {
insertedNodes.willRemoveNodePreservingChildren(*element);
removeNodePreservingChildren(element);
@@ -728,6 +735,7 @@ static bool handleStyleSpansBeforeInsertion(ReplacementFragment& fragment, const
if (!isLegacyAppleStyleSpan(topNode))
return false;
+ UseCounter::count(topNode->document(), UseCounter::EditingAppleStyleSpanClass);
Node* wrappingStyleSpan = topNode;
RefPtrWillBeRawPtr<EditingStyle> styleAtInsertionPos = EditingStyle::create(insertionPos.parentAnchoredEquivalent());
String styleText = styleAtInsertionPos->style()->asText();
@@ -757,6 +765,7 @@ void ReplaceSelectionCommand::handleStyleSpans(InsertedNodes& insertedNodes)
// so search for the top level style span instead of assuming it's at the top.
for (Node* node = insertedNodes.firstNodeInserted(); node; node = NodeTraversal::next(*node)) {
if (isLegacyAppleStyleSpan(node)) {
+ UseCounter::count(document(), UseCounter::EditingAppleStyleSpanClass);
wrappingStyleSpan = toHTMLElement(node);
break;
}
@@ -866,10 +875,18 @@ static bool isInlineNodeWithStyle(const Node* node)
// one of our internal classes.
const HTMLElement* element = toHTMLElement(node);
const AtomicString& classAttributeValue = element->getAttribute(classAttr);
- if (classAttributeValue == AppleTabSpanClass
- || classAttributeValue == AppleConvertedSpace
- || classAttributeValue == ApplePasteAsQuotation)
+ if (classAttributeValue == AppleTabSpanClass) {
+ UseCounter::count(node->document(), UseCounter::EditingAppleTabSpanClass);
return true;
+ }
+ if (classAttributeValue == AppleConvertedSpace) {
+ UseCounter::count(node->document(), UseCounter::EditingAppleConvertedSpace);
+ return true;
+ }
+ if (classAttributeValue == ApplePasteAsQuotation) {
+ UseCounter::count(node->document(), UseCounter::EditingApplePasteAsQuotation);
+ return true;
+ }
return EditingStyle::elementIsStyledSpanOrHTMLEquivalent(element);
}
@@ -1075,9 +1092,11 @@ void ReplaceSelectionCommand::doApply()
Node* blockStart = enclosingBlock(insertionPos.deprecatedNode());
if ((isListElement(refNode.get()) || (isLegacyAppleStyleSpan(refNode.get()) && isListElement(refNode->firstChild())))
- && blockStart && blockStart->renderer()->isListItem())
+ && blockStart && blockStart->renderer()->isListItem()) {
+ if (isLegacyAppleStyleSpan(refNode.get()))
+ UseCounter::count(document(), UseCounter::EditingAppleStyleSpanClass);
refNode = insertAsListItems(toHTMLElement(refNode), blockStart, insertionPos, insertedNodes);
- else {
+ } else {
insertNodeAt(refNode, insertionPos);
insertedNodes.respondToNodeInsertion(*refNode);
}
« no previous file with comments | « no previous file | Source/core/editing/htmlediting.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698