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

Side by Side Diff: third_party/WebKit/Source/core/editing/EditingUtilities.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 1255
1256 // Check that the table cell contains no child layoutObjects except for perh aps a single <br>. 1256 // Check that the table cell contains no child layoutObjects except for perh aps a single <br>.
1257 LayoutObject* childLayoutObject = toLayoutTableCell(layoutObject)->firstChil d(); 1257 LayoutObject* childLayoutObject = toLayoutTableCell(layoutObject)->firstChil d();
1258 if (!childLayoutObject) 1258 if (!childLayoutObject)
1259 return true; 1259 return true;
1260 if (!childLayoutObject->isBR()) 1260 if (!childLayoutObject->isBR())
1261 return false; 1261 return false;
1262 return !childLayoutObject->nextSibling(); 1262 return !childLayoutObject->nextSibling();
1263 } 1263 }
1264 1264
1265 PassRefPtrWillBeRawPtr<HTMLElement> createDefaultParagraphElement(Document& docu ment) 1265 RawPtr<HTMLElement> createDefaultParagraphElement(Document& document)
1266 { 1266 {
1267 switch (document.frame()->editor().defaultParagraphSeparator()) { 1267 switch (document.frame()->editor().defaultParagraphSeparator()) {
1268 case EditorParagraphSeparatorIsDiv: 1268 case EditorParagraphSeparatorIsDiv:
1269 return HTMLDivElement::create(document); 1269 return HTMLDivElement::create(document);
1270 case EditorParagraphSeparatorIsP: 1270 case EditorParagraphSeparatorIsP:
1271 return HTMLParagraphElement::create(document); 1271 return HTMLParagraphElement::create(document);
1272 } 1272 }
1273 1273
1274 ASSERT_NOT_REACHED(); 1274 ASSERT_NOT_REACHED();
1275 return nullptr; 1275 return nullptr;
1276 } 1276 }
1277 1277
1278 PassRefPtrWillBeRawPtr<HTMLElement> createHTMLElement(Document& document, const QualifiedName& name) 1278 RawPtr<HTMLElement> createHTMLElement(Document& document, const QualifiedName& n ame)
1279 { 1279 {
1280 return HTMLElementFactory::createHTMLElement(name.localName(), document, 0, false); 1280 return HTMLElementFactory::createHTMLElement(name.localName(), document, 0, false);
1281 } 1281 }
1282 1282
1283 bool isTabHTMLSpanElement(const Node* node) 1283 bool isTabHTMLSpanElement(const Node* node)
1284 { 1284 {
1285 if (!isHTMLSpanElement(node) || toHTMLSpanElement(node)->getAttribute(classA ttr) != AppleTabSpanClass) 1285 if (!isHTMLSpanElement(node) || toHTMLSpanElement(node)->getAttribute(classA ttr) != AppleTabSpanClass)
1286 return false; 1286 return false;
1287 UseCounter::count(node->document(), UseCounter::EditingAppleTabSpanClass); 1287 UseCounter::count(node->document(), UseCounter::EditingAppleTabSpanClass);
1288 return true; 1288 return true;
1289 } 1289 }
1290 1290
1291 bool isTabHTMLSpanElementTextNode(const Node* node) 1291 bool isTabHTMLSpanElementTextNode(const Node* node)
1292 { 1292 {
1293 return node && node->isTextNode() && node->parentNode() && isTabHTMLSpanElem ent(node->parentNode()); 1293 return node && node->isTextNode() && node->parentNode() && isTabHTMLSpanElem ent(node->parentNode());
1294 } 1294 }
1295 1295
1296 HTMLSpanElement* tabSpanElement(const Node* node) 1296 HTMLSpanElement* tabSpanElement(const Node* node)
1297 { 1297 {
1298 return isTabHTMLSpanElementTextNode(node) ? toHTMLSpanElement(node->parentNo de()) : 0; 1298 return isTabHTMLSpanElementTextNode(node) ? toHTMLSpanElement(node->parentNo de()) : 0;
1299 } 1299 }
1300 1300
1301 static PassRefPtrWillBeRawPtr<HTMLSpanElement> createTabSpanElement(Document& do cument, PassRefPtrWillBeRawPtr<Text> prpTabTextNode) 1301 static RawPtr<HTMLSpanElement> createTabSpanElement(Document& document, RawPtr<T ext> prpTabTextNode)
1302 { 1302 {
1303 RefPtrWillBeRawPtr<Text> tabTextNode = prpTabTextNode; 1303 RawPtr<Text> tabTextNode = prpTabTextNode;
1304 1304
1305 // Make the span to hold the tab. 1305 // Make the span to hold the tab.
1306 RefPtrWillBeRawPtr<HTMLSpanElement> spanElement = HTMLSpanElement::create(do cument); 1306 RawPtr<HTMLSpanElement> spanElement = HTMLSpanElement::create(document);
1307 spanElement->setAttribute(classAttr, AppleTabSpanClass); 1307 spanElement->setAttribute(classAttr, AppleTabSpanClass);
1308 spanElement->setAttribute(styleAttr, "white-space:pre"); 1308 spanElement->setAttribute(styleAttr, "white-space:pre");
1309 1309
1310 // Add tab text to that span. 1310 // Add tab text to that span.
1311 if (!tabTextNode) 1311 if (!tabTextNode)
1312 tabTextNode = document.createEditingTextNode("\t"); 1312 tabTextNode = document.createEditingTextNode("\t");
1313 1313
1314 spanElement->appendChild(tabTextNode.release()); 1314 spanElement->appendChild(tabTextNode.release());
1315 1315
1316 return spanElement.release(); 1316 return spanElement.release();
1317 } 1317 }
1318 1318
1319 PassRefPtrWillBeRawPtr<HTMLSpanElement> createTabSpanElement(Document& document, const String& tabText) 1319 RawPtr<HTMLSpanElement> createTabSpanElement(Document& document, const String& t abText)
1320 { 1320 {
1321 return createTabSpanElement(document, document.createTextNode(tabText)); 1321 return createTabSpanElement(document, document.createTextNode(tabText));
1322 } 1322 }
1323 1323
1324 PassRefPtrWillBeRawPtr<HTMLSpanElement> createTabSpanElement(Document& document) 1324 RawPtr<HTMLSpanElement> createTabSpanElement(Document& document)
1325 { 1325 {
1326 return createTabSpanElement(document, PassRefPtrWillBeRawPtr<Text>(nullptr)) ; 1326 return createTabSpanElement(document, RawPtr<Text>(nullptr));
1327 } 1327 }
1328 1328
1329 bool isNodeRendered(const Node& node) 1329 bool isNodeRendered(const Node& node)
1330 { 1330 {
1331 LayoutObject* layoutObject = node.layoutObject(); 1331 LayoutObject* layoutObject = node.layoutObject();
1332 if (!layoutObject) 1332 if (!layoutObject)
1333 return false; 1333 return false;
1334 1334
1335 return layoutObject->style()->visibility() == VISIBLE; 1335 return layoutObject->style()->visibility() == VISIBLE;
1336 } 1336 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 1507
1508 return newSelection; 1508 return newSelection;
1509 } 1509 }
1510 1510
1511 // FIXME: indexForVisiblePosition and visiblePositionForIndex use TextIterators to convert between 1511 // FIXME: indexForVisiblePosition and visiblePositionForIndex use TextIterators to convert between
1512 // VisiblePositions and indices. But TextIterator iteration using TextIteratorEm itsCharactersBetweenAllVisiblePositions 1512 // VisiblePositions and indices. But TextIterator iteration using TextIteratorEm itsCharactersBetweenAllVisiblePositions
1513 // does not exactly match VisiblePosition iteration, so using them to preserve a selection during an editing 1513 // does not exactly match VisiblePosition iteration, so using them to preserve a selection during an editing
1514 // opertion is unreliable. TextIterator's TextIteratorEmitsCharactersBetweenAllV isiblePositions mode needs to be fixed, 1514 // opertion is unreliable. TextIterator's TextIteratorEmitsCharactersBetweenAllV isiblePositions mode needs to be fixed,
1515 // or these functions need to be changed to iterate using actual VisiblePosition s. 1515 // or these functions need to be changed to iterate using actual VisiblePosition s.
1516 // FIXME: Deploy these functions everywhere that TextIterators are used to conve rt between VisiblePositions and indices. 1516 // FIXME: Deploy these functions everywhere that TextIterators are used to conve rt between VisiblePositions and indices.
1517 int indexForVisiblePosition(const VisiblePosition& visiblePosition, RefPtrWillBe RawPtr<ContainerNode>& scope) 1517 int indexForVisiblePosition(const VisiblePosition& visiblePosition, RawPtr<Conta inerNode>& scope)
1518 { 1518 {
1519 if (visiblePosition.isNull()) 1519 if (visiblePosition.isNull())
1520 return 0; 1520 return 0;
1521 1521
1522 Position p(visiblePosition.deepEquivalent()); 1522 Position p(visiblePosition.deepEquivalent());
1523 Document& document = *p.document(); 1523 Document& document = *p.document();
1524 ShadowRoot* shadowRoot = p.anchorNode()->containingShadowRoot(); 1524 ShadowRoot* shadowRoot = p.anchorNode()->containingShadowRoot();
1525 1525
1526 if (shadowRoot) 1526 if (shadowRoot)
1527 scope = shadowRoot; 1527 scope = shadowRoot;
1528 else 1528 else
1529 scope = document.documentElement(); 1529 scope = document.documentElement();
1530 1530
1531 RefPtrWillBeRawPtr<Range> range = Range::create(document, firstPositionInNod e(scope.get()), p.parentAnchoredEquivalent()); 1531 RawPtr<Range> range = Range::create(document, firstPositionInNode(scope.get( )), p.parentAnchoredEquivalent());
1532 1532
1533 return TextIterator::rangeLength(range->startPosition(), range->endPosition( ), true); 1533 return TextIterator::rangeLength(range->startPosition(), range->endPosition( ), true);
1534 } 1534 }
1535 1535
1536 EphemeralRange makeRange(const VisiblePosition &start, const VisiblePosition &en d) 1536 EphemeralRange makeRange(const VisiblePosition &start, const VisiblePosition &en d)
1537 { 1537 {
1538 if (start.isNull() || end.isNull()) 1538 if (start.isNull() || end.isNull())
1539 return EphemeralRange(); 1539 return EphemeralRange();
1540 1540
1541 Position s = start.deepEquivalent().parentAnchoredEquivalent(); 1541 Position s = start.deepEquivalent().parentAnchoredEquivalent();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 // instead of possibly at the end of the last node before the selection 1677 // instead of possibly at the end of the last node before the selection
1678 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); 1678 return mostForwardCaretPosition(visiblePosition.deepEquivalent());
1679 } 1679 }
1680 1680
1681 bool isTextSecurityNode(const Node* node) 1681 bool isTextSecurityNode(const Node* node)
1682 { 1682 {
1683 return node && node->layoutObject() && node->layoutObject()->style()->textSe curity() != TSNONE; 1683 return node && node->layoutObject() && node->layoutObject()->style()->textSe curity() != TSNONE;
1684 } 1684 }
1685 1685
1686 } // namespace blink 1686 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698