Title: [215872] trunk/Source
Revision
215872
Author
[email protected]
Date
2017-04-27 09:42:13 -0700 (Thu, 27 Apr 2017)

Log Message

Modernize Frame.h
https://bugs.webkit.org/show_bug.cgi?id=171357

Reviewed by Andy Estes.

Source/WebCore:

Frame.h has several std::unique_ptrs that are created in the constructor, never null,
and destroyed in the destructor.  This is what WTF::UniqueRef is for, and using UniqueRef
allows us to not check for null values because a UniqueRef can never be null.
An interesting case was the EventHandler, which we explicitly set to nullptr in the destructor
of MainFrame, a subclass of Frame.  We added this in r199181 to fix a crash tested by
fast/events/wheel-event-destroys-frame.html and this improved lifetime also does not crash
or assert in that test.

Using UniqueRef also requires const correctness, which this patch adds when necessary.

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::dispatchTouchEvent):
* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::calculateTypingStyleAfterDelete):
* editing/Editor.cpp:
(WebCore::Editor::isSelectTrailingWhitespaceEnabled):
(WebCore::Editor::computeAndSetTypingStyle):
* editing/Editor.h:
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::contains):
(WebCore::FrameSelection::copyTypingStyle):
* editing/FrameSelection.h:
(WebCore::FrameSelection::setTypingStyle):
* loader/EmptyClients.cpp:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::clear):
* page/EditorClient.h:
* page/EventHandler.cpp:
(WebCore::EventHandler::hitTestResultAtPoint):
* page/EventHandler.h:
* page/Frame.cpp:
(WebCore::Frame::Frame):
(WebCore::Frame::setView):
(WebCore::Frame::injectUserScripts):
* page/Frame.h:
(WebCore::Frame::editor):
(WebCore::Frame::eventHandler):
(WebCore::Frame::selection):
(WebCore::Frame::animation):
(WebCore::Frame::script):
(WebCore::Frame::eventHandlerPtr): Deleted.
* page/MainFrame.cpp:
(WebCore::MainFrame::~MainFrame):
* replay/UserInputBridge.cpp:
(WebCore::UserInputBridge::handleContextMenuEvent):
* replay/UserInputBridge.h:

Source/WebKit/mac:

* WebCoreSupport/WebEditorClient.h:
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::isSelectTrailingWhitespaceEnabled):

Source/WebKit/win:

* WebCoreSupport/WebEditorClient.cpp:
(WebEditorClient::isSelectTrailingWhitespaceEnabled):
* WebCoreSupport/WebEditorClient.h:

Source/WebKit2:

* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::isSelectTrailingWhitespaceEnabled):
* WebProcess/WebCoreSupport/WebEditorClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::contextMenuAtPointInWindow):
(WebKit::handleContextMenuEvent):
(WebKit::WebPage::isSelectTrailingWhitespaceEnabled):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::selectWithGesture):
(WebKit::WebPage::selectPositionAtPoint):
(WebKit::WebPage::selectPositionAtBoundaryWithDirection):
(WebKit::WebPage::rangeForGranularityAtPoint):
(WebKit::WebPage::selectTextWithGranularityAtPoint):
(WebKit::WebPage::updateSelectionWithExtentPointAndBoundary):
(WebKit::WebPage::updateSelectionWithExtentPoint):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (215871 => 215872)


--- trunk/Source/WebCore/ChangeLog	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/ChangeLog	2017-04-27 16:42:13 UTC (rev 215872)
@@ -1,3 +1,57 @@
+2017-04-27  Alex Christensen  <[email protected]>
+
+        Modernize Frame.h
+        https://bugs.webkit.org/show_bug.cgi?id=171357
+
+        Reviewed by Andy Estes.
+
+        Frame.h has several std::unique_ptrs that are created in the constructor, never null,
+        and destroyed in the destructor.  This is what WTF::UniqueRef is for, and using UniqueRef
+        allows us to not check for null values because a UniqueRef can never be null.
+        An interesting case was the EventHandler, which we explicitly set to nullptr in the destructor
+        of MainFrame, a subclass of Frame.  We added this in r199181 to fix a crash tested by
+        fast/events/wheel-event-destroys-frame.html and this improved lifetime also does not crash
+        or assert in that test.
+
+        Using UniqueRef also requires const correctness, which this patch adds when necessary.
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::dispatchTouchEvent):
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::calculateTypingStyleAfterDelete):
+        * editing/Editor.cpp:
+        (WebCore::Editor::isSelectTrailingWhitespaceEnabled):
+        (WebCore::Editor::computeAndSetTypingStyle):
+        * editing/Editor.h:
+        * editing/FrameSelection.cpp:
+        (WebCore::FrameSelection::contains):
+        (WebCore::FrameSelection::copyTypingStyle):
+        * editing/FrameSelection.h:
+        (WebCore::FrameSelection::setTypingStyle):
+        * loader/EmptyClients.cpp:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::clear):
+        * page/EditorClient.h:
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::hitTestResultAtPoint):
+        * page/EventHandler.h:
+        * page/Frame.cpp:
+        (WebCore::Frame::Frame):
+        (WebCore::Frame::setView):
+        (WebCore::Frame::injectUserScripts):
+        * page/Frame.h:
+        (WebCore::Frame::editor):
+        (WebCore::Frame::eventHandler):
+        (WebCore::Frame::selection):
+        (WebCore::Frame::animation):
+        (WebCore::Frame::script):
+        (WebCore::Frame::eventHandlerPtr): Deleted.
+        * page/MainFrame.cpp:
+        (WebCore::MainFrame::~MainFrame):
+        * replay/UserInputBridge.cpp:
+        (WebCore::UserInputBridge::handleContextMenuEvent):
+        * replay/UserInputBridge.h:
+
 2017-04-27  Andy Estes  <[email protected]>
 
         Fix the macOS build.

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (215871 => 215872)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2017-04-27 16:42:13 UTC (rev 215872)
@@ -951,15 +951,11 @@
     
 bool AccessibilityObject::dispatchTouchEvent()
 {
-    bool handled = false;
 #if ENABLE(IOS_TOUCH_EVENTS)
-    MainFrame* frame = mainFrame();
-    if (!frame)
-        return false;
-
-    handled = frame->eventHandler().dispatchSimulatedTouchEvent(clickPoint());
+    if (auto* frame = mainFrame())
+        return frame->eventHandler().dispatchSimulatedTouchEvent(clickPoint());
 #endif
-    return handled;
+    return false;
 }
 
 Frame* AccessibilityObject::frame() const

