Reviewed by Darin.
authorthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 May 2006 02:44:53 +0000 (02:44 +0000)
committerthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 May 2006 02:44:53 +0000 (02:44 +0000)
        http://bugzilla.opendarwin.org/show_bug.cgi?id=7156
        Bug 7156: TinyMCE: Links are actually activated in editable area, not editable.

        Links in editable areas will not activate or perform a navigation
        change (on par with WinIE and Firefox.) To visit the link
        you can shift-click. Manual test added.

        * css/cssstyleselector.cpp:
        (WebCore::CSSStyleSelector::adjustRenderStyle):
        * html/HTMLAnchorElement.cpp:
        (WebCore::HTMLAnchorElement::defaultEventHandler):
        (WebCore::HTMLAnchorElement::setActive):
        * html/HTMLAnchorElement.h:
        * manual-tests/contenteditable-link.html: Added.
        * page/FrameView.cpp:
        (WebCore::selectCursor):

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

WebCore/ChangeLog
WebCore/css/cssstyleselector.cpp
WebCore/html/HTMLAnchorElement.cpp
WebCore/html/HTMLAnchorElement.h
WebCore/manual-tests/contenteditable-link.html [new file with mode: 0644]
WebCore/page/FrameView.cpp

index cb54560bd09127d7e23e133e8ee4002c3a12469f..c7ae60f0a25cc9959293a0223264044496ed4b5f 100644 (file)
@@ -1,3 +1,24 @@
+2006-05-12  Timothy Hatcher  <timothy@apple.com>
+
+        Reviewed by Darin.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=7156
+        Bug 7156: TinyMCE: Links are actually activated in editable area, not editable.
+        
+        Links in editable areas will not activate or perform a navigation
+        change (on par with WinIE and Firefox.) To visit the link
+        you can shift-click. Manual test added.
+
+        * css/cssstyleselector.cpp:
+        (WebCore::CSSStyleSelector::adjustRenderStyle):
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::defaultEventHandler):
+        (WebCore::HTMLAnchorElement::setActive):
+        * html/HTMLAnchorElement.h:
+        * manual-tests/contenteditable-link.html: Added.
+        * page/FrameView.cpp:
+        (WebCore::selectCursor):
+
 2006-05-12  Eric Seidel  <eseidel@apple.com>
 
         Reviewed by timo.
 
         * WebCore: Removed an extra WebCore subtree that somehow got checked in.
 
->>>>>>> .r14297
 2006-05-10  David Carson <dacarson@gmail.com>
 
         - Fix for bug 8833. Removed inline keyword from functions declared
index c22f6ca103ad8ac23f95a3a6e3b9015c4108373e..e83735957cca8f6ea30dcad695a38541ca95c43e 100644 (file)
@@ -999,6 +999,10 @@ void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, Element *e)
          style->display() == TABLE_ROW_GROUP || style->display() == TABLE_ROW))
         style->setOverflow(OVISIBLE);
 
+    // Links should be user selectable when content editable
+    if (e && e->isLink() && (style->userModify() == READ_WRITE || style->userModify() == READ_WRITE_PLAINTEXT_ONLY))
+        style->setUserSelect(SELECT_AUTO);
+
     // Cull out any useless layers and also repeat patterns into additional layers.
     style->adjustBackgroundLayers();
 
index 12b2429a4a86dda8d542dd3168ab0bddd8fef87c..a25b6b646ab878079a3c21f110871718fcda5081 100644 (file)
@@ -104,7 +104,7 @@ void HTMLAnchorElement::defaultEventHandler(Event *evt)
     // React on clicks and on keypresses.
     // Don't make this KEYUP_EVENT again, it makes khtml follow links it shouldn't,
     // when pressing Enter in the combo.
