#include "third_party/blink/renderer/core/editing/commands/replace_selection_command.h"
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/css/css_property_value_set.h"
#include "third_party/blink/renderer/core/css/css_style_declaration.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/document_fragment.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/text.h"
#include "third_party/blink/renderer/core/editing/commands/apply_style_command.h"
#include "third_party/blink/renderer/core/editing/commands/break_blockquote_command.h"
#include "third_party/blink/renderer/core/editing/commands/delete_selection_options.h"
#include "third_party/blink/renderer/core/editing/commands/editing_commands_utilities.h"
#include "third_party/blink/renderer/core/editing/commands/simplify_markup_command.h"
#include "third_party/blink/renderer/core/editing/commands/smart_replace.h"
#include "third_party/blink/renderer/core/editing/editing_style.h"
#include "third_party/blink/renderer/core/editing/editing_utilities.h"
#include "third_party/blink/renderer/core/editing/editor.h"
#include "third_party/blink/renderer/core/editing/ephemeral_range.h"
#include "third_party/blink/renderer/core/editing/iterators/text_iterator.h"
#include "third_party/blink/renderer/core/editing/selection_template.h"
#include "third_party/blink/renderer/core/editing/serializers/html_interchange.h"
#include "third_party/blink/renderer/core/editing/serializers/serialization.h"
#include "third_party/blink/renderer/core/editing/visible_position.h"
#include "third_party/blink/renderer/core/editing/visible_units.h"
#include "third_party/blink/renderer/core/events/before_text_inserted_event.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/forms/html_select_element.h"
#include "third_party/blink/renderer/core/html/html_base_element.h"
#include "third_party/blink/renderer/core/html/html_body_element.h"
#include "third_party/blink/renderer/core/html/html_br_element.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/html/html_li_element.h"
#include "third_party/blink/renderer/core/html/html_link_element.h"
#include "third_party/blink/renderer/core/html/html_meta_element.h"
#include "third_party/blink/renderer/core/html/html_quote_element.h"
#include "third_party/blink/renderer/core/html/html_span_element.h"
#include "third_party/blink/renderer/core/html/html_style_element.h"
#include "third_party/blink/renderer/core/html/html_title_element.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/input_type_names.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/layout_text.h"
#include "third_party/blink/renderer/core/svg/svg_style_element.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
FormControlType;
class ReplacementFragment final { … };
static bool IsInterchangeHTMLBRElement(const Node* node) { … }
static Position PositionAvoidingPrecedingNodes(Position pos) { … }
ReplacementFragment::ReplacementFragment(Document* document,
DocumentFragment* fragment,
const VisibleSelection& selection)
: … { … }
bool ReplacementFragment::IsEmpty() const { … }
Node* ReplacementFragment::FirstChild() const { … }
Node* ReplacementFragment::LastChild() const { … }
void ReplacementFragment::RemoveNodePreservingChildren(ContainerNode* node) { … }
void ReplacementFragment::RemoveNode(Node* node) { … }
void ReplacementFragment::InsertNodeBefore(Node* node, Node* ref_node) { … }
HTMLElement* ReplacementFragment::InsertFragmentForTestRendering(
Element* root_editable_element) { … }
void ReplacementFragment::RestoreAndRemoveTestRenderingNodesToFragment(
Element* holder) { … }
void ReplacementFragment::RemoveUnrenderedNodes(ContainerNode* holder) { … }
void ReplacementFragment::RemoveInterchangeNodes(ContainerNode* container) { … }
inline void ReplaceSelectionCommand::InsertedNodes::RespondToNodeInsertion(
Node& node) { … }
inline void
ReplaceSelectionCommand::InsertedNodes::WillRemoveNodePreservingChildren(
Node& node) { … }
inline void ReplaceSelectionCommand::InsertedNodes::WillRemoveNode(Node& node) { … }
inline void ReplaceSelectionCommand::InsertedNodes::DidReplaceNode(
Node& node,
Node& new_node) { … }
ReplaceSelectionCommand::ReplaceSelectionCommand(
Document& document,
DocumentFragment* fragment,
CommandOptions options,
InputEvent::InputType input_type)
: … { … }
String ReplaceSelectionCommand::TextDataForInputEvent() const { … }
static bool HasMatchingQuoteLevel(VisiblePosition end_of_existing_content,
VisiblePosition end_of_inserted_content) { … }
bool ReplaceSelectionCommand::ShouldMergeStart(
bool selection_start_was_start_of_paragraph,
bool fragment_has_interchange_newline_at_start,
bool selection_start_was_inside_mail_blockquote) { … }
bool ReplaceSelectionCommand::ShouldMergeEnd(
bool selection_end_was_end_of_paragraph) { … }
static bool IsHTMLHeaderElement(const Node* a) { … }
static bool HaveSameTagName(Element* a, Element* b) { … }
bool ReplaceSelectionCommand::ShouldMerge(const VisiblePosition& source,
const VisiblePosition& destination) { … }
void ReplaceSelectionCommand::RemoveRedundantStylesAndKeepStyleSpanInline(
InsertedNodes& inserted_nodes,
EditingState* editing_state) { … }
static bool IsProhibitedParagraphChild(const AtomicString& name) { … }
void ReplaceSelectionCommand::
MakeInsertedContentRoundTrippableWithHTMLTreeBuilder(
const InsertedNodes& inserted_nodes,
EditingState* editing_state) { … }
void ReplaceSelectionCommand::MoveElementOutOfAncestor(
Element* element,
Element* ancestor,
EditingState* editing_state) { … }
static inline bool NodeHasVisibleLayoutText(Text& text) { … }
void ReplaceSelectionCommand::RemoveUnrenderedTextNodesAtEnds(
InsertedNodes& inserted_nodes) { … }
VisiblePosition ReplaceSelectionCommand::PositionAtEndOfInsertedContent()
const { … }
VisiblePosition ReplaceSelectionCommand::PositionAtStartOfInsertedContent()
const { … }
static void RemoveHeadContents(ReplacementFragment& fragment) { … }
static bool FollowBlockElementStyle(const Node* node) { … }
void ReplaceSelectionCommand::HandleStyleSpansBeforeInsertion(
ReplacementFragment& fragment,
const Position& insertion_pos) { … }
void ReplaceSelectionCommand::MergeEndIfNeeded(EditingState* editing_state) { … }
static Node* EnclosingInline(Node* node) { … }
static bool IsInlineHTMLElementWithStyle(const Node* node) { … }
static inline HTMLElement*
ElementToSplitToAvoidPastingIntoInlineElementsWithStyle(
const Position& insertion_pos) { … }
void ReplaceSelectionCommand::SetUpStyle(const VisibleSelection& selection) { … }
void ReplaceSelectionCommand::InsertParagraphSeparatorIfNeeds(
const VisibleSelection& selection,
const ReplacementFragment& fragment,
EditingState* editing_state) { … }
void ReplaceSelectionCommand::DoApply(EditingState* editing_state) { … }
bool ReplaceSelectionCommand::ShouldRemoveEndBR(
HTMLBRElement* end_br,
const VisiblePosition& original_vis_pos_before_end_br) { … }
bool ReplaceSelectionCommand::ShouldPerformSmartReplace() const { … }
static bool IsCharacterSmartReplaceExemptConsideringNonBreakingSpace(
UChar32 character,
bool previous_character) { … }
void ReplaceSelectionCommand::AddSpacesForSmartReplace(
EditingState* editing_state) { … }
void ReplaceSelectionCommand::CompleteHTMLReplacement(
const Position& last_position_to_select,
EditingState* editing_state) { … }
void ReplaceSelectionCommand::MergeTextNodesAroundPosition(
Position& position,
Position& position_only_to_be_updated,
EditingState* editing_state) { … }
InputEvent::InputType ReplaceSelectionCommand::GetInputType() const { … }
Node* ReplaceSelectionCommand::InsertAsListItems(HTMLElement* list_element,
Element* insertion_block,
const Position& insert_pos,
InsertedNodes& inserted_nodes,
EditingState* editing_state) { … }
void ReplaceSelectionCommand::UpdateNodesInserted(Node* node) { … }
bool ReplaceSelectionCommand::PerformTrivialReplace(
const ReplacementFragment& fragment,
EditingState* editing_state) { … }
bool ReplaceSelectionCommand::IsReplaceSelectionCommand() const { … }
EphemeralRange ReplaceSelectionCommand::InsertedRange() const { … }
void ReplaceSelectionCommand::Trace(Visitor* visitor) const { … }
}