Modified: trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp (215871 => 215872)


--- trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp	2017-04-27 16:42:13 UTC (rev 215872)
@@ -763,7 +763,7 @@
     // In this case if we start typing, the new characters should have the same style as the just deleted ones,
     // but, if we change the selection, come back and start typing that style should be lost.  Also see 
     // preserveTypingStyle() below.
-    frame().selection().setTypingStyle(m_typingStyle);
+    frame().selection().setTypingStyle(m_typingStyle.copyRef());
 }
 
 void DeleteSelectionCommand::clearTransientState()

Modified: trunk/Source/WebCore/editing/Editor.cpp (215871 => 215872)


--- trunk/Source/WebCore/editing/Editor.cpp	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/editing/Editor.cpp	2017-04-27 16:42:13 UTC (rev 215872)
@@ -361,7 +361,7 @@
     return client() && client()->smartInsertDeleteEnabled() && m_frame.selection().granularity() == WordGranularity;
 }
 
-bool Editor::isSelectTrailingWhitespaceEnabled()
+bool Editor::isSelectTrailingWhitespaceEnabled() const
 {
     return client() && client()->isSelectTrailingWhitespaceEnabled();
 }
@@ -3041,7 +3041,7 @@
         applyCommand(ApplyStyleCommand::create(document(), blockStyle.get(), editingAction));
 
     // Set the remaining style as the typing style.
-    m_frame.selection().setTypingStyle(typingStyle);
+    m_frame.selection().setTypingStyle(WTFMove(typingStyle));
 }
 
 void Editor::computeAndSetTypingStyle(StyleProperties& properties, EditAction editingAction)

Modified: trunk/Source/WebCore/editing/Editor.h (215871 => 215872)


--- trunk/Source/WebCore/editing/Editor.h	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/editing/Editor.h	2017-04-27 16:42:13 UTC (rev 215872)
@@ -312,7 +312,7 @@
     // smartInsertDeleteEnabled and selectTrailingWhitespaceEnabled are 
     // mutually exclusive, meaning that enabling one will disable the other.
     bool smartInsertDeleteEnabled();
-    bool isSelectTrailingWhitespaceEnabled();
+    bool isSelectTrailingWhitespaceEnabled() const;
     
     WEBCORE_EXPORT bool hasBidiSelection() const;
 

Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (215871 => 215872)


--- trunk/Source/WebCore/editing/FrameSelection.cpp	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp	2017-04-27 16:42:13 UTC (rev 215872)
@@ -1813,7 +1813,7 @@
     }
 }
 
-bool FrameSelection::contains(const LayoutPoint& point)
+bool FrameSelection::contains(const LayoutPoint& point) const
 {
     // Treat a collapsed selection like no selection.
     if (!isRange())
@@ -2201,10 +2201,10 @@
 #endif
 }
 
-PassRefPtr<MutableStyleProperties> FrameSelection::copyTypingStyle() const
+RefPtr<MutableStyleProperties> FrameSelection::copyTypingStyle() const
 {
     if (!m_typingStyle || !m_typingStyle->style())
-        return 0;
+        return nullptr;
     return m_typingStyle->style()->mutableCopy();
 }
 
@@ -2428,7 +2428,7 @@
     setSelection(selection);
 }
 
-PassRefPtr<Range> FrameSelection::elementRangeContainingCaretSelection() const
+RefPtr<Range> FrameSelection::elementRangeContainingCaretSelection() const
 {
     if (m_selection.isNone())
         return nullptr;
@@ -2467,7 +2467,7 @@
         setSelection(selection);
 }
 
-PassRefPtr<Range> FrameSelection::wordRangeContainingCaretSelection()
+RefPtr<Range> FrameSelection::wordRangeContainingCaretSelection()
 {
     return wordSelectionContainingCaretSelection(m_selection).toNormalizedRange();
 }
