WebKit Bugzilla
Attachment 362089 Details for
Bug 194686
: Refactor EditingStyle::textDirection to return an Optional<WritingDirection> instead of a bool
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194686-20190214183507.patch (text/plain), 8.33 KB, created by
Wenson Hsieh
on 2019-02-14 18:35:08 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2019-02-14 18:35:08 PST
Size:
8.33 KB
patch
obsolete
>Subversion Revision: 241553 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 898f8e8ec89eacbae6fcd5d7a91afc7ea4307729..a6b17b59a9882f177c16c088256f9a7676507e5e 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,21 @@ >+2019-02-14 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ Refactor EditingStyle::textDirection to return an Optional<WritingDirection> instead of a bool >+ https://bugs.webkit.org/show_bug.cgi?id=194686 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Changes EditingStyle::textDirection to return an Optional<WritingDirection>, instead of taking a reference to >+ the resulting WritingDirection. No change in behavior. >+ >+ * editing/ApplyStyleCommand.cpp: >+ (WebCore::ApplyStyleCommand::splitAncestorsWithUnicodeBidi): >+ (WebCore::ApplyStyleCommand::applyInlineStyle): >+ * editing/EditingStyle.cpp: >+ (WebCore::EditingStyle::textDirection const): >+ (WebCore::EditingStyle::textDirectionForSelection): >+ * editing/EditingStyle.h: >+ > 2019-02-14 Wenson Hsieh <wenson_hsieh@apple.com> > > [iOS] Support pasting item-provider-backed data on the pasteboard as attachment elements >diff --git a/Source/WebCore/editing/ApplyStyleCommand.cpp b/Source/WebCore/editing/ApplyStyleCommand.cpp >index 7a3a1600fba937dad7426f74b6036971fc8ce267..49163d7b77f4bcae66057e95f567201921086a5a 100644 >--- a/Source/WebCore/editing/ApplyStyleCommand.cpp >+++ b/Source/WebCore/editing/ApplyStyleCommand.cpp >@@ -485,17 +485,15 @@ HTMLElement* ApplyStyleCommand::splitAncestorsWithUnicodeBidi(Node* node, bool b > > HTMLElement* unsplitAncestor = nullptr; > >- WritingDirection highestAncestorDirection; >- if (allowedDirection != WritingDirection::Natural >- && highestAncestorUnicodeBidi != CSSValueBidiOverride >- && is<HTMLElement>(*highestAncestorWithUnicodeBidi) >- && EditingStyle::create(highestAncestorWithUnicodeBidi, EditingStyle::AllProperties)->textDirection(highestAncestorDirection) >- && highestAncestorDirection == allowedDirection) { >- if (!nextHighestAncestorWithUnicodeBidi) >- return downcast<HTMLElement>(highestAncestorWithUnicodeBidi); >- >- unsplitAncestor = downcast<HTMLElement>(highestAncestorWithUnicodeBidi); >- highestAncestorWithUnicodeBidi = nextHighestAncestorWithUnicodeBidi; >+ if (allowedDirection != WritingDirection::Natural && highestAncestorUnicodeBidi != CSSValueBidiOverride && is<HTMLElement>(*highestAncestorWithUnicodeBidi)) { >+ auto highestAncestorDirection = EditingStyle::create(highestAncestorWithUnicodeBidi, EditingStyle::AllProperties)->textDirection(); >+ if (highestAncestorDirection && *highestAncestorDirection == allowedDirection) { >+ if (!nextHighestAncestorWithUnicodeBidi) >+ return downcast<HTMLElement>(highestAncestorWithUnicodeBidi); >+ >+ unsplitAncestor = downcast<HTMLElement>(highestAncestorWithUnicodeBidi); >+ highestAncestorWithUnicodeBidi = nextHighestAncestorWithUnicodeBidi; >+ } > } > > // Split every ancestor through highest ancestor with embedding. >@@ -616,14 +614,13 @@ void ApplyStyleCommand::applyInlineStyle(EditingStyle& style) > // and prevent us from adding redundant ones, as described in: > // <rdar://problem/3724344> Bolding and unbolding creates extraneous tags > Position removeStart = start.upstream(); >- WritingDirection textDirection = WritingDirection::Natural; >- bool hasTextDirection = style.textDirection(textDirection); >+ auto textDirection = style.textDirection(); > RefPtr<EditingStyle> styleWithoutEmbedding; > RefPtr<EditingStyle> embeddingStyle; >- if (hasTextDirection) { >+ if (textDirection.hasValue()) { > // Leave alone an ancestor that provides the desired single level embedding, if there is one. >- HTMLElement* startUnsplitAncestor = splitAncestorsWithUnicodeBidi(start.deprecatedNode(), true, textDirection); >- HTMLElement* endUnsplitAncestor = splitAncestorsWithUnicodeBidi(end.deprecatedNode(), false, textDirection); >+ auto* startUnsplitAncestor = splitAncestorsWithUnicodeBidi(start.deprecatedNode(), true, *textDirection); >+ auto* endUnsplitAncestor = splitAncestorsWithUnicodeBidi(end.deprecatedNode(), false, *textDirection); > removeEmbeddingUpToEnclosingBlock(start.deprecatedNode(), startUnsplitAncestor); > removeEmbeddingUpToEnclosingBlock(end.deprecatedNode(), endUnsplitAncestor); > >@@ -671,7 +668,7 @@ void ApplyStyleCommand::applyInlineStyle(EditingStyle& style) > document().updateLayoutIgnorePendingStylesheets(); > > RefPtr<EditingStyle> styleToApply = &style; >- if (hasTextDirection) { >+ if (textDirection.hasValue()) { > // Avoid applying the unicode-bidi and direction properties beneath ancestors that already have them. > Node* embeddingStartNode = highestEmbeddingAncestor(start.deprecatedNode(), enclosingBlock(start.deprecatedNode())); > Node* embeddingEndNode = highestEmbeddingAncestor(end.deprecatedNode(), enclosingBlock(end.deprecatedNode())); >diff --git a/Source/WebCore/editing/EditingStyle.cpp b/Source/WebCore/editing/EditingStyle.cpp >index 6bbf014304b48c7751ec98ccb262b8a9a3070c01..8a45ba6f61d0d7d35eca4de4d94ca84f267f6fce 100644 >--- a/Source/WebCore/editing/EditingStyle.cpp >+++ b/Source/WebCore/editing/EditingStyle.cpp >@@ -553,32 +553,28 @@ Ref<MutableStyleProperties> EditingStyle::styleWithResolvedTextDecorations() con > return style; > } > >-bool EditingStyle::textDirection(WritingDirection& writingDirection) const >+Optional<WritingDirection> EditingStyle::textDirection() const > { > if (!m_mutableStyle) >- return false; >+ return WTF::nullopt; > > RefPtr<CSSValue> unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi); > if (!is<CSSPrimitiveValue>(unicodeBidi)) >- return false; >+ return WTF::nullopt; > > CSSValueID unicodeBidiValue = downcast<CSSPrimitiveValue>(*unicodeBidi).valueID(); > if (unicodeBidiValue == CSSValueEmbed) { > RefPtr<CSSValue> direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection); > if (!is<CSSPrimitiveValue>(direction)) >- return false; >+ return WTF::nullopt; > >- writingDirection = downcast<CSSPrimitiveValue>(*direction).valueID() == CSSValueLtr ? WritingDirection::LeftToRight : WritingDirection::RightToLeft; >- >- return true; >+ return downcast<CSSPrimitiveValue>(*direction).valueID() == CSSValueLtr ? WritingDirection::LeftToRight : WritingDirection::RightToLeft; > } > >- if (unicodeBidiValue == CSSValueNormal) { >- writingDirection = WritingDirection::Natural; >- return true; >- } >+ if (unicodeBidiValue == CSSValueNormal) >+ return WritingDirection::Natural; > >- return false; >+ return WTF::nullopt; > } > > void EditingStyle::setStyle(RefPtr<MutableStyleProperties>&& style) >@@ -1497,10 +1493,11 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection& > } > > if (selection.isCaret()) { >- WritingDirection direction; >- if (typingStyle && typingStyle->textDirection(direction)) { >- hasNestedOrMultipleEmbeddings = false; >- return direction; >+ if (typingStyle) { >+ if (auto direction = typingStyle->textDirection()) { >+ hasNestedOrMultipleEmbeddings = false; >+ return *direction; >+ } > } > node = selection.visibleStart().deepEquivalent().deprecatedNode(); > } >diff --git a/Source/WebCore/editing/EditingStyle.h b/Source/WebCore/editing/EditingStyle.h >index b7991efd4856dacf30ba7d5018e2e132b61a312a..fd08033e267fa337f0b3e2e3da6a3add19a2faeb 100644 >--- a/Source/WebCore/editing/EditingStyle.h >+++ b/Source/WebCore/editing/EditingStyle.h >@@ -36,6 +36,7 @@ > #include "StyleProperties.h" > #include "WritingDirection.h" > #include <wtf/Forward.h> >+#include <wtf/Optional.h> > #include <wtf/RefCounted.h> > #include <wtf/RefPtr.h> > #include <wtf/TriState.h> >@@ -110,7 +111,7 @@ public: > > MutableStyleProperties* style() { return m_mutableStyle.get(); } > Ref<MutableStyleProperties> styleWithResolvedTextDecorations() const; >- bool textDirection(WritingDirection&) const; >+ Optional<WritingDirection> textDirection() const; > bool isEmpty() const; > void setStyle(RefPtr<MutableStyleProperties>&&); > void overrideWithStyle(const StyleProperties&);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194686
: 362089