Diff
Modified: trunk/Source/WebCore/ChangeLog (234115 => 234116)
--- trunk/Source/WebCore/ChangeLog 2018-07-23 23:00:00 UTC (rev 234115)
+++ trunk/Source/WebCore/ChangeLog 2018-07-23 23:07:33 UTC (rev 234116)
@@ -1,3 +1,44 @@
+2018-07-23 Sam Weinig <[email protected]>
+
+ Convert some obvious never-null pointers to references in the editing code
+ https://bugs.webkit.org/show_bug.cgi?id=187914
+
+ Reviewed by Dean Jackson.
+
+ Fixup trivial cases of never-null pointers that really should be references.
+
+ * editing/ApplyStyleCommand.cpp:
+ (WebCore::ApplyStyleCommand::shouldApplyInlineStyleToRun):
+ (WebCore::ApplyStyleCommand::removeInlineStyleFromElement):
+ (WebCore::ApplyStyleCommand::removeImplicitlyStyledElement):
+ (WebCore::ApplyStyleCommand::removeCSSStyle):
+ (WebCore::ApplyStyleCommand::applyInlineStyleToPushDown):
+ (WebCore::ApplyStyleCommand::applyInlineStyleChange):
+ * editing/EditingStyle.cpp:
+ (WebCore::EditingStyle::overrideWithStyle):
+ (WebCore::EditingStyle::conflictsWithInlineStyleOfElement const):
+ (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement const):
+ (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes const):
+ (WebCore::EditingStyle::extractConflictingImplicitStyleOfAttributes const):
+ (WebCore::EditingStyle::styleIsPresentInComputedStyleOfNode const):
+ (WebCore::EditingStyle::elementIsStyledSpanOrHTMLEquivalent):
+ (WebCore::EditingStyle::mergeInlineStyleOfElement):
+ (WebCore::EditingStyle::wrappingStyleForSerialization):
+ (WebCore::EditingStyle::legacyFontSize const):
+ (WebCore::StyleChange::StyleChange):
+ (WebCore::StyleChange::extractTextStyles):
+ (WebCore::legacyFontSizeFromCSSValue):
+ * editing/EditingStyle.h:
+ (WebCore::EditingStyle::conflictsWithInlineStyleOfElement const):
+ * editing/Editor.cpp:
+ (WebCore::Editor::selectionStartCSSPropertyValue):
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
+ (WebCore::isInlineNodeWithStyle):
+ * editing/markup.cpp:
+ (WebCore::StyledMarkupAccumulator::appendElement):
+ (WebCore::StyledMarkupAccumulator::serializeNodes):
+
2018-07-23 Per Arne Vollan <[email protected]>
WebCore::primaryScreenDisplayID() always return 0
Modified: trunk/Source/WebCore/editing/ApplyStyleCommand.cpp (234115 => 234116)
--- trunk/Source/WebCore/editing/ApplyStyleCommand.cpp 2018-07-23 23:00:00 UTC (rev 234115)
+++ trunk/Source/WebCore/editing/ApplyStyleCommand.cpp 2018-07-23 23:07:33 UTC (rev 234116)
@@ -858,7 +858,7 @@
if (node->hasChildNodes())
continue;
// We don't consider m_isInlineElementToRemoveFunction here because we never apply style when m_isInlineElementToRemoveFunction is specified
- if (!style.styleIsPresentInComputedStyleOfNode(node))
+ if (!style.styleIsPresentInComputedStyleOfNode(*node))
return true;
if (m_styledInlineElement && !enclosingElementWithTag(positionBeforeNode(node), m_styledInlineElement->tagQName()))
return true;
@@ -903,7 +903,7 @@
if (mode == RemoveNone)
return true;
if (extractedStyle)
- extractedStyle->mergeInlineStyleOfElement(&element, EditingStyle::OverrideValues);
+ extractedStyle->mergeInlineStyleOfElement(element, EditingStyle::OverrideValues);
removeNodePreservingChildren(element);
return true;
}
@@ -937,11 +937,11 @@
{
if (mode == RemoveNone) {
ASSERT(!extractedStyle);
- return style.conflictsWithImplicitStyleOfElement(&element) || style.conflictsWithImplicitStyleOfAttributes(&element);
+ return style.conflictsWithImplicitStyleOfElement(element) || style.conflictsWithImplicitStyleOfAttributes(element);
}
ASSERT(mode == RemoveIfNeeded || mode == RemoveAlways);
- if (style.conflictsWithImplicitStyleOfElement(&element, extractedStyle, mode == RemoveAlways ? EditingStyle::ExtractMatchingStyle : EditingStyle::DoNotExtractMatchingStyle)) {
+ if (style.conflictsWithImplicitStyleOfElement(element, extractedStyle, mode == RemoveAlways ? EditingStyle::ExtractMatchingStyle : EditingStyle::DoNotExtractMatchingStyle)) {
replaceWithSpanOrRemoveIfWithoutAttributes(element);
return true;
}
@@ -948,10 +948,8 @@
// unicode-bidi and direction are pushed down separately so don't push down with other styles
Vector<QualifiedName> attributes;
- if (!style.extractConflictingImplicitStyleOfAttributes(&element, extractedStyle ? EditingStyle::PreserveWritingDirection : EditingStyle::DoNotPreserveWritingDirection,
- extractedStyle, attributes, mode == RemoveAlways ? EditingStyle::ExtractMatchingStyle : EditingStyle::DoNotExtractMatchingStyle)) {
+ if (!style.extractConflictingImplicitStyleOfAttributes(element, extractedStyle ? EditingStyle::PreserveWritingDirection : EditingStyle::DoNotPreserveWritingDirection, extractedStyle, attributes, mode == RemoveAlways ? EditingStyle::ExtractMatchingStyle : EditingStyle::DoNotExtractMatchingStyle))
return false;
- }
for (auto& attribute : attributes)
removeNodeAttribute(element, attribute);
@@ -965,10 +963,10 @@
bool ApplyStyleCommand::removeCSSStyle(EditingStyle& style, HTMLElement& element, InlineStyleRemovalMode mode, EditingStyle* extractedStyle)
{
if (mode == RemoveNone)
- return style.conflictsWithInlineStyleOfElement(&element);
+ return style.conflictsWithInlineStyleOfElement(element);
RefPtr<MutableStyleProperties> newInlineStyle;
- if (!style.conflictsWithInlineStyleOfElement(&element, newInlineStyle, extractedStyle))
+ if (!style.conflictsWithInlineStyleOfElement(element, newInlineStyle, extractedStyle))
return false;
if (newInlineStyle->isEmpty())
@@ -1012,7 +1010,7 @@
RefPtr<EditingStyle> newInlineStyle = style;
if (is<HTMLElement>(node) && downcast<HTMLElement>(node).inlineStyle()) {
newInlineStyle = style->copy();
- newInlineStyle->mergeInlineStyleOfElement(&downcast<HTMLElement>(node), EditingStyle::OverrideValues);
+ newInlineStyle->mergeInlineStyleOfElement(downcast<HTMLElement>(node), EditingStyle::OverrideValues);
}
// Since addInlineStyleIfNeeded can't add styles to block-flow render objects, add style attribute instead.
@@ -1462,7 +1460,7 @@
if (styleContainer) {
if (auto existingStyle = styleContainer->inlineStyle()) {
auto inlineStyle = EditingStyle::create(existingStyle);
- inlineStyle->overrideWithStyle(styleToMerge);
+ inlineStyle->overrideWithStyle(*styleToMerge);
setNodeAttribute(*styleContainer, styleAttr, inlineStyle->style()->asText());
} else
setNodeAttribute(*styleContainer, styleAttr, styleToMerge->asText());
Modified: trunk/Source/WebCore/editing/EditingStyle.cpp (234115 => 234116)
--- trunk/Source/WebCore/editing/EditingStyle.cpp 2018-07-23 23:00:00 UTC (rev 234115)
+++ trunk/Source/WebCore/editing/EditingStyle.cpp 2018-07-23 23:07:33 UTC (rev 234116)
@@ -152,7 +152,7 @@
template<typename T> Ref<MutableStyleProperties> getPropertiesNotIn(StyleProperties& styleWithRedundantProperties, T& baseStyle);
enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelValuesMatch };
-static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool shouldUseFixedFontDefaultSize, LegacyFontSizeMode);
+static int legacyFontSizeFromCSSValue(Document&, CSSPrimitiveValue*, bool shouldUseFixedFontDefaultSize, LegacyFontSizeMode);
static bool hasTransparentBackgroundColor(StyleProperties*);
static RefPtr<CSSValue> backgroundColorInEffect(Node*);
@@ -583,9 +583,9 @@
extractFontSizeDelta();
}
-void EditingStyle::overrideWithStyle(const StyleProperties* style)
+void EditingStyle::overrideWithStyle(const StyleProperties& style)
{
- return mergeStyle(style, OverrideValues);
+ return mergeStyle(&style, OverrideValues);
}
static void applyTextDecorationChangeToValueList(CSSValueList& valueList, TextDecorationChange change, Ref<CSSPrimitiveValue>&& value)
@@ -806,11 +806,9 @@
return downcast<CSSValueList>(value.get());
}
-bool EditingStyle::conflictsWithInlineStyleOfElement(StyledElement* element, RefPtr<MutableStyleProperties>* newInlineStylePtr, EditingStyle* extractedStyle) const
+bool EditingStyle::conflictsWithInlineStyleOfElement(StyledElement& element, RefPtr<MutableStyleProperties>* newInlineStylePtr, EditingStyle* extractedStyle) const
{
- ASSERT(element);
-
- const StyleProperties* inlineStyle = element->inlineStyle();
+ const StyleProperties* inlineStyle = element.inlineStyle();
if (!inlineStyle)
return false;
bool conflicts = false;
@@ -863,7 +861,7 @@
CSSPropertyID propertyID = m_mutableStyle->propertyAt(i).id();
// We don't override whitespace property of a tab span because that would collapse the tab into a space.
- if (propertyID == CSSPropertyWhiteSpace && isTabSpanNode(element))
+ if (propertyID == CSSPropertyWhiteSpace && isTabSpanNode(&element))
continue;
if (propertyID == CSSPropertyWebkitTextDecorationsInEffect && inlineStyle->getPropertyCSSValue(CSSPropertyTextDecoration)) {
@@ -917,16 +915,16 @@
}
-bool EditingStyle::conflictsWithImplicitStyleOfElement(HTMLElement* element, EditingStyle* extractedStyle, ShouldExtractMatchingStyle shouldExtractMatchingStyle) const
+bool EditingStyle::conflictsWithImplicitStyleOfElement(HTMLElement& element, EditingStyle* extractedStyle, ShouldExtractMatchingStyle shouldExtractMatchingStyle) const
{
if (isEmpty())
return false;
for (auto& equivalent : htmlElementEquivalents()) {
- if (equivalent->matches(*element) && equivalent->propertyExistsInStyle(*this)
- && (shouldExtractMatchingStyle == ExtractMatchingStyle || !equivalent->valueIsPresentInStyle(*element, *this))) {
+ if (equivalent->matches(element) && equivalent->propertyExistsInStyle(*this)
+ && (shouldExtractMatchingStyle == ExtractMatchingStyle || !equivalent->valueIsPresentInStyle(element, *this))) {
if (extractedStyle)
- equivalent->addToStyle(element, extractedStyle);
+ equivalent->addToStyle(&element, extractedStyle);
return true;
}
}
@@ -948,14 +946,13 @@
return equivalents;
}
-bool EditingStyle::conflictsWithImplicitStyleOfAttributes(HTMLElement* element) const
+bool EditingStyle::conflictsWithImplicitStyleOfAttributes(HTMLElement& element) const
{
- ASSERT(element);
if (isEmpty())
return false;
for (auto& equivalent : htmlAttributeEquivalents()) {
- if (equivalent->matches(*element) && equivalent->propertyExistsInStyle(*this) && !equivalent->valueIsPresentInStyle(*element, *this))
+ if (equivalent->matches(element) && equivalent->propertyExistsInStyle(*this) && !equivalent->valueIsPresentInStyle(element, *this))
return true;
}
@@ -962,10 +959,9 @@
return false;
}
-bool EditingStyle::extractConflictingImplicitStyleOfAttributes(HTMLElement* element, ShouldPreserveWritingDirection shouldPreserveWritingDirection,
+bool EditingStyle::extractConflictingImplicitStyleOfAttributes(HTMLElement& element, ShouldPreserveWritingDirection shouldPreserveWritingDirection,
EditingStyle* extractedStyle, Vector<QualifiedName>& conflictingAttributes, ShouldExtractMatchingStyle shouldExtractMatchingStyle) const
{
- ASSERT(element);
// HTMLAttributeEquivalent::addToStyle doesn't support unicode-bidi and direction properties
ASSERT(!extractedStyle || shouldPreserveWritingDirection == PreserveWritingDirection);
if (!m_mutableStyle)
@@ -977,12 +973,12 @@
if (shouldPreserveWritingDirection == PreserveWritingDirection && equivalent->attributeName() == HTMLNames::dirAttr)
continue;
- if (!equivalent->matches(*element) || !equivalent->propertyExistsInStyle(*this)
- || (shouldExtractMatchingStyle == DoNotExtractMatchingStyle && equivalent->valueIsPresentInStyle(*element, *this)))
+ if (!equivalent->matches(element) || !equivalent->propertyExistsInStyle(*this)
+ || (shouldExtractMatchingStyle == DoNotExtractMatchingStyle && equivalent->valueIsPresentInStyle(element, *this)))
continue;
if (extractedStyle)
- equivalent->addToStyle(element, extractedStyle);
+ equivalent->addToStyle(&element, extractedStyle);
conflictingAttributes.append(equivalent->attributeName());
removed = true;
}
@@ -990,11 +986,11 @@
return removed;
}
-bool EditingStyle::styleIsPresentInComputedStyleOfNode(Node* node) const
+bool EditingStyle::styleIsPresentInComputedStyleOfNode(Node& node) const
{
if (isEmpty())
return true;
- ComputedStyleExtractor computedStyle(node);
+ ComputedStyleExtractor computedStyle(&node);
bool shouldAddUnderline = underlineChange() == TextDecorationChange::Add;
bool shouldAddLineThrough = strikeThroughChange() == TextDecorationChange::Add;
@@ -1016,14 +1012,14 @@
return !m_mutableStyle || getPropertiesNotIn(*m_mutableStyle, computedStyle)->isEmpty();
}
-bool EditingStyle::elementIsStyledSpanOrHTMLEquivalent(const HTMLElement* element)
+bool EditingStyle::elementIsStyledSpanOrHTMLEquivalent(const HTMLElement& element)
{
bool elementIsSpanOrElementEquivalent = false;
- if (element->hasTagName(HTMLNames::spanTag))
+ if (element.hasTagName(HTMLNames::spanTag))
elementIsSpanOrElementEquivalent = true;
else {
for (auto& equivalent : htmlElementEquivalents()) {
- if (equivalent->matches(*element)) {
+ if (equivalent->matches(element)) {
elementIsSpanOrElementEquivalent = true;
break;
}
@@ -1030,12 +1026,12 @@
}
}
- if (!element->hasAttributes())
+ if (!element.hasAttributes())
return elementIsSpanOrElementEquivalent; // span, b, etc... without any attributes
unsigned matchedAttributes = 0;
for (auto& equivalent : htmlAttributeEquivalents()) {
- if (equivalent->matches(*element) && equivalent->attributeName() != HTMLNames::dirAttr)
+ if (equivalent->matches(element) && equivalent->attributeName() != HTMLNames::dirAttr)
matchedAttributes++;
}
@@ -1042,11 +1038,11 @@
if (!elementIsSpanOrElementEquivalent && !matchedAttributes)
return false; // element is not a span, a html element equivalent, or font element.
- if (element->attributeWithoutSynchronization(HTMLNames::classAttr) == AppleStyleSpanClass)
+ if (element.attributeWithoutSynchronization(HTMLNames::classAttr) == AppleStyleSpanClass)
matchedAttributes++;
- if (element->hasAttribute(HTMLNames::styleAttr)) {
- if (const StyleProperties* style = element->inlineStyle()) {
+ if (element.hasAttribute(HTMLNames::styleAttr)) {
+ if (const StyleProperties* style = element.inlineStyle()) {
unsigned propertyCount = style->propertyCount();
for (unsigned i = 0; i < propertyCount; ++i) {
if (!isEditingProperty(style->propertyAt(i).id()))
@@ -1057,8 +1053,8 @@
}
// font with color attribute, span with style attribute, etc...
- ASSERT(matchedAttributes <= element->attributeCount());
- return matchedAttributes >= element->attributeCount();
+ ASSERT(matchedAttributes <= element.attributeCount());
+ return matchedAttributes >= element.attributeCount();
}
void EditingStyle::prepareToApplyAt(const Position& position, ShouldPreserveWritingDirection shouldPreserveWritingDirection)
@@ -1107,21 +1103,20 @@
mergeStyle(typingStyle->style(), OverrideValues);
}
-void EditingStyle::mergeInlineStyleOfElement(StyledElement* element, CSSPropertyOverrideMode mode, PropertiesToInclude propertiesToInclude)
+void EditingStyle::mergeInlineStyleOfElement(StyledElement& element, CSSPropertyOverrideMode mode, PropertiesToInclude propertiesToInclude)
{
- ASSERT(element);
- if (!element->inlineStyle())
+ if (!element.inlineStyle())
return;
switch (propertiesToInclude) {
case AllProperties:
- mergeStyle(element->inlineStyle(), mode);
+ mergeStyle(element.inlineStyle(), mode);
return;
case OnlyEditingInheritableProperties:
- mergeStyle(copyEditingProperties(element->inlineStyle(), OnlyInheritableEditingProperties).ptr(), mode);
+ mergeStyle(copyEditingProperties(element.inlineStyle(), OnlyInheritableEditingProperties).ptr(), mode);
return;
case EditingPropertiesInEffect:
- mergeStyle(copyEditingProperties(element->inlineStyle(), AllEditingProperties).ptr(), mode);
+ mergeStyle(copyEditingProperties(element.inlineStyle(), AllEditingProperties).ptr(), mode);
return;
}
}
@@ -1176,15 +1171,15 @@
}
}
-Ref<EditingStyle> EditingStyle::wrappingStyleForSerialization(Node* context, bool shouldAnnotate)
+Ref<EditingStyle> EditingStyle::wrappingStyleForSerialization(Node& context, bool shouldAnnotate)
{
if (shouldAnnotate) {
- auto wrappingStyle = EditingStyle::create(context, EditingStyle::EditingPropertiesInEffect);
+ auto wrappingStyle = EditingStyle::create(&context, EditingStyle::EditingPropertiesInEffect);
// Styles that Mail blockquotes contribute should only be placed on the Mail blockquote,
// to help us differentiate those styles from ones that the user has applied.
// This helps us get the color of content pasted into blockquotes right.
- wrappingStyle->removeStyleAddedByNode(enclosingNodeOfType(firstPositionInOrBeforeNode(context), isMailBlockquote, CanCrossEditingBoundary));
+ wrappingStyle->removeStyleAddedByNode(enclosingNodeOfType(firstPositionInOrBeforeNode(&context), isMailBlockquote, CanCrossEditingBoundary));
// Call collapseTextDecorationProperties first or otherwise it'll copy the value over from in-effect to text-decorations.
wrappingStyle->collapseTextDecorationProperties();
@@ -1195,11 +1190,9 @@
auto wrappingStyle = EditingStyle::create();
// When not annotating for interchange, we only preserve inline style declarations.
- for (Node* node = context; node && !node->isDocumentNode(); node = node->parentNode()) {
- if (is<StyledElement>(*node) && !isMailBlockquote(node)) {
- wrappingStyle->mergeInlineAndImplicitStyleOfElement(downcast<StyledElement>(*node), EditingStyle::DoNotOverrideValues,
- EditingStyle::EditingPropertiesInEffect);
- }
+ for (Node* node = &context; node && !node->isDocumentNode(); node = node->parentNode()) {
+ if (is<StyledElement>(*node) && !isMailBlockquote(node))
+ wrappingStyle->mergeInlineAndImplicitStyleOfElement(downcast<StyledElement>(*node), EditingStyle::DoNotOverrideValues, EditingStyle::EditingPropertiesInEffect);
}
return wrappingStyle;
@@ -1405,7 +1398,7 @@
return v && !v->equals(*noneValue);
}
-int EditingStyle::legacyFontSize(Document* document) const
+int EditingStyle::legacyFontSize(Document& document) const
{
RefPtr<CSSValue> cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize);
if (!is<CSSPrimitiveValue>(cssValue))
@@ -1610,7 +1603,7 @@
reconcileTextDecorationProperties(mutableStyle.get());
bool shouldStyleWithCSS = document->frame()->editor().shouldStyleWithCSS();
if (!shouldStyleWithCSS)
- extractTextStyles(document, *mutableStyle, computedStyle.useFixedFontDefaultSize());
+ extractTextStyles(*document, *mutableStyle, computedStyle.useFixedFontDefaultSize());
bool shouldAddUnderline = style->underlineChange() == TextDecorationChange::Add;
bool shouldAddStrikeThrough = style->strikeThroughChange() == TextDecorationChange::Add;
@@ -1683,7 +1676,7 @@
}
}
-void StyleChange::extractTextStyles(Document* document, MutableStyleProperties& style, bool shouldUseFixedFontDefaultSize)
+void StyleChange::extractTextStyles(Document& document, MutableStyleProperties& style, bool shouldUseFixedFontDefaultSize)
{
if (identifierForStyleProperty(style, CSSPropertyFontWeight) == CSSValueBold) {
style.removeProperty(CSSPropertyFontWeight);
@@ -1826,16 +1819,14 @@
return value->isFontIndependentLength();
}
-int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, bool shouldUseFixedFontDefaultSize, LegacyFontSizeMode mode)
+int legacyFontSizeFromCSSValue(Document& document, CSSPrimitiveValue* value, bool shouldUseFixedFontDefaultSize, LegacyFontSizeMode mode)
{
- ASSERT(document); // FIXME: This method should take a Document&
-
if (isCSSValueLength(value)) {
int pixelFontSize = value->intValue(CSSPrimitiveValue::CSS_PX);
- int legacyFontSize = Style::legacyFontSizeForPixelSize(pixelFontSize, shouldUseFixedFontDefaultSize, *document);
+ int legacyFontSize = Style::legacyFontSizeForPixelSize(pixelFontSize, shouldUseFixedFontDefaultSize, document);
// Use legacy font size only if pixel value matches exactly to that of legacy font size.
int cssPrimitiveEquivalent = legacyFontSize - 1 + CSSValueXSmall;
- if (mode == AlwaysUseLegacyFontSize || Style::fontSizeForKeyword(cssPrimitiveEquivalent, shouldUseFixedFontDefaultSize, *document) == pixelFontSize)
+ if (mode == AlwaysUseLegacyFontSize || Style::fontSizeForKeyword(cssPrimitiveEquivalent, shouldUseFixedFontDefaultSize, document) == pixelFontSize)
return legacyFontSize;
return 0;
Modified: trunk/Source/WebCore/editing/EditingStyle.h (234115 => 234116)
--- trunk/Source/WebCore/editing/EditingStyle.h 2018-07-23 23:00:00 UTC (rev 234115)
+++ trunk/Source/WebCore/editing/EditingStyle.h 2018-07-23 23:07:33 UTC (rev 234116)
@@ -113,7 +113,7 @@
bool textDirection(WritingDirection&) const;
bool isEmpty() const;
void setStyle(RefPtr<MutableStyleProperties>&&);
- void overrideWithStyle(const StyleProperties*);
+ void overrideWithStyle(const StyleProperties&);
void overrideTypingStyleAt(const EditingStyle&, const Position&);
void clear();
Ref<EditingStyle> copy() const;
@@ -127,25 +127,23 @@
enum ShouldIgnoreTextOnlyProperties { IgnoreTextOnlyProperties, DoNotIgnoreTextOnlyProperties };
TriState triStateOfStyle(EditingStyle*) const;
TriState triStateOfStyle(const VisibleSelection&) const;
- bool conflictsWithInlineStyleOfElement(StyledElement* element) const { return conflictsWithInlineStyleOfElement(element, 0, 0); }
- bool conflictsWithInlineStyleOfElement(StyledElement* element, RefPtr<MutableStyleProperties>& newInlineStyle,
- EditingStyle* extractedStyle) const
+ bool conflictsWithInlineStyleOfElement(StyledElement& element) const { return conflictsWithInlineStyleOfElement(element, nullptr, nullptr); }
+ bool conflictsWithInlineStyleOfElement(StyledElement& element, RefPtr<MutableStyleProperties>& newInlineStyle, EditingStyle* extractedStyle) const
{
return conflictsWithInlineStyleOfElement(element, &newInlineStyle, extractedStyle);
}
- bool conflictsWithImplicitStyleOfElement(HTMLElement*, EditingStyle* extractedStyle = nullptr, ShouldExtractMatchingStyle = DoNotExtractMatchingStyle) const;
- bool conflictsWithImplicitStyleOfAttributes(HTMLElement*) const;
- bool extractConflictingImplicitStyleOfAttributes(HTMLElement*, ShouldPreserveWritingDirection, EditingStyle* extractedStyle,
- Vector<QualifiedName>& conflictingAttributes, ShouldExtractMatchingStyle) const;
- bool styleIsPresentInComputedStyleOfNode(Node*) const;
+ bool conflictsWithImplicitStyleOfElement(HTMLElement&, EditingStyle* extractedStyle = nullptr, ShouldExtractMatchingStyle = DoNotExtractMatchingStyle) const;
+ bool conflictsWithImplicitStyleOfAttributes(HTMLElement&) const;
+ bool extractConflictingImplicitStyleOfAttributes(HTMLElement&, ShouldPreserveWritingDirection, EditingStyle* extractedStyle, Vector<QualifiedName>& conflictingAttributes, ShouldExtractMatchingStyle) const;
+ bool styleIsPresentInComputedStyleOfNode(Node&) const;
- static bool elementIsStyledSpanOrHTMLEquivalent(const HTMLElement*);
+ static bool elementIsStyledSpanOrHTMLEquivalent(const HTMLElement&);
void prepareToApplyAt(const Position&, ShouldPreserveWritingDirection = DoNotPreserveWritingDirection);
void mergeTypingStyle(Document&);
enum CSSPropertyOverrideMode { OverrideValues, DoNotOverrideValues };
- void mergeInlineStyleOfElement(StyledElement*, CSSPropertyOverrideMode, PropertiesToInclude = AllProperties);
- static Ref<EditingStyle> wrappingStyleForSerialization(Node* context, bool shouldAnnotate);
+ void mergeInlineStyleOfElement(StyledElement&, CSSPropertyOverrideMode, PropertiesToInclude = AllProperties);
+ static Ref<EditingStyle> wrappingStyleForSerialization(Node& context, bool shouldAnnotate);
void mergeStyleFromRules(StyledElement&);
void mergeStyleFromRulesForSerialization(StyledElement&);
void removeStyleFromRulesAndContext(StyledElement&, Node* context);
@@ -153,7 +151,7 @@
void forceInline();
bool convertPositionStyle();
bool isFloating();
- int legacyFontSize(Document*) const;
+ int legacyFontSize(Document&) const;
float fontSizeDelta() const { return m_fontSizeDelta; }
bool hasFontSizeDelta() const { return m_fontSizeDelta != NoFontDelta; }
@@ -183,7 +181,7 @@
void setProperty(CSSPropertyID, const String& value, bool important = false);
void extractFontSizeDelta();
template<typename T> TriState triStateOfStyle(T& styleToCompare, ShouldIgnoreTextOnlyProperties) const;
- bool conflictsWithInlineStyleOfElement(StyledElement*, RefPtr<MutableStyleProperties>* newInlineStyle, EditingStyle* extractedStyle) const;
+ bool conflictsWithInlineStyleOfElement(StyledElement&, RefPtr<MutableStyleProperties>* newInlineStyle, EditingStyle* extractedStyle) const;
void mergeInlineAndImplicitStyleOfElement(StyledElement&, CSSPropertyOverrideMode, PropertiesToInclude);
void mergeStyle(const StyleProperties*, CSSPropertyOverrideMode);
@@ -224,7 +222,7 @@
return !(*this == other);
}
private:
- void extractTextStyles(Document*, MutableStyleProperties&, bool shouldUseFixedFontDefaultSize);
+ void extractTextStyles(Document&, MutableStyleProperties&, bool shouldUseFixedFontDefaultSize);
RefPtr<MutableStyleProperties> m_cssStyle;
bool m_applyBold = false;
Modified: trunk/Source/WebCore/editing/Editor.cpp (234115 => 234116)
--- trunk/Source/WebCore/editing/Editor.cpp 2018-07-23 23:00:00 UTC (rev 234115)
+++ trunk/Source/WebCore/editing/Editor.cpp 2018-07-23 23:07:33 UTC (rev 234116)
@@ -1005,7 +1005,7 @@
return String();
if (propertyID == CSSPropertyFontSize)
- return String::number(selectionStyle->legacyFontSize(&document()));
+ return String::number(selectionStyle->legacyFontSize(document()));
return selectionStyle->style()->getPropertyValue(propertyID);
}
Modified: trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp (234115 => 234116)
--- trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2018-07-23 23:00:00 UTC (rev 234115)
+++ trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2018-07-23 23:07:33 UTC (rev 234116)
@@ -502,13 +502,12 @@
Vector<QualifiedName> attributes;
HTMLElement& htmlElement = downcast<HTMLElement>(*element);
- if (newInlineStyle->conflictsWithImplicitStyleOfElement(&htmlElement)) {
+ if (newInlineStyle->conflictsWithImplicitStyleOfElement(htmlElement)) {
// e.g. <b style="font-weight: normal;"> is converted to <span style="font-weight: normal;">
node = replaceElementWithSpanPreservingChildrenAndAttributes(htmlElement);
element = downcast<StyledElement>(node.get());
insertedNodes.didReplaceNode(&htmlElement, node.get());
- } else if (newInlineStyle->extractConflictingImplicitStyleOfAttributes(&htmlElement, EditingStyle::PreserveWritingDirection, 0, attributes,
- EditingStyle::DoNotExtractMatchingStyle)) {
+ } else if (newInlineStyle->extractConflictingImplicitStyleOfAttributes(htmlElement, EditingStyle::PreserveWritingDirection, nullptr, attributes, EditingStyle::DoNotExtractMatchingStyle)) {
// e.g. <font size="3" style="font-size: 20px;"> is converted to <font style="font-size: 20px;">
for (auto& attribute : attributes)
removeNodeAttribute(*element, attribute);
@@ -909,7 +908,7 @@
|| classAttributeValue == ApplePasteAsQuotation)
return true;
- return EditingStyle::elementIsStyledSpanOrHTMLEquivalent(element);
+ return EditingStyle::elementIsStyledSpanOrHTMLEquivalent(*element);
}
inline Node* nodeToSplitToAvoidPastingIntoInlineNodesWithStyle(const Position& insertionPos)
Modified: trunk/Source/WebCore/editing/markup.cpp (234115 => 234116)
--- trunk/Source/WebCore/editing/markup.cpp 2018-07-23 23:00:00 UTC (rev 234115)
+++ trunk/Source/WebCore/editing/markup.cpp 2018-07-23 23:07:33 UTC (rev 234116)
@@ -466,7 +466,7 @@
newInlineStyle = EditingStyle::create();
if (is<StyledElement>(element) && downcast<StyledElement>(element).inlineStyle())
- newInlineStyle->overrideWithStyle(downcast<StyledElement>(element).inlineStyle());
+ newInlineStyle->overrideWithStyle(*downcast<StyledElement>(element).inlineStyle());
if (shouldAnnotateOrForceInline) {
if (shouldAnnotate())
@@ -504,7 +504,7 @@
}
if (m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->parentNode())
- m_wrappingStyle = EditingStyle::wrappingStyleForSerialization(m_highestNodeToBeSerialized->parentNode(), shouldAnnotate());
+ m_wrappingStyle = EditingStyle::wrappingStyleForSerialization(*m_highestNodeToBeSerialized->parentNode(), shouldAnnotate());
return traverseNodesForSerialization(startNode, pastEnd, EmitString);
}