@@ -2619,12 +2619,12 @@
     return result;
 }
 
-PassRefPtr<Range> FrameSelection::rangeByMovingCurrentSelection(int amount) const
+RefPtr<Range> FrameSelection::rangeByMovingCurrentSelection(int amount) const
 {
     return rangeByAlteringCurrentSelection(AlterationMove, amount);
 }
 
-PassRefPtr<Range> FrameSelection::rangeByExtendingCurrentSelection(int amount) const
+RefPtr<Range> FrameSelection::rangeByExtendingCurrentSelection(int amount) const
 {
     return rangeByAlteringCurrentSelection(AlterationExtend, amount);
 }
@@ -2785,7 +2785,7 @@
     return result;
 }
 
-PassRefPtr<Range> FrameSelection::rangeByAlteringCurrentSelection(EAlteration alteration, int amount) const
+RefPtr<Range> FrameSelection::rangeByAlteringCurrentSelection(EAlteration alteration, int amount) const
 {
     if (m_selection.isNone())
         return nullptr;

Modified: trunk/Source/WebCore/editing/FrameSelection.h (215871 => 215872)


--- trunk/Source/WebCore/editing/FrameSelection.h	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/editing/FrameSelection.h	2017-04-27 16:42:13 UTC (rev 215872)
@@ -153,7 +153,7 @@
     void updateAppearanceAfterLayout();
     void setNeedsSelectionUpdate();
 
-    bool contains(const LayoutPoint&);
+    bool contains(const LayoutPoint&) const;
 
     WEBCORE_EXPORT bool modify(EAlteration, SelectionDirection, TextGranularity, EUserTriggered = NotUserTriggered);
     enum VerticalDirection { DirectionUp, DirectionDown };
@@ -215,9 +215,9 @@
 #if PLATFORM(IOS)
 public:
     WEBCORE_EXPORT void expandSelectionToElementContainingCaretSelection();
-    WEBCORE_EXPORT PassRefPtr<Range> elementRangeContainingCaretSelection() const;
+    WEBCORE_EXPORT RefPtr<Range> elementRangeContainingCaretSelection() const;
     WEBCORE_EXPORT void expandSelectionToWordContainingCaretSelection();
-    WEBCORE_EXPORT PassRefPtr<Range> wordRangeContainingCaretSelection();
+    WEBCORE_EXPORT RefPtr<Range> wordRangeContainingCaretSelection();
     WEBCORE_EXPORT void expandSelectionToStartOfWordContainingCaretSelection();
     WEBCORE_EXPORT UChar characterInRelationToCaretSelection(int amount) const;
     WEBCORE_EXPORT UChar characterBeforeCaretSelection() const;
@@ -227,8 +227,8 @@
     WEBCORE_EXPORT bool selectionAtDocumentStart() const;
     WEBCORE_EXPORT bool selectionAtSentenceStart() const;
     WEBCORE_EXPORT bool selectionAtWordStart() const;
-    WEBCORE_EXPORT PassRefPtr<Range> rangeByMovingCurrentSelection(int amount) const;
-    WEBCORE_EXPORT PassRefPtr<Range> rangeByExtendingCurrentSelection(int amount) const;
+    WEBCORE_EXPORT RefPtr<Range> rangeByMovingCurrentSelection(int amount) const;
+    WEBCORE_EXPORT RefPtr<Range> rangeByExtendingCurrentSelection(int amount) const;
     WEBCORE_EXPORT void selectRangeOnElement(unsigned location, unsigned length, Node&);
     WEBCORE_EXPORT void clearCurrentSelection();
     void setCaretBlinks(bool caretBlinks = true);
@@ -243,7 +243,7 @@
     }
 private:
     bool actualSelectionAtSentenceStart(const VisibleSelection&) const;
-    PassRefPtr<Range> rangeByAlteringCurrentSelection(EAlteration, int amount) const;
+    RefPtr<Range> rangeByAlteringCurrentSelection(EAlteration, int amount) const;
 public:
 #endif
 
@@ -253,8 +253,8 @@
     void setSelectionByMouseIfDifferent(const VisibleSelection&, TextGranularity, EndPointsAdjustmentMode = DoNotAdjsutEndpoints);
 
     EditingStyle* typingStyle() const;
-    WEBCORE_EXPORT PassRefPtr<MutableStyleProperties> copyTypingStyle() const;
-    void setTypingStyle(PassRefPtr<EditingStyle>);
+    WEBCORE_EXPORT RefPtr<MutableStyleProperties> copyTypingStyle() const;
+    void setTypingStyle(RefPtr<EditingStyle>&& style) { m_typingStyle = WTFMove(style); }
     void clearTypingStyle();
 
     WEBCORE_EXPORT FloatRect selectionBounds(bool clipToVisibleContent = true) const;
@@ -364,11 +364,6 @@
     m_typingStyle = nullptr;
 }
 
-inline void FrameSelection::setTypingStyle(PassRefPtr<EditingStyle> style)
-{
-    m_typingStyle = style;
-}
-
 #if !(PLATFORM(COCOA) || PLATFORM(GTK))
 #if HAVE(ACCESSIBILITY)
 inline void FrameSelection::notifyAccessibilityForSelectionChange(const AXTextStateChangeIntent&)

Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (215871 => 215872)


