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

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

Issue 24278008: [oilpan] Handlify Nodes in htmlediting (Closed) Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Created 7 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc. 2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc.
3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 } 440 }
441 441
442 static int textAlignResolvingStartAndEnd(const Handle<CSSStyleDeclaration>& styl e) 442 static int textAlignResolvingStartAndEnd(const Handle<CSSStyleDeclaration>& styl e)
443 { 443 {
444 return textAlignResolvingStartAndEnd(getIdentifierValue(style, CSSPropertyTe xtAlign), getIdentifierValue(style, CSSPropertyDirection)); 444 return textAlignResolvingStartAndEnd(getIdentifierValue(style, CSSPropertyTe xtAlign), getIdentifierValue(style, CSSPropertyDirection));
445 } 445 }
446 446
447 void EditingStyle::init(const Handle<Node>& node, PropertiesToInclude properties ToInclude) 447 void EditingStyle::init(const Handle<Node>& node, PropertiesToInclude properties ToInclude)
448 { 448 {
449 Handle<Node> target = node; 449 Handle<Node> target = node;
450 if (isTabSpanTextNode(target.raw())) 450 if (isTabSpanTextNode(target))
451 target = tabSpanNode(target.raw())->parentNode(); 451 target = tabSpanNode(target)->parentNode();
452 else if (isTabSpanNode(target.raw())) 452 else if (isTabSpanNode(target))
453 target = target->parentNode(); 453 target = target->parentNode();
454 454
455 Handle<CSSComputedStyleDeclaration> computedStyleAtPosition = CSSComputedSty leDeclaration::create(target); 455 Handle<CSSComputedStyleDeclaration> computedStyleAtPosition = CSSComputedSty leDeclaration::create(target);
456 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi tion ? computedStyleAtPosition->copy() : editingStyleFromComputedStyle(computedS tyleAtPosition); 456 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi tion ? computedStyleAtPosition->copy() : editingStyleFromComputedStyle(computedS tyleAtPosition);
457 457
458 if (propertiesToInclude == EditingPropertiesInEffect) { 458 if (propertiesToInclude == EditingPropertiesInEffect) {
459 if (Handle<CSSValue> value = backgroundColorInEffect(target)) 459 if (Handle<CSSValue> value = backgroundColorInEffect(target))
460 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe xt()); 460 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe xt());
461 if (Handle<CSSValue> value = computedStyleAtPosition->getPropertyCSSValu e(CSSPropertyWebkitTextDecorationsInEffect)) 461 if (Handle<CSSValue> value = computedStyleAtPosition->getPropertyCSSValu e(CSSPropertyWebkitTextDecorationsInEffect))
462 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex t()); 462 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex t());
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 742
743 Handle<const StylePropertySet> inlineStyle = element->inlineStyle(); 743 Handle<const StylePropertySet> inlineStyle = element->inlineStyle();
744 if (!m_mutableStyle || !inlineStyle) 744 if (!m_mutableStyle || !inlineStyle)
745 return false; 745 return false;
746 746
747 unsigned propertyCount = m_mutableStyle->propertyCount(); 747 unsigned propertyCount = m_mutableStyle->propertyCount();
748 for (unsigned i = 0; i < propertyCount; ++i) { 748 for (unsigned i = 0; i < propertyCount; ++i) {
749 CSSPropertyID propertyID = m_mutableStyle->propertyAt(i).id(); 749 CSSPropertyID propertyID = m_mutableStyle->propertyAt(i).id();
750 750
751 // We don't override whitespace property of a tab span because that woul d collapse the tab into a space. 751 // We don't override whitespace property of a tab span because that woul d collapse the tab into a space.
752 if (propertyID == CSSPropertyWhiteSpace && isTabSpanNode(element.raw())) 752 if (propertyID == CSSPropertyWhiteSpace && isTabSpanNode(element))
753 continue; 753 continue;
754 754
755 if (propertyID == CSSPropertyWebkitTextDecorationsInEffect && inlineStyl e->getPropertyCSSValue(CSSPropertyTextDecoration)) { 755 if (propertyID == CSSPropertyWebkitTextDecorationsInEffect && inlineStyl e->getPropertyCSSValue(CSSPropertyTextDecoration)) {
756 if (!conflictingProperties) 756 if (!conflictingProperties)
757 return true; 757 return true;
758 conflictingProperties->append(CSSPropertyTextDecoration); 758 conflictingProperties->append(CSSPropertyTextDecoration);
759 if (extractedStyle) 759 if (extractedStyle)
760 extractedStyle->setProperty(CSSPropertyTextDecoration, inlineSty le->getPropertyValue(CSSPropertyTextDecoration), inlineStyle->propertyIsImportan t(CSSPropertyTextDecoration)); 760 extractedStyle->setProperty(CSSPropertyTextDecoration, inlineSty le->getPropertyValue(CSSPropertyTextDecoration), inlineStyle->propertyIsImportan t(CSSPropertyTextDecoration));
761 continue; 761 continue;
762 } 762 }
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 1044
1045 PassRefPtr<EditingStyle> EditingStyle::wrappingStyleForSerialization(const Handl e<Node>& context, bool shouldAnnotate) 1045 PassRefPtr<EditingStyle> EditingStyle::wrappingStyleForSerialization(const Handl e<Node>& context, bool shouldAnnotate)
1046 { 1046 {
1047 RefPtr<EditingStyle> wrappingStyle; 1047 RefPtr<EditingStyle> wrappingStyle;
1048 if (shouldAnnotate) { 1048 if (shouldAnnotate) {
1049 wrappingStyle = EditingStyle::create(context, EditingStyle::EditingPrope rtiesInEffect); 1049 wrappingStyle = EditingStyle::create(context, EditingStyle::EditingPrope rtiesInEffect);
1050 1050
1051 // Styles that Mail blockquotes contribute should only be placed on the Mail blockquote, 1051 // Styles that Mail blockquotes contribute should only be placed on the Mail blockquote,
1052 // to help us differentiate those styles from ones that the user has app lied. 1052 // to help us differentiate those styles from ones that the user has app lied.
1053 // This helps us get the color of content pasted into blockquotes right. 1053 // This helps us get the color of content pasted into blockquotes right.
1054 wrappingStyle->removeStyleAddedByNode(adoptRawResult(enclosingNodeOfType (firstPositionInOrBeforeNode(context.raw()), isMailBlockquote, CanCrossEditingBo undary))); 1054 wrappingStyle->removeStyleAddedByNode(enclosingNodeOfType(firstPositionI nOrBeforeNode(context), isMailBlockquote, CanCrossEditingBoundary));
1055 1055
1056 // Call collapseTextDecorationProperties first or otherwise it'll copy t he value over from in-effect to text-decorations. 1056 // Call collapseTextDecorationProperties first or otherwise it'll copy t he value over from in-effect to text-decorations.
1057 wrappingStyle->collapseTextDecorationProperties(); 1057 wrappingStyle->collapseTextDecorationProperties();
1058 1058
1059 return wrappingStyle.release(); 1059 return wrappingStyle.release();
1060 } 1060 }
1061 1061
1062 wrappingStyle = EditingStyle::create(); 1062 wrappingStyle = EditingStyle::create();
1063 1063
1064 // When not annotating for interchange, we only preserve inline style declar ations. 1064 // When not annotating for interchange, we only preserve inline style declar ations.
1065 for (Handle<Node> node = context; node && !node->isDocumentNode(); node = no de->parentNode()) { 1065 for (Handle<Node> node = context; node && !node->isDocumentNode(); node = no de->parentNode()) {
1066 HandleScope scope; 1066 HandleScope scope;
1067 if (node->isStyledElement() && !isMailBlockquote(node.raw())) { 1067 if (node->isStyledElement() && !isMailBlockquote(node)) {
1068 wrappingStyle->mergeInlineAndImplicitStyleOfElement(Handle<StyledEle ment>::cast(node), 1068 wrappingStyle->mergeInlineAndImplicitStyleOfElement(Handle<StyledEle ment>::cast(node),
1069 EditingStyle::DoNotOverrideValues, 1069 EditingStyle::DoNotOverrideValues,
1070 EditingStyle::EditingPropertiesInEffect); 1070 EditingStyle::EditingPropertiesInEffect);
1071 } 1071 }
1072 } 1072 }
1073 1073
1074 return wrappingStyle.release(); 1074 return wrappingStyle.release();
1075 } 1075 }
1076 1076
1077 1077
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 WritingDirection direction; 1309 WritingDirection direction;
1310 if (typingStyle && typingStyle->textDirection(direction)) { 1310 if (typingStyle && typingStyle->textDirection(direction)) {
1311 hasNestedOrMultipleEmbeddings = false; 1311 hasNestedOrMultipleEmbeddings = false;
1312 return direction; 1312 return direction;
1313 } 1313 }
1314 node = selection.visibleStart().deepEquivalent().deprecatedNode(); 1314 node = selection.visibleStart().deepEquivalent().deprecatedNode();
1315 } 1315 }
1316 1316
1317 // The selection is either a caret with no typing attributes or a range in w hich no embedding is added, so just use the start position 1317 // The selection is either a caret with no typing attributes or a range in w hich no embedding is added, so just use the start position
1318 // to decide. 1318 // to decide.
1319 Handle<Node> block = enclosingBlock(node.raw()); 1319 Handle<Node> block = enclosingBlock(node);
1320 WritingDirection foundDirection = NaturalWritingDirection; 1320 WritingDirection foundDirection = NaturalWritingDirection;
1321 1321
1322 for (; node != block; node = node->parentNode()) { 1322 for (; node != block; node = node->parentNode()) {
1323 HandleScope scope; 1323 HandleScope scope;
1324 if (!node->isStyledElement()) 1324 if (!node->isStyledElement())
1325 continue; 1325 continue;
1326 1326
1327 Handle<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclaration: :create(node); 1327 Handle<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclaration: :create(node);
1328 Handle<CSSValue> unicodeBidi = style->getPropertyCSSValue(CSSPropertyUni codeBidi); 1328 Handle<CSSValue> unicodeBidi = style->getPropertyCSSValue(CSSPropertyUni codeBidi);
1329 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) 1329 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 1389
1390 Handle<CSSComputedStyleDeclaration> computedStyle = position.computedStyle() ; 1390 Handle<CSSComputedStyleDeclaration> computedStyle = position.computedStyle() ;
1391 // FIXME: take care of background-color in effect 1391 // FIXME: take care of background-color in effect
1392 Handle<StylePropertySet> mutableStyle = getPropertiesNotIn(style->style(), c omputedStyle); 1392 Handle<StylePropertySet> mutableStyle = getPropertiesNotIn(style->style(), c omputedStyle);
1393 1393
1394 reconcileTextDecorationProperties(mutableStyle); 1394 reconcileTextDecorationProperties(mutableStyle);
1395 if (!document->frame()->editor()->shouldStyleWithCSS()) 1395 if (!document->frame()->editor()->shouldStyleWithCSS())
1396 extractTextStyles(document, mutableStyle, computedStyle->useFixedFontDef aultSize()); 1396 extractTextStyles(document, mutableStyle, computedStyle->useFixedFontDef aultSize());
1397 1397
1398 // Changing the whitespace style in a tab span would collapse the tab into a space. 1398 // Changing the whitespace style in a tab span would collapse the tab into a space.
1399 if (isTabSpanTextNode(position.deprecatedNode().handle().raw()) || isTabSpan Node((position.deprecatedNode().handle().raw()))) 1399 if (isTabSpanTextNode(position.deprecatedNode()) || isTabSpanNode((position. deprecatedNode())))
1400 mutableStyle->removeProperty(CSSPropertyWhiteSpace); 1400 mutableStyle->removeProperty(CSSPropertyWhiteSpace);
1401 1401
1402 // If unicode-bidi is present in mutableStyle and direction is not, then add direction to mutableStyle. 1402 // If unicode-bidi is present in mutableStyle and direction is not, then add direction to mutableStyle.
1403 // FIXME: Shouldn't this be done in getPropertiesNotIn? 1403 // FIXME: Shouldn't this be done in getPropertiesNotIn?
1404 if (mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi) && !style->sty le()->getPropertyCSSValue(CSSPropertyDirection)) 1404 if (mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi) && !style->sty le()->getPropertyCSSValue(CSSPropertyDirection))
1405 mutableStyle->setProperty(CSSPropertyDirection, style->style()->getPrope rtyValue(CSSPropertyDirection)); 1405 mutableStyle->setProperty(CSSPropertyDirection, style->style()->getPrope rtyValue(CSSPropertyDirection));
1406 1406
1407 // Save the result for later 1407 // Save the result for later
1408 m_cssStyle = mutableStyle->asText().stripWhiteSpace(); 1408 m_cssStyle = mutableStyle->asText().stripWhiteSpace();
1409 } 1409 }
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 for (Handle<Node> ancestor = node; ancestor; ancestor = ancestor->parentNode ()) { 1643 for (Handle<Node> ancestor = node; ancestor; ancestor = ancestor->parentNode ()) {
1644 HandleScope scope; 1644 HandleScope scope;
1645 Handle<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor); 1645 Handle<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor);
1646 if (!hasTransparentBackgroundColorCSS(Handle<CSSStyleDeclaration>(ancest orStyle))) 1646 if (!hasTransparentBackgroundColorCSS(Handle<CSSStyleDeclaration>(ancest orStyle)))
1647 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); 1647 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor );
1648 } 1648 }
1649 return nullptr; 1649 return nullptr;
1650 } 1650 }
1651 1651
1652 } 1652 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698