Reviewed by Hyatt.
authorthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Oct 2006 22:19:19 +0000 (22:19 +0000)
committerthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Oct 2006 22:19:19 +0000 (22:19 +0000)
        <rdar://problem/4478625> Basic table editing and culling

        Refined the criteria for deletable elements, rely on the renderer more.
        Corrected the interface positioning for elements that have borders.

        * editing/DeleteButtonController.cpp:
        (WebCore::isDeletableElement):
        (WebCore::DeleteButtonController::show):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17445 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/editing/DeleteButtonController.cpp

index 7cf27a89fe2d3de5ce9b5ec9706889f68e2b016c..37f7fbd312acb43c9abb890419a395a30a50faaa 100644 (file)
@@ -1,3 +1,16 @@
+2006-10-30  Timothy Hatcher  <timothy@apple.com>
+
+        Reviewed by Hyatt.
+
+        <rdar://problem/4478625> Basic table editing and culling
+
+        Refined the criteria for deletable elements, rely on the renderer more.
+        Corrected the interface positioning for elements that have borders.
+
+        * editing/DeleteButtonController.cpp:
+        (WebCore::isDeletableElement):
+        (WebCore::DeleteButtonController::show):
+
 2006-10-30  Darin Adler  <darin@apple.com>
 
         - fix build
index 3c63fc3ebedd7f7e6556032c61f0d5faf1fa1d22..d757bb691b89f474c3fb2c1d506776eff2c6380b 100644 (file)
@@ -65,21 +65,31 @@ static bool isDeletableElement(Node* node)
     if (!node || !node->isHTMLElement() || !node->isContentEditable())
         return false;
 
+    const unsigned minimumWidth = 25;
+    const unsigned minimumHeight = 25;
+    const unsigned minimumVisibleBorders = 3;
+
     RenderObject* renderer = node->renderer();
-    if (!renderer || renderer->width() < 25 || renderer->height() < 25)
+    if (!renderer || renderer->width() < minimumWidth || renderer->height() < minimumHeight)
         return false;
 
-    if (node->hasTagName(tableTag) || node->hasTagName(ulTag) || node->hasTagName(olTag))
+    if (renderer->isTable())
+        return true;
+
+    if (node->hasTagName(ulTag) || node->hasTagName(olTag))
+        return true;
+
+    if (renderer->isPositioned())
         return true;
 
-    if (renderer->isRenderBlock()) {
+    // allow block elements (excluding table cells) that have some non-transparent borders
+    if (renderer->isRenderBlock() && !renderer->isTableCell()) {
         RenderStyle* style = renderer->style();
-        if (!style)
-            return false;
-        if (style->position() == AbsolutePosition || style->position() == FixedPosition)
-            return true;
-        if (style->border().hasBorder())
-            return true;
+        if (style && style->hasBorder()) {
+            unsigned visibleBorders = !style->borderTop().isTransparent() + !style->borderBottom().isTransparent() + !style->borderLeft().isTransparent() + !style->borderRight().isTransparent();
+            if (visibleBorders >= minimumVisibleBorders)
+                return true;
+        }
     }
 
     return false;
@@ -158,8 +168,8 @@ void DeleteButtonController::show(HTMLElement* element)
 
     CSSMutableStyleDeclaration* style = m_containerElement->getInlineStyleDecl();
     style->setProperty(CSS_PROP_POSITION, CSS_VAL_ABSOLUTE);
-    style->setProperty(CSS_PROP_TOP, "0px");
-    style->setProperty(CSS_PROP_LEFT, "0px");
+    style->setProperty(CSS_PROP_TOP, String::number(-m_element->renderer()->borderTop()) + "px");
+    style->setProperty(CSS_PROP_LEFT, String::number(-m_element->renderer()->borderLeft()) + "px");
     style->setProperty(CSS_PROP__WEBKIT_USER_DRAG, CSS_VAL_NONE);
     style->setProperty(CSS_PROP__WEBKIT_USER_SELECT, CSS_VAL_NONE);
     style->setProperty(CSS_PROP__WEBKIT_USER_MODIFY, CSS_VAL_NONE);