--- trunk/Source/WebCore/loader/EmptyClients.cpp	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp	2017-04-27 16:42:13 UTC (rev 215872)
@@ -146,7 +146,7 @@
 private:
     bool shouldDeleteRange(Range*) final { return false; }
     bool smartInsertDeleteEnabled() final { return false; }
-    bool isSelectTrailingWhitespaceEnabled() final { return false; }
+    bool isSelectTrailingWhitespaceEnabled() const final { return false; }
     bool isContinuousSpellCheckingEnabled() final { return false; }
     void toggleContinuousSpellChecking() final { }
     bool isGrammarCheckingEnabled() final { return false; }

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (215871 => 215872)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2017-04-27 16:42:13 UTC (rev 215872)
@@ -627,11 +627,8 @@
     }
 
     m_frame.selection().prepareForDestruction();
+    m_frame.eventHandler().clear();
 
-    // We may call this code during object destruction, so need to make sure eventHandler is present.
-    if (auto eventHandler = m_frame.eventHandlerPtr())
-        eventHandler->clear();
-
     if (clearFrameView && m_frame.view())
         m_frame.view()->clear();
 

Modified: trunk/Source/WebCore/page/EditorClient.h (215871 => 215872)


--- trunk/Source/WebCore/page/EditorClient.h	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/page/EditorClient.h	2017-04-27 16:42:13 UTC (rev 215872)
@@ -70,7 +70,7 @@
 
     virtual bool shouldDeleteRange(Range*) = 0;
     virtual bool smartInsertDeleteEnabled() = 0; 
-    virtual bool isSelectTrailingWhitespaceEnabled() = 0;
+    virtual bool isSelectTrailingWhitespaceEnabled() const = 0;
     virtual bool isContinuousSpellCheckingEnabled() = 0;
     virtual void toggleContinuousSpellChecking() = 0;
     virtual bool isGrammarCheckingEnabled() = 0;

Modified: trunk/Source/WebCore/page/EventHandler.cpp (215871 => 215872)


--- trunk/Source/WebCore/page/EventHandler.cpp	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2017-04-27 16:42:13 UTC (rev 215872)
@@ -1118,7 +1118,7 @@
 }
 #endif // ENABLE(DRAG_SUPPORT)
 
-HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTestRequest::HitTestRequestType hitType, const LayoutSize& padding)
+HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTestRequest::HitTestRequestType hitType, const LayoutSize& padding) const
 {
     Ref<Frame> protectedFrame(m_frame);
 

Modified: trunk/Source/WebCore/page/EventHandler.h (215871 => 215872)


--- trunk/Source/WebCore/page/EventHandler.h	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/page/EventHandler.h	2017-04-27 16:42:13 UTC (rev 215872)
@@ -147,9 +147,7 @@
     WEBCORE_EXPORT void dispatchFakeMouseMoveEventSoon();
     void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&);
 
-    WEBCORE_EXPORT HitTestResult hitTestResultAtPoint(const LayoutPoint&,
-        HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowUserAgentShadowContent,
-        const LayoutSize& padding = LayoutSize());
+    WEBCORE_EXPORT HitTestResult hitTestResultAtPoint(const LayoutPoint&, HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowUserAgentShadowContent, const LayoutSize& padding = LayoutSize()) const;
 
     bool mousePressed() const { return m_mousePressed; }
     Node* mousePressNode() const { return m_mousePressNode.get(); }

Modified: trunk/Source/WebCore/page/Frame.cpp (215871 => 215872)


--- trunk/Source/WebCore/page/Frame.cpp	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/page/Frame.cpp	2017-04-27 16:42:13 UTC (rev 215872)
@@ -157,10 +157,10 @@
     , m_loader(*this, frameLoaderClient)
     , m_navigationScheduler(*this)
     , m_ownerElement(ownerElement)
-    , m_script(std::make_unique<ScriptController>(*this))
-    , m_editor(std::make_unique<Editor>(*this))
-    , m_selection(std::make_unique<FrameSelection>(this))
-    , m_animationController(std::make_unique<CSSAnimationController>(*this))
+    , m_script(makeUniqueRef<ScriptController>(*this))
+    , m_editor(makeUniqueRef<Editor>(*this))
+    , m_selection(makeUniqueRef<FrameSelection>(this))
+    , m_animationController(makeUniqueRef<CSSAnimationController>(*this))
 #if PLATFORM(IOS)
     , m_overflowAutoScrollTimer(*this, &Frame::overflowAutoScrollTimerFired)
     , m_selectionChangeCallbacksDisabled(false)
@@ -168,7 +168,7 @@
     , m_pageZoomFactor(parentPageZoomFactor(this))
     , m_textZoomFactor(parentTextZoomFactor(this))
     , m_activeDOMObjectsAndAnimationsSuspendedCount(0)