-    if ((evt->type() == clickEvent || (evt->type() == keydownEvent && m_focused)) && m_isLink) {
+    if (m_isLink && (evt->type() == clickEvent || (evt->type() == keydownEvent && m_focused))) {
         MouseEvent* e = 0;
         if (evt->type() == clickEvent)
             e = static_cast<MouseEvent*>(evt);
@@ -113,14 +113,16 @@ void HTMLAnchorElement::defaultEventHandler(Event *evt)
         if (evt->type() == keydownEvent)
             k = static_cast<KeyboardEvent*>(evt);
 
-        DeprecatedString utarget;
-        DeprecatedString url;
-
         if (e && e->button() == 2) {
             HTMLElement::defaultEventHandler(evt);
             return;
         }
 
+        if (e && !e->shiftKey() && isContentEditable()) {
+            HTMLElement::defaultEventHandler(evt);
+            return;
+        }
+
         if (k) {
             if (k->keyIdentifier() != "Enter") {
                 HTMLElement::defaultEventHandler(evt);
@@ -133,9 +135,8 @@ void HTMLAnchorElement::defaultEventHandler(Event *evt)
             }
         }
 
-        url = parseURL(getAttribute(hrefAttr)).deprecatedString();
-
-        utarget = getAttribute(targetAttr).deprecatedString();
+        DeprecatedString url = WebCore::parseURL(getAttribute(hrefAttr)).deprecatedString();
+        String utarget = getAttribute(targetAttr);
 
         if (e && e->button() == 1)
             utarget = "_blank";
@@ -143,7 +144,7 @@ void HTMLAnchorElement::defaultEventHandler(Event *evt)
         if (evt->target()->hasTagName(imgTag)) {
             HTMLImageElement* img = static_cast<HTMLImageElement*>(evt->target());
             if (img && img->isServerMap()) {
-                RenderImage *r = static_cast<RenderImage*>(img->renderer());
+                RenderImager = static_cast<RenderImage*>(img->renderer());
                 if(r && e) {
                     int absx, absy;
                     r->absolutePosition(absx, absy);
@@ -159,15 +160,22 @@ void HTMLAnchorElement::defaultEventHandler(Event *evt)
                 }
             }
         }
-        if (!evt->defaultPrevented()) {
-            if (document()->frame())
-                document()->frame()->urlSelected(url, utarget);
-        }
+
+        if (!evt->defaultPrevented() && document()->frame())
+            document()->frame()->urlSelected(url, utarget);
+
         evt->setDefaultHandled();
     }
+
     HTMLElement::defaultEventHandler(evt);
 }
 
+void HTMLAnchorElement::setActive(bool down, bool pause)
+{
+    if (isContentEditable())
+        return;
+    ContainerNode::setActive(down, pause);
+}
 
 void HTMLAnchorElement::parseMappedAttribute(MappedAttribute *attr)
 {
index d9d534f6ab393033046b4a4a53e2973f28579950..ac2d6ea870115ac6ce15dd605bfc7e446aaa2879 100644 (file)
@@ -45,6 +45,7 @@ public:
     virtual bool isFocusable() const;
     virtual void parseMappedAttribute(MappedAttribute*);
     virtual void defaultEventHandler(Event*);
+    virtual void setActive(bool active = true, bool pause = false);
     virtual void accessKeyAction(bool fullAction);
     virtual bool isURLAttribute(Attribute*) const;
 
diff --git a/WebCore/manual-tests/contenteditable-link.html b/WebCore/manual-tests/contenteditable-link.html
new file mode 100644 (file)
index 0000000..47265c3
--- /dev/null
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+<TITLE> Webkit bugzilla repro movie: #7156 </TITLE>
+<META NAME="Author" CONTENT="Aldo Hoeben">
+<style type="text/css">
+#editable {
+  width: 40em;
+  height: 10em;
+  border: 1px solid black;
+}
+</STYLE>
+</HEAD>
+
+<BODY>
+<P>Repro movie for bug <a href="http://bugzilla.opendarwin.org/show_bug.cgi?id=7156">#7156</a></P>
+
+<div id="editable" contentEditable="true">
+  <p>Test content</p>
+  <p><a href="about:blank">Test link</a></p>
+</div>
+
+</BODY>
+</HTML>
index b73278f13a8b226d240bec15ce163480ff9ab63c..cd0c2758ee18f476a4fd7346670dcd71cbcbca8e 100644 (file)
@@ -554,12 +554,14 @@ static Cursor selectCursor(const MouseEventWithHitTestResults& event, Frame* fra
         return style->cursorImage()->image();
 
     switch (style ? style->cursor() : CURSOR_AUTO) {
-        case CURSOR_AUTO:
-            if (event.isOverLink() || isSubmitImage(node))
+        case CURSOR_AUTO: {
+            bool editable = (node && node->isContentEditable());
+            if ((event.isOverLink() || isSubmitImage(node)) && (!editable || event.event().shiftKey()))
                 return handCursor();
-            if ((node && node->isContentEditable()) || (renderer && renderer->isText() && renderer->canSelect()))
+            if (editable || (renderer && renderer->isText() && renderer->canSelect()))
                 return iBeamCursor();
             return pointerCursor();
+        }
         case CURSOR_CROSS:
             return crossCursor();
         case CURSOR_POINTER: