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

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

Issue 960353002: Handle null baseStyle in getPropertiesNotIn (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add test Created 5 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 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 , m_applyItalic(false) 1421 , m_applyItalic(false)
1422 , m_applyUnderline(false) 1422 , m_applyUnderline(false)
1423 , m_applyLineThrough(false) 1423 , m_applyLineThrough(false)
1424 , m_applySubscript(false) 1424 , m_applySubscript(false)
1425 , m_applySuperscript(false) 1425 , m_applySuperscript(false)
1426 { 1426 {
1427 Document* document = position.document(); 1427 Document* document = position.document();
1428 if (!style || !style->style() || !document || !document->frame()) 1428 if (!style || !style->style() || !document || !document->frame())
1429 return; 1429 return;
1430 1430
1431 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyle = position.com putedStyle(); 1431 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyle = position.com putedStyle();
yosin_UTC9 2015/03/10 05:27:07 Where |position| does point? Does |point| point to
rwlbuis 2015/03/10 23:44:21 Indeed position is a Document in the case where co
1432 // FIXME: take care of background-color in effect 1432 // FIXME: take care of background-color in effect
1433 RefPtrWillBeRawPtr<MutableStylePropertySet> mutableStyle = getPropertiesNotI n(style->style(), computedStyle.get()); 1433 RefPtrWillBeRawPtr<MutableStylePropertySet> mutableStyle = getPropertiesNotI n(style->style(), computedStyle.get());
1434 1434
1435 reconcileTextDecorationProperties(mutableStyle.get()); 1435 reconcileTextDecorationProperties(mutableStyle.get());
1436 if (!document->frame()->editor().shouldStyleWithCSS()) 1436 if (!document->frame()->editor().shouldStyleWithCSS())
1437 extractTextStyles(document, mutableStyle.get(), computedStyle->fixedPitc hFontType()); 1437 extractTextStyles(document, mutableStyle.get(), computedStyle ? computed Style->fixedPitchFontType() : NonFixedPitchFont);
1438 1438
1439 // Changing the whitespace style in a tab span would collapse the tab into a space. 1439 // Changing the whitespace style in a tab span would collapse the tab into a space.
1440 if (isTabHTMLSpanElementTextNode(position.deprecatedNode()) || isTabHTMLSpan Element((position.deprecatedNode()))) 1440 if (isTabHTMLSpanElementTextNode(position.deprecatedNode()) || isTabHTMLSpan Element((position.deprecatedNode())))
1441 mutableStyle->removeProperty(CSSPropertyWhiteSpace); 1441 mutableStyle->removeProperty(CSSPropertyWhiteSpace);
1442 1442
1443 // If unicode-bidi is present in mutableStyle and direction is not, then add direction to mutableStyle. 1443 // If unicode-bidi is present in mutableStyle and direction is not, then add direction to mutableStyle.
1444 // FIXME: Shouldn't this be done in getPropertiesNotIn? 1444 // FIXME: Shouldn't this be done in getPropertiesNotIn?
1445 if (mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi) && !style->sty le()->getPropertyCSSValue(CSSPropertyDirection)) 1445 if (mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi) && !style->sty le()->getPropertyCSSValue(CSSPropertyDirection))
1446 mutableStyle->setProperty(CSSPropertyDirection, style->style()->getPrope rtyValue(CSSPropertyDirection)); 1446 mutableStyle->setProperty(CSSPropertyDirection, style->style()->getPrope rtyValue(CSSPropertyDirection));
1447 1447
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 if (!fontWeight->isPrimitiveValue()) 1571 if (!fontWeight->isPrimitiveValue())
1572 return true; 1572 return true;
1573 1573
1574 CSSValueID value = toCSSPrimitiveValue(fontWeight)->getValueID(); 1574 CSSValueID value = toCSSPrimitiveValue(fontWeight)->getValueID();
1575 return value == CSSValueLighter || value == CSSValueBolder; 1575 return value == CSSValueLighter || value == CSSValueBolder;
1576 } 1576 }
1577 1577
1578 PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleProperty Set* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle) 1578 PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleProperty Set* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle)
1579 { 1579 {
1580 ASSERT(styleWithRedundantProperties); 1580 ASSERT(styleWithRedundantProperties);
1581 ASSERT(baseStyle);
1582 RefPtrWillBeRawPtr<MutableStylePropertySet> result = styleWithRedundantPrope rties->mutableCopy(); 1581 RefPtrWillBeRawPtr<MutableStylePropertySet> result = styleWithRedundantPrope rties->mutableCopy();
1582 if (!baseStyle)
1583 return result.release();
1583 1584
1584 result->removeEquivalentProperties(baseStyle); 1585 result->removeEquivalentProperties(baseStyle);
1585 1586
1586 RefPtrWillBeRawPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPro pertyCSSValueInternal(CSSPropertyWebkitTextDecorationsInEffect); 1587 RefPtrWillBeRawPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPro pertyCSSValueInternal(CSSPropertyWebkitTextDecorationsInEffect);
1587 diffTextDecorations(result.get(), textDecorationPropertyForEditing(), baseTe xtDecorationsInEffect.get()); 1588 diffTextDecorations(result.get(), textDecorationPropertyForEditing(), baseTe xtDecorationsInEffect.get());
1588 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get()); 1589 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get());
1589 1590
1590 if (RefPtrWillBeRawPtr<CSSValue> baseFontWeight = baseStyle->getPropertyCSSV alueInternal(CSSPropertyFontWeight)) { 1591 if (RefPtrWillBeRawPtr<CSSValue> baseFontWeight = baseStyle->getPropertyCSSV alueInternal(CSSPropertyFontWeight)) {
1591 if (RefPtrWillBeRawPtr<CSSValue> fontWeight = result->getPropertyCSSValu e(CSSPropertyFontWeight)) { 1592 if (RefPtrWillBeRawPtr<CSSValue> fontWeight = result->getPropertyCSSValu e(CSSPropertyFontWeight)) {
1592 if (!fontWeightNeedsResolving(fontWeight.get()) && (fontWeightIsBold (fontWeight.get()) == fontWeightIsBold(baseFontWeight.get()))) 1593 if (!fontWeightNeedsResolving(fontWeight.get()) && (fontWeightIsBold (fontWeight.get()) == fontWeightIsBold(baseFontWeight.get())))
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 { 1679 {
1679 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 1680 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
1680 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu tedStyleDeclaration::create(ancestor); 1681 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu tedStyleDeclaration::create(ancestor);
1681 if (!hasTransparentBackgroundColor(ancestorStyle.get())) 1682 if (!hasTransparentBackgroundColor(ancestorStyle.get()))
1682 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); 1683 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor );
1683 } 1684 }
1684 return nullptr; 1685 return nullptr;
1685 } 1686 }
1686 1687
1687 } 1688 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698