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

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

Issue 2135993003: Add null check to fix crash in blink::ComputedStyle::display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 || isHTMLMetaElement(*node) 787 || isHTMLMetaElement(*node)
788 || isHTMLTitleElement(*node)) { 788 || isHTMLTitleElement(*node)) {
789 next = NodeTraversal::nextSkippingChildren(*node); 789 next = NodeTraversal::nextSkippingChildren(*node);
790 fragment.removeNode(node); 790 fragment.removeNode(node);
791 } else { 791 } else {
792 next = NodeTraversal::next(*node); 792 next = NodeTraversal::next(*node);
793 } 793 }
794 } 794 }
795 } 795 }
796 796
797 static bool isListItemStyle(const HTMLElement& element)
yosin_UTC9 2016/07/12 01:30:36 Can make |isListItem()| in "EditingUtilitis.h" to
joone 2016/07/12 23:08:54 Done.
798 {
799 if (element.computedStyle() && element.computedStyle()->display() == LIST_IT EM)
yosin_UTC9 2016/07/12 01:30:36 nit: We should avoid to use |return true| with |re
joone 2016/07/12 23:08:54 Done.
800 return true;
801 return false;
802 }
803
804 static bool isTableCellStyle(const HTMLElement& element)
yosin_UTC9 2016/07/12 01:30:36 Can make |isTableCell()| in "EditingUtilitis.h" to
joone 2016/07/12 23:08:54 Done.
805 {
806 if (element.computedStyle() && element.computedStyle()->display() == TABLE_C ELL)
yosin_UTC9 2016/07/12 01:30:36 nit: We should avoid to use |return true| with |re
joone 2016/07/12 23:08:54 Done.
807 return true;
808 return false;
809 }
810
797 static bool followBlockElementStyle(const Node* node) 811 static bool followBlockElementStyle(const Node* node)
798 { 812 {
799 if (!node->isHTMLElement()) 813 if (!node->isHTMLElement())
800 return false; 814 return false;
801 815
yosin_UTC9 2016/07/12 01:30:36 I think computedStyle() should not be return nullp
joone 2016/07/12 23:08:54 We can use isInline() function defined in EditingU
802 const HTMLElement& element = toHTMLElement(*node); 816 const HTMLElement& element = toHTMLElement(*node);
803 return element.computedStyle()->display() == LIST_ITEM 817 return isListItemStyle(element)
804 || element.computedStyle()->display() == TABLE_CELL 818 || isTableCellStyle(element)
805 || element.hasTagName(preTag) 819 || element.hasTagName(preTag)
806 || element.hasTagName(h1Tag) 820 || element.hasTagName(h1Tag)
807 || element.hasTagName(h2Tag) 821 || element.hasTagName(h2Tag)
808 || element.hasTagName(h3Tag) 822 || element.hasTagName(h3Tag)
809 || element.hasTagName(h4Tag) 823 || element.hasTagName(h4Tag)
810 || element.hasTagName(h5Tag) 824 || element.hasTagName(h5Tag)
811 || element.hasTagName(h6Tag); 825 || element.hasTagName(h6Tag);
812 } 826 }
813 827
814 // Remove style spans before insertion if they are unnecessary. It's faster bec ause we'll 828 // Remove style spans before insertion if they are unnecessary. It's faster bec ause we'll
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 visitor->trace(m_startOfInsertedContent); 1770 visitor->trace(m_startOfInsertedContent);
1757 visitor->trace(m_endOfInsertedContent); 1771 visitor->trace(m_endOfInsertedContent);
1758 visitor->trace(m_insertionStyle); 1772 visitor->trace(m_insertionStyle);
1759 visitor->trace(m_documentFragment); 1773 visitor->trace(m_documentFragment);
1760 visitor->trace(m_startOfInsertedRange); 1774 visitor->trace(m_startOfInsertedRange);
1761 visitor->trace(m_endOfInsertedRange); 1775 visitor->trace(m_endOfInsertedRange);
1762 CompositeEditCommand::trace(visitor); 1776 CompositeEditCommand::trace(visitor);
1763 } 1777 }
1764 1778
1765 } // namespace blink 1779 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698