Add logging for EditorState in RemoteLayerTree transactions
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Dec 2017 00:15:29 +0000 (00:15 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Dec 2017 00:15:29 +0000 (00:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180515

Reviewed by Wenson Hsieh.

Make EditorState TextStream-able, and dump it in layer tree transactions.

* Shared/EditorState.cpp:
(WebKit::operator<<):
* Shared/EditorState.h:
* Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::description const):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225651 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/Shared/EditorState.cpp
Source/WebKit/Shared/EditorState.h
Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm

index 3a60c09..2ec7b55 100644 (file)
@@ -1,3 +1,18 @@
+2017-12-07  Simon Fraser  <simon.fraser@apple.com>
+
+        Add logging for EditorState in RemoteLayerTree transactions
+        https://bugs.webkit.org/show_bug.cgi?id=180515
+
+        Reviewed by Wenson Hsieh.
+       
+        Make EditorState TextStream-able, and dump it in layer tree transactions.
+
+        * Shared/EditorState.cpp:
+        (WebKit::operator<<):
+        * Shared/EditorState.h:
+        * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::description const):
+
 2017-12-07  Youenn Fablet  <youenn@apple.com>
 
         CacheStorage Cache should not remove any disk entry when clearing its memory representation
index 400d833..02ca367 100644 (file)
@@ -27,6 +27,9 @@
 #include "EditorState.h"
 
 #include "WebCoreArgumentCoders.h"
+#include <wtf/text/TextStream.h>
+
+using namespace WebCore;
 
 namespace WebKit {
 
@@ -202,4 +205,100 @@ bool EditorState::PostLayoutData::decode(IPC::Decoder& decoder, PostLayoutData&
     return true;
 }
 
+TextStream& operator<<(TextStream& ts, const EditorState& editorState)
+{
+#if PLATFORM(IOS)
+    if (editorState.firstMarkedRect != IntRect())
+        ts.dumpProperty("firstMarkedRect", editorState.firstMarkedRect);
+    if (editorState.lastMarkedRect != IntRect())
+        ts.dumpProperty("lastMarkedRect", editorState.lastMarkedRect);
+    if (editorState.markedText.length())
+        ts.dumpProperty("markedText", editorState.markedText);
+#endif
+
+    if (editorState.shouldIgnoreSelectionChanges)
+        ts.dumpProperty("shouldIgnoreSelectionChanges", editorState.shouldIgnoreSelectionChanges);
+    if (!editorState.selectionIsNone)
+        ts.dumpProperty("selectionIsNone", editorState.selectionIsNone);
+    if (editorState.selectionIsRange)
+        ts.dumpProperty("selectionIsRange", editorState.selectionIsRange);
+    if (editorState.isContentEditable)
+        ts.dumpProperty("isContentEditable", editorState.isContentEditable);
+    if (editorState.isContentRichlyEditable)
+        ts.dumpProperty("isContentRichlyEditable", editorState.isContentRichlyEditable);
+    if (editorState.isInPasswordField)
+        ts.dumpProperty("isInPasswordField", editorState.isInPasswordField);
+    if (editorState.isInPlugin)
+        ts.dumpProperty("isInPlugin", editorState.isInPlugin);
+    if (editorState.hasComposition)
+        ts.dumpProperty("hasComposition", editorState.hasComposition);
+    if (editorState.isMissingPostLayoutData)
+        ts.dumpProperty("isMissingPostLayoutData", editorState.isMissingPostLayoutData);
+
+    if (editorState.isMissingPostLayoutData)
+        return ts;
+
+    TextStream::GroupScope scope(ts);
+    ts << "postLayoutData";
+    if (editorState.postLayoutData().typingAttributes != AttributeNone)
+        ts.dumpProperty("typingAttributes", editorState.postLayoutData().typingAttributes);
+#if PLATFORM(IOS) || PLATFORM(GTK)
+    if (editorState.postLayoutData().caretRectAtStart != IntRect())
+        ts.dumpProperty("caretRectAtStart", editorState.postLayoutData().caretRectAtStart);
+#endif
+#if PLATFORM(IOS) || PLATFORM(MAC)
+    if (editorState.postLayoutData().selectionClipRect != IntRect())
+        ts.dumpProperty("selectionClipRect", editorState.postLayoutData().selectionClipRect);
+    if (editorState.postLayoutData().selectedTextLength)
+        ts.dumpProperty("selectedTextLength", editorState.postLayoutData().selectedTextLength);
+    if (editorState.postLayoutData().textAlignment != NoAlignment)
+        ts.dumpProperty("textAlignment", editorState.postLayoutData().textAlignment);
+    if (editorState.postLayoutData().textColor.isValid())
+        ts.dumpProperty("textColor", editorState.postLayoutData().textColor);
+    if (editorState.postLayoutData().enclosingListType != NoList)
+        ts.dumpProperty("enclosingListType", editorState.postLayoutData().enclosingListType);
+#endif
+#if PLATFORM(IOS)
+    if (editorState.postLayoutData().caretRectAtEnd != IntRect())
+        ts.dumpProperty("caretRectAtEnd", editorState.postLayoutData().caretRectAtEnd);
+    if (editorState.postLayoutData().selectionRects.size())
+        ts.dumpProperty("selectionRects", editorState.postLayoutData().selectionRects);
+    if (editorState.postLayoutData().wordAtSelection.length())
+        ts.dumpProperty("wordAtSelection", editorState.postLayoutData().wordAtSelection);
+    if (editorState.postLayoutData().characterAfterSelection)
+        ts.dumpProperty("characterAfterSelection", editorState.postLayoutData().characterAfterSelection);
+    if (editorState.postLayoutData().characterBeforeSelection)
+        ts.dumpProperty("characterBeforeSelection", editorState.postLayoutData().characterBeforeSelection);
+    if (editorState.postLayoutData().twoCharacterBeforeSelection)
+        ts.dumpProperty("twoCharacterBeforeSelection", editorState.postLayoutData().twoCharacterBeforeSelection);
+
+    if (editorState.postLayoutData().isReplaceAllowed)
+        ts.dumpProperty("isReplaceAllowed", editorState.postLayoutData().isReplaceAllowed);
+    if (editorState.postLayoutData().hasContent)
+        ts.dumpProperty("hasContent", editorState.postLayoutData().hasContent);
+    ts.dumpProperty("isStableStateUpdate", editorState.postLayoutData().isStableStateUpdate);
+    if (editorState.postLayoutData().insideFixedPosition)
+        ts.dumpProperty("insideFixedPosition", editorState.postLayoutData().insideFixedPosition);
+    if (editorState.postLayoutData().caretColor.isValid())
+        ts.dumpProperty("caretColor", editorState.postLayoutData().caretColor);
+#endif
+#if PLATFORM(MAC)
+    if (editorState.postLayoutData().candidateRequestStartPosition)
+        ts.dumpProperty("candidateRequestStartPosition", editorState.postLayoutData().candidateRequestStartPosition);
+    if (editorState.postLayoutData().paragraphContextForCandidateRequest.length())
+        ts.dumpProperty("paragraphContextForCandidateRequest", editorState.postLayoutData().paragraphContextForCandidateRequest);
+    if (editorState.postLayoutData().stringForCandidateRequest.length())
+        ts.dumpProperty("stringForCandidateRequest", editorState.postLayoutData().stringForCandidateRequest);
+#endif
+
+    if (editorState.postLayoutData().canCut)
+        ts.dumpProperty("canCut", editorState.postLayoutData().canCut);
+    if (editorState.postLayoutData().canCopy)
+        ts.dumpProperty("canCopy", editorState.postLayoutData().canCopy);
+    if (editorState.postLayoutData().canPaste)
+        ts.dumpProperty("canPaste", editorState.postLayoutData().canPaste);
+
+    return ts;
 }
+
+} // namespace WebKit
index dc0c183..a2173a4 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef EditorState_h
-#define EditorState_h
+#pragma once
 
 #include "ArgumentCoders.h"
 #include <WebCore/Color.h>
 #include <WebCore/SelectionRect.h>
 #endif
 
+namespace WTF {
+class TextStream;
+};
+
 namespace WebKit {
 
 enum TypingAttributes {
@@ -139,6 +142,6 @@ inline auto EditorState::postLayoutData() const -> const PostLayoutData&
     return m_postLayoutData;
 }
 
-}
+WTF::TextStream& operator<<(WTF::TextStream&, const EditorState&);
 
-#endif // EditorState_h
+} // namespace WebKit
index 6c92f00..caf72df 100644 (file)
@@ -905,8 +905,7 @@ CString RemoteLayerTreeTransaction::description() const
     ts.dumpProperty("avoidsUnsafeArea", m_avoidsUnsafeArea);
     ts.dumpProperty("isInStableState", m_isInStableState);
     ts.dumpProperty("renderTreeSize", m_renderTreeSize);
-
-    ts << "root-layer " << m_rootLayerID << ")";
+    ts.dumpProperty("root-layer", m_rootLayerID);
 
     if (!m_createdLayers.isEmpty()) {
         TextStream::GroupScope group(ts);
@@ -935,6 +934,12 @@ CString RemoteLayerTreeTransaction::description() const
     if (!m_destroyedLayerIDs.isEmpty())
         ts.dumpProperty<Vector<GraphicsLayer::PlatformLayerID>>("destroyed-layers", m_destroyedLayerIDs);
 
+    if (m_editorState) {
+        TextStream::GroupScope scope(ts);
+        ts << "EditorState";
+        ts << *m_editorState;
+    }
+
     ts.endGroup();
 
     return ts.release().utf8();