Skip to content

Commit 4ed3c27

Browse files
committed
Reviewed by Darin.
<rdar://problem/4478625> HTML Editing: Basic table editing and culling Expanded the Deletion UI to lists, positioned block element and block elementss with borders. * editing/DeleteButtonController.cpp: (WebCore::isDeletableElement): (WebCore::enclosingDeletableElement): (WebCore::DeleteButtonController::respondToChangedSelection): Canonical link: https://commits.webkit.org/14613@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17392 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 67f92d7 commit 4ed3c27

2 files changed

Lines changed: 50 additions & 16 deletions

File tree

WebCore/ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2006-10-27 Timothy Hatcher <timothy@apple.com>
2+
3+
Reviewed by Darin.
4+
5+
<rdar://problem/4478625> HTML Editing: Basic table editing and culling
6+
7+
Expanded the Deletion UI to lists, positioned block element and block elementss with borders.
8+
9+
* editing/DeleteButtonController.cpp:
10+
(WebCore::isDeletableElement):
11+
(WebCore::enclosingDeletableElement):
12+
(WebCore::DeleteButtonController::respondToChangedSelection):
13+
114
2006-10-27 John Sullivan <sullivan@apple.com>
215

316
Reviewed by Kevin Decker

WebCore/editing/DeleteButtonController.cpp

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,32 @@ DeleteButtonController::DeleteButtonController(Frame* frame)
6060
{
6161
}
6262

63-
static HTMLElement* enclosingDeletableTable(const Selection& selection)
63+
static bool isDeletableElement(Node* node)
64+
{
65+
if (!node || !node->isHTMLElement() || !node->isContentEditable())
66+
return false;
67+
68+
RenderObject* renderer = node->renderer();
69+
if (!renderer || renderer->width() < 25 || renderer->height() < 25)
70+
return false;
71+
72+
if (node->hasTagName(tableTag) || node->hasTagName(ulTag) || node->hasTagName(olTag))
73+
return true;
74+
75+
if (renderer->isRenderBlock()) {
76+
RenderStyle* style = renderer->style();
77+
if (!style)
78+
return false;
79+
if (style->position() == AbsolutePosition || style->position() == FixedPosition)
80+
return true;
81+
if (style->border().hasBorder())
82+
return true;
83+
}
84+
85+
return false;
86+
}
87+
88+
static HTMLElement* enclosingDeletableElement(const Selection& selection)
6489
{
6590
if (!selection.isContentEditable())
6691
return 0;
@@ -74,33 +99,29 @@ static HTMLElement* enclosingDeletableTable(const Selection& selection)
7499
ASSERT(container);
75100
ASSERT(ec == 0);
76101

77-
// The enclosingNodeWithTag function only works on nodes that are editable
102+
// The enclosingNodeOfType function only works on nodes that are editable
78103
// (which is strange, given its name).
79104
if (!container->isContentEditable())
80105
return 0;
81106

82-
Node* table = enclosingNodeWithTag(container, tableTag);
83-
if (!table)
84-
return 0;
85-
86-
// The table must be editable too.
87-
if (!table->isContentEditable())
107+
Node* element = enclosingNodeOfType(container, &isDeletableElement);
108+
if (!element)
88109
return 0;
89110

90-
ASSERT(table->isHTMLElement());
91-
return static_cast<HTMLElement*>(table);
111+
ASSERT(element->isHTMLElement());
112+
return static_cast<HTMLElement*>(element);
92113
}
93114

94115
void DeleteButtonController::respondToChangedSelection(const Selection& oldSelection)
95116
{
96-
HTMLElement* oldTable = enclosingDeletableTable(oldSelection);
97-
HTMLElement* newTable = enclosingDeletableTable(m_frame->selectionController()->selection());
98-
if (oldTable == newTable)
117+
HTMLElement* oldElement = enclosingDeletableElement(oldSelection);
118+
HTMLElement* newElement = enclosingDeletableElement(m_frame->selectionController()->selection());
119+
if (oldElement == newElement)
99120
return;
100121

101-
// If the base is inside an editable table, give the table a close widget.
102-
if (newTable)
103-
show(newTable);
122+
// If the base is inside a deletable element, give the element a delete widget.
123+
if (newElement)
124+
show(newElement);
104125
else
105126
hide();
106127
}

0 commit comments

Comments
 (0)