-    , m_eventHandler(std::make_unique<EventHandler>(*this))
+    , m_eventHandler(makeUniqueRef<EventHandler>(*this))
 {
     AtomicString::init();
     HTMLNames::init();
@@ -251,9 +251,7 @@
     if (m_view)
         m_view->unscheduleRelayout();
     
-    // This may be called during destruction, so need to do a null check.
-    if (m_eventHandler)
-        m_eventHandler->clear();
+    m_eventHandler->clear();
 
     RELEASE_ASSERT(!m_doc || !m_doc->hasLivingRenderTree());
 
@@ -714,8 +712,7 @@
         if (script.injectionTime() == injectionTime && UserContentURLPattern::matchesPatterns(document->url(), script.whitelist(), script.blacklist())) {
             if (m_page)
                 m_page->setAsRunningUserScripts();
-            if (m_script)
-                m_script->evaluateInWorld(ScriptSourceCode(script.source(), script.url()), world);
+            m_script->evaluateInWorld(ScriptSourceCode(script.source(), script.url()), world);
         }
     });
 }

Modified: trunk/Source/WebCore/page/Frame.h (215871 => 215872)


--- trunk/Source/WebCore/page/Frame.h	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/page/Frame.h	2017-04-27 16:42:13 UTC (rev 215872)
@@ -34,8 +34,8 @@
 #include "NavigationScheduler.h"
 #include "ScrollTypes.h"
 #include "UserScriptTypes.h"
-#include <memory>
 #include <wtf/ThreadSafeRefCounted.h>
+#include <wtf/UniqueRef.h>
 
 #if PLATFORM(IOS)
 #include "ViewportArguments.h"
@@ -143,15 +143,19 @@
     Document* document() const;
     FrameView* view() const;
 
-    Editor& editor() const;
-    EventHandler& eventHandler() const;
-    EventHandler* eventHandlerPtr() const;
+    Editor& editor() { return m_editor; }
+    const Editor& editor() const { return m_editor; }
+    EventHandler& eventHandler() { return m_eventHandler; }
+    const EventHandler& eventHandler() const { return m_eventHandler; }
     FrameLoader& loader() const;
     NavigationScheduler& navigationScheduler() const;
-    FrameSelection& selection() const;
+    FrameSelection& selection() { return m_selection; }
+    const FrameSelection& selection() const { return m_selection; }
     FrameTree& tree() const;
-    CSSAnimationController& animation() const;
-    ScriptController& script();
+    CSSAnimationController& animation() { return m_animationController; }
+    const CSSAnimationController& animation() const { return m_animationController; }
+    ScriptController& script() { return m_script; }
+    const ScriptController& script() const { return m_script; }
     
     WEBCORE_EXPORT RenderView* contentRenderer() const; // Root of the render tree for the document contained in this frame.
     WEBCORE_EXPORT RenderWidget* ownerRenderer() const; // Renderer for the element that contains this frame.
@@ -241,8 +245,8 @@
 
     WEBCORE_EXPORT int preferredHeight() const;
     WEBCORE_EXPORT void updateLayout() const;
-    WEBCORE_EXPORT NSRect caretRect() const;
-    WEBCORE_EXPORT NSRect rectForScrollToVisible() const;
+    WEBCORE_EXPORT NSRect caretRect();
+    WEBCORE_EXPORT NSRect rectForScrollToVisible();
     WEBCORE_EXPORT unsigned formElementsCharacterCount() const;
 
     // This function is used by Legacy WebKit.
@@ -288,10 +292,10 @@
     RefPtr<FrameView> m_view;
     RefPtr<Document> m_doc;
 
-    const std::unique_ptr<ScriptController> m_script;
-    const std::unique_ptr<Editor> m_editor;
-    const std::unique_ptr<FrameSelection> m_selection;
-    const std::unique_ptr<CSSAnimationController> m_animationController;
+    UniqueRef<ScriptController> m_script;
+    UniqueRef<Editor> m_editor;
+    UniqueRef<FrameSelection> m_selection;
+    UniqueRef<CSSAnimationController> m_animationController;
 
 #if ENABLE(DATA_DETECTION)
     RetainPtr<NSArray> m_dataDetectionResults;
@@ -324,7 +328,7 @@
     bool m_documentIsBeingReplaced { false };
 
 protected:
-    std::unique_ptr<EventHandler> m_eventHandler;
+    UniqueRef<EventHandler> m_eventHandler;
 };
 
 inline void Frame::init()
@@ -347,31 +351,11 @@
     return m_view.get();
 }
 
-inline ScriptController& Frame::script()
-{
-    return *m_script;
-}
-
 inline Document* Frame::document() const
 {
     return m_doc.get();
 }
 
-inline FrameSelection& Frame::selection() const
-{
-    return *m_selection;
-}
-
-inline Editor& Frame::editor() const
-{
-    return *m_editor;
-}
-
-inline CSSAnimationController& Frame::animation() const
-{
-    return *m_animationController;
-}
-
 inline HTMLFrameOwnerElement* Frame::ownerElement() const
 {
     return m_ownerElement;
@@ -392,16 +376,6 @@
     m_page = nullptr;
 }
 
-inline EventHandler& Frame::eventHandler() const
-{
-    return *m_eventHandler;
-}
-
-inline EventHandler* Frame::eventHandlerPtr() const
-{
-    return m_eventHandler.get();
-}
-
 inline MainFrame& Frame::mainFrame() const
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!m_mainFrameWasDestroyed);

Modified: trunk/Source/WebCore/page/MainFrame.cpp (215871 => 215872)


