From ff01c4fd2dd883be84bae2b7d1373505c11180da Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Thu, 14 Sep 2000 08:47:46 +0000 Subject: [PATCH] before starting a selection, make sure we aren't in a link because we don't want to usurp the DnD code. r=mjudge, bug# 52541. git-svn-id: svn://10.0.0.236/trunk@79104 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/content/src/nsGenericHTMLElement.cpp | 1 - mozilla/layout/generic/nsFrame.cpp | 47 ++++++++++++++----- mozilla/layout/html/base/src/nsFrame.cpp | 47 ++++++++++++++----- .../html/content/src/nsGenericHTMLElement.cpp | 1 - 4 files changed, 68 insertions(+), 28 deletions(-) diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index ff998f25d1f..c5acc06b924 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -1102,7 +1102,6 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsIContent* aOuter, NS_RELEASE(stateManager); } NS_RELEASE(handler); - *aEventStatus = nsEventStatus_eConsumeNoDefault; } } break; diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 3019ee480e1..543e821d490 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -53,6 +53,7 @@ #include "nsIFrameSelection.h" #include "nsHTMLParts.h" #include "nsLayoutAtoms.h" +#include "nsHTMLAtoms.h" #include "nsFrameTraversal.h" #include "nsCOMPtr.h" @@ -1007,15 +1008,44 @@ nsFrame::HandlePress(nsIPresContext* aPresContext, if (nsEventStatus_eConsumeNoDefault == *aEventStatus) { return NS_OK; } - // check whether style allows selection - // if not, don't tell selection the mouse event even occured. + nsresult rv; - + nsCOMPtr shell; + aPresContext->GetShell(getter_AddRefs(shell)); + if (!shell) + return NS_ERROR_FAILURE; + + // if we are in Navigator and the click is in a link, we don't want to start + // selection because we don't want to interfere with a potential drag of said + // link and steal all its glory. + PRBool isEditor = PR_FALSE; + shell->GetDisplayNonTextSelection ( &isEditor ); + if ( !isEditor ) { + nsCOMPtr content; + GetContent ( getter_AddRefs(content) ); + if ( content ) { + do { + // are we an anchor? If so, bail out now! + nsCOMPtr tag; + content->GetTag(*getter_AddRefs(tag)); + if ( tag == nsHTMLAtoms::a ) + return NS_OK; + + // now try the parent + nsIContent* parent; + content->GetParent(parent); + content = dont_AddRef(parent); + } while ( content ); + } + } // if browser, not editor + + // check whether style allows selection + // if not, don't tell selection the mouse event even occured. PRBool selectable; PRUint8 selectStyle; rv = IsSelectable(&selectable, &selectStyle); if (NS_FAILED(rv)) return rv; - + // check for select: none if (!selectable) return NS_OK; @@ -1040,15 +1070,6 @@ nsFrame::HandlePress(nsIPresContext* aPresContext, //get the frame selection from sel controller - nsCOMPtr shell; - rv = aPresContext->GetShell(getter_AddRefs(shell)); - - if (NS_FAILED(rv)) - return rv; - - if (!shell) - return NS_ERROR_FAILURE; - // nsFrameState state; // GetFrameState(&state); // if (state & NS_FRAME_INDEPENDENT_SELECTION) diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index 3019ee480e1..543e821d490 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -53,6 +53,7 @@ #include "nsIFrameSelection.h" #include "nsHTMLParts.h" #include "nsLayoutAtoms.h" +#include "nsHTMLAtoms.h" #include "nsFrameTraversal.h" #include "nsCOMPtr.h" @@ -1007,15 +1008,44 @@ nsFrame::HandlePress(nsIPresContext* aPresContext, if (nsEventStatus_eConsumeNoDefault == *aEventStatus) { return NS_OK; } - // check whether style allows selection - // if not, don't tell selection the mouse event even occured. + nsresult rv; - + nsCOMPtr shell; + aPresContext->GetShell(getter_AddRefs(shell)); + if (!shell) + return NS_ERROR_FAILURE; + + // if we are in Navigator and the click is in a link, we don't want to start + // selection because we don't want to interfere with a potential drag of said + // link and steal all its glory. + PRBool isEditor = PR_FALSE; + shell->GetDisplayNonTextSelection ( &isEditor ); + if ( !isEditor ) { + nsCOMPtr content; + GetContent ( getter_AddRefs(content) ); + if ( content ) { + do { + // are we an anchor? If so, bail out now! + nsCOMPtr tag; + content->GetTag(*getter_AddRefs(tag)); + if ( tag == nsHTMLAtoms::a ) + return NS_OK; + + // now try the parent + nsIContent* parent; + content->GetParent(parent); + content = dont_AddRef(parent); + } while ( content ); + } + } // if browser, not editor + + // check whether style allows selection + // if not, don't tell selection the mouse event even occured. PRBool selectable; PRUint8 selectStyle; rv = IsSelectable(&selectable, &selectStyle); if (NS_FAILED(rv)) return rv; - + // check for select: none if (!selectable) return NS_OK; @@ -1040,15 +1070,6 @@ nsFrame::HandlePress(nsIPresContext* aPresContext, //get the frame selection from sel controller - nsCOMPtr shell; - rv = aPresContext->GetShell(getter_AddRefs(shell)); - - if (NS_FAILED(rv)) - return rv; - - if (!shell) - return NS_ERROR_FAILURE; - // nsFrameState state; // GetFrameState(&state); // if (state & NS_FRAME_INDEPENDENT_SELECTION) diff --git a/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp b/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp index ff998f25d1f..c5acc06b924 100644 --- a/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp @@ -1102,7 +1102,6 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsIContent* aOuter, NS_RELEASE(stateManager); } NS_RELEASE(handler); - *aEventStatus = nsEventStatus_eConsumeNoDefault; } } break;