| OLD | NEW |
| 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 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 | 1224 |
| 1225 // Check that the table cell contains no child layoutObjects except for perh
aps a single <br>. | 1225 // Check that the table cell contains no child layoutObjects except for perh
aps a single <br>. |
| 1226 LayoutObject* childLayoutObject = toLayoutTableCell(layoutObject)->firstChil
d(); | 1226 LayoutObject* childLayoutObject = toLayoutTableCell(layoutObject)->firstChil
d(); |
| 1227 if (!childLayoutObject) | 1227 if (!childLayoutObject) |
| 1228 return true; | 1228 return true; |
| 1229 if (!childLayoutObject->isBR()) | 1229 if (!childLayoutObject->isBR()) |
| 1230 return false; | 1230 return false; |
| 1231 return !childLayoutObject->nextSibling(); | 1231 return !childLayoutObject->nextSibling(); |
| 1232 } | 1232 } |
| 1233 | 1233 |
| 1234 PassRefPtrWillBeRawPtr<HTMLElement> createDefaultParagraphElement(Document& docu
ment) | 1234 RawPtr<HTMLElement> createDefaultParagraphElement(Document& document) |
| 1235 { | 1235 { |
| 1236 switch (document.frame()->editor().defaultParagraphSeparator()) { | 1236 switch (document.frame()->editor().defaultParagraphSeparator()) { |
| 1237 case EditorParagraphSeparatorIsDiv: | 1237 case EditorParagraphSeparatorIsDiv: |
| 1238 return HTMLDivElement::create(document); | 1238 return HTMLDivElement::create(document); |
| 1239 case EditorParagraphSeparatorIsP: | 1239 case EditorParagraphSeparatorIsP: |
| 1240 return HTMLParagraphElement::create(document); | 1240 return HTMLParagraphElement::create(document); |
| 1241 } | 1241 } |
| 1242 | 1242 |
| 1243 ASSERT_NOT_REACHED(); | 1243 ASSERT_NOT_REACHED(); |
| 1244 return nullptr; | 1244 return nullptr; |
| 1245 } | 1245 } |
| 1246 | 1246 |
| 1247 PassRefPtrWillBeRawPtr<HTMLElement> createHTMLElement(Document& document, const
QualifiedName& name) | 1247 RawPtr<HTMLElement> createHTMLElement(Document& document, const QualifiedName& n
ame) |
| 1248 { | 1248 { |
| 1249 return HTMLElementFactory::createHTMLElement(name.localName(), document, 0,
false); | 1249 return HTMLElementFactory::createHTMLElement(name.localName(), document, 0,
false); |
| 1250 } | 1250 } |
| 1251 | 1251 |
| 1252 bool isTabHTMLSpanElement(const Node* node) | 1252 bool isTabHTMLSpanElement(const Node* node) |
| 1253 { | 1253 { |
| 1254 if (!isHTMLSpanElement(node) || toHTMLSpanElement(node)->getAttribute(classA
ttr) != AppleTabSpanClass) | 1254 if (!isHTMLSpanElement(node) || toHTMLSpanElement(node)->getAttribute(classA
ttr) != AppleTabSpanClass) |
| 1255 return false; | 1255 return false; |
| 1256 UseCounter::count(node->document(), UseCounter::EditingAppleTabSpanClass); | 1256 UseCounter::count(node->document(), UseCounter::EditingAppleTabSpanClass); |
| 1257 return true; | 1257 return true; |
| 1258 } | 1258 } |
| 1259 | 1259 |
| 1260 bool isTabHTMLSpanElementTextNode(const Node* node) | 1260 bool isTabHTMLSpanElementTextNode(const Node* node) |
| 1261 { | 1261 { |
| 1262 return node && node->isTextNode() && node->parentNode() && isTabHTMLSpanElem
ent(node->parentNode()); | 1262 return node && node->isTextNode() && node->parentNode() && isTabHTMLSpanElem
ent(node->parentNode()); |
| 1263 } | 1263 } |
| 1264 | 1264 |
| 1265 HTMLSpanElement* tabSpanElement(const Node* node) | 1265 HTMLSpanElement* tabSpanElement(const Node* node) |
| 1266 { | 1266 { |
| 1267 return isTabHTMLSpanElementTextNode(node) ? toHTMLSpanElement(node->parentNo
de()) : 0; | 1267 return isTabHTMLSpanElementTextNode(node) ? toHTMLSpanElement(node->parentNo
de()) : 0; |
| 1268 } | 1268 } |
| 1269 | 1269 |
| 1270 static PassRefPtrWillBeRawPtr<HTMLSpanElement> createTabSpanElement(Document& do
cument, PassRefPtrWillBeRawPtr<Text> prpTabTextNode) | 1270 static RawPtr<HTMLSpanElement> createTabSpanElement(Document& document, RawPtr<T
ext> prpTabTextNode) |
| 1271 { | 1271 { |
| 1272 RefPtrWillBeRawPtr<Text> tabTextNode = prpTabTextNode; | 1272 RawPtr<Text> tabTextNode = prpTabTextNode; |
| 1273 | 1273 |
| 1274 // Make the span to hold the tab. | 1274 // Make the span to hold the tab. |
| 1275 RefPtrWillBeRawPtr<HTMLSpanElement> spanElement = HTMLSpanElement::create(do
cument); | 1275 RawPtr<HTMLSpanElement> spanElement = HTMLSpanElement::create(document); |
| 1276 spanElement->setAttribute(classAttr, AppleTabSpanClass); | 1276 spanElement->setAttribute(classAttr, AppleTabSpanClass); |
| 1277 spanElement->setAttribute(styleAttr, "white-space:pre"); | 1277 spanElement->setAttribute(styleAttr, "white-space:pre"); |
| 1278 | 1278 |
| 1279 // Add tab text to that span. | 1279 // Add tab text to that span. |
| 1280 if (!tabTextNode) | 1280 if (!tabTextNode) |
| 1281 tabTextNode = document.createEditingTextNode("\t"); | 1281 tabTextNode = document.createEditingTextNode("\t"); |
| 1282 | 1282 |
| 1283 spanElement->appendChild(tabTextNode.release()); | 1283 spanElement->appendChild(tabTextNode.release()); |
| 1284 | 1284 |
| 1285 return spanElement.release(); | 1285 return spanElement.release(); |
| 1286 } | 1286 } |
| 1287 | 1287 |
| 1288 PassRefPtrWillBeRawPtr<HTMLSpanElement> createTabSpanElement(Document& document,
const String& tabText) | 1288 RawPtr<HTMLSpanElement> createTabSpanElement(Document& document, const String& t
abText) |
| 1289 { | 1289 { |
| 1290 return createTabSpanElement(document, document.createTextNode(tabText)); | 1290 return createTabSpanElement(document, document.createTextNode(tabText)); |
| 1291 } | 1291 } |
| 1292 | 1292 |
| 1293 PassRefPtrWillBeRawPtr<HTMLSpanElement> createTabSpanElement(Document& document) | 1293 RawPtr<HTMLSpanElement> createTabSpanElement(Document& document) |
| 1294 { | 1294 { |
| 1295 return createTabSpanElement(document, PassRefPtrWillBeRawPtr<Text>(nullptr))
; | 1295 return createTabSpanElement(document, RawPtr<Text>(nullptr)); |
| 1296 } | 1296 } |
| 1297 | 1297 |
| 1298 bool isNodeRendered(const Node& node) | 1298 bool isNodeRendered(const Node& node) |
| 1299 { | 1299 { |
| 1300 LayoutObject* layoutObject = node.layoutObject(); | 1300 LayoutObject* layoutObject = node.layoutObject(); |
| 1301 if (!layoutObject) | 1301 if (!layoutObject) |
| 1302 return false; | 1302 return false; |
| 1303 | 1303 |
| 1304 return layoutObject->style()->visibility() == VISIBLE; | 1304 return layoutObject->style()->visibility() == VISIBLE; |
| 1305 } | 1305 } |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1476 | 1476 |
| 1477 return newSelection; | 1477 return newSelection; |
| 1478 } | 1478 } |
| 1479 | 1479 |
| 1480 // FIXME: indexForVisiblePosition and visiblePositionForIndex use TextIterators
to convert between | 1480 // FIXME: indexForVisiblePosition and visiblePositionForIndex use TextIterators
to convert between |
| 1481 // VisiblePositions and indices. But TextIterator iteration using TextIteratorEm
itsCharactersBetweenAllVisiblePositions | 1481 // VisiblePositions and indices. But TextIterator iteration using TextIteratorEm
itsCharactersBetweenAllVisiblePositions |
| 1482 // does not exactly match VisiblePosition iteration, so using them to preserve a
selection during an editing | 1482 // does not exactly match VisiblePosition iteration, so using them to preserve a
selection during an editing |
| 1483 // opertion is unreliable. TextIterator's TextIteratorEmitsCharactersBetweenAllV
isiblePositions mode needs to be fixed, | 1483 // opertion is unreliable. TextIterator's TextIteratorEmitsCharactersBetweenAllV
isiblePositions mode needs to be fixed, |
| 1484 // or these functions need to be changed to iterate using actual VisiblePosition
s. | 1484 // or these functions need to be changed to iterate using actual VisiblePosition
s. |
| 1485 // FIXME: Deploy these functions everywhere that TextIterators are used to conve
rt between VisiblePositions and indices. | 1485 // FIXME: Deploy these functions everywhere that TextIterators are used to conve
rt between VisiblePositions and indices. |
| 1486 int indexForVisiblePosition(const VisiblePosition& visiblePosition, RefPtrWillBe
RawPtr<ContainerNode>& scope) | 1486 int indexForVisiblePosition(const VisiblePosition& visiblePosition, RawPtr<Conta
inerNode>& scope) |
| 1487 { | 1487 { |
| 1488 if (visiblePosition.isNull()) | 1488 if (visiblePosition.isNull()) |
| 1489 return 0; | 1489 return 0; |
| 1490 | 1490 |
| 1491 Position p(visiblePosition.deepEquivalent()); | 1491 Position p(visiblePosition.deepEquivalent()); |
| 1492 Document& document = *p.document(); | 1492 Document& document = *p.document(); |
| 1493 ShadowRoot* shadowRoot = p.anchorNode()->containingShadowRoot(); | 1493 ShadowRoot* shadowRoot = p.anchorNode()->containingShadowRoot(); |
| 1494 | 1494 |
| 1495 if (shadowRoot) | 1495 if (shadowRoot) |
| 1496 scope = shadowRoot; | 1496 scope = shadowRoot; |
| 1497 else | 1497 else |
| 1498 scope = document.documentElement(); | 1498 scope = document.documentElement(); |
| 1499 | 1499 |
| 1500 RefPtrWillBeRawPtr<Range> range = Range::create(document, firstPositionInNod
e(scope.get()), p.parentAnchoredEquivalent()); | 1500 RawPtr<Range> range = Range::create(document, firstPositionInNode(scope.get(
)), p.parentAnchoredEquivalent()); |
| 1501 | 1501 |
| 1502 return TextIterator::rangeLength(range->startPosition(), range->endPosition(
), true); | 1502 return TextIterator::rangeLength(range->startPosition(), range->endPosition(
), true); |
| 1503 } | 1503 } |
| 1504 | 1504 |
| 1505 EphemeralRange makeRange(const VisiblePosition &start, const VisiblePosition &en
d) | 1505 EphemeralRange makeRange(const VisiblePosition &start, const VisiblePosition &en
d) |
| 1506 { | 1506 { |
| 1507 if (start.isNull() || end.isNull()) | 1507 if (start.isNull() || end.isNull()) |
| 1508 return EphemeralRange(); | 1508 return EphemeralRange(); |
| 1509 | 1509 |
| 1510 Position s = start.deepEquivalent().parentAnchoredEquivalent(); | 1510 Position s = start.deepEquivalent().parentAnchoredEquivalent(); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1646 // instead of possibly at the end of the last node before the selection | 1646 // instead of possibly at the end of the last node before the selection |
| 1647 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); | 1647 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); |
| 1648 } | 1648 } |
| 1649 | 1649 |
| 1650 bool isTextSecurityNode(const Node* node) | 1650 bool isTextSecurityNode(const Node* node) |
| 1651 { | 1651 { |
| 1652 return node && node->layoutObject() && node->layoutObject()->style()->textSe
curity() != TSNONE; | 1652 return node && node->layoutObject() && node->layoutObject()->style()->textSe
curity() != TSNONE; |
| 1653 } | 1653 } |
| 1654 | 1654 |
| 1655 } // namespace blink | 1655 } // namespace blink |
| OLD | NEW |