| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008, 2009 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 int endIndex = TextIterator::rangeLength(endRange.get(), true); | 259 int endIndex = TextIterator::rangeLength(endRange.get(), true); |
| 260 | 260 |
| 261 VisiblePosition paragraphStart(startOfParagraph(visibleStart)); | 261 VisiblePosition paragraphStart(startOfParagraph(visibleStart)); |
| 262 VisiblePosition nextParagraphStart(endOfParagraph(paragraphStart).next()); | 262 VisiblePosition nextParagraphStart(endOfParagraph(paragraphStart).next()); |
| 263 VisiblePosition beyondEnd(endOfParagraph(visibleEnd).next()); | 263 VisiblePosition beyondEnd(endOfParagraph(visibleEnd).next()); |
| 264 while (paragraphStart.isNotNull() && paragraphStart != beyondEnd) { | 264 while (paragraphStart.isNotNull() && paragraphStart != beyondEnd) { |
| 265 StyleChange styleChange(style, paragraphStart.deepEquivalent()); | 265 StyleChange styleChange(style, paragraphStart.deepEquivalent()); |
| 266 if (styleChange.cssStyle().length() || m_removeOnly) { | 266 if (styleChange.cssStyle().length() || m_removeOnly) { |
| 267 RefPtrWillBeRawPtr<Node> block = enclosingBlock(paragraphStart.deepE
quivalent().deprecatedNode()); | 267 RefPtrWillBeRawPtr<Node> block = enclosingBlock(paragraphStart.deepE
quivalent().deprecatedNode()); |
| 268 if (!m_removeOnly) { | 268 if (!m_removeOnly) { |
| 269 RefPtrWillBeRawPtr<Node> newBlock = moveParagraphContentsToNewBl
ockIfNecessary(paragraphStart.deepEquivalent()); | 269 RefPtrWillBeRawPtr<Element> newBlock = moveParagraphContentsToNe
wBlockIfNecessary(paragraphStart.deepEquivalent()); |
| 270 if (newBlock) | 270 if (newBlock) |
| 271 block = newBlock; | 271 block = newBlock; |
| 272 } | 272 } |
| 273 ASSERT(!block || block->isHTMLElement()); | 273 ASSERT(!block || block->isHTMLElement()); |
| 274 if (block && block->isHTMLElement()) { | 274 if (block && block->isHTMLElement()) { |
| 275 removeCSSStyle(style, toHTMLElement(block)); | 275 removeCSSStyle(style, toHTMLElement(block)); |
| 276 if (!m_removeOnly) | 276 if (!m_removeOnly) |
| 277 addBlockStyle(styleChange, toHTMLElement(block)); | 277 addBlockStyle(styleChange, toHTMLElement(block)); |
| 278 } | 278 } |
| 279 | 279 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 if (isSpanWithoutAttributesOrUnstyledStyleSpan(element.get())) | 417 if (isSpanWithoutAttributesOrUnstyledStyleSpan(element.get())) |
| 418 unstyledSpans.append(element.release()); | 418 unstyledSpans.append(element.release()); |
| 419 } | 419 } |
| 420 } | 420 } |
| 421 | 421 |
| 422 size_t size = unstyledSpans.size(); | 422 size_t size = unstyledSpans.size(); |
| 423 for (size_t i = 0; i < size; ++i) | 423 for (size_t i = 0; i < size; ++i) |
| 424 removeNodePreservingChildren(unstyledSpans[i].get()); | 424 removeNodePreservingChildren(unstyledSpans[i].get()); |
| 425 } | 425 } |
| 426 | 426 |
| 427 static Node* dummySpanAncestorForNode(const Node* node) | 427 static ContainerNode* dummySpanAncestorForNode(const Node* node) |
| 428 { | 428 { |
| 429 while (node && (!node->isElementNode() || !isStyleSpanOrSpanWithOnlyStyleAtt
ribute(toElement(node)))) | 429 while (node && (!node->isElementNode() || !isStyleSpanOrSpanWithOnlyStyleAtt
ribute(toElement(node)))) |
| 430 node = node->parentNode(); | 430 node = node->parentNode(); |
| 431 | 431 |
| 432 return node ? node->parentNode() : 0; | 432 return node ? node->parentNode() : 0; |
| 433 } | 433 } |
| 434 | 434 |
| 435 void ApplyStyleCommand::cleanupUnstyledAppleStyleSpans(Node* dummySpanAncestor) | 435 void ApplyStyleCommand::cleanupUnstyledAppleStyleSpans(ContainerNode* dummySpanA
ncestor) |
| 436 { | 436 { |
| 437 if (!dummySpanAncestor) | 437 if (!dummySpanAncestor) |
| 438 return; | 438 return; |
| 439 | 439 |
| 440 // Dummy spans are created when text node is split, so that style informatio
n | 440 // Dummy spans are created when text node is split, so that style informatio
n |
| 441 // can be propagated, which can result in more splitting. If a dummy span ge
ts | 441 // can be propagated, which can result in more splitting. If a dummy span ge
ts |
| 442 // cloned/split, the new node is always a sibling of it. Therefore, we scan | 442 // cloned/split, the new node is always a sibling of it. Therefore, we scan |
| 443 // all the children of the dummy's parent | 443 // all the children of the dummy's parent |
| 444 Node* next; | 444 Node* next; |
| 445 for (Node* node = dummySpanAncestor->firstChild(); node; node = next) { | 445 for (Node* node = dummySpanAncestor->firstChild(); node; node = next) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 for (Node* n = startNode; n && n != enclosingNode; n = n->parentNode()) { | 539 for (Node* n = startNode; n && n != enclosingNode; n = n->parentNode()) { |
| 540 if (n->isHTMLElement() && getIdentifierValue(CSSComputedStyleDeclaration
::create(n).get(), CSSPropertyUnicodeBidi) == CSSValueEmbed) | 540 if (n->isHTMLElement() && getIdentifierValue(CSSComputedStyleDeclaration
::create(n).get(), CSSPropertyUnicodeBidi) == CSSValueEmbed) |
| 541 return n; | 541 return n; |
| 542 } | 542 } |
| 543 | 543 |
| 544 return 0; | 544 return 0; |
| 545 } | 545 } |
| 546 | 546 |
| 547 void ApplyStyleCommand::applyInlineStyle(EditingStyle* style) | 547 void ApplyStyleCommand::applyInlineStyle(EditingStyle* style) |
| 548 { | 548 { |
| 549 RefPtrWillBeRawPtr<Node> startDummySpanAncestor = nullptr; | 549 RefPtrWillBeRawPtr<ContainerNode> startDummySpanAncestor = nullptr; |
| 550 RefPtrWillBeRawPtr<Node> endDummySpanAncestor = nullptr; | 550 RefPtrWillBeRawPtr<ContainerNode> endDummySpanAncestor = nullptr; |
| 551 | 551 |
| 552 // update document layout once before removing styles | 552 // update document layout once before removing styles |
| 553 // so that we avoid the expense of updating before each and every call | 553 // so that we avoid the expense of updating before each and every call |
| 554 // to check a computed style | 554 // to check a computed style |
| 555 document().updateLayoutIgnorePendingStylesheets(); | 555 document().updateLayoutIgnorePendingStylesheets(); |
| 556 | 556 |
| 557 // adjust to the positions we want to use for applying style | 557 // adjust to the positions we want to use for applying style |
| 558 Position start = startPosition(); | 558 Position start = startPosition(); |
| 559 Position end = endPosition(); | 559 Position end = endPosition(); |
| 560 | 560 |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1521 if (!style) | 1521 if (!style) |
| 1522 return 0; | 1522 return 0; |
| 1523 | 1523 |
| 1524 RefPtrWillBeRawPtr<CSSPrimitiveValue> value = static_pointer_cast<CSSPrimiti
veValue>(style->getPropertyCSSValue(CSSPropertyFontSize)); | 1524 RefPtrWillBeRawPtr<CSSPrimitiveValue> value = static_pointer_cast<CSSPrimiti
veValue>(style->getPropertyCSSValue(CSSPropertyFontSize)); |
| 1525 if (!value) | 1525 if (!value) |
| 1526 return 0; | 1526 return 0; |
| 1527 | 1527 |
| 1528 return value->getFloatValue(CSSPrimitiveValue::CSS_PX); | 1528 return value->getFloatValue(CSSPrimitiveValue::CSS_PX); |
| 1529 } | 1529 } |
| 1530 | 1530 |
| 1531 void ApplyStyleCommand::joinChildTextNodes(Node* node, const Position& start, co
nst Position& end) | 1531 void ApplyStyleCommand::joinChildTextNodes(ContainerNode* node, const Position&
start, const Position& end) |
| 1532 { | 1532 { |
| 1533 if (!node) | 1533 if (!node) |
| 1534 return; | 1534 return; |
| 1535 | 1535 |
| 1536 Position newStart = start; | 1536 Position newStart = start; |
| 1537 Position newEnd = end; | 1537 Position newEnd = end; |
| 1538 | 1538 |
| 1539 WillBeHeapVector<RefPtrWillBeMember<Text> > textNodes; | 1539 WillBeHeapVector<RefPtrWillBeMember<Text> > textNodes; |
| 1540 for (Node* curr = node->firstChild(); curr; curr = curr->nextSibling()) { | 1540 for (Node* curr = node->firstChild(); curr; curr = curr->nextSibling()) { |
| 1541 if (!curr->isTextNode()) | 1541 if (!curr->isTextNode()) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1567 void ApplyStyleCommand::trace(Visitor* visitor) | 1567 void ApplyStyleCommand::trace(Visitor* visitor) |
| 1568 { | 1568 { |
| 1569 visitor->trace(m_style); | 1569 visitor->trace(m_style); |
| 1570 visitor->trace(m_start); | 1570 visitor->trace(m_start); |
| 1571 visitor->trace(m_end); | 1571 visitor->trace(m_end); |
| 1572 visitor->trace(m_styledInlineElement); | 1572 visitor->trace(m_styledInlineElement); |
| 1573 CompositeEditCommand::trace(visitor); | 1573 CompositeEditCommand::trace(visitor); |
| 1574 } | 1574 } |
| 1575 | 1575 |
| 1576 } | 1576 } |
| OLD | NEW |