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

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

Issue 23819007: Have Node::document() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master 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
« no previous file with comments | « Source/core/editing/DeleteSelectionCommand.cpp ('k') | Source/core/editing/Editor.cpp » ('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) 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 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 } 1126 }
1127 1127
1128 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value)) 1128 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value))
1129 m_mutableStyle->setProperty(property.id(), property.value()->cssText (), property.isImportant()); 1129 m_mutableStyle->setProperty(property.id(), property.value()->cssText (), property.isImportant());
1130 } 1130 }
1131 } 1131 }
1132 1132
1133 static PassRefPtr<MutableStylePropertySet> styleFromMatchedRulesForElement(Eleme nt* element, unsigned rulesToInclude) 1133 static PassRefPtr<MutableStylePropertySet> styleFromMatchedRulesForElement(Eleme nt* element, unsigned rulesToInclude)
1134 { 1134 {
1135 RefPtr<MutableStylePropertySet> style = MutableStylePropertySet::create(); 1135 RefPtr<MutableStylePropertySet> style = MutableStylePropertySet::create();
1136 RefPtr<CSSRuleList> matchedRules = element->document()->styleResolver()->sty leRulesForElement(element, rulesToInclude); 1136 RefPtr<CSSRuleList> matchedRules = element->document().styleResolver()->styl eRulesForElement(element, rulesToInclude);
1137 if (matchedRules) { 1137 if (matchedRules) {
1138 for (unsigned i = 0; i < matchedRules->length(); i++) { 1138 for (unsigned i = 0; i < matchedRules->length(); i++) {
1139 if (matchedRules->item(i)->type() == CSSRule::STYLE_RULE) 1139 if (matchedRules->item(i)->type() == CSSRule::STYLE_RULE)
1140 style->mergeAndOverrideOnConflict(static_cast<CSSStyleRule*>(mat chedRules->item(i))->styleRule()->properties()); 1140 style->mergeAndOverrideOnConflict(static_cast<CSSStyleRule*>(mat chedRules->item(i))->styleRule()->properties());
1141 } 1141 }
1142 } 1142 }
1143 1143
1144 return style.release(); 1144 return style.release();
1145 } 1145 }
1146 1146
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 // We only do this for range because caret at Position("hello", 5) in <b>hel lo</b>world should give you font-weight: bold. 1263 // We only do this for range because caret at Position("hello", 5) in <b>hel lo</b>world should give you font-weight: bold.
1264 Node* positionNode = position.containerNode(); 1264 Node* positionNode = position.containerNode();
1265 if (selection.isRange() && positionNode && positionNode->isTextNode() && pos ition.computeOffsetInContainerNode() == positionNode->maxCharacterOffset()) 1265 if (selection.isRange() && positionNode && positionNode->isTextNode() && pos ition.computeOffsetInContainerNode() == positionNode->maxCharacterOffset())
1266 position = nextVisuallyDistinctCandidate(position); 1266 position = nextVisuallyDistinctCandidate(position);
1267 1267
1268 Element* element = position.element(); 1268 Element* element = position.element();
1269 if (!element) 1269 if (!element)
1270 return 0; 1270 return 0;
1271 1271
1272 RefPtr<EditingStyle> style = EditingStyle::create(element, EditingStyle::All Properties); 1272 RefPtr<EditingStyle> style = EditingStyle::create(element, EditingStyle::All Properties);
1273 style->mergeTypingStyle(element->document()); 1273 style->mergeTypingStyle(&element->document());
1274 1274
1275 // If background color is transparent, traverse parent nodes until we hit a different value or document root 1275 // If background color is transparent, traverse parent nodes until we hit a different value or document root
1276 // Also, if the selection is a range, ignore the background color at the sta rt of selection, 1276 // Also, if the selection is a range, ignore the background color at the sta rt of selection,
1277 // and find the background color of the common ancestor. 1277 // and find the background color of the common ancestor.
1278 if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTranspare ntBackgroundColor(style->m_mutableStyle.get()))) { 1278 if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTranspare ntBackgroundColor(style->m_mutableStyle.get()))) {
1279 RefPtr<Range> range(selection.toNormalizedRange()); 1279 RefPtr<Range> range(selection.toNormalizedRange());
1280 if (PassRefPtr<CSSValue> value = backgroundColorInEffect(range->commonAn cestorContainer(IGNORE_EXCEPTION))) 1280 if (PassRefPtr<CSSValue> value = backgroundColorInEffect(range->commonAn cestorContainer(IGNORE_EXCEPTION)))
1281 style->setProperty(CSSPropertyBackgroundColor, value->cssText()); 1281 style->setProperty(CSSPropertyBackgroundColor, value->cssText());
1282 } 1282 }
1283 1283
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 } 1387 }
1388 1388
1389 StyleChange::StyleChange(EditingStyle* style, const Position& position) 1389 StyleChange::StyleChange(EditingStyle* style, const Position& position)
1390 : m_applyBold(false) 1390 : m_applyBold(false)
1391 , m_applyItalic(false) 1391 , m_applyItalic(false)
1392 , m_applyUnderline(false) 1392 , m_applyUnderline(false)
1393 , m_applyLineThrough(false) 1393 , m_applyLineThrough(false)
1394 , m_applySubscript(false) 1394 , m_applySubscript(false)
1395 , m_applySuperscript(false) 1395 , m_applySuperscript(false)
1396 { 1396 {
1397 Document* document = position.anchorNode() ? position.anchorNode()->document () : 0; 1397 Document* document = position.anchorNode() ? &position.anchorNode()->documen t() : 0;
1398 if (!style || !style->style() || !document || !document->frame()) 1398 if (!style || !style->style() || !document || !document->frame())
1399 return; 1399 return;
1400 1400
1401 RefPtr<CSSComputedStyleDeclaration> computedStyle = position.computedStyle() ; 1401 RefPtr<CSSComputedStyleDeclaration> computedStyle = position.computedStyle() ;
1402 // FIXME: take care of background-color in effect 1402 // FIXME: take care of background-color in effect
1403 RefPtr<MutableStylePropertySet> mutableStyle = getPropertiesNotIn(style->sty le(), computedStyle.get()); 1403 RefPtr<MutableStylePropertySet> mutableStyle = getPropertiesNotIn(style->sty le(), computedStyle.get());
1404 1404
1405 reconcileTextDecorationProperties(mutableStyle.get()); 1405 reconcileTextDecorationProperties(mutableStyle.get());
1406 if (!document->frame()->editor().shouldStyleWithCSS()) 1406 if (!document->frame()->editor().shouldStyleWithCSS())
1407 extractTextStyles(document, mutableStyle.get(), computedStyle->useFixedF ontDefaultSize()); 1407 extractTextStyles(document, mutableStyle.get(), computedStyle->useFixedF ontDefaultSize());
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 { 1652 {
1653 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 1653 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
1654 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor); 1654 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor);
1655 if (!hasTransparentBackgroundColor(ancestorStyle.get())) 1655 if (!hasTransparentBackgroundColor(ancestorStyle.get()))
1656 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); 1656 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor );
1657 } 1657 }
1658 return 0; 1658 return 0;
1659 } 1659 }
1660 1660
1661 } 1661 }
OLDNEW
« no previous file with comments | « Source/core/editing/DeleteSelectionCommand.cpp ('k') | Source/core/editing/Editor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698