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

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

Issue 2687243002: Rename the methods in EditingStyleUtilities class and make them used in editing (Closed)
Patch Set: 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) 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 29 matching lines...) Expand all
40 CSSValueID value) { 40 CSSValueID value) {
41 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(node)) { 41 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(node)) {
42 CSSComputedStyleDeclaration* ancestorStyle = 42 CSSComputedStyleDeclaration* ancestorStyle =
43 CSSComputedStyleDeclaration::create(&runner); 43 CSSComputedStyleDeclaration::create(&runner);
44 if (getIdentifierValue(ancestorStyle, CSSPropertyVerticalAlign) == value) 44 if (getIdentifierValue(ancestorStyle, CSSPropertyVerticalAlign) == value)
45 return true; 45 return true;
46 } 46 }
47 return false; 47 return false;
48 } 48 }
49 49
50 EditingStyle* EditingStyleUtilities::wrappingStyleForAnnotatedSerialization( 50 EditingStyle*
51 EditingStyleUtilities::createWrappingStyleForAnnotatedSerialization(
51 ContainerNode* context) { 52 ContainerNode* context) {
52 EditingStyle* wrappingStyle = 53 EditingStyle* wrappingStyle =
53 EditingStyle::create(context, EditingStyle::EditingPropertiesInEffect); 54 EditingStyle::create(context, EditingStyle::EditingPropertiesInEffect);
54 55
55 // Styles that Mail blockquotes contribute should only be placed on the Mail 56 // Styles that Mail blockquotes contribute should only be placed on the Mail
56 // blockquote, to help us differentiate those styles from ones that the user 57 // blockquote, to help us differentiate those styles from ones that the user
57 // has applied. This helps us get the color of content pasted into 58 // has applied. This helps us get the color of content pasted into
58 // blockquotes right. 59 // blockquotes right.
59 wrappingStyle->removeStyleAddedByElement(toHTMLElement(enclosingNodeOfType( 60 wrappingStyle->removeStyleAddedByElement(toHTMLElement(enclosingNodeOfType(
60 firstPositionInOrBeforeNode(context), isMailHTMLBlockquoteElement, 61 firstPositionInOrBeforeNode(context), isMailHTMLBlockquoteElement,
61 CanCrossEditingBoundary))); 62 CanCrossEditingBoundary)));
62 63
63 // Call collapseTextDecorationProperties first or otherwise it'll copy the 64 // Call collapseTextDecorationProperties first or otherwise it'll copy the
64 // value over from in-effect to text-decorations. 65 // value over from in-effect to text-decorations.
65 wrappingStyle->collapseTextDecorationProperties(); 66 wrappingStyle->collapseTextDecorationProperties();
66 67
67 return wrappingStyle; 68 return wrappingStyle;
68 } 69 }
69 70
70 EditingStyle* EditingStyleUtilities::wrappingStyleForSerialization( 71 EditingStyle* EditingStyleUtilities::createWrappingStyleForSerialization(
71 ContainerNode* context) { 72 ContainerNode* context) {
72 DCHECK(context); 73 DCHECK(context);
73 EditingStyle* wrappingStyle = EditingStyle::create(); 74 EditingStyle* wrappingStyle = EditingStyle::create();
74 75
75 // When not annotating for interchange, we only preserve inline style 76 // When not annotating for interchange, we only preserve inline style
76 // declarations. 77 // declarations.
77 for (Node& node : NodeTraversal::inclusiveAncestorsOf(*context)) { 78 for (Node& node : NodeTraversal::inclusiveAncestorsOf(*context)) {
78 if (node.isDocumentNode()) 79 if (node.isDocumentNode())
79 break; 80 break;
80 if (node.isStyledElement() && !isMailHTMLBlockquoteElement(&node)) { 81 if (node.isStyledElement() && !isMailHTMLBlockquoteElement(&node)) {
81 wrappingStyle->mergeInlineAndImplicitStyleOfElement( 82 wrappingStyle->mergeInlineAndImplicitStyleOfElement(
82 toElement(&node), EditingStyle::DoNotOverrideValues, 83 toElement(&node), EditingStyle::DoNotOverrideValues,
83 EditingStyle::EditingPropertiesInEffect); 84 EditingStyle::EditingPropertiesInEffect);
84 } 85 }
85 } 86 }
86 87
87 return wrappingStyle; 88 return wrappingStyle;
88 } 89 }
89 90
90 EditingStyle* EditingStyleUtilities::styleAtSelectionStart( 91 EditingStyle* EditingStyleUtilities::createStyleAtSelectionStart(
91 const VisibleSelection& selection, 92 const VisibleSelection& selection,
92 bool shouldUseBackgroundColorInEffect, 93 bool shouldUseBackgroundColorInEffect,
93 MutableStylePropertySet* styleToCheck) { 94 MutableStylePropertySet* styleToCheck) {
94 if (selection.isNone()) 95 if (selection.isNone())
95 return nullptr; 96 return nullptr;
96 97
97 Document& document = *selection.start().document(); 98 Document& document = *selection.start().document();
98 99
99 DCHECK(!document.needsLayoutTreeUpdate()); 100 DCHECK(!document.needsLayoutTreeUpdate());
100 DocumentLifecycle::DisallowTransitionScope disallowTransition( 101 DocumentLifecycle::DisallowTransitionScope disallowTransition(
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 297 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
297 CSSComputedStyleDeclaration* ancestorStyle = 298 CSSComputedStyleDeclaration* ancestorStyle =
298 CSSComputedStyleDeclaration::create(ancestor); 299 CSSComputedStyleDeclaration::create(ancestor);
299 if (!hasTransparentBackgroundColor(ancestorStyle)) 300 if (!hasTransparentBackgroundColor(ancestorStyle))
300 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor); 301 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor);
301 } 302 }
302 return nullptr; 303 return nullptr;
303 } 304 }
304 305
305 } // namespace blink 306 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/EditingStyleUtilities.h ('k') | third_party/WebKit/Source/core/editing/Editor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698