| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |