Title: [179902] branches/safari-600.1.4.15-branch/Source/WebKit2

Diff

Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog (179901 => 179902)


--- branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog	2015-02-11 00:13:51 UTC (rev 179901)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog	2015-02-11 00:16:50 UTC (rev 179902)
@@ -1,3 +1,42 @@
+2015-02-10  Babak Shafiei  <[email protected]>
+
+        Merge r179578.
+
+    2015-02-03  Joseph Pecoraro  <[email protected]>
+
+            [iOS] Selection Callout should not immediately disappear on pages with frequent layouts
+            https://bugs.webkit.org/show_bug.cgi?id=141210
+
+            Reviewed by Enrica Casucci.
+
+            In iOS WebKit2 in order to keep caret refreshes in sync with WebCore layouts
+            the selection assistant is told to update whenever WebKit's layer tree
+            commits. Unfortunately, for pages with _javascript_ animation that are
+            frequently doing a layout / layer tree update, this would trigger very
+            frequent selection updates that would keep the caret from blinking and
+            dismiss any selection callouts.
+
+            This change tracks the last selection drawing information so that we can
+            avoid informing the assistant of a selection updates unless it has changed
+            visually or needs to redraw (zoom).
+
+            * Shared/EditorState.cpp:
+            Remove include already in header.
+
+            * UIProcess/ios/WKContentViewInteraction.h:
+            * UIProcess/ios/WKContentViewInteraction.mm:
+            (WebKit::WKSelectionDrawingInfo::WKSelectionDrawingInfo):
+            (WebKit::operator==):
+            (WebKit::operator!=):
+            (-[WKContentView observeValueForKeyPath:ofObject:change:context:]):
+            When zooming, force the selection update, even though the drawing
+            information hasn't changed, the views will need to be updated.
+
+            (-[WKContentView _updateChangedSelection]):
+            (-[WKContentView _updateChangedSelection:]):
+            Monitor EditorState for changes in selection drawing and avoid
+            informing the selection assistant unless necessary.
+
 2015-01-28  David Kilzer  <[email protected]>
 
         run-webkit-tests: Merge 46 commits from trunk to make it work

Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/Shared/EditorState.cpp (179901 => 179902)


--- branches/safari-600.1.4.15-branch/Source/WebKit2/Shared/EditorState.cpp	2015-02-11 00:13:51 UTC (rev 179901)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/Shared/EditorState.cpp	2015-02-11 00:16:50 UTC (rev 179902)
@@ -29,10 +29,6 @@
 #include "Arguments.h"
 #include "WebCoreArgumentCoders.h"
 
-#if PLATFORM(IOS)
-#include <WebCore/SelectionRect.h>
-#endif
-
 namespace WebKit {
 
 void EditorState::encode(IPC::ArgumentEncoder& encoder) const

Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (179901 => 179902)


--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2015-02-11 00:13:51 UTC (rev 179901)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2015-02-11 00:16:50 UTC (rev 179902)
@@ -28,6 +28,7 @@
 #import "WKContentView.h"
 
 #import "AssistedNodeInformation.h"
+#import "EditorState.h"
 #import "GestureTypes.h"
 #import "InteractionInformationAtPosition.h"
 #import "WKActionSheetAssistant.h"
@@ -73,6 +74,14 @@
 typedef void (^UIWKDictationContextHandler)(NSString *selectedText, NSString *beforeText, NSString *afterText);
 
 namespace WebKit {
+struct WKSelectionDrawingInfo {
+    enum class SelectionType { None, Plugin, Range };
+    WKSelectionDrawingInfo();
+    explicit WKSelectionDrawingInfo(const EditorState&);
+    SelectionType type;
+    WebCore::IntRect caretRect;
+    Vector<WebCore::SelectionRect> selectionRects;
+};
 struct WKAutoCorrectionData {
     String fontName;
     CGFloat fontSize;
@@ -131,6 +140,8 @@
 
     CGPoint _lastInteractionLocation;
 
+    WebKit::WKSelectionDrawingInfo _lastSelectionDrawingInfo;
+
     BOOL _isEditable;
     BOOL _showingTextStyleOptions;
     BOOL _hasValidPositionInformation;

Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (179901 => 179902)


--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2015-02-11 00:13:51 UTC (rev 179901)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2015-02-11 00:16:50 UTC (rev 179902)
@@ -82,6 +82,58 @@
 using namespace WebCore;
 using namespace WebKit;
 
+namespace WebKit {
+
+WKSelectionDrawingInfo::WKSelectionDrawingInfo()
+    : type(SelectionType::None)
+{
+}
+
+WKSelectionDrawingInfo::WKSelectionDrawingInfo(const EditorState& editorState)
+{
+    if (editorState.selectionIsNone) {
+        type = SelectionType::None;
+        return;
+    }
+
+    if (editorState.isInPlugin) {
+        type = SelectionType::Plugin;
+        return;
+    }
+
+    type = SelectionType::Range;
+    caretRect = editorState.caretRectAtEnd;
+    selectionRects = editorState.selectionRects;
+}
+
+inline bool operator==(const WKSelectionDrawingInfo& a, const WKSelectionDrawingInfo& b)
+{
+    if (a.type != b.type)
+        return false;
+
+    if (a.type == WKSelectionDrawingInfo::SelectionType::Range) {
+        if (a.caretRect != b.caretRect)
+            return false;
+
+        if (a.selectionRects.size() != b.selectionRects.size())
+            return false;
+
+        for (unsigned i = 0; i < a.selectionRects.size(); ++i) {
+            if (a.selectionRects[i].rect() != b.selectionRects[i].rect())
+                return false;
+        }
+    }
+
+    return true;
+}
+
+inline bool operator!=(const WKSelectionDrawingInfo& a, const WKSelectionDrawingInfo& b)
+{
+    return !(a == b);
+}
+
+} // namespace WebKit
+
 static const float highlightDelay = 0.12;
 static const float tapAndHoldDelay  = 0.75;
 const CGFloat minimumTapHighlightRadius = 2.0;
@@ -391,7 +443,7 @@
     }
 
     _selectionNeedsUpdate = YES;
-    [self _updateChangedSelection];
+    [self _updateChangedSelection:YES];
     [self _updateTapHighlight];
 }
 
@@ -2659,9 +2711,20 @@
 
 - (void)_updateChangedSelection
 {
+    [self _updateChangedSelection:NO];
+}
+
+- (void)_updateChangedSelection:(BOOL)force
+{
     if (!_selectionNeedsUpdate)
         return;
 
+    WKSelectionDrawingInfo selectionDrawingInfo(_page->editorState());
+    if (!force && selectionDrawingInfo == _lastSelectionDrawingInfo)
+        return;
+
+    _lastSelectionDrawingInfo = selectionDrawingInfo;
+
     // FIXME: We need to figure out what to do if the selection is changed by _javascript_.
     if (_textSelectionAssistant) {
         _markedText = (_page->editorState().hasComposition) ? _page->editorState().markedText : String();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to