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

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp

Issue 2685793002: Remove Apple-style-span CSS class support (Closed)
Patch Set: Update test cases Created 3 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008, 2009 Apple 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "core/layout/LayoutObject.h" 49 #include "core/layout/LayoutObject.h"
50 #include "core/layout/LayoutText.h" 50 #include "core/layout/LayoutText.h"
51 #include "platform/heap/Handle.h" 51 #include "platform/heap/Handle.h"
52 #include "wtf/StdLibExtras.h" 52 #include "wtf/StdLibExtras.h"
53 #include "wtf/text/StringBuilder.h" 53 #include "wtf/text/StringBuilder.h"
54 54
55 namespace blink { 55 namespace blink {
56 56
57 using namespace HTMLNames; 57 using namespace HTMLNames;
58 58
59 static String& styleSpanClassString() {
60 DEFINE_STATIC_LOCAL(String, styleSpanClassString, ((AppleStyleSpanClass)));
61 return styleSpanClassString;
62 }
63
64 bool isLegacyAppleHTMLSpanElement(const Node* node) {
65 if (!isHTMLSpanElement(node))
66 return false;
67
68 const HTMLSpanElement& span = toHTMLSpanElement(*node);
69 if (span.getAttribute(classAttr) != styleSpanClassString())
70 return false;
71 UseCounter::count(span.document(), UseCounter::EditingAppleStyleSpanClass);
72 return true;
73 }
74
75 static bool hasNoAttributeOrOnlyStyleAttribute( 59 static bool hasNoAttributeOrOnlyStyleAttribute(
76 const HTMLElement* element, 60 const HTMLElement* element,
77 ShouldStyleAttributeBeEmpty shouldStyleAttributeBeEmpty) { 61 ShouldStyleAttributeBeEmpty shouldStyleAttributeBeEmpty) {
78 AttributeCollection attributes = element->attributes(); 62 AttributeCollection attributes = element->attributes();
79 if (attributes.isEmpty()) 63 if (attributes.isEmpty())
80 return true; 64 return true;
81 65
82 unsigned matchedAttributes = 0; 66 unsigned matchedAttributes = 0;
83 if (element->getAttribute(classAttr) == styleSpanClassString())
84 matchedAttributes++;
85 if (element->hasAttribute(styleAttr) && 67 if (element->hasAttribute(styleAttr) &&
86 (shouldStyleAttributeBeEmpty == AllowNonEmptyStyleAttribute || 68 (shouldStyleAttributeBeEmpty == AllowNonEmptyStyleAttribute ||
87 !element->inlineStyle() || element->inlineStyle()->isEmpty())) 69 !element->inlineStyle() || element->inlineStyle()->isEmpty()))
88 matchedAttributes++; 70 matchedAttributes++;
89 71
90 DCHECK_LE(matchedAttributes, attributes.size()); 72 DCHECK_LE(matchedAttributes, attributes.size());
91 return matchedAttributes == attributes.size(); 73 return matchedAttributes == attributes.size();
92 } 74 }
93 75
94 bool isStyleSpanOrSpanWithOnlyStyleAttribute(const Element* element) { 76 bool isStyleSpanOrSpanWithOnlyStyleAttribute(const Element* element) {
(...skipping 1935 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 2012
2031 DEFINE_TRACE(ApplyStyleCommand) { 2013 DEFINE_TRACE(ApplyStyleCommand) {
2032 visitor->trace(m_style); 2014 visitor->trace(m_style);
2033 visitor->trace(m_start); 2015 visitor->trace(m_start);
2034 visitor->trace(m_end); 2016 visitor->trace(m_end);
2035 visitor->trace(m_styledInlineElement); 2017 visitor->trace(m_styledInlineElement);
2036 CompositeEditCommand::trace(visitor); 2018 CompositeEditCommand::trace(visitor);
2037 } 2019 }
2038 2020
2039 } // namespace blink 2021 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698