OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 // No more reference to marked node. | 181 // No more reference to marked node. |
182 ThreadState::current()->collectAllGarbage(); | 182 ThreadState::current()->collectAllGarbage(); |
183 EXPECT_EQ(0u, markerController().markers().size()); | 183 EXPECT_EQ(0u, markerController().markers().size()); |
184 } | 184 } |
185 | 185 |
186 TEST_F(DocumentMarkerControllerTest, UpdateRenderedRects) { | 186 TEST_F(DocumentMarkerControllerTest, UpdateRenderedRects) { |
187 setBodyInnerHTML("<div style='margin: 100px'>foo</div>"); | 187 setBodyInnerHTML("<div style='margin: 100px'>foo</div>"); |
188 Element* div = toElement(document().body()->firstChild()); | 188 Element* div = toElement(document().body()->firstChild()); |
189 markNodeContents(div); | 189 markNodeContents(div); |
190 Vector<IntRect> renderedRects = | 190 Vector<IntRect> renderedRects = |
191 markerController().renderedRectsForMarkers(DocumentMarker::TextMatch); | 191 markerController().renderedRectsForTextMatchMarkers(); |
192 EXPECT_EQ(1u, renderedRects.size()); | 192 EXPECT_EQ(1u, renderedRects.size()); |
193 | 193 |
194 div->setAttribute(HTMLNames::styleAttr, "margin: 200px"); | 194 div->setAttribute(HTMLNames::styleAttr, "margin: 200px"); |
195 document().updateStyleAndLayout(); | 195 document().updateStyleAndLayout(); |
196 Vector<IntRect> newRenderedRects = | 196 Vector<IntRect> newRenderedRects = |
197 markerController().renderedRectsForMarkers(DocumentMarker::TextMatch); | 197 markerController().renderedRectsForTextMatchMarkers(); |
198 EXPECT_EQ(1u, newRenderedRects.size()); | 198 EXPECT_EQ(1u, newRenderedRects.size()); |
199 EXPECT_NE(renderedRects[0], newRenderedRects[0]); | 199 EXPECT_NE(renderedRects[0], newRenderedRects[0]); |
200 } | 200 } |
201 | 201 |
202 TEST_F(DocumentMarkerControllerTest, CompositionMarkersNotMerged) { | 202 TEST_F(DocumentMarkerControllerTest, CompositionMarkersNotMerged) { |
203 setBodyInnerHTML("<div style='margin: 100px'>foo</div>"); | 203 setBodyInnerHTML("<div style='margin: 100px'>foo</div>"); |
204 Node* text = document().body()->firstChild()->firstChild(); | 204 Node* text = document().body()->firstChild()->firstChild(); |
205 document().updateStyleAndLayout(); | 205 document().updateStyleAndLayout(); |
206 markerController().addCompositionMarker(Position(text, 0), Position(text, 1), | 206 markerController().addCompositionMarker(Position(text, 0), Position(text, 1), |
207 Color::black, false, Color::black); | 207 Color::black, false, Color::black); |
208 markerController().addCompositionMarker(Position(text, 1), Position(text, 3), | 208 markerController().addCompositionMarker(Position(text, 1), Position(text, 3), |
209 Color::black, true, Color::black); | 209 Color::black, true, Color::black); |
210 | 210 |
211 EXPECT_EQ(2u, markerController().markers().size()); | 211 EXPECT_EQ(2u, markerController().markers().size()); |
212 } | 212 } |
213 | 213 |
214 TEST_F(DocumentMarkerControllerTest, SetMarkerActiveTest) { | 214 TEST_F(DocumentMarkerControllerTest, SetMarkerActiveTest) { |
215 setBodyInnerHTML("<b>foo</b>"); | 215 setBodyInnerHTML("<b>foo</b>"); |
216 document().updateStyleAndLayout(); | 216 document().updateStyleAndLayout(); |
217 Element* bElement = toElement(document().body()->firstChild()); | 217 Element* bElement = toElement(document().body()->firstChild()); |
218 EphemeralRange ephemeralRange = EphemeralRange::rangeOfContents(*bElement); | 218 EphemeralRange ephemeralRange = EphemeralRange::rangeOfContents(*bElement); |
219 Position startBElement = toPositionInDOMTree(ephemeralRange.startPosition()); | 219 Position startBElement = toPositionInDOMTree(ephemeralRange.startPosition()); |
220 Position endBElement = toPositionInDOMTree(ephemeralRange.endPosition()); | 220 Position endBElement = toPositionInDOMTree(ephemeralRange.endPosition()); |
221 const EphemeralRange range(startBElement, endBElement); | 221 const EphemeralRange range(startBElement, endBElement); |
222 // Try to make active a marker that doesn't exist. | 222 // Try to make active a marker that doesn't exist. |
223 EXPECT_FALSE(markerController().setMarkersActive(range, true)); | 223 EXPECT_FALSE(markerController().setTextMatchMarkersActive(range, true)); |
224 | 224 |
225 // Add a marker and try it once more. | 225 // Add a marker and try it once more. |
226 markerController().addTextMatchMarker(range, false); | 226 markerController().addTextMatchMarker(range, false); |
227 EXPECT_EQ(1u, markerController().markers().size()); | 227 EXPECT_EQ(1u, markerController().markers().size()); |
228 EXPECT_TRUE(markerController().setMarkersActive(range, true)); | 228 EXPECT_TRUE(markerController().setTextMatchMarkersActive(range, true)); |
229 } | 229 } |
230 | 230 |
231 } // namespace blink | 231 } // namespace blink |
OLD | NEW |