Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: third_party/WebKit/Source/core/dom/Range.cpp

Issue 1409073004: Return EphemeralRange from Editor::findRangeOfString. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Extract text bounds collecting to a function Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no)
4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no)
5 * (C) 2001 Peter Kelly (pmk@post.com) 5 * (C) 2001 Peter Kelly (pmk@post.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 IntRect result; 1293 IntRect result;
1294 Vector<IntRect> rects; 1294 Vector<IntRect> rects;
1295 textRects(rects); 1295 textRects(rects);
1296 for (const IntRect& rect : rects) 1296 for (const IntRect& rect : rects)
1297 result.unite(rect); 1297 result.unite(rect);
1298 return result; 1298 return result;
1299 } 1299 }
1300 1300
1301 void Range::textRects(Vector<IntRect>& rects, bool useSelectionHeight, RangeInFi xedPosition* inFixed) const 1301 void Range::textRects(Vector<IntRect>& rects, bool useSelectionHeight, RangeInFi xedPosition* inFixed) const
1302 { 1302 {
1303 Node* startContainer = m_start.container();
1304 ASSERT(startContainer);
1305 Node* endContainer = m_end.container();
1306 ASSERT(endContainer);
1307
1308 bool allFixed = true; 1303 bool allFixed = true;
1309 bool someFixed = false; 1304 bool someFixed = false;
1310 1305 collectTextBoundsInRange(
1311 Node* stopNode = pastLastNode(); 1306 m_start.container(), m_start.offset(), m_end.container(), m_end.offset() ,
1312 for (Node* node = firstNode(); node != stopNode; node = NodeTraversal::next( *node)) { 1307 firstNode(), pastLastNode(), &NodeTraversal::next,
1313 LayoutObject* r = node->layoutObject(); 1308 rects, useSelectionHeight, &allFixed, &someFixed);
1314 if (!r || !r->isText())
1315 continue;
1316 LayoutText* layoutText = toLayoutText(r);
1317 int startOffset = node == startContainer ? m_start.offset() : 0;
1318 int endOffset = node == endContainer ? m_end.offset() : std::numeric_lim its<int>::max();
1319 bool isFixed = false;
1320 layoutText->absoluteRectsForRange(rects, startOffset, endOffset, useSele ctionHeight, &isFixed);
1321 allFixed &= isFixed;
1322 someFixed |= isFixed;
1323 }
1324 1309
1325 if (inFixed) 1310 if (inFixed)
1326 *inFixed = allFixed ? EntirelyFixedPosition : (someFixed ? PartiallyFixe dPosition : NotFixedPosition); 1311 *inFixed = allFixed ? EntirelyFixedPosition : (someFixed ? PartiallyFixe dPosition : NotFixedPosition);
1327 } 1312 }
1328 1313
1329 void Range::textQuads(Vector<FloatQuad>& quads, bool useSelectionHeight, RangeIn FixedPosition* inFixed) const 1314 void Range::textQuads(Vector<FloatQuad>& quads, bool useSelectionHeight, RangeIn FixedPosition* inFixed) const
1330 { 1315 {
1331 Node* startContainer = m_start.container();
1332 ASSERT(startContainer);
1333 Node* endContainer = m_end.container();
1334 ASSERT(endContainer);
1335
1336 bool allFixed = true; 1316 bool allFixed = true;
1337 bool someFixed = false; 1317 bool someFixed = false;
1338 1318 collectTextBoundsInRange(
1339 Node* stopNode = pastLastNode(); 1319 m_start.container(), m_start.offset(), m_end.container(), m_end.offset() ,
1340 for (Node* node = firstNode(); node != stopNode; node = NodeTraversal::next( *node)) { 1320 firstNode(), pastLastNode(), &NodeTraversal::next,
1341 LayoutObject* r = node->layoutObject(); 1321 quads, useSelectionHeight, &allFixed, &someFixed);
1342 if (!r || !r->isText())
1343 continue;
1344 LayoutText* layoutText = toLayoutText(r);
1345 int startOffset = node == startContainer ? m_start.offset() : 0;
1346 int endOffset = node == endContainer ? m_end.offset() : std::numeric_lim its<int>::max();
1347 bool isFixed = false;
1348 layoutText->absoluteQuadsForRange(quads, startOffset, endOffset, useSele ctionHeight, &isFixed);
1349 allFixed &= isFixed;
1350 someFixed |= isFixed;
1351 }
1352 1322
1353 if (inFixed) 1323 if (inFixed)
1354 *inFixed = allFixed ? EntirelyFixedPosition : (someFixed ? PartiallyFixe dPosition : NotFixedPosition); 1324 *inFixed = allFixed ? EntirelyFixedPosition : (someFixed ? PartiallyFixe dPosition : NotFixedPosition);
1355 } 1325 }
1356 1326
1357 #ifndef NDEBUG 1327 #ifndef NDEBUG
1358 void Range::formatForDebugger(char* buffer, unsigned length) const 1328 void Range::formatForDebugger(char* buffer, unsigned length) const
1359 { 1329 {
1360 StringBuilder result; 1330 StringBuilder result;
1361 1331
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 { 1621 {
1652 if (range && range->boundaryPointsValid()) { 1622 if (range && range->boundaryPointsValid()) {
1653 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); 1623 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E");
1654 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); 1624 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset());
1655 } else { 1625 } else {
1656 fprintf(stderr, "Cannot show tree if range is null, or if boundary point s are invalid.\n"); 1626 fprintf(stderr, "Cannot show tree if range is null, or if boundary point s are invalid.\n");
1657 } 1627 }
1658 } 1628 }
1659 1629
1660 #endif 1630 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698