Text markers don't paint on simple lines
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 May 2014 13:05:20 +0000 (13:05 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 May 2014 13:05:20 +0000 (13:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=133177

Reviewed by Anders Carlsson.

Source/WebCore:

Marker painting code does not yet support simple lines.

Tests: fast/text/mark-matches-rendering-simple-lines.html
       fast/text/mark-matches-rendering.html

* dom/DocumentMarkerController.cpp:
(WebCore::DocumentMarkerController::addMarker):

    Force text blocks with markers to use line boxes.

* testing/Internals.cpp:
(WebCore::Internals::setMarkedTextMatchesAreHighlighted):

    Expose this so we can make reftests for marker rendering.

* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* fast/text/mark-matches-rendering-expected.html: Added.
* fast/text/mark-matches-rendering-simple-lines-expected.html: Added.
* fast/text/mark-matches-rendering-simple-lines.html: Added.
* fast/text/mark-matches-rendering.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/text/mark-matches-rendering-expected.html [new file with mode: 0644]
LayoutTests/fast/text/mark-matches-rendering-simple-lines-expected.html [new file with mode: 0644]
LayoutTests/fast/text/mark-matches-rendering-simple-lines.html [new file with mode: 0644]
LayoutTests/fast/text/mark-matches-rendering.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/DocumentMarkerController.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl

index ab62e4e..a7594c8 100644 (file)
@@ -1,3 +1,15 @@
+2014-05-22  Antti Koivisto  <antti@apple.com>
+
+        Text markers don't paint on simple lines
+        https://bugs.webkit.org/show_bug.cgi?id=133177
+
+        Reviewed by Anders Carlsson.
+
+        * fast/text/mark-matches-rendering-expected.html: Added.
+        * fast/text/mark-matches-rendering-simple-lines-expected.html: Added.
+        * fast/text/mark-matches-rendering-simple-lines.html: Added.
+        * fast/text/mark-matches-rendering.html: Added.
+
 2014-05-22  Javier Fernandez  <jfernandez@igalia.com>
 
         [CSS Grid Layout] Split the grid-item-margin-auto-columns-rows.html test.
diff --git a/LayoutTests/fast/text/mark-matches-rendering-expected.html b/LayoutTests/fast/text/mark-matches-rendering-expected.html
new file mode 100644 (file)
index 0000000..637ff33
--- /dev/null
@@ -0,0 +1,3 @@
+<p style="display:inline-block; background-color:yellow">
+Quo usque tandem abutere, Catilina, patientia nostra?
+</p>
diff --git a/LayoutTests/fast/text/mark-matches-rendering-simple-lines-expected.html b/LayoutTests/fast/text/mark-matches-rendering-simple-lines-expected.html
new file mode 100644 (file)
index 0000000..945344d
--- /dev/null
@@ -0,0 +1,13 @@
+<script>
+if (window.internals)
+    internals.settings.setSimpleLineLayoutEnabled(false);
+</script>
+<p>
+Quo usque tandem abutere, Catilina, patientia nostra?
+</p>
+<script>
+if (window.internals) {
+    internals.setMarkedTextMatchesAreHighlighted(true);
+    internals.countMatchesForText("ti", 0, "mark");
+}
+</script>
diff --git a/LayoutTests/fast/text/mark-matches-rendering-simple-lines.html b/LayoutTests/fast/text/mark-matches-rendering-simple-lines.html
new file mode 100644 (file)
index 0000000..cf3d2c9
--- /dev/null
@@ -0,0 +1,9 @@
+<p>
+Quo usque tandem abutere, Catilina, patientia nostra?
+</p>
+<script>
+if (window.internals) {
+    internals.setMarkedTextMatchesAreHighlighted(true);
+    internals.countMatchesForText("ti", 0, "mark");
+}
+</script>
diff --git a/LayoutTests/fast/text/mark-matches-rendering.html b/LayoutTests/fast/text/mark-matches-rendering.html
new file mode 100644 (file)
index 0000000..291dd84
--- /dev/null
@@ -0,0 +1,9 @@
+<p style="display:inline-block; background-color:red">
+Quo usque tandem abutere, Catilina, patientia nostra?
+</p>
+<script>
+if (window.internals) {
+    internals.setMarkedTextMatchesAreHighlighted(true);
+    internals.countMatchesForText("Quo usque tandem abutere, Catilina, patientia nostra?", 0, "mark");
+}
+</script>
index 0945ab5..810ba02 100644 (file)
@@ -1,3 +1,28 @@
+2014-05-22  Antti Koivisto  <antti@apple.com>
+
+        Text markers don't paint on simple lines
+        https://bugs.webkit.org/show_bug.cgi?id=133177
+
+        Reviewed by Anders Carlsson.
+        
+        Marker painting code does not yet support simple lines.
+
+        Tests: fast/text/mark-matches-rendering-simple-lines.html
+               fast/text/mark-matches-rendering.html
+
+        * dom/DocumentMarkerController.cpp:
+        (WebCore::DocumentMarkerController::addMarker):
+        
+            Force text blocks with markers to use line boxes.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::setMarkedTextMatchesAreHighlighted):
+        
+            Expose this so we can make reftests for marker rendering.
+
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2014-05-22  Manuel Rego Casasnovas  <rego@igalia.com>
 
         [CSS Grid Layout] Guard RenderObject::isRenderGrid() method
index c7d69c3..4748165 100644 (file)
@@ -29,7 +29,8 @@
 
 #include "NodeTraversal.h"
 #include "Range.h"
-#include "RenderObject.h"
+#include "RenderBlockFlow.h"
+#include "RenderText.h"
 #include "RenderedDocumentMarker.h"
 #include "TextIterator.h"
 #include <stdio.h>
@@ -166,6 +167,14 @@ void DocumentMarkerController::addMarker(Node* node, const DocumentMarker& newMa
     if (newMarker.endOffset() == newMarker.startOffset())
         return;
 
+    if (auto* renderer = node->renderer()) {
+        // FIXME: Factor the marker painting code out of InlineTextBox and teach simple line layout to use it.
+        if (renderer->isText())
+            toRenderText(*renderer).ensureLineBoxes();
+        else if (renderer->isRenderBlockFlow())
+            toRenderBlockFlow(*renderer).ensureLineBoxes();
+    }
+
     m_possiblyExistingMarkerTypes.add(newMarker.type());
 
     std::unique_ptr<MarkerList>& list = m_markers.add(node, nullptr).iterator->value;
index e0be09c..de856c8 100644 (file)
@@ -801,6 +801,16 @@ void Internals::addTextMatchMarker(const Range* range, bool isActive)
     range->ownerDocument().markers().addTextMatchMarker(range, isActive);
 }
 
+void Internals::setMarkedTextMatchesAreHighlighted(bool flag, ExceptionCode& ec)
+{
+    Document* document = contextDocument();
+    if (!document || !document->frame()) {
+        ec = INVALID_ACCESS_ERR;
+        return;
+    }
+    document->frame()->editor().setMarkedTextMatchesAreHighlighted(flag);
+}
+
 void Internals::setScrollViewPosition(long x, long y, ExceptionCode& ec)
 {
     Document* document = contextDocument();
index 255c4a1..639e275 100644 (file)
@@ -130,6 +130,7 @@ public:
     PassRefPtr<Range> markerRangeForNode(Node*, const String& markerType, unsigned index, ExceptionCode&);
     String markerDescriptionForNode(Node*, const String& markerType, unsigned index, ExceptionCode&);
     void addTextMatchMarker(const Range*, bool isActive);
+    void setMarkedTextMatchesAreHighlighted(bool, ExceptionCode&);
 
     void setScrollViewPosition(long x, long y, ExceptionCode&);
     void setPagination(const String& mode, int gap, ExceptionCode& ec) { setPagination(mode, gap, 0, ec); }
index 9562a6d..259e518 100644 (file)
@@ -81,6 +81,7 @@
     [RaisesException] Range markerRangeForNode(Node node, DOMString markerType, unsigned long index);
     [RaisesException] DOMString markerDescriptionForNode(Node node, DOMString markerType, unsigned long index);
     void addTextMatchMarker(Range range, boolean isActive);
+    [RaisesException] void setMarkedTextMatchesAreHighlighted(boolean flag);
 
     [RaisesException] void setScrollViewPosition(long x, long y);