Commit c9fcd518 authored by yosin@chromium.org's avatar yosin@chromium.org

Introduce use counters for Blink specific CSS classes for editing

This patch introduces Blink specific CSS classes for editing for
  - Apple-interchange-newline
  - Apple-converted-space
  - Apple-paste-as-quotation
  - Apple-style-span
  - Apple-tab-span
These CSS classes are defined in "core/editing/HTMLInterchange.h"

We would like to deprecate these Blink specific CSS classes for browser
compatibility, if possible.

BUG=383677
TEST=n/a

Review URL: https://codereview.chromium.org/327323005

git-svn-id: svn://svn.chromium.org/blink/trunk@176171 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 54a20390
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "core/editing/TextIterator.h" #include "core/editing/TextIterator.h"
#include "core/editing/VisibleUnits.h" #include "core/editing/VisibleUnits.h"
#include "core/editing/htmlediting.h" #include "core/editing/htmlediting.h"
#include "core/frame/UseCounter.h"
#include "core/rendering/RenderObject.h" #include "core/rendering/RenderObject.h"
#include "core/rendering/RenderText.h" #include "core/rendering/RenderText.h"
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
...@@ -65,7 +66,10 @@ bool isLegacyAppleStyleSpan(const Node *node) ...@@ -65,7 +66,10 @@ bool isLegacyAppleStyleSpan(const Node *node)
return false; return false;
const HTMLElement* elem = toHTMLElement(node); const HTMLElement* elem = toHTMLElement(node);
return elem->hasLocalName(spanAttr) && elem->getAttribute(classAttr) == styleSpanClassString(); if (!elem->hasLocalName(spanAttr) || elem->getAttribute(classAttr) != styleSpanClassString())
return false;
UseCounter::count(elem->document(), UseCounter::EditingAppleStyleSpanClass);
return true;
} }
static bool hasNoAttributeOrOnlyStyleAttribute(const Element* element, ShouldStyleAttributeBeEmpty shouldStyleAttributeBeEmpty) static bool hasNoAttributeOrOnlyStyleAttribute(const Element* element, ShouldStyleAttributeBeEmpty shouldStyleAttributeBeEmpty)
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "core/editing/markup.h" #include "core/editing/markup.h"
#include "core/events/BeforeTextInsertedEvent.h" #include "core/events/BeforeTextInsertedEvent.h"
#include "core/frame/LocalFrame.h" #include "core/frame/LocalFrame.h"
#include "core/frame/UseCounter.h"
#include "core/html/HTMLElement.h" #include "core/html/HTMLElement.h"
#include "core/html/HTMLInputElement.h" #include "core/html/HTMLInputElement.h"
#include "core/rendering/RenderObject.h" #include "core/rendering/RenderObject.h"
...@@ -97,13 +98,19 @@ private: ...@@ -97,13 +98,19 @@ private:
static bool isInterchangeNewlineNode(const Node *node) static bool isInterchangeNewlineNode(const Node *node)
{ {
DEFINE_STATIC_LOCAL(String, interchangeNewlineClassString, (AppleInterchangeNewline)); DEFINE_STATIC_LOCAL(String, interchangeNewlineClassString, (AppleInterchangeNewline));
return isHTMLBRElement(node) && toElement(node)->getAttribute(classAttr) == interchangeNewlineClassString; if (!isHTMLBRElement(node) || toElement(node)->getAttribute(classAttr) != interchangeNewlineClassString)
return false;
UseCounter::count(node->document(), UseCounter::EditingAppleInterchangeNewline);
return true;
} }
static bool isInterchangeConvertedSpaceSpan(const Node *node) static bool isInterchangeConvertedSpaceSpan(const Node *node)
{ {
DEFINE_STATIC_LOCAL(String, convertedSpaceSpanClassString, (AppleConvertedSpace)); DEFINE_STATIC_LOCAL(String, convertedSpaceSpanClassString, (AppleConvertedSpace));
return node->isHTMLElement() && toHTMLElement(node)->getAttribute(classAttr) == convertedSpaceSpanClassString; if (!node->isHTMLElement() || toHTMLElement(node)->getAttribute(classAttr) != convertedSpaceSpanClassString)
return false;
UseCounter::count(node->document(), UseCounter::EditingAppleConvertedSpace);
return true;
} }
static Position positionAvoidingPrecedingNodes(Position pos) static Position positionAvoidingPrecedingNodes(Position pos)
...@@ -418,7 +425,10 @@ bool ReplaceSelectionCommand::shouldMergeEnd(bool selectionEndWasEndOfParagraph) ...@@ -418,7 +425,10 @@ bool ReplaceSelectionCommand::shouldMergeEnd(bool selectionEndWasEndOfParagraph)
static bool isMailPasteAsQuotationNode(const Node* node) 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) static bool isHeaderElement(const Node* a)
...@@ -866,10 +876,18 @@ static bool isInlineNodeWithStyle(const Node* node) ...@@ -866,10 +876,18 @@ static bool isInlineNodeWithStyle(const Node* node)
// one of our internal classes. // one of our internal classes.
const HTMLElement* element = toHTMLElement(node); const HTMLElement* element = toHTMLElement(node);
const AtomicString& classAttributeValue = element->getAttribute(classAttr); const AtomicString& classAttributeValue = element->getAttribute(classAttr);
if (classAttributeValue == AppleTabSpanClass if (classAttributeValue == AppleTabSpanClass) {
|| classAttributeValue == AppleConvertedSpace UseCounter::count(node->document(), UseCounter::EditingAppleTabSpanClass);
|| classAttributeValue == ApplePasteAsQuotation)
return true; 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); return EditingStyle::elementIsStyledSpanOrHTMLEquivalent(element);
} }
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "core/editing/VisibleSelection.h" #include "core/editing/VisibleSelection.h"
#include "core/editing/VisibleUnits.h" #include "core/editing/VisibleUnits.h"
#include "core/frame/LocalFrame.h" #include "core/frame/LocalFrame.h"
#include "core/frame/UseCounter.h"
#include "core/html/HTMLBRElement.h" #include "core/html/HTMLBRElement.h"
#include "core/html/HTMLDivElement.h" #include "core/html/HTMLDivElement.h"
#include "core/html/HTMLLIElement.h" #include "core/html/HTMLLIElement.h"
...@@ -824,7 +825,10 @@ PassRefPtrWillBeRawPtr<HTMLElement> createHTMLElement(Document& document, const ...@@ -824,7 +825,10 @@ PassRefPtrWillBeRawPtr<HTMLElement> createHTMLElement(Document& document, const
bool isTabSpanNode(const Node* node) bool isTabSpanNode(const Node* node)
{ {
return isHTMLSpanElement(node) && toElement(node)->getAttribute(classAttr) == AppleTabSpanClass; if (!isHTMLSpanElement(node) || toElement(node)->getAttribute(classAttr) != AppleTabSpanClass)
return false;
UseCounter::count(node->document(), UseCounter::EditingAppleTabSpanClass);
return true;
} }
bool isTabSpanTextNode(const Node* node) bool isTabSpanTextNode(const Node* node)
......
...@@ -455,6 +455,11 @@ public: ...@@ -455,6 +455,11 @@ public:
HTMLImports = 455, HTMLImports = 455,
ElementCreateShadowRoot = 456, ElementCreateShadowRoot = 456,
DocumentRegisterElement = 457, DocumentRegisterElement = 457,
EditingAppleInterchangeNewline = 458,
EditingAppleConvertedSpace = 459,
EditingApplePasteAsQuotation = 460,
EditingAppleStyleSpanClass = 461,
EditingAppleTabSpanClass = 462,
// Add new features immediately above this line. Don't change assigned // Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots. // numbers of any item, and don't reuse removed slots.
// Also, run update_use_counter_feature_enum.py in chromium/src/tools/metrics/histograms/ // Also, run update_use_counter_feature_enum.py in chromium/src/tools/metrics/histograms/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment