OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 static bool isMailPasteAsQuotationNode(const Node* node) | 430 static bool isMailPasteAsQuotationNode(const Node* node) |
431 { | 431 { |
432 if (!node || !node->hasTagName(blockquoteTag) || toElement(node)->getAttribu
te(classAttr) != ApplePasteAsQuotation) | 432 if (!node || !node->hasTagName(blockquoteTag) || toElement(node)->getAttribu
te(classAttr) != ApplePasteAsQuotation) |
433 return false; | 433 return false; |
434 UseCounter::count(node->document(), UseCounter::EditingApplePasteAsQuotation
); | 434 UseCounter::count(node->document(), UseCounter::EditingApplePasteAsQuotation
); |
435 return true; | 435 return true; |
436 } | 436 } |
437 | 437 |
438 static bool isHeaderElement(const Node* a) | 438 static bool isHeaderElement(const Node* a) |
439 { | 439 { |
440 if (!a) | 440 if (!a || !a->isHTMLElement()) |
441 return false; | 441 return false; |
442 | 442 |
443 return a->hasTagName(h1Tag) | 443 const HTMLElement& element = toHTMLElement(*a); |
444 || a->hasTagName(h2Tag) | 444 return element.hasTagName(h1Tag) |
445 || a->hasTagName(h3Tag) | 445 || element.hasTagName(h2Tag) |
446 || a->hasTagName(h4Tag) | 446 || element.hasTagName(h3Tag) |
447 || a->hasTagName(h5Tag) | 447 || element.hasTagName(h4Tag) |
448 || a->hasTagName(h6Tag); | 448 || element.hasTagName(h5Tag) |
| 449 || element.hasTagName(h6Tag); |
449 } | 450 } |
450 | 451 |
451 static bool haveSameTagName(Node* a, Node* b) | 452 static bool haveSameTagName(Node* a, Node* b) |
452 { | 453 { |
453 return a && b && a->isElementNode() && b->isElementNode() && toElement(a)->t
agName() == toElement(b)->tagName(); | 454 return a && b && a->isElementNode() && b->isElementNode() && toElement(a)->t
agName() == toElement(b)->tagName(); |
454 } | 455 } |
455 | 456 |
456 bool ReplaceSelectionCommand::shouldMerge(const VisiblePosition& source, const V
isiblePosition& destination) | 457 bool ReplaceSelectionCommand::shouldMerge(const VisiblePosition& source, const V
isiblePosition& destination) |
457 { | 458 { |
458 if (source.isNull() || destination.isNull()) | 459 if (source.isNull() || destination.isNull()) |
459 return false; | 460 return false; |
460 | 461 |
461 Node* sourceNode = source.deepEquivalent().deprecatedNode(); | 462 Node* sourceNode = source.deepEquivalent().deprecatedNode(); |
462 Node* destinationNode = destination.deepEquivalent().deprecatedNode(); | 463 Node* destinationNode = destination.deepEquivalent().deprecatedNode(); |
463 Node* sourceBlock = enclosingBlock(sourceNode); | 464 Element* sourceBlock = enclosingBlock(sourceNode); |
464 Node* destinationBlock = enclosingBlock(destinationNode); | 465 Element* destinationBlock = enclosingBlock(destinationNode); |
465 return !enclosingNodeOfType(source.deepEquivalent(), &isMailPasteAsQuotation
Node) && | 466 return !enclosingNodeOfType(source.deepEquivalent(), &isMailPasteAsQuotation
Node) && |
466 sourceBlock && (!sourceBlock->hasTagName(blockquoteTag) || isMailBloc
kquote(sourceBlock)) && | 467 sourceBlock && (!sourceBlock->hasTagName(blockquoteTag) || isMailBloc
kquote(sourceBlock)) && |
467 enclosingListChild(sourceBlock) == enclosingListChild(destinationNode
) && | 468 enclosingListChild(sourceBlock) == enclosingListChild(destinationNode
) && |
468 enclosingTableCell(source.deepEquivalent()) == enclosingTableCell(des
tination.deepEquivalent()) && | 469 enclosingTableCell(source.deepEquivalent()) == enclosingTableCell(des
tination.deepEquivalent()) && |
469 (!isHeaderElement(sourceBlock) || haveSameTagName(sourceBlock, destin
ationBlock)) && | 470 (!isHeaderElement(sourceBlock) || haveSameTagName(sourceBlock, destin
ationBlock)) && |
470 // Don't merge to or from a position before or after a block because
it would | 471 // Don't merge to or from a position before or after a block because
it would |
471 // be a no-op and cause infinite recursion. | 472 // be a no-op and cause infinite recursion. |
472 !isBlock(sourceNode) && !isBlock(destinationNode); | 473 !isBlock(sourceNode) && !isBlock(destinationNode); |
473 } | 474 } |
474 | 475 |
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 void ReplaceSelectionCommand::trace(Visitor* visitor) | 1529 void ReplaceSelectionCommand::trace(Visitor* visitor) |
1529 { | 1530 { |
1530 visitor->trace(m_startOfInsertedContent); | 1531 visitor->trace(m_startOfInsertedContent); |
1531 visitor->trace(m_endOfInsertedContent); | 1532 visitor->trace(m_endOfInsertedContent); |
1532 visitor->trace(m_insertionStyle); | 1533 visitor->trace(m_insertionStyle); |
1533 visitor->trace(m_documentFragment); | 1534 visitor->trace(m_documentFragment); |
1534 CompositeEditCommand::trace(visitor); | 1535 CompositeEditCommand::trace(visitor); |
1535 } | 1536 } |
1536 | 1537 |
1537 } // namespace blink | 1538 } // namespace blink |
OLD | NEW |