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

Side by Side Diff: Source/core/editing/ApplyStyleCommand.cpp

Issue 423413005: Use tighter typing in editing: ReplaceSelectionCommand (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Wrap lines Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/ApplyStyleCommand.h ('k') | Source/core/editing/CompositeEditCommand.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 namespace blink { 55 namespace blink {
56 56
57 using namespace HTMLNames; 57 using namespace HTMLNames;
58 58
59 static String& styleSpanClassString() 59 static String& styleSpanClassString()
60 { 60 {
61 DEFINE_STATIC_LOCAL(String, styleSpanClassString, ((AppleStyleSpanClass))); 61 DEFINE_STATIC_LOCAL(String, styleSpanClassString, ((AppleStyleSpanClass)));
62 return styleSpanClassString; 62 return styleSpanClassString;
63 } 63 }
64 64
65 bool isLegacyAppleStyleSpan(const Node* node) 65 bool isLegacyAppleHTMLSpanElement(const Node* node)
66 { 66 {
67 if (!isHTMLSpanElement(node)) 67 if (!isHTMLSpanElement(node))
68 return false; 68 return false;
69 69
70 const HTMLSpanElement& span = toHTMLSpanElement(*node); 70 const HTMLSpanElement& span = toHTMLSpanElement(*node);
71 if (span.getAttribute(classAttr) != styleSpanClassString()) 71 if (span.getAttribute(classAttr) != styleSpanClassString())
72 return false; 72 return false;
73 UseCounter::count(span.document(), UseCounter::EditingAppleStyleSpanClass); 73 UseCounter::count(span.document(), UseCounter::EditingAppleStyleSpanClass);
74 return true; 74 return true;
75 } 75 }
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 RefPtrWillBeRawPtr<CSSValue> value = inlineStyle->getPropertyCSSValue(CS SPropertyFontSize); 413 RefPtrWillBeRawPtr<CSSValue> value = inlineStyle->getPropertyCSSValue(CS SPropertyFontSize);
414 if (value) { 414 if (value) {
415 element->removeInlineStyleProperty(CSSPropertyFontSize); 415 element->removeInlineStyleProperty(CSSPropertyFontSize);
416 currentFontSize = computedFontSize(node); 416 currentFontSize = computedFontSize(node);
417 } 417 }
418 if (currentFontSize != desiredFontSize) { 418 if (currentFontSize != desiredFontSize) {
419 inlineStyle->setProperty(CSSPropertyFontSize, cssValuePool().createV alue(desiredFontSize, CSSPrimitiveValue::CSS_PX), false); 419 inlineStyle->setProperty(CSSPropertyFontSize, cssValuePool().createV alue(desiredFontSize, CSSPrimitiveValue::CSS_PX), false);
420 setNodeAttribute(element.get(), styleAttr, AtomicString(inlineStyle- >asText())); 420 setNodeAttribute(element.get(), styleAttr, AtomicString(inlineStyle- >asText()));
421 } 421 }
422 if (inlineStyle->isEmpty()) { 422 if (inlineStyle->isEmpty()) {
423 removeNodeAttribute(element.get(), styleAttr); 423 removeElementAttribute(element.get(), styleAttr);
424 if (isSpanWithoutAttributesOrUnstyledStyleSpan(element.get())) 424 if (isSpanWithoutAttributesOrUnstyledStyleSpan(element.get()))
425 unstyledSpans.append(element.release()); 425 unstyledSpans.append(element.release());
426 } 426 }
427 } 427 }
428 428
429 size_t size = unstyledSpans.size(); 429 size_t size = unstyledSpans.size();
430 for (size_t i = 0; i < size; ++i) 430 for (size_t i = 0; i < size; ++i)
431 removeNodePreservingChildren(unstyledSpans[i].get()); 431 removeNodePreservingChildren(unstyledSpans[i].get());
432 } 432 }
433 433
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 if (!unicodeBidi || unicodeBidi == CSSValueNormal) 522 if (!unicodeBidi || unicodeBidi == CSSValueNormal)
523 continue; 523 continue;
524 524
525 // FIXME: This code should really consider the mapped attribute 'dir', t he inline style declaration, 525 // FIXME: This code should really consider the mapped attribute 'dir', t he inline style declaration,
526 // and all matching style rules in order to determine how to best set th e unicode-bidi property to 'normal'. 526 // and all matching style rules in order to determine how to best set th e unicode-bidi property to 'normal'.
527 // For now, it assumes that if the 'dir' attribute is present, then remo ving it will suffice, and 527 // For now, it assumes that if the 'dir' attribute is present, then remo ving it will suffice, and
528 // otherwise it sets the property in the inline style declaration. 528 // otherwise it sets the property in the inline style declaration.
529 if (element->hasAttribute(dirAttr)) { 529 if (element->hasAttribute(dirAttr)) {
530 // FIXME: If this is a BDO element, we should probably just remove i t if it has no 530 // FIXME: If this is a BDO element, we should probably just remove i t if it has no
531 // other attributes, like we (should) do with B and I elements. 531 // other attributes, like we (should) do with B and I elements.
532 removeNodeAttribute(element, dirAttr); 532 removeElementAttribute(element, dirAttr);
533 } else { 533 } else {
534 RefPtrWillBeRawPtr<MutableStylePropertySet> inlineStyle = copyStyleO rCreateEmpty(element->inlineStyle()); 534 RefPtrWillBeRawPtr<MutableStylePropertySet> inlineStyle = copyStyleO rCreateEmpty(element->inlineStyle());
535 inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal); 535 inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal);
536 inlineStyle->removeProperty(CSSPropertyDirection); 536 inlineStyle->removeProperty(CSSPropertyDirection);
537 setNodeAttribute(element, styleAttr, AtomicString(inlineStyle->asTex t())); 537 setNodeAttribute(element, styleAttr, AtomicString(inlineStyle->asTex t()));
538 if (isSpanWithoutAttributesOrUnstyledStyleSpan(element)) 538 if (isSpanWithoutAttributesOrUnstyledStyleSpan(element))
539 removeNodePreservingChildren(element); 539 removeNodePreservingChildren(element);
540 } 540 }
541 } 541 }
542 } 542 }
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 return true; 959 return true;
960 } 960 }
961 961
962 // unicode-bidi and direction are pushed down separately so don't push down with other styles 962 // unicode-bidi and direction are pushed down separately so don't push down with other styles
963 Vector<QualifiedName> attributes; 963 Vector<QualifiedName> attributes;
964 if (!style->extractConflictingImplicitStyleOfAttributes(element, extractedSt yle ? EditingStyle::PreserveWritingDirection : EditingStyle::DoNotPreserveWritin gDirection, 964 if (!style->extractConflictingImplicitStyleOfAttributes(element, extractedSt yle ? EditingStyle::PreserveWritingDirection : EditingStyle::DoNotPreserveWritin gDirection,
965 extractedStyle, attributes, mode == RemoveAlways ? EditingStyle::Extract MatchingStyle : EditingStyle::DoNotExtractMatchingStyle)) 965 extractedStyle, attributes, mode == RemoveAlways ? EditingStyle::Extract MatchingStyle : EditingStyle::DoNotExtractMatchingStyle))
966 return false; 966 return false;
967 967
968 for (size_t i = 0; i < attributes.size(); i++) 968 for (size_t i = 0; i < attributes.size(); i++)
969 removeNodeAttribute(element, attributes[i]); 969 removeElementAttribute(element, attributes[i]);
970 970
971 if (isEmptyFontTag(element) || isSpanWithoutAttributesOrUnstyledStyleSpan(el ement)) 971 if (isEmptyFontTag(element) || isSpanWithoutAttributesOrUnstyledStyleSpan(el ement))
972 removeNodePreservingChildren(element); 972 removeNodePreservingChildren(element);
973 973
974 return true; 974 return true;
975 } 975 }
976 976
977 bool ApplyStyleCommand::removeCSSStyle(EditingStyle* style, HTMLElement* element , InlineStyleRemovalMode mode, EditingStyle* extractedStyle) 977 bool ApplyStyleCommand::removeCSSStyle(EditingStyle* style, HTMLElement* element , InlineStyleRemovalMode mode, EditingStyle* extractedStyle)
978 { 978 {
979 ASSERT(style); 979 ASSERT(style);
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 void ApplyStyleCommand::trace(Visitor* visitor) 1572 void ApplyStyleCommand::trace(Visitor* visitor)
1573 { 1573 {
1574 visitor->trace(m_style); 1574 visitor->trace(m_style);
1575 visitor->trace(m_start); 1575 visitor->trace(m_start);
1576 visitor->trace(m_end); 1576 visitor->trace(m_end);
1577 visitor->trace(m_styledInlineElement); 1577 visitor->trace(m_styledInlineElement);
1578 CompositeEditCommand::trace(visitor); 1578 CompositeEditCommand::trace(visitor);
1579 } 1579 }
1580 1580
1581 } 1581 }
OLDNEW
« no previous file with comments | « Source/core/editing/ApplyStyleCommand.h ('k') | Source/core/editing/CompositeEditCommand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698