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

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

Issue 2718543003: Remove EditingAppleTabSpan class handling (Closed)
Patch Set: Make editing/inserting/5549929-2.html pass Created 3 years, 9 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 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 NOTREACHED(); 1563 NOTREACHED();
1564 return nullptr; 1564 return nullptr;
1565 } 1565 }
1566 1566
1567 HTMLElement* createHTMLElement(Document& document, const QualifiedName& name) { 1567 HTMLElement* createHTMLElement(Document& document, const QualifiedName& name) {
1568 return HTMLElementFactory::createHTMLElement(name.localName(), document, 1568 return HTMLElementFactory::createHTMLElement(name.localName(), document,
1569 CreatedByCloneNode); 1569 CreatedByCloneNode);
1570 } 1570 }
1571 1571
1572 bool isTabHTMLSpanElement(const Node* node) { 1572 bool isTabHTMLSpanElement(const Node* node) {
1573 if (!isHTMLSpanElement(node) || 1573 if (!isHTMLSpanElement(node) || !node->firstChild())
1574 toHTMLSpanElement(node)->getAttribute(classAttr) != AppleTabSpanClass)
1575 return false; 1574 return false;
1576 UseCounter::count(node->document(), UseCounter::EditingAppleTabSpanClass); 1575 if (node->firstChild()->isCharacterDataNode() &&
1577 return true; 1576 toCharacterData(node->firstChild())->data().contains('\t'))
1577 return true;
1578 return false;
1578 } 1579 }
1579 1580
1580 bool isTabHTMLSpanElementTextNode(const Node* node) { 1581 bool isTabHTMLSpanElementTextNode(const Node* node) {
1581 return node && node->isTextNode() && node->parentNode() && 1582 return node && node->isTextNode() && node->parentNode() &&
1582 isTabHTMLSpanElement(node->parentNode()); 1583 isTabHTMLSpanElement(node->parentNode());
1583 } 1584 }
1584 1585
1585 HTMLSpanElement* tabSpanElement(const Node* node) { 1586 HTMLSpanElement* tabSpanElement(const Node* node) {
1586 return isTabHTMLSpanElementTextNode(node) 1587 return isTabHTMLSpanElementTextNode(node)
1587 ? toHTMLSpanElement(node->parentNode()) 1588 ? toHTMLSpanElement(node->parentNode())
1588 : 0; 1589 : 0;
1589 } 1590 }
1590 1591
1591 static HTMLSpanElement* createTabSpanElement(Document& document, 1592 static HTMLSpanElement* createTabSpanElement(Document& document,
1592 Text* tabTextNode) { 1593 Text* tabTextNode) {
1593 // Make the span to hold the tab. 1594 // Make the span to hold the tab.
1594 HTMLSpanElement* spanElement = HTMLSpanElement::create(document); 1595 HTMLSpanElement* spanElement = HTMLSpanElement::create(document);
1595 spanElement->setAttribute(classAttr, AppleTabSpanClass);
1596 spanElement->setAttribute(styleAttr, "white-space:pre"); 1596 spanElement->setAttribute(styleAttr, "white-space:pre");
1597 1597
1598 // Add tab text to that span. 1598 // Add tab text to that span.
1599 if (!tabTextNode) 1599 if (!tabTextNode)
1600 tabTextNode = document.createEditingTextNode("\t"); 1600 tabTextNode = document.createEditingTextNode("\t");
1601 1601
1602 spanElement->appendChild(tabTextNode); 1602 spanElement->appendChild(tabTextNode);
1603 1603
1604 return spanElement; 1604 return spanElement;
1605 } 1605 }
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
2171 return InputType::DeleteWordBackward; 2171 return InputType::DeleteWordBackward;
2172 if (granularity == LineBoundary) 2172 if (granularity == LineBoundary)
2173 return InputType::DeleteLineBackward; 2173 return InputType::DeleteLineBackward;
2174 return InputType::DeleteContentBackward; 2174 return InputType::DeleteContentBackward;
2175 default: 2175 default:
2176 return InputType::None; 2176 return InputType::None;
2177 } 2177 }
2178 } 2178 }
2179 2179
2180 } // namespace blink 2180 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698