Skip to content
Permalink
Browse files
Deploy Ref/RefPtr in Editor
https://bugs.webkit.org/show_bug.cgi?id=224708

Reviewed by Wenson Hsieh.

Source/WebCore:

Deployed smart pointers in WebCore::Editor.

Also deployed ScriptDisallowedScope around the code which accesses the render tree.

* dom/Position.cpp:
(WebCore::Position::containerOrParentElement const): Added.
* dom/Position.h:
* editing/Editor.cpp:
(WebCore::Editor::selectionForCommand):
(WebCore::Editor::pasteAsPlainText):
(WebCore::Editor::pasteAsFragment):
(WebCore::Editor::shouldInsertFragment):
(WebCore::Editor::replaceSelectionWithFragment):
(WebCore::Editor::respondToChangedContents):
(WebCore::Editor::hasBidiSelection const):
(WebCore::Editor::selectionUnorderedListState const):
(WebCore::Editor::selectionOrderedListState const):
(WebCore::Editor::findEventTargetFrom const):
(WebCore::Editor::findEventTargetFromSelection const):
(WebCore::notifyTextFromControls):
(WebCore::Editor::willApplyEditing const):
(WebCore::Editor::appliedEditing):
(WebCore::Editor::insertTextWithoutSendingTextEvent):
(WebCore::Editor::performCutOrCopy):
(WebCore::Editor::simplifyMarkup): Replaced the manual tree traversal by treeOrder(~).
(WebCore::Editor::copyImage):
(WebCore::Editor::setBaseWritingDirection):
(WebCore::Editor::baseWritingDirectionForSelectionStart const):
(WebCore::Editor::setComposition):
(WebCore::Editor::advanceToNextMisspelling):
(WebCore::Editor::markMisspellingsAfterTypingToWord): Use containerOrParentElement.
(WebCore::Editor::isSpellCheckingEnabledFor const):
(WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
(WebCore::Editor::markAndReplaceFor):
(WebCore::scanForTelephoneNumbers):
(WebCore::Editor::scanSelectionForTelephoneNumbers): Restrucuted the code with makeScopeExit
to exit early instead of nesting if's.
(WebCore::findFirstMarkable):
(WebCore::Editor::selectionStartHasMarkerFor const):
(WebCore::Editor::resolveTextCheckingTypeMask):
(WebCore::Editor::stringForCandidateRequest const):
(WebCore::Editor::fontAttributesAtSelectionStart):
(WebCore::Editor::promisedAttachmentInfo):
(WebCore::Editor::styleForSelectionStart):
(WebCore::Editor::fontForSelection):
* editing/Editor.h:
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor):

Source/WebKit:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::editorState const):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::requestAutocorrectionData):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::fontAtSelection):

Source/WebKitLegacy/mac:

* WebView/WebFrame.mm:
(-[WebFrame fontForSelection:]):
* WebView/WebHTMLView.mm:
(-[WebHTMLView _updateFontPanel]):
* WebView/WebView.mm:
(-[WebView updateTextTouchBar]):


Canonical link: https://commits.webkit.org/236673@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276191 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
rniwa committed Apr 17, 2021
1 parent 48ad034 commit 2bbaecee3f31e4096128226a5aba3b85a9679a32
Showing 14 changed files with 245 additions and 134 deletions.
@@ -1,3 +1,59 @@
2021-04-16 Ryosuke Niwa <rniwa@webkit.org>

Deploy Ref/RefPtr in Editor
https://bugs.webkit.org/show_bug.cgi?id=224708

Reviewed by Wenson Hsieh.

Deployed smart pointers in WebCore::Editor.

Also deployed ScriptDisallowedScope around the code which accesses the render tree.

* dom/Position.cpp:
(WebCore::Position::containerOrParentElement const): Added.
* dom/Position.h:
* editing/Editor.cpp:
(WebCore::Editor::selectionForCommand):
(WebCore::Editor::pasteAsPlainText):
(WebCore::Editor::pasteAsFragment):
(WebCore::Editor::shouldInsertFragment):
(WebCore::Editor::replaceSelectionWithFragment):
(WebCore::Editor::respondToChangedContents):
(WebCore::Editor::hasBidiSelection const):
(WebCore::Editor::selectionUnorderedListState const):
(WebCore::Editor::selectionOrderedListState const):
(WebCore::Editor::findEventTargetFrom const):
(WebCore::Editor::findEventTargetFromSelection const):
(WebCore::notifyTextFromControls):
(WebCore::Editor::willApplyEditing const):
(WebCore::Editor::appliedEditing):
(WebCore::Editor::insertTextWithoutSendingTextEvent):
(WebCore::Editor::performCutOrCopy):
(WebCore::Editor::simplifyMarkup): Replaced the manual tree traversal by treeOrder(~).
(WebCore::Editor::copyImage):
(WebCore::Editor::setBaseWritingDirection):
(WebCore::Editor::baseWritingDirectionForSelectionStart const):
(WebCore::Editor::setComposition):
(WebCore::Editor::advanceToNextMisspelling):
(WebCore::Editor::markMisspellingsAfterTypingToWord): Use containerOrParentElement.
(WebCore::Editor::isSpellCheckingEnabledFor const):
(WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
(WebCore::Editor::markAndReplaceFor):
(WebCore::scanForTelephoneNumbers):
(WebCore::Editor::scanSelectionForTelephoneNumbers): Restrucuted the code with makeScopeExit
to exit early instead of nesting if's.
(WebCore::findFirstMarkable):
(WebCore::Editor::selectionStartHasMarkerFor const):
(WebCore::Editor::resolveTextCheckingTypeMask):
(WebCore::Editor::stringForCandidateRequest const):
(WebCore::Editor::fontAttributesAtSelectionStart):
(WebCore::Editor::promisedAttachmentInfo):
(WebCore::Editor::styleForSelectionStart):
(WebCore::Editor::fontForSelection):
* editing/Editor.h:
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor):

2021-04-16 Darin Adler <darin@apple.com>

font-size with viewport units in calc() doesn't change when viewport resizes
@@ -197,6 +197,16 @@ Text* Position::containerText() const
return nullptr;
}

Element* Position::containerOrParentElement() const
{
auto* container = containerNode();
if (!container)
return nullptr;
if (is<Element>(container))
return downcast<Element>(container);
return container->parentElement();
}

int Position::computeOffsetInContainerNode() const
{
if (!m_anchorNode)
@@ -83,6 +83,7 @@ class Position {
// will return img->parentNode() and img->computeNodeIndex() from these functions.
WEBCORE_EXPORT Node* containerNode() const; // null for a before/after position anchored to a node with no parent
Text* containerText() const;
Element* containerOrParentElement() const;

int computeOffsetInContainerNode() const; // O(n) for before/after-anchored positions, O(1) for parent-anchored positions
WEBCORE_EXPORT Position parentAnchoredEquivalent() const; // Convenience method for DOM positions that also fixes up some positions for editing

0 comments on commit 2bbaece

Please sign in to comment.