| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "core/frame/UseCounter.h" | 51 #include "core/frame/UseCounter.h" |
| 52 #include "core/html/HTMLBRElement.h" | 52 #include "core/html/HTMLBRElement.h" |
| 53 #include "core/html/HTMLElement.h" | 53 #include "core/html/HTMLElement.h" |
| 54 #include "core/html/HTMLInputElement.h" | 54 #include "core/html/HTMLInputElement.h" |
| 55 #include "core/html/HTMLLIElement.h" | 55 #include "core/html/HTMLLIElement.h" |
| 56 #include "core/html/HTMLQuoteElement.h" | 56 #include "core/html/HTMLQuoteElement.h" |
| 57 #include "core/html/HTMLSelectElement.h" | 57 #include "core/html/HTMLSelectElement.h" |
| 58 #include "core/html/HTMLSpanElement.h" | 58 #include "core/html/HTMLSpanElement.h" |
| 59 #include "core/layout/LayoutObject.h" | 59 #include "core/layout/LayoutObject.h" |
| 60 #include "core/layout/LayoutText.h" | 60 #include "core/layout/LayoutText.h" |
| 61 #include "platform/TraceEvent.h" |
| 61 #include "wtf/StdLibExtras.h" | 62 #include "wtf/StdLibExtras.h" |
| 62 #include "wtf/Vector.h" | 63 #include "wtf/Vector.h" |
| 63 | 64 |
| 64 namespace blink { | 65 namespace blink { |
| 65 | 66 |
| 66 using namespace HTMLNames; | 67 using namespace HTMLNames; |
| 67 | 68 |
| 68 enum EFragmentType { EmptyFragment, SingleTextNodeFragment, TreeFragment }; | 69 enum EFragmentType { EmptyFragment, SingleTextNodeFragment, TreeFragment }; |
| 69 | 70 |
| 70 // --- ReplacementFragment helper class | 71 // --- ReplacementFragment helper class |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 : m_document(document) | 149 : m_document(document) |
| 149 , m_fragment(fragment) | 150 , m_fragment(fragment) |
| 150 , m_hasInterchangeNewlineAtStart(false) | 151 , m_hasInterchangeNewlineAtStart(false) |
| 151 , m_hasInterchangeNewlineAtEnd(false) | 152 , m_hasInterchangeNewlineAtEnd(false) |
| 152 { | 153 { |
| 153 if (!m_document) | 154 if (!m_document) |
| 154 return; | 155 return; |
| 155 if (!m_fragment || !m_fragment->hasChildren()) | 156 if (!m_fragment || !m_fragment->hasChildren()) |
| 156 return; | 157 return; |
| 157 | 158 |
| 159 TRACE_EVENT0("blink", "ReplacementFragment constructor"); |
| 158 RefPtrWillBeRawPtr<Element> editableRoot = selection.rootEditableElement(); | 160 RefPtrWillBeRawPtr<Element> editableRoot = selection.rootEditableElement(); |
| 159 ASSERT(editableRoot); | 161 ASSERT(editableRoot); |
| 160 if (!editableRoot) | 162 if (!editableRoot) |
| 161 return; | 163 return; |
| 162 | 164 |
| 163 Element* shadowAncestorElement; | 165 Element* shadowAncestorElement; |
| 164 if (editableRoot->isInShadowTree()) | 166 if (editableRoot->isInShadowTree()) |
| 165 shadowAncestorElement = editableRoot->shadowHost(); | 167 shadowAncestorElement = editableRoot->shadowHost(); |
| 166 else | 168 else |
| 167 shadowAncestorElement = editableRoot.get(); | 169 shadowAncestorElement = editableRoot.get(); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 252 |
| 251 ContainerNode* parent = refNode->nonShadowBoundaryParentNode(); | 253 ContainerNode* parent = refNode->nonShadowBoundaryParentNode(); |
| 252 if (!parent) | 254 if (!parent) |
| 253 return; | 255 return; |
| 254 | 256 |
| 255 parent->insertBefore(node, refNode); | 257 parent->insertBefore(node, refNode); |
| 256 } | 258 } |
| 257 | 259 |
| 258 PassRefPtrWillBeRawPtr<HTMLElement> ReplacementFragment::insertFragmentForTestRe
ndering(Element* rootEditableElement) | 260 PassRefPtrWillBeRawPtr<HTMLElement> ReplacementFragment::insertFragmentForTestRe
ndering(Element* rootEditableElement) |
| 259 { | 261 { |
| 262 TRACE_EVENT0("blink", "ReplacementFragment::insertFragmentForTestRendering")
; |
| 260 ASSERT(m_document); | 263 ASSERT(m_document); |
| 261 RefPtrWillBeRawPtr<HTMLElement> holder = createDefaultParagraphElement(*m_do
cument.get()); | 264 RefPtrWillBeRawPtr<HTMLElement> holder = createDefaultParagraphElement(*m_do
cument.get()); |
| 262 | 265 |
| 263 holder->appendChild(m_fragment); | 266 holder->appendChild(m_fragment); |
| 264 rootEditableElement->appendChild(holder.get()); | 267 rootEditableElement->appendChild(holder.get()); |
| 265 m_document->updateLayoutIgnorePendingStylesheets(); | 268 m_document->updateLayoutIgnorePendingStylesheets(); |
| 266 | 269 |
| 267 return holder.release(); | 270 return holder.release(); |
| 268 } | 271 } |
| 269 | 272 |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 } | 944 } |
| 942 | 945 |
| 943 static inline HTMLElement* elementToSplitToAvoidPastingIntoInlineElementsWithSty
le(const Position& insertionPos) | 946 static inline HTMLElement* elementToSplitToAvoidPastingIntoInlineElementsWithSty
le(const Position& insertionPos) |
| 944 { | 947 { |
| 945 Element* containingBlock = enclosingBlock(insertionPos.computeContainerNode(
)); | 948 Element* containingBlock = enclosingBlock(insertionPos.computeContainerNode(
)); |
| 946 return toHTMLElement(highestEnclosingNodeOfType(insertionPos, isInlineHTMLEl
ementWithStyle, CannotCrossEditingBoundary, containingBlock)); | 949 return toHTMLElement(highestEnclosingNodeOfType(insertionPos, isInlineHTMLEl
ementWithStyle, CannotCrossEditingBoundary, containingBlock)); |
| 947 } | 950 } |
| 948 | 951 |
| 949 void ReplaceSelectionCommand::doApply(EditingState* editingState) | 952 void ReplaceSelectionCommand::doApply(EditingState* editingState) |
| 950 { | 953 { |
| 954 TRACE_EVENT0("blink", "ReplaceSelectionCommand::doApply"); |
| 951 const VisibleSelection selection = endingSelection(); | 955 const VisibleSelection selection = endingSelection(); |
| 952 ASSERT(selection.isCaretOrRange()); | 956 ASSERT(selection.isCaretOrRange()); |
| 953 ASSERT(selection.start().anchorNode()); | 957 ASSERT(selection.start().anchorNode()); |
| 954 if (!selection.isNonOrphanedCaretOrRange() || !selection.start().anchorNode(
)) | 958 if (!selection.isNonOrphanedCaretOrRange() || !selection.start().anchorNode(
)) |
| 955 return; | 959 return; |
| 956 | 960 |
| 957 if (!selection.rootEditableElement()) | 961 if (!selection.rootEditableElement()) |
| 958 return; | 962 return; |
| 959 | 963 |
| 960 ReplacementFragment fragment(&document(), m_documentFragment.get(), selectio
n); | 964 ReplacementFragment fragment(&document(), m_documentFragment.get(), selectio
n); |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1665 visitor->trace(m_startOfInsertedContent); | 1669 visitor->trace(m_startOfInsertedContent); |
| 1666 visitor->trace(m_endOfInsertedContent); | 1670 visitor->trace(m_endOfInsertedContent); |
| 1667 visitor->trace(m_insertionStyle); | 1671 visitor->trace(m_insertionStyle); |
| 1668 visitor->trace(m_documentFragment); | 1672 visitor->trace(m_documentFragment); |
| 1669 visitor->trace(m_startOfInsertedRange); | 1673 visitor->trace(m_startOfInsertedRange); |
| 1670 visitor->trace(m_endOfInsertedRange); | 1674 visitor->trace(m_endOfInsertedRange); |
| 1671 CompositeEditCommand::trace(visitor); | 1675 CompositeEditCommand::trace(visitor); |
| 1672 } | 1676 } |
| 1673 | 1677 |
| 1674 } // namespace blink | 1678 } // namespace blink |
| OLD | NEW |