--- trunk/Source/WebCore/page/MainFrame.cpp	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/page/MainFrame.cpp	2017-04-27 16:42:13 UTC (rev 215872)
@@ -59,7 +59,6 @@
 MainFrame::~MainFrame()
 {
     m_recentWheelEventDeltaFilter = nullptr;
-    m_eventHandler = nullptr;
 
     setMainFrameWasDestroyed();
 }

Modified: trunk/Source/WebCore/page/ios/FrameIOS.mm (215871 => 215872)


--- trunk/Source/WebCore/page/ios/FrameIOS.mm	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/page/ios/FrameIOS.mm	2017-04-27 16:42:13 UTC (rev 215872)
@@ -510,7 +510,7 @@
         view->adjustViewSize();
 }
 
-NSRect Frame::caretRect() const
+NSRect Frame::caretRect()
 {
     VisibleSelection visibleSelection = selection().selection();
     if (visibleSelection.isNone())
@@ -518,7 +518,7 @@
     return visibleSelection.isCaret() ? selection().absoluteCaretBounds() : VisiblePosition(visibleSelection.end()).absoluteCaretBounds();
 }
 
-NSRect Frame::rectForScrollToVisible() const
+NSRect Frame::rectForScrollToVisible()
 {
     VisibleSelection selection(this->selection().selection());
 

Modified: trunk/Source/WebCore/replay/UserInputBridge.cpp (215871 => 215872)


--- trunk/Source/WebCore/replay/UserInputBridge.cpp	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/replay/UserInputBridge.cpp	2017-04-27 16:42:13 UTC (rev 215872)
@@ -69,9 +69,9 @@
 #endif
 
 #if ENABLE(CONTEXT_MENUS)
-bool UserInputBridge::handleContextMenuEvent(const PlatformMouseEvent& mouseEvent, const Frame* frame, InputSource)
+bool UserInputBridge::handleContextMenuEvent(const PlatformMouseEvent& mouseEvent, Frame& frame, InputSource)
 {
-    return frame->eventHandler().sendContextMenuEvent(mouseEvent);
+    return frame.eventHandler().sendContextMenuEvent(mouseEvent);
 }
 #endif
 

Modified: trunk/Source/WebCore/replay/UserInputBridge.h (215871 => 215872)


--- trunk/Source/WebCore/replay/UserInputBridge.h	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebCore/replay/UserInputBridge.h	2017-04-27 16:42:13 UTC (rev 215872)
@@ -72,7 +72,7 @@
 
     // User input APIs.
 #if ENABLE(CONTEXT_MENUS)
-    WEBCORE_EXPORT bool handleContextMenuEvent(const PlatformMouseEvent&, const Frame*, InputSource source = InputSource::User);
+    WEBCORE_EXPORT bool handleContextMenuEvent(const PlatformMouseEvent&, Frame&, InputSource = InputSource::User);
 #endif
     WEBCORE_EXPORT bool handleMousePressEvent(const PlatformMouseEvent&, InputSource source = InputSource::User);
     WEBCORE_EXPORT bool handleMouseReleaseEvent(const PlatformMouseEvent&, InputSource source = InputSource::User);

Modified: trunk/Source/WebKit/mac/ChangeLog (215871 => 215872)


--- trunk/Source/WebKit/mac/ChangeLog	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebKit/mac/ChangeLog	2017-04-27 16:42:13 UTC (rev 215872)
@@ -1,3 +1,14 @@
+2017-04-27  Alex Christensen  <[email protected]>
+
+        Modernize Frame.h
+        https://bugs.webkit.org/show_bug.cgi?id=171357
+
+        Reviewed by Andy Estes.
+
+        * WebCoreSupport/WebEditorClient.h:
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::isSelectTrailingWhitespaceEnabled):
+
 2017-04-27  Wenson Hsieh  <[email protected]>
 
         [WK1] Tweak the data interaction SPI to indicate whether or not a data interaction was handled

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h (215871 => 215872)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h	2017-04-27 16:42:13 UTC (rev 215872)
@@ -58,7 +58,7 @@
     int spellCheckerDocumentTag() final;
 
     bool smartInsertDeleteEnabled() final;
-    bool isSelectTrailingWhitespaceEnabled() final;
+    bool isSelectTrailingWhitespaceEnabled() const final;
 
     bool shouldDeleteRange(WebCore::Range*) final;
 

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (215871 => 215872)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm	2017-04-27 16:42:13 UTC (rev 215872)
@@ -242,7 +242,7 @@
     return page->settings().smartInsertDeleteEnabled();
 }
 
-bool WebEditorClient::isSelectTrailingWhitespaceEnabled()
+bool WebEditorClient::isSelectTrailingWhitespaceEnabled() const
 {
     Page* page = [m_webView page];
     if (!page)

Modified: trunk/Source/WebKit/win/ChangeLog (215871 => 215872)


--- trunk/Source/WebKit/win/ChangeLog	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebKit/win/ChangeLog	2017-04-27 16:42:13 UTC (rev 215872)
@@ -1,3 +1,14 @@
+2017-04-27  Alex Christensen  <[email protected]>
+
+        Modernize Frame.h
+        https://bugs.webkit.org/show_bug.cgi?id=171357
+
+        Reviewed by Andy Estes.
+
+        * WebCoreSupport/WebEditorClient.cpp:
+        (WebEditorClient::isSelectTrailingWhitespaceEnabled):
+        * WebCoreSupport/WebEditorClient.h:
+
 2017-04-20  Fujii Hironori  <[email protected]>
 
         [WinCairo] Fix build break after updating ANGLE

Modified: trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp (215871 => 215872)


--- trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp	2017-04-27 16:42:13 UTC (rev 215872)
@@ -382,7 +382,7 @@
     return page->settings().smartInsertDeleteEnabled();
 }
 
-bool WebEditorClient::isSelectTrailingWhitespaceEnabled(void)
+bool WebEditorClient::isSelectTrailingWhitespaceEnabled(void) const
 {
     Page* page = m_webView->page();
     if (!page)

Modified: trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.h (215871 => 215872)


--- trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.h	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.h	2017-04-27 16:42:13 UTC (rev 215872)
@@ -70,7 +70,7 @@
     bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*) final;
 
     bool smartInsertDeleteEnabled() final;
-    bool isSelectTrailingWhitespaceEnabled() final;
+    bool isSelectTrailingWhitespaceEnabled() const final;
 
     void registerUndoStep(WebCore::UndoStep&) final;
     void registerRedoStep(WebCore::UndoStep&) final;

Modified: trunk/Source/WebKit2/ChangeLog (215871 => 215872)


--- trunk/Source/WebKit2/ChangeLog	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebKit2/ChangeLog	2017-04-27 16:42:13 UTC (rev 215872)
@@ -1,3 +1,27 @@
+2017-04-27  Alex Christensen  <[email protected]>
+
+        Modernize Frame.h
+        https://bugs.webkit.org/show_bug.cgi?id=171357
+
+        Reviewed by Andy Estes.
+
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+        (WebKit::WebEditorClient::isSelectTrailingWhitespaceEnabled):
+        * WebProcess/WebCoreSupport/WebEditorClient.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::contextMenuAtPointInWindow):
+        (WebKit::handleContextMenuEvent):
+        (WebKit::WebPage::isSelectTrailingWhitespaceEnabled):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::selectWithGesture):
+        (WebKit::WebPage::selectPositionAtPoint):
+        (WebKit::WebPage::selectPositionAtBoundaryWithDirection):
+        (WebKit::WebPage::rangeForGranularityAtPoint):
+        (WebKit::WebPage::selectTextWithGranularityAtPoint):
+        (WebKit::WebPage::updateSelectionWithExtentPointAndBoundary):
+        (WebKit::WebPage::updateSelectionWithExtentPoint):
+
 2017-04-27  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Remote inspector should support inspecting targets with previous version of backend commands

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp (215871 => 215872)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp	2017-04-27 16:42:13 UTC (rev 215872)
@@ -82,7 +82,7 @@
     return m_page->isSmartInsertDeleteEnabled();
 }
  
-bool WebEditorClient::isSelectTrailingWhitespaceEnabled()
+bool WebEditorClient::isSelectTrailingWhitespaceEnabled() const
 {
     return m_page->isSelectTrailingWhitespaceEnabled();
 }

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h (215871 => 215872)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h	2017-04-27 16:42:13 UTC (rev 215872)
@@ -42,7 +42,7 @@
 private:
     bool shouldDeleteRange(WebCore::Range*) final;
     bool smartInsertDeleteEnabled() final;
-    bool isSelectTrailingWhitespaceEnabled() final;
+    bool isSelectTrailingWhitespaceEnabled() const final;
     bool isContinuousSpellCheckingEnabled() final;
     void toggleContinuousSpellChecking() final;
     bool isGrammarCheckingEnabled() final;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (215871 => 215872)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2017-04-27 16:42:13 UTC (rev 215872)
@@ -2135,7 +2135,7 @@
     
     // Simulate a mouse click to generate the correct menu.
     PlatformMouseEvent mouseEvent(point, point, RightButton, PlatformEvent::MousePressed, 1, false, false, false, false, currentTime(), WebCore::ForceAtClick, WebCore::NoTap);
-    bool handled = corePage()->userInputBridge().handleContextMenuEvent(mouseEvent, &corePage()->mainFrame());
+    bool handled = corePage()->userInputBridge().handleContextMenuEvent(mouseEvent, corePage()->mainFrame());
     if (!handled)
         return 0;
 
@@ -2260,7 +2260,7 @@
     if (result.innerNonSharedNode())
         frame = result.innerNonSharedNode()->document().frame();
 
-    bool handled = page->corePage()->userInputBridge().handleContextMenuEvent(platformMouseEvent, frame);
+    bool handled = page->corePage()->userInputBridge().handleContextMenuEvent(platformMouseEvent, *frame);
     if (handled)
         page->contextMenu()->show();
 
@@ -5186,7 +5186,7 @@
     }
 }
 
-bool WebPage::isSelectTrailingWhitespaceEnabled()
+bool WebPage::isSelectTrailingWhitespaceEnabled() const
 {
     return m_page->settings().selectTrailingWhitespaceEnabled();
 }

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (215871 => 215872)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2017-04-27 16:42:13 UTC (rev 215872)
@@ -720,7 +720,7 @@
     bool isSmartInsertDeleteEnabled();
     void setSmartInsertDeleteEnabled(bool);
 
-    bool isSelectTrailingWhitespaceEnabled();
+    bool isSelectTrailingWhitespaceEnabled() const;
     void setSelectTrailingWhitespaceEnabled(bool);
 
     void replaceSelectionWithText(WebCore::Frame*, const String&);
@@ -1011,7 +1011,7 @@
     void sendTapHighlightForNodeIfNecessary(uint64_t requestID, WebCore::Node*);
     void resetTextAutosizing();
     WebCore::VisiblePosition visiblePositionInFocusedNodeForPoint(const WebCore::Frame&, const WebCore::IntPoint&, bool isInteractingWithAssistedNode);
-    RefPtr<WebCore::Range> rangeForGranularityAtPoint(const WebCore::Frame&, const WebCore::IntPoint&, uint32_t granularity, bool isInteractingWithAssistedNode);
+    RefPtr<WebCore::Range> rangeForGranularityAtPoint(WebCore::Frame&, const WebCore::IntPoint&, uint32_t granularity, bool isInteractingWithAssistedNode);
     bool shouldSwitchToBlockModeForHandle(const WebCore::IntPoint& handlePoint, SelectionHandlePosition);
     RefPtr<WebCore::Range> switchToBlockSelectionAtPoint(const WebCore::IntPoint&, SelectionHandlePosition);
 #if ENABLE(DATA_INTERACTION)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (215871 => 215872)


--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2017-04-27 16:03:52 UTC (rev 215871)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2017-04-27 16:42:13 UTC (rev 215872)
@@ -1040,7 +1040,7 @@
 
 void WebPage::selectWithGesture(const IntPoint& point, uint32_t granularity, uint32_t gestureType, uint32_t gestureState, bool isInteractingWithAssistedNode, uint64_t callbackID)
 {
-    const Frame& frame = m_page->focusController().focusedOrMainFrame();
+    auto& frame = m_page->focusController().focusedOrMainFrame();
     VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithAssistedNode);
 
     if (position.isNull()) {
@@ -1919,7 +1919,7 @@
 
 void WebPage::selectPositionAtPoint(const WebCore::IntPoint& point, bool isInteractingWithAssistedNode, uint64_t callbackID)
 {
-    const Frame& frame = m_page->focusController().focusedOrMainFrame();
+    auto& frame = m_page->focusController().focusedOrMainFrame();
     VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithAssistedNode);
     
     if (position.isNotNull())
@@ -1929,7 +1929,7 @@
 
 void WebPage::selectPositionAtBoundaryWithDirection(const WebCore::IntPoint& point, uint32_t granularity, uint32_t direction, bool isInteractingWithAssistedNode, uint64_t callbackID)
 {
-    const Frame& frame = m_page->focusController().focusedOrMainFrame();
+    auto& frame = m_page->focusController().focusedOrMainFrame();
     VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithAssistedNode);
 
     if (position.isNotNull()) {
@@ -1954,7 +1954,7 @@
     send(Messages::WebPageProxy::VoidCallback(callbackID));
 }
 
-RefPtr<Range> WebPage::rangeForGranularityAtPoint(const Frame& frame, const WebCore::IntPoint& point, uint32_t granularity, bool isInteractingWithAssistedNode)
+RefPtr<Range> WebPage::rangeForGranularityAtPoint(Frame& frame, const WebCore::IntPoint& point, uint32_t granularity, bool isInteractingWithAssistedNode)
 {
     VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithAssistedNode);
 
@@ -1986,7 +1986,7 @@
 
 void WebPage::selectTextWithGranularityAtPoint(const WebCore::IntPoint& point, uint32_t granularity, bool isInteractingWithAssistedNode, uint64_t callbackID)
 {
-    const Frame& frame = m_page->focusController().focusedOrMainFrame();
+    auto& frame = m_page->focusController().focusedOrMainFrame();
     RefPtr<Range> range = rangeForGranularityAtPoint(frame, point, granularity, isInteractingWithAssistedNode);
     if (!isInteractingWithAssistedNode) {
         m_blockSelectionDesiredSize.setWidth(blockSelectionStartWidth);
@@ -2019,7 +2019,7 @@
 
 void WebPage::updateSelectionWithExtentPointAndBoundary(const WebCore::IntPoint& point, uint32_t granularity, bool isInteractingWithAssistedNode, uint64_t callbackID)
 {
-    const Frame& frame = m_page->focusController().focusedOrMainFrame();
+    auto& frame = m_page->focusController().focusedOrMainFrame();
     VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithAssistedNode);
     RefPtr<Range> newRange = rangeForGranularityAtPoint(frame, point, granularity, isInteractingWithAssistedNode);
     
@@ -2048,7 +2048,7 @@
 
 void WebPage::updateSelectionWithExtentPoint(const WebCore::IntPoint& point, bool isInteractingWithAssistedNode, uint64_t callbackID)
 {
-    const Frame& frame = m_page->focusController().focusedOrMainFrame();
+    auto& frame = m_page->focusController().focusedOrMainFrame();
     VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithAssistedNode);
 
     if (position.isNull()) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to