mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Merge on a CLOSED TREE.
This commit is contained in:
commit
dc93e0ad7e
@ -7,7 +7,8 @@
|
||||
#define mozilla_a11y_TreeWalker_h_
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
class nsIContent;
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
@ -9,10 +9,10 @@
|
||||
#define _nsTextEquivUtils_H_
|
||||
|
||||
#include "Accessible.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "Role.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsIStringBundle.h"
|
||||
class nsIContent;
|
||||
|
||||
/**
|
||||
* Text equivalent computation rules (see nsTextEquivUtils::gRoleToNameRulesMap)
|
||||
|
@ -16,8 +16,8 @@
|
||||
#include "nsIAccessibleSelectable.h"
|
||||
#include "nsIAccessibleValue.h"
|
||||
#include "nsIAccessibleStates.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsStringGlue.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsRefPtrHashtable.h"
|
||||
@ -25,7 +25,6 @@
|
||||
struct nsRoleMapEntry;
|
||||
|
||||
struct nsRect;
|
||||
class nsIContent;
|
||||
class nsIFrame;
|
||||
class nsIAtom;
|
||||
class nsView;
|
||||
|
@ -8,7 +8,8 @@
|
||||
|
||||
#include "AccessibleWrap.h"
|
||||
#include "HyperTextAccessibleWrap.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
class nsIContent;
|
||||
|
||||
/**
|
||||
* This file contains a number of classes that are used as base
|
||||
|
@ -9,9 +9,10 @@
|
||||
#include "HyperTextAccessible.h"
|
||||
#include "DocAccessibleWrap.h"
|
||||
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
|
||||
class nsIDocument;
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "nsIAccessible.h"
|
||||
#include "nsIAccessibleEvent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsAccessNode.h"
|
||||
#include "oleidl.h"
|
||||
#include "oleacc.h"
|
||||
@ -43,6 +42,8 @@
|
||||
{ } \
|
||||
return E_FAIL;
|
||||
|
||||
class nsIContent;
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsFrameLoader;
|
||||
interface nsIDocShell;
|
||||
interface nsIURI;
|
||||
interface nsIFrame;
|
||||
|
@ -25,7 +25,7 @@ interface nsIURI;
|
||||
* interface to mirror this interface when changing it.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(b6c5ae8a-5e30-41f1-975a-be73cd6f71db)]
|
||||
[scriptable, uuid(e2ef99fe-f7d3-422f-a7b4-834e8bdde710)]
|
||||
interface nsIObjectLoadingContent : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -5,11 +5,12 @@
|
||||
#ifndef nsTreeSanitizer_h_
|
||||
#define nsTreeSanitizer_h_
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "mozilla/css/StyleRule.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
class nsIContent;
|
||||
|
||||
/**
|
||||
* See the documentation of nsIParserUtils::sanitize for documentation
|
||||
* about the default behavior and the configuration options of this sanitizer.
|
||||
|
@ -6,15 +6,17 @@
|
||||
#ifndef nsDOMParser_h_
|
||||
#define nsDOMParser_h_
|
||||
|
||||
#include "nsIDOMParser.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMParser.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/DOMParserBinding.h"
|
||||
#include "mozilla/dom/TypedArray.h"
|
||||
|
||||
class nsIDocument;
|
||||
|
||||
class nsDOMParser MOZ_FINAL : public nsIDOMParser,
|
||||
public nsSupportsWeakReference,
|
||||
public nsWrapperCache
|
||||
|
@ -12,15 +12,17 @@
|
||||
#ifndef nsPlainTextSerializer_h__
|
||||
#define nsPlainTextSerializer_h__
|
||||
|
||||
#include "nsIContentSerializer.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsILineBreaker.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIContentSerializer.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsILineBreaker.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsIContent;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class Element;
|
||||
|
@ -12,7 +12,6 @@
|
||||
#ifndef nsXMLContentSerializer_h__
|
||||
#define nsXMLContentSerializer_h__
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentSerializer.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsCOMPtr.h"
|
||||
@ -22,8 +21,9 @@
|
||||
#define kIndentStr NS_LITERAL_STRING(" ")
|
||||
#define kEndTag NS_LITERAL_STRING("</")
|
||||
|
||||
class nsIDOMNode;
|
||||
class nsIAtom;
|
||||
class nsIDOMNode;
|
||||
class nsINode;
|
||||
|
||||
class nsXMLContentSerializer : public nsIContentSerializer {
|
||||
public:
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIMEStateManager.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIWidget.h"
|
||||
|
@ -11,14 +11,15 @@
|
||||
|
||||
#include "nsISelection.h"
|
||||
#include "nsRange.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMTreeWalker.h"
|
||||
|
||||
class nsPresContext;
|
||||
class nsCaret;
|
||||
class nsIContent;
|
||||
class nsIPresShell;
|
||||
class nsPresContext;
|
||||
class nsQueryContentEvent;
|
||||
class nsSelectionEvent;
|
||||
class nsCaret;
|
||||
|
||||
struct nsRect;
|
||||
|
||||
/*
|
||||
|
@ -10,24 +10,23 @@
|
||||
|
||||
#include "nsEvent.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsIFrameLoader.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIMarkupDocumentViewer.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsEventStates.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "nsIFrame.h"
|
||||
|
||||
class nsIPresShell;
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIDocShell;
|
||||
class nsIDocShellTreeNode;
|
||||
class nsIDocShellTreeItem;
|
||||
|
@ -12,9 +12,10 @@
|
||||
#include "nsILink.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "Link.h"
|
||||
|
||||
class nsIDocument;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
|
@ -10,10 +10,10 @@
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "mozilla/dom/Nullable.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
class nsITransactionManager;
|
||||
class nsIMutationObserver;
|
||||
|
@ -10,9 +10,10 @@
|
||||
#include "nsSVGElement.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsSVGString.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsScriptElement.h"
|
||||
|
||||
class nsIDocument;
|
||||
|
||||
nsresult NS_NewSVGScriptElement(nsIContent **aResult,
|
||||
already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
mozilla::dom::FromParser aFromParser);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#ifndef nsBindingManager_h_
|
||||
#define nsBindingManager_h_
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsStubMutationObserver.h"
|
||||
#include "pldhash.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
@ -17,7 +18,6 @@
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
struct ElementDependentRuleProcessorData;
|
||||
class nsIContent;
|
||||
class nsIXPConnectWrappedJS;
|
||||
class nsIAtom;
|
||||
class nsIDOMNodeList;
|
||||
|
@ -4,6 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsString.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "jsapi.h"
|
||||
|
@ -9,11 +9,12 @@
|
||||
#include "nsIAtom.h"
|
||||
#include "nsString.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXBLProtoImplMember.h"
|
||||
#include "nsXBLSerialize.h"
|
||||
|
||||
class nsIContent;
|
||||
|
||||
struct nsXBLParameter {
|
||||
nsXBLParameter* mNext;
|
||||
char* mName;
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "nsIAtom.h"
|
||||
#include "nsString.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXBLSerialize.h"
|
||||
#include "nsXBLProtoImplMember.h"
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "nsXBLProtoImplMethod.h"
|
||||
#include "nsICSSLoaderObserver.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsXBLDocumentInfo.h"
|
||||
@ -20,6 +19,7 @@
|
||||
#include "nsXBLProtoImpl.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIScriptContext;
|
||||
class nsSupportsHashtable;
|
||||
|
@ -6,7 +6,7 @@
|
||||
#ifndef nsXBLPrototypeResources_h__
|
||||
#define nsXBLPrototypeResources_h__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsICSSLoaderObserver.h"
|
||||
#include "nsIStyleRuleProcessor.h"
|
||||
|
||||
|
@ -2,14 +2,15 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
#ifndef nsXMLPrettyPrinter_h__
|
||||
#define nsXMLPrettyPrinter_h__
|
||||
|
||||
#include "nsStubDocumentObserver.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsIDocument;
|
||||
|
||||
class nsXMLPrettyPrinter : public nsStubDocumentObserver
|
||||
{
|
||||
public:
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "txExprResult.h"
|
||||
#include "nsIDOMXPathResult.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsStubMutationObserver.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCOMArray.h"
|
||||
@ -16,6 +15,8 @@
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
class nsIDocument;
|
||||
|
||||
// {662f2c9a-c7cd-4cab-9349-e733df5a838c}
|
||||
#define NS_IXPATHRESULT_IID \
|
||||
{ 0x662f2c9a, 0xc7cd, 0x4cab, {0x93, 0x49, 0xe7, 0x33, 0xdf, 0x5a, 0x83, 0x8c }}
|
||||
|
@ -4,6 +4,8 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsIDOMHTMLElement.h"
|
||||
#include "nsIDOMHTMLMenuItemElement.h"
|
||||
#include "nsXULContextMenuBuilder.h"
|
||||
|
@ -5,12 +5,15 @@
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIMenuBuilder.h"
|
||||
#include "nsIXULContextMenuBuilder.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIDOMHTMLElement;
|
||||
|
||||
class nsXULContextMenuBuilder : public nsIMenuBuilder,
|
||||
public nsIXULContextMenuBuilder
|
||||
{
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "nsEventListenerManager.h"
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsIRDFResource.h"
|
||||
#include "nsBindingManager.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIXULTemplateBuilder.h"
|
||||
#include "nsIBoxObject.h"
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "nsStubDocumentObserver.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsIRDFContainer.h"
|
||||
@ -31,9 +30,10 @@
|
||||
extern PRLogModuleInfo* gXULTemplateLog;
|
||||
#endif
|
||||
|
||||
class nsIXULDocument;
|
||||
class nsIRDFCompositeDataSource;
|
||||
class nsIContent;
|
||||
class nsIObserverService;
|
||||
class nsIRDFCompositeDataSource;
|
||||
class nsIXULDocument;
|
||||
|
||||
/**
|
||||
* An object that translates an RDF graph into a presentation using a
|
||||
|
@ -4,6 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsICollation.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFObserver.h"
|
||||
|
@ -7,7 +7,6 @@
|
||||
#ifndef nsXULTemplateQueryProcessorRDF_h__
|
||||
#define nsXULTemplateQueryProcessorRDF_h__
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsIRDFContainer.h"
|
||||
#include "nsIRDFContainerUtils.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
@ -15,7 +14,6 @@
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIXULTemplateBuilder.h"
|
||||
#include "nsIXULTemplateQueryProcessor.h"
|
||||
#include "nsICollation.h"
|
||||
#include "nsCollationCID.h"
|
||||
|
||||
#include "nsResourceSet.h"
|
||||
@ -24,7 +22,6 @@
|
||||
#include "nsRDFBinding.h"
|
||||
#include "nsXULTemplateResultSetRDF.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsIArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsRefPtrHashtable.h"
|
||||
@ -36,6 +33,7 @@
|
||||
extern PRLogModuleInfo* gXULTemplateLog;
|
||||
#endif
|
||||
|
||||
class nsIContent;
|
||||
class nsIRDFCompositeDataSource;
|
||||
class nsXULTemplateResultRDF;
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsDocShellCID.h"
|
||||
#include "nsIWebNavigationInfo.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
@ -6,13 +6,13 @@
|
||||
#define nsILinkHandler_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
class nsIInputStream;
|
||||
class nsGUIEvent;
|
||||
class nsIContent;
|
||||
class nsIDocShell;
|
||||
class nsIInputStream;
|
||||
class nsIRequest;
|
||||
class nsString;
|
||||
class nsGUIEvent;
|
||||
|
||||
// Interface ID for nsILinkHandler
|
||||
#define NS_ILINKHANDLER_IID \
|
||||
|
@ -6,11 +6,12 @@
|
||||
#ifndef nsFocusManager_h___
|
||||
#define nsFocusManager_h___
|
||||
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIFocusManager.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
#define FOCUSMETHOD_MASK 0xF000
|
||||
@ -18,6 +19,7 @@
|
||||
|
||||
#define FOCUSMANAGER_CONTRACTID "@mozilla.org/focus-manager;1"
|
||||
|
||||
class nsIContent;
|
||||
class nsIDocShellTreeItem;
|
||||
class nsPIDOMWindow;
|
||||
|
||||
|
@ -51,7 +51,6 @@
|
||||
#include "nsIDOMStorageIndexedDB.h"
|
||||
#include "nsIDOMOfflineResourceList.h"
|
||||
#include "nsIArray.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIIDBFactory.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
@ -91,6 +90,7 @@
|
||||
// Min idle notification time in seconds.
|
||||
#define MIN_IDLE_NOTIFICATION_TIME_S 1
|
||||
|
||||
class nsIContent;
|
||||
class nsIDOMBarProp;
|
||||
class nsIDocument;
|
||||
class nsPresContext;
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIArray.h"
|
||||
#include "nsIScriptTimeoutHandler.h"
|
||||
#include "nsIXPConnect.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "nsWindowMemoryReporter.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIEffectiveTLDService.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsIControllers.h"
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "DOMCameraPreview.h"
|
||||
#include "CameraCommon.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
@ -3936,14 +3936,11 @@ GetAllHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
||||
bool hasResult;
|
||||
while (NS_SUCCEEDED((rv = stmt->ExecuteStep(&hasResult))) && hasResult) {
|
||||
if (mCloneReadInfos.Capacity() == mCloneReadInfos.Length()) {
|
||||
if (!mCloneReadInfos.SetCapacity(mCloneReadInfos.Capacity() * 2)) {
|
||||
NS_ERROR("Out of memory!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
mCloneReadInfos.SetCapacity(mCloneReadInfos.Capacity() * 2);
|
||||
}
|
||||
|
||||
StructuredCloneReadInfo* readInfo = mCloneReadInfos.AppendElement();
|
||||
NS_ASSERTION(readInfo, "Shouldn't fail if SetCapacity succeeded!");
|
||||
NS_ASSERTION(readInfo, "Shouldn't fail since SetCapacity succeeded!");
|
||||
|
||||
rv = IDBObjectStore::GetStructuredCloneReadInfoFromStatement(stmt, 0, 1,
|
||||
mDatabase, *readInfo);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsHostObjectProtocolHandler.h"
|
||||
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMFile.h"
|
||||
|
||||
USING_WORKERS_NAMESPACE
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsBaseHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "gfxPattern.h"
|
||||
#include "gfxFont.h"
|
||||
#include "mozilla/gfx/UserData.h"
|
||||
|
@ -493,11 +493,6 @@ Debugger::slowPathOnEnterFrame(JSContext *cx, AbstractFramePtr frame, MutableHan
|
||||
AutoValueVector triggered(cx);
|
||||
Handle<GlobalObject*> global = cx->global();
|
||||
|
||||
#ifdef DEBUG
|
||||
ScriptFrameIter iter(cx);
|
||||
JS_ASSERT(iter.abstractFramePtr() == frame);
|
||||
#endif
|
||||
|
||||
if (GlobalObject::DebuggerVector *debuggers = global->getDebuggers()) {
|
||||
for (Debugger **p = debuggers->begin(); p != debuggers->end(); p++) {
|
||||
Debugger *dbg = *p;
|
||||
@ -531,11 +526,6 @@ DebuggerFrame_freeStackIterData(FreeOp *fop, RawObject obj);
|
||||
bool
|
||||
Debugger::slowPathOnLeaveFrame(JSContext *cx, AbstractFramePtr frame, bool frameOk)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
ScriptFrameIter iter(cx);
|
||||
JS_ASSERT(iter.abstractFramePtr() == frame);
|
||||
#endif
|
||||
|
||||
Handle<GlobalObject*> global = cx->global();
|
||||
|
||||
/* Save the frame's completion value. */
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "WrapperFactory.h"
|
||||
|
||||
#include "nsINode.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
#define nsContentDLF_h__
|
||||
|
||||
#include "nsIDocumentLoaderFactory.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsMimeTypes.h"
|
||||
|
||||
class nsIChannel;
|
||||
|
@ -22,10 +22,10 @@
|
||||
#include "nsIListControlFrame.h"
|
||||
#include "nsISelectControlFrame.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsSelectsAreaFrame.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIDOMHTMLSelectElement;
|
||||
class nsIDOMHTMLOptionsCollection;
|
||||
class nsIDOMHTMLOptionElement;
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
// Interfaces
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIObserver.h"
|
||||
|
||||
@ -27,6 +26,7 @@
|
||||
class nsPagePrintTimer;
|
||||
class nsIDocShellTreeNode;
|
||||
class nsDeviceContext;
|
||||
class nsIDocument;
|
||||
class nsIDocumentViewerPrint;
|
||||
class nsPrintObject;
|
||||
class nsIDocShell;
|
||||
|
@ -9,14 +9,14 @@
|
||||
|
||||
// Interfaces
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsStyleSet.h"
|
||||
#include "nsViewManager.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsPresContext;
|
||||
|
||||
// nsPrintObject Document Type
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsIStyleSheet.h"
|
||||
#include "nsIStyleRuleProcessor.h"
|
||||
|
||||
|
@ -12,12 +12,13 @@
|
||||
#ifndef nsHTMLStyleSheet_h_
|
||||
#define nsHTMLStyleSheet_h_
|
||||
|
||||
#include "nsIStyleSheet.h"
|
||||
#include "nsIStyleRuleProcessor.h"
|
||||
#include "nsIStyleRule.h"
|
||||
#include "pldhash.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIStyleRule.h"
|
||||
#include "nsIStyleRuleProcessor.h"
|
||||
#include "nsIStyleSheet.h"
|
||||
#include "pldhash.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
class nsMappedAttributes;
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsChangeHint.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
struct RuleProcessorData;
|
||||
struct ElementRuleProcessorData;
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "nsPresContext.h" // for nsCompatibility
|
||||
#include "nsString.h"
|
||||
#include "nsChangeHint.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsCSSPseudoElements.h"
|
||||
#include "nsRuleWalker.h"
|
||||
#include "nsNthIndexCache.h"
|
||||
@ -23,10 +22,11 @@
|
||||
#include "mozilla/BloomFilter.h"
|
||||
#include "mozilla/GuardObjects.h"
|
||||
|
||||
class nsIStyleSheet;
|
||||
class nsIAtom;
|
||||
class nsICSSPseudoComparator;
|
||||
class nsAttrValue;
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
class nsICSSPseudoComparator;
|
||||
class nsIStyleSheet;
|
||||
struct TreeMatchContext;
|
||||
|
||||
/**
|
||||
|
@ -19,12 +19,12 @@
|
||||
#include "nsMenuParent.h"
|
||||
#include "nsXULPopupManager.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsIContent.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
nsIFrame* NS_NewMenuFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
||||
nsIFrame* NS_NewMenuItemFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
||||
|
||||
class nsIContent;
|
||||
class nsMenuBarFrame;
|
||||
|
||||
#define NS_STATE_ACCELTEXT_IS_DERIVED NS_STATE_BOX_CHILD_RESERVED
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsCOMPtr.h"
|
||||
@ -20,6 +19,8 @@
|
||||
#include "nsWeakPtr.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
class nsIContent;
|
||||
|
||||
class nsXULTooltipListener MOZ_FINAL : public nsIDOMEventListener
|
||||
{
|
||||
public:
|
||||
|
@ -6,8 +6,8 @@
|
||||
#ifndef nsTreeContentView_h__
|
||||
#define nsTreeContentView_h__
|
||||
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsStubDocumentObserver.h"
|
||||
#include "nsITreeBoxObject.h"
|
||||
#include "nsITreeColumns.h"
|
||||
@ -16,6 +16,7 @@
|
||||
#include "nsITreeSelection.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
class nsIDocument;
|
||||
class Row;
|
||||
|
||||
nsresult NS_NewTreeContentView(nsITreeView** aResult);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsINodeInfo.h"
|
||||
|
||||
|
@ -6,9 +6,13 @@
|
||||
#ifndef nsTreeUtils_h__
|
||||
#define nsTreeUtils_h__
|
||||
|
||||
#include "nsError.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTreeStyleCache.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
class nsISupportsArray;
|
||||
|
||||
class nsTreeUtils
|
||||
{
|
||||
|
587
mobile/android/chrome/content/SelectionHandler.js
Normal file
587
mobile/android/chrome/content/SelectionHandler.js
Normal file
@ -0,0 +1,587 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
var SelectionHandler = {
|
||||
HANDLE_TYPE_START: "START",
|
||||
HANDLE_TYPE_MIDDLE: "MIDDLE",
|
||||
HANDLE_TYPE_END: "END",
|
||||
|
||||
TYPE_NONE: 0,
|
||||
TYPE_CURSOR: 1,
|
||||
TYPE_SELECTION: 2,
|
||||
|
||||
// Keeps track of data about the dimensions of the selection. Coordinates
|
||||
// stored here are relative to the _view window.
|
||||
cache: null,
|
||||
_activeType: 0, // TYPE_NONE
|
||||
|
||||
// The window that holds the selection (can be a sub-frame)
|
||||
get _view() {
|
||||
if (this._viewRef)
|
||||
return this._viewRef.get();
|
||||
return null;
|
||||
},
|
||||
|
||||
set _view(aView) {
|
||||
this._viewRef = Cu.getWeakReference(aView);
|
||||
},
|
||||
|
||||
// The target can be a window or an input element
|
||||
get _target() {
|
||||
if (this._targetRef)
|
||||
return this._targetRef.get();
|
||||
return null;
|
||||
},
|
||||
|
||||
set _target(aTarget) {
|
||||
this._targetRef = Cu.getWeakReference(aTarget);
|
||||
},
|
||||
|
||||
get _cwu() {
|
||||
return BrowserApp.selectedBrowser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsIDOMWindowUtils);
|
||||
},
|
||||
|
||||
_isRTL: false,
|
||||
|
||||
_addObservers: function sh_addObservers() {
|
||||
Services.obs.addObserver(this, "Gesture:SingleTap", false);
|
||||
Services.obs.addObserver(this, "Window:Resize", false);
|
||||
Services.obs.addObserver(this, "Tab:Selected", false);
|
||||
Services.obs.addObserver(this, "after-viewport-change", false);
|
||||
Services.obs.addObserver(this, "TextSelection:Move", false);
|
||||
Services.obs.addObserver(this, "TextSelection:Position", false);
|
||||
BrowserApp.deck.addEventListener("compositionend", this, false);
|
||||
},
|
||||
|
||||
_removeObservers: function sh_removeObservers() {
|
||||
Services.obs.removeObserver(this, "Gesture:SingleTap");
|
||||
Services.obs.removeObserver(this, "Window:Resize");
|
||||
Services.obs.removeObserver(this, "Tab:Selected");
|
||||
Services.obs.removeObserver(this, "after-viewport-change");
|
||||
Services.obs.removeObserver(this, "TextSelection:Move");
|
||||
Services.obs.removeObserver(this, "TextSelection:Position");
|
||||
BrowserApp.deck.removeEventListener("compositionend", this);
|
||||
},
|
||||
|
||||
observe: function sh_observe(aSubject, aTopic, aData) {
|
||||
switch (aTopic) {
|
||||
case "Gesture:SingleTap": {
|
||||
if (this._activeType == this.TYPE_SELECTION) {
|
||||
let data = JSON.parse(aData);
|
||||
this.endSelection(data.x, data.y);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "Tab:Selected":
|
||||
if (this._activeType == this.TYPE_CURSOR) {
|
||||
this.hideThumb();
|
||||
}
|
||||
// fall through
|
||||
case "Window:Resize": {
|
||||
if (this._activeType == this.TYPE_SELECTION) {
|
||||
// Knowing when the page is done drawing is hard, so let's just cancel
|
||||
// the selection when the window changes. We should fix this later.
|
||||
this.endSelection();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "after-viewport-change": {
|
||||
if (this._activeType == this.TYPE_SELECTION) {
|
||||
// Update the cache after the viewport changes (e.g. panning, zooming).
|
||||
this.updateCacheForSelection();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "TextSelection:Move": {
|
||||
let data = JSON.parse(aData);
|
||||
if (this._activeType == this.TYPE_SELECTION)
|
||||
this.moveSelection(data.handleType == this.HANDLE_TYPE_START, data.x, data.y);
|
||||
else if (this._activeType == this.TYPE_CURSOR) {
|
||||
// Send a click event to the text box, which positions the caret
|
||||
this._sendMouseEvents(data.x, data.y);
|
||||
|
||||
// Move the handle directly under the caret
|
||||
this.positionHandles();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "TextSelection:Position": {
|
||||
if (this._activeType == this.TYPE_SELECTION) {
|
||||
let data = JSON.parse(aData);
|
||||
|
||||
// Reverse the handles if necessary.
|
||||
let selectionReversed = this.updateCacheForSelection(data.handleType == this.HANDLE_TYPE_START);
|
||||
if (selectionReversed) {
|
||||
// Re-send mouse events to update the selection corresponding to the new handles.
|
||||
if (this._isRTL) {
|
||||
this._sendMouseEvents(this.cache.end.x, this.cache.end.y, false);
|
||||
this._sendMouseEvents(this.cache.start.x, this.cache.start.y, true);
|
||||
} else {
|
||||
this._sendMouseEvents(this.cache.start.x, this.cache.start.y, false);
|
||||
this._sendMouseEvents(this.cache.end.x, this.cache.end.y, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Position the handles to align with the edges of the selection.
|
||||
this.positionHandles();
|
||||
} else if (this._activeType == this.TYPE_CURSOR) {
|
||||
this.positionHandles();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
handleEvent: function sh_handleEvent(aEvent) {
|
||||
switch (aEvent.type) {
|
||||
case "pagehide":
|
||||
if (this._activeType == this.TYPE_SELECTION)
|
||||
this.endSelection();
|
||||
else
|
||||
this.hideThumb();
|
||||
break;
|
||||
|
||||
case "keydown":
|
||||
case "blur":
|
||||
if (this._activeType == this.TYPE_CURSOR)
|
||||
this.hideThumb();
|
||||
break;
|
||||
|
||||
case "compositionend":
|
||||
// If the handles are displayed during user input, hide them.
|
||||
if (this._activeType == this.TYPE_CURSOR) {
|
||||
this.hideThumb();
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
_ignoreCollapsedSelection: false,
|
||||
|
||||
notifySelectionChanged: function sh_notifySelectionChanged(aDoc, aSel, aReason) {
|
||||
if (aSel.isCollapsed) {
|
||||
// Bail if we're ignoring events for a collapsed selection.
|
||||
if (this._ignoreCollapsedSelection)
|
||||
return;
|
||||
|
||||
// If the selection is collapsed because of one of the mouse events we
|
||||
// sent while moving the handle, don't get rid of the selection handles.
|
||||
if (aReason & Ci.nsISelectionListener.MOUSEDOWN_REASON) {
|
||||
this._ignoreCollapsedSelection = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, we do want to end the selection.
|
||||
this.endSelection();
|
||||
}
|
||||
|
||||
this._ignoreCollapsedSelection = false;
|
||||
},
|
||||
|
||||
/** Returns true if the provided element can be selected in text selection, false otherwise. */
|
||||
canSelect: function sh_canSelect(aElement) {
|
||||
return !(aElement instanceof Ci.nsIDOMHTMLButtonElement ||
|
||||
aElement instanceof Ci.nsIDOMHTMLEmbedElement ||
|
||||
aElement instanceof Ci.nsIDOMHTMLImageElement ||
|
||||
aElement instanceof Ci.nsIDOMHTMLMediaElement) &&
|
||||
aElement.style.MozUserSelect != 'none';
|
||||
},
|
||||
|
||||
// aX/aY are in top-level window browser coordinates
|
||||
startSelection: function sh_startSelection(aElement, aX, aY) {
|
||||
// Clear out any existing selection
|
||||
if (this._activeType == this.TYPE_SELECTION) {
|
||||
this.endSelection();
|
||||
} else if (this._activeType == this.TYPE_CURSOR) {
|
||||
// Hide the cursor handles.
|
||||
this.hideThumb();
|
||||
}
|
||||
|
||||
// Get the element's view
|
||||
this._view = aElement.ownerDocument.defaultView;
|
||||
|
||||
if (aElement instanceof Ci.nsIDOMNSEditableElement)
|
||||
this._target = aElement;
|
||||
else
|
||||
this._target = this._view;
|
||||
|
||||
this._addObservers();
|
||||
this._view.addEventListener("pagehide", this, false);
|
||||
this._isRTL = (this._view.getComputedStyle(aElement, "").direction == "rtl");
|
||||
|
||||
// Remove any previous selected or created ranges. Tapping anywhere on a
|
||||
// page will create an empty range.
|
||||
let selection = this.getSelection();
|
||||
selection.removeAllRanges();
|
||||
|
||||
// Position the caret using a fake mouse click sent to the top-level window
|
||||
this._sendMouseEvents(aX, aY, false);
|
||||
|
||||
try {
|
||||
let selectionController = this.getSelectionController();
|
||||
|
||||
// Select the word nearest the caret
|
||||
selectionController.wordMove(false, false);
|
||||
|
||||
// Move forward in LTR, backward in RTL
|
||||
selectionController.wordMove(!this._isRTL, true);
|
||||
} catch(e) {
|
||||
// If we couldn't select the word at the given point, bail
|
||||
this._cleanUp();
|
||||
return;
|
||||
}
|
||||
|
||||
// If there isn't an appropriate selection, bail
|
||||
if (!selection.rangeCount || !selection.getRangeAt(0) || !selection.toString().trim().length) {
|
||||
selection.collapseToStart();
|
||||
this._cleanUp();
|
||||
return;
|
||||
}
|
||||
|
||||
// Add a listener to end the selection if it's removed programatically
|
||||
selection.QueryInterface(Ci.nsISelectionPrivate).addSelectionListener(this);
|
||||
|
||||
// Initialize the cache
|
||||
this.cache = { start: {}, end: {}};
|
||||
this.updateCacheForSelection();
|
||||
|
||||
this._activeType = this.TYPE_SELECTION;
|
||||
this.positionHandles();
|
||||
|
||||
sendMessageToJava({
|
||||
type: "TextSelection:ShowHandles",
|
||||
handles: [this.HANDLE_TYPE_START, this.HANDLE_TYPE_END]
|
||||
});
|
||||
|
||||
if (aElement instanceof Ci.nsIDOMNSEditableElement)
|
||||
aElement.focus();
|
||||
},
|
||||
|
||||
getSelection: function sh_getSelection() {
|
||||
if (this._target instanceof Ci.nsIDOMNSEditableElement)
|
||||
return this._target.QueryInterface(Ci.nsIDOMNSEditableElement).editor.selection;
|
||||
else
|
||||
return this._target.getSelection();
|
||||
},
|
||||
|
||||
getSelectionController: function sh_getSelectionController() {
|
||||
if (this._target instanceof Ci.nsIDOMNSEditableElement)
|
||||
return this._target.QueryInterface(Ci.nsIDOMNSEditableElement).editor.selectionController;
|
||||
else
|
||||
return this._target.QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsIWebNavigation).
|
||||
QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsISelectionDisplay).
|
||||
QueryInterface(Ci.nsISelectionController);
|
||||
},
|
||||
|
||||
// Used by the contextmenu "matches" functions in ClipboardHelper
|
||||
shouldShowContextMenu: function sh_shouldShowContextMenu(aX, aY) {
|
||||
return (this._activeType == this.TYPE_SELECTION) && this._pointInSelection(aX, aY);
|
||||
},
|
||||
|
||||
selectAll: function sh_selectAll(aElement, aX, aY) {
|
||||
if (this._activeType != this.TYPE_SELECTION)
|
||||
this.startSelection(aElement, aX, aY);
|
||||
|
||||
let selectionController = this.getSelectionController();
|
||||
selectionController.selectAll();
|
||||
this.updateCacheForSelection();
|
||||
this.positionHandles();
|
||||
},
|
||||
|
||||
// Moves the ends of the selection in the page. aX/aY are in top-level window
|
||||
// browser coordinates.
|
||||
moveSelection: function sh_moveSelection(aIsStartHandle, aX, aY) {
|
||||
// Update the handle position as it's dragged.
|
||||
if (aIsStartHandle) {
|
||||
this.cache.start.x = aX;
|
||||
this.cache.start.y = aY;
|
||||
} else {
|
||||
this.cache.end.x = aX;
|
||||
this.cache.end.y = aY;
|
||||
}
|
||||
|
||||
// The handles work the same on both LTR and RTL pages, but the underlying selection
|
||||
// works differently, so we need to reverse how we send mouse events on RTL pages.
|
||||
if (this._isRTL) {
|
||||
// Position the caret at the end handle using a fake mouse click
|
||||
if (!aIsStartHandle)
|
||||
this._sendMouseEvents(this.cache.end.x, this.cache.end.y, false);
|
||||
|
||||
// Selects text between the carat and the start handle using a fake shift+click
|
||||
this._sendMouseEvents(this.cache.start.x, this.cache.start.y, true);
|
||||
} else {
|
||||
// Position the caret at the start handle using a fake mouse click
|
||||
if (aIsStartHandle)
|
||||
this._sendMouseEvents(this.cache.start.x, this.cache.start.y, false);
|
||||
|
||||
// Selects text between the carat and the end handle using a fake shift+click
|
||||
this._sendMouseEvents( this.cache.end.x, this.cache.end.y, true);
|
||||
}
|
||||
},
|
||||
|
||||
_sendMouseEvents: function sh_sendMouseEvents(aX, aY, useShift) {
|
||||
// If we're positioning a cursor in an input field, make sure the handle
|
||||
// stays within the bounds of the field
|
||||
if (this._activeType == this.TYPE_CURSOR) {
|
||||
// Get rect of text inside element
|
||||
let range = document.createRange();
|
||||
range.selectNodeContents(this._target.QueryInterface(Ci.nsIDOMNSEditableElement).editor.rootElement);
|
||||
let textBounds = range.getBoundingClientRect();
|
||||
|
||||
// Get rect of editor
|
||||
let editorBounds = this._cwu.sendQueryContentEvent(this._cwu.QUERY_EDITOR_RECT, 0, 0, 0, 0);
|
||||
let editorRect = new Rect(editorBounds.left, editorBounds.top, editorBounds.width, editorBounds.height);
|
||||
|
||||
// Use intersection of the text rect and the editor rect
|
||||
let rect = new Rect(textBounds.left, textBounds.top, textBounds.width, textBounds.height);
|
||||
rect.restrictTo(editorRect);
|
||||
|
||||
// Clamp vertically and scroll if handle is at bounds. The top and bottom
|
||||
// must be restricted by an additional pixel since clicking on the top
|
||||
// edge of an input field moves the cursor to the beginning of that
|
||||
// field's text (and clicking the bottom moves the cursor to the end).
|
||||
if (aY < rect.y + 1) {
|
||||
aY = rect.y + 1;
|
||||
this.getSelectionController().scrollLine(false);
|
||||
} else if (aY > rect.y + rect.height - 1) {
|
||||
aY = rect.y + rect.height - 1;
|
||||
this.getSelectionController().scrollLine(true);
|
||||
}
|
||||
|
||||
// Clamp horizontally and scroll if handle is at bounds
|
||||
if (aX < rect.x) {
|
||||
aX = rect.x;
|
||||
this.getSelectionController().scrollCharacter(false);
|
||||
} else if (aX > rect.x + rect.width) {
|
||||
aX = rect.x + rect.width;
|
||||
this.getSelectionController().scrollCharacter(true);
|
||||
}
|
||||
} else if (this._activeType == this.TYPE_SELECTION) {
|
||||
// Send mouse event 1px too high to prevent selection from entering the line below where it should be
|
||||
aY -= 1;
|
||||
}
|
||||
|
||||
this._cwu.sendMouseEventToWindow("mousedown", aX, aY, 0, 0, useShift ? Ci.nsIDOMNSEvent.SHIFT_MASK : 0, true);
|
||||
this._cwu.sendMouseEventToWindow("mouseup", aX, aY, 0, 0, useShift ? Ci.nsIDOMNSEvent.SHIFT_MASK : 0, true);
|
||||
},
|
||||
|
||||
// aX/aY are in top-level window browser coordinates
|
||||
endSelection: function sh_endSelection(aX, aY) {
|
||||
if (this._activeType != this.TYPE_SELECTION)
|
||||
return "";
|
||||
|
||||
this._activeType = this.TYPE_NONE;
|
||||
sendMessageToJava({
|
||||
type: "TextSelection:HideHandles",
|
||||
handles: [this.HANDLE_TYPE_START, this.HANDLE_TYPE_END]
|
||||
});
|
||||
|
||||
|
||||
let selectedText = "";
|
||||
let pointInSelection = false;
|
||||
if (this._view) {
|
||||
let selection = this.getSelection();
|
||||
if (selection) {
|
||||
// Get the text before we clear the selection!
|
||||
selectedText = selection.toString().trim();
|
||||
|
||||
// Also figure out if the point is in the selection before we clear it.
|
||||
if (arguments.length == 2 && this._pointInSelection(aX, aY))
|
||||
pointInSelection = true;
|
||||
|
||||
selection.removeAllRanges();
|
||||
selection.QueryInterface(Ci.nsISelectionPrivate).removeSelectionListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Only try copying text if there's text to copy!
|
||||
if (pointInSelection && selectedText.length) {
|
||||
let element = ElementTouchHelper.anyElementFromPoint(aX, aY);
|
||||
// Only try copying text if the tap happens in the same view
|
||||
if (element.ownerDocument.defaultView == this._view) {
|
||||
let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper);
|
||||
clipboard.copyString(selectedText, element.ownerDocument);
|
||||
NativeWindow.toast.show(Strings.browser.GetStringFromName("selectionHelper.textCopied"), "short");
|
||||
}
|
||||
}
|
||||
|
||||
this._cleanUp();
|
||||
|
||||
return selectedText;
|
||||
},
|
||||
|
||||
_cleanUp: function sh_cleanUp() {
|
||||
this._removeObservers();
|
||||
this._view.removeEventListener("pagehide", this, false);
|
||||
this._view.removeEventListener("keydown", this, false);
|
||||
this._view.removeEventListener("blur", this, true);
|
||||
this._activeType = this.TYPE_NONE;
|
||||
this._view = null;
|
||||
this._target = null;
|
||||
this._isRTL = false;
|
||||
this.cache = null;
|
||||
},
|
||||
|
||||
_getViewOffset: function sh_getViewOffset() {
|
||||
let offset = { x: 0, y: 0 };
|
||||
let win = this._view;
|
||||
|
||||
// Recursively look through frames to compute the total position offset.
|
||||
while (win.frameElement) {
|
||||
let rect = win.frameElement.getBoundingClientRect();
|
||||
offset.x += rect.left;
|
||||
offset.y += rect.top;
|
||||
|
||||
win = win.parent;
|
||||
}
|
||||
|
||||
return offset;
|
||||
},
|
||||
|
||||
_pointInSelection: function sh_pointInSelection(aX, aY) {
|
||||
let offset = this._getViewOffset();
|
||||
let rangeRect = this.getSelection().getRangeAt(0).getBoundingClientRect();
|
||||
let radius = ElementTouchHelper.getTouchRadius();
|
||||
return (aX - offset.x > rangeRect.left - radius.left &&
|
||||
aX - offset.x < rangeRect.right + radius.right &&
|
||||
aY - offset.y > rangeRect.top - radius.top &&
|
||||
aY - offset.y < rangeRect.bottom + radius.bottom);
|
||||
},
|
||||
|
||||
// Returns true if the selection has been reversed. Takes optional aIsStartHandle
|
||||
// param to decide whether the selection has been reversed.
|
||||
updateCacheForSelection: function sh_updateCacheForSelection(aIsStartHandle) {
|
||||
let selection = this.getSelection();
|
||||
let rects = selection.getRangeAt(0).getClientRects();
|
||||
let start = { x: this._isRTL ? rects[0].right : rects[0].left, y: rects[0].bottom };
|
||||
let end = { x: this._isRTL ? rects[rects.length - 1].left : rects[rects.length - 1].right, y: rects[rects.length - 1].bottom };
|
||||
|
||||
let selectionReversed = false;
|
||||
if (this.cache.start) {
|
||||
// If the end moved past the old end, but we're dragging the start handle, then that handle should become the end handle (and vice versa)
|
||||
selectionReversed = (aIsStartHandle && (end.y > this.cache.end.y || (end.y == this.cache.end.y && end.x > this.cache.end.x))) ||
|
||||
(!aIsStartHandle && (start.y < this.cache.start.y || (start.y == this.cache.start.y && start.x < this.cache.start.x)));
|
||||
}
|
||||
|
||||
this.cache.start = start;
|
||||
this.cache.end = end;
|
||||
|
||||
return selectionReversed;
|
||||
},
|
||||
|
||||
showThumb: function sh_showThumb(aElement) {
|
||||
if (!aElement)
|
||||
return;
|
||||
|
||||
// Get the element's view
|
||||
this._view = aElement.ownerDocument.defaultView;
|
||||
this._target = aElement;
|
||||
|
||||
this._addObservers();
|
||||
this._view.addEventListener("pagehide", this, false);
|
||||
this._view.addEventListener("keydown", this, false);
|
||||
this._view.addEventListener("blur", this, true);
|
||||
|
||||
this._activeType = this.TYPE_CURSOR;
|
||||
this.positionHandles();
|
||||
|
||||
sendMessageToJava({
|
||||
type: "TextSelection:ShowHandles",
|
||||
handles: [this.HANDLE_TYPE_MIDDLE]
|
||||
});
|
||||
},
|
||||
|
||||
hideThumb: function sh_hideThumb() {
|
||||
this._activeType = this.TYPE_NONE;
|
||||
this._cleanUp();
|
||||
|
||||
sendMessageToJava({
|
||||
type: "TextSelection:HideHandles",
|
||||
handles: [this.HANDLE_TYPE_MIDDLE]
|
||||
});
|
||||
},
|
||||
|
||||
positionHandles: function sh_positionHandles() {
|
||||
let scrollX = {}, scrollY = {};
|
||||
this._view.top.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).getScrollXY(false, scrollX, scrollY);
|
||||
|
||||
// the checkHidden function tests to see if the given point is hidden inside an
|
||||
// iframe/subdocument. this is so that if we select some text inside an iframe and
|
||||
// scroll the iframe so the selection is out of view, we hide the handles rather
|
||||
// than having them float on top of the main page content.
|
||||
let checkHidden = function(x, y) {
|
||||
return false;
|
||||
};
|
||||
if (this._view.frameElement) {
|
||||
let bounds = this._view.frameElement.getBoundingClientRect();
|
||||
checkHidden = function(x, y) {
|
||||
return x < 0 || y < 0 || x > bounds.width || y > bounds.height;
|
||||
}
|
||||
}
|
||||
|
||||
let positions = null;
|
||||
if (this._activeType == this.TYPE_CURSOR) {
|
||||
// The left and top properties returned are relative to the client area
|
||||
// of the window, so we don't need to account for a sub-frame offset.
|
||||
let cursor = this._cwu.sendQueryContentEvent(this._cwu.QUERY_CARET_RECT, this._target.selectionEnd, 0, 0, 0);
|
||||
let x = cursor.left;
|
||||
let y = cursor.top + cursor.height;
|
||||
positions = [{ handle: this.HANDLE_TYPE_MIDDLE,
|
||||
left: x + scrollX.value,
|
||||
top: y + scrollY.value,
|
||||
hidden: checkHidden(x, y) }];
|
||||
} else {
|
||||
let sx = this.cache.start.x;
|
||||
let sy = this.cache.start.y;
|
||||
let ex = this.cache.end.x;
|
||||
let ey = this.cache.end.y;
|
||||
|
||||
// Translate coordinates to account for selections in sub-frames. We can't cache
|
||||
// this because the top-level page may have scrolled since selection started.
|
||||
let offset = this._getViewOffset();
|
||||
|
||||
positions = [{ handle: this.HANDLE_TYPE_START,
|
||||
left: sx + offset.x + scrollX.value,
|
||||
top: sy + offset.y + scrollY.value,
|
||||
hidden: checkHidden(sx, sy) },
|
||||
{ handle: this.HANDLE_TYPE_END,
|
||||
left: ex + offset.x + scrollX.value,
|
||||
top: ey + offset.y + scrollY.value,
|
||||
hidden: checkHidden(ex, ey) }];
|
||||
}
|
||||
|
||||
sendMessageToJava({
|
||||
type: "TextSelection:PositionHandles",
|
||||
positions: positions,
|
||||
rtl: this._isRTL
|
||||
});
|
||||
},
|
||||
|
||||
subdocumentScrolled: function sh_subdocumentScrolled(aElement) {
|
||||
if (this._activeType == this.TYPE_NONE) {
|
||||
return;
|
||||
}
|
||||
let scrollView = aElement.ownerDocument.defaultView;
|
||||
let view = this._view;
|
||||
while (true) {
|
||||
if (view == scrollView) {
|
||||
// The selection is in a view (or sub-view) of the view that scrolled.
|
||||
// So we need to reposition the handles.
|
||||
if (this._activeType == this.TYPE_SELECTION) {
|
||||
this.updateCacheForSelection();
|
||||
}
|
||||
this.positionHandles();
|
||||
break;
|
||||
}
|
||||
if (view == view.parent) {
|
||||
break;
|
||||
}
|
||||
view = view.parent;
|
||||
}
|
||||
}
|
||||
};
|
@ -60,6 +60,7 @@ XPCOMUtils.defineLazyGetter(this, "Sanitizer", function() {
|
||||
[
|
||||
["HelperApps", "chrome://browser/content/HelperApps.js"],
|
||||
["SelectHelper", "chrome://browser/content/SelectHelper.js"],
|
||||
["SelectionHandler", "chrome://browser/content/SelectionHandler.js"],
|
||||
["InputWidgetHelper", "chrome://browser/content/InputWidgetHelper.js"],
|
||||
["AboutReader", "chrome://browser/content/aboutReader.js"],
|
||||
["WebAppRT", "chrome://browser/content/WebAppRT.js"],
|
||||
@ -226,7 +227,6 @@ var BrowserApp = {
|
||||
window.addEventListener("MozShowFullScreenWarning", showFullScreenWarning, true);
|
||||
|
||||
NativeWindow.init();
|
||||
SelectionHandler.init();
|
||||
LightWeightThemeWebInstaller.init();
|
||||
Downloads.init();
|
||||
FindHelper.init();
|
||||
@ -520,7 +520,6 @@ var BrowserApp = {
|
||||
|
||||
shutdown: function shutdown() {
|
||||
NativeWindow.uninit();
|
||||
SelectionHandler.uninit();
|
||||
LightWeightThemeWebInstaller.uninit();
|
||||
FormAssistant.uninit();
|
||||
FindHelper.uninit();
|
||||
@ -1946,586 +1945,6 @@ var NativeWindow = {
|
||||
}
|
||||
};
|
||||
|
||||
var SelectionHandler = {
|
||||
HANDLE_TYPE_START: "START",
|
||||
HANDLE_TYPE_MIDDLE: "MIDDLE",
|
||||
HANDLE_TYPE_END: "END",
|
||||
|
||||
TYPE_NONE: 0,
|
||||
TYPE_CURSOR: 1,
|
||||
TYPE_SELECTION: 2,
|
||||
|
||||
// Keeps track of data about the dimensions of the selection. Coordinates
|
||||
// stored here are relative to the _view window.
|
||||
cache: null,
|
||||
_activeType: 0, // TYPE_NONE
|
||||
|
||||
// The window that holds the selection (can be a sub-frame)
|
||||
get _view() {
|
||||
if (this._viewRef)
|
||||
return this._viewRef.get();
|
||||
return null;
|
||||
},
|
||||
|
||||
set _view(aView) {
|
||||
this._viewRef = Cu.getWeakReference(aView);
|
||||
},
|
||||
|
||||
// The target can be a window or an input element
|
||||
get _target() {
|
||||
if (this._targetRef)
|
||||
return this._targetRef.get();
|
||||
return null;
|
||||
},
|
||||
|
||||
set _target(aTarget) {
|
||||
this._targetRef = Cu.getWeakReference(aTarget);
|
||||
},
|
||||
|
||||
get _cwu() {
|
||||
return BrowserApp.selectedBrowser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsIDOMWindowUtils);
|
||||
},
|
||||
|
||||
_isRTL: false,
|
||||
|
||||
init: function sh_init() {
|
||||
Services.obs.addObserver(this, "Gesture:SingleTap", false);
|
||||
Services.obs.addObserver(this, "Window:Resize", false);
|
||||
Services.obs.addObserver(this, "Tab:Selected", false);
|
||||
Services.obs.addObserver(this, "after-viewport-change", false);
|
||||
Services.obs.addObserver(this, "TextSelection:Move", false);
|
||||
Services.obs.addObserver(this, "TextSelection:Position", false);
|
||||
BrowserApp.deck.addEventListener("compositionend", this, false);
|
||||
},
|
||||
|
||||
uninit: function sh_uninit() {
|
||||
Services.obs.removeObserver(this, "Gesture:SingleTap");
|
||||
Services.obs.removeObserver(this, "Window:Resize");
|
||||
Services.obs.removeObserver(this, "Tab:Selected");
|
||||
Services.obs.removeObserver(this, "after-viewport-change");
|
||||
Services.obs.removeObserver(this, "TextSelection:Move");
|
||||
Services.obs.removeObserver(this, "TextSelection:Position");
|
||||
BrowserApp.deck.removeEventListener("compositionend", this);
|
||||
},
|
||||
|
||||
observe: function sh_observe(aSubject, aTopic, aData) {
|
||||
switch (aTopic) {
|
||||
case "Gesture:SingleTap": {
|
||||
if (this._activeType == this.TYPE_SELECTION) {
|
||||
let data = JSON.parse(aData);
|
||||
this.endSelection(data.x, data.y);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "Tab:Selected":
|
||||
if (this._activeType == this.TYPE_CURSOR) {
|
||||
this.hideThumb();
|
||||
}
|
||||
// fall through
|
||||
case "Window:Resize": {
|
||||
if (this._activeType == this.TYPE_SELECTION) {
|
||||
// Knowing when the page is done drawing is hard, so let's just cancel
|
||||
// the selection when the window changes. We should fix this later.
|
||||
this.endSelection();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "after-viewport-change": {
|
||||
if (this._activeType == this.TYPE_SELECTION) {
|
||||
// Update the cache after the viewport changes (e.g. panning, zooming).
|
||||
this.updateCacheForSelection();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "TextSelection:Move": {
|
||||
let data = JSON.parse(aData);
|
||||
if (this._activeType == this.TYPE_SELECTION)
|
||||
this.moveSelection(data.handleType == this.HANDLE_TYPE_START, data.x, data.y);
|
||||
else if (this._activeType == this.TYPE_CURSOR) {
|
||||
// Send a click event to the text box, which positions the caret
|
||||
this._sendMouseEvents(data.x, data.y);
|
||||
|
||||
// Move the handle directly under the caret
|
||||
this.positionHandles();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "TextSelection:Position": {
|
||||
if (this._activeType == this.TYPE_SELECTION) {
|
||||
let data = JSON.parse(aData);
|
||||
|
||||
// Reverse the handles if necessary.
|
||||
let selectionReversed = this.updateCacheForSelection(data.handleType == this.HANDLE_TYPE_START);
|
||||
if (selectionReversed) {
|
||||
// Re-send mouse events to update the selection corresponding to the new handles.
|
||||
if (this._isRTL) {
|
||||
this._sendMouseEvents(this.cache.end.x, this.cache.end.y, false);
|
||||
this._sendMouseEvents(this.cache.start.x, this.cache.start.y, true);
|
||||
} else {
|
||||
this._sendMouseEvents(this.cache.start.x, this.cache.start.y, false);
|
||||
this._sendMouseEvents(this.cache.end.x, this.cache.end.y, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Position the handles to align with the edges of the selection.
|
||||
this.positionHandles();
|
||||
} else if (this._activeType == this.TYPE_CURSOR) {
|
||||
this.positionHandles();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
handleEvent: function sh_handleEvent(aEvent) {
|
||||
switch (aEvent.type) {
|
||||
case "pagehide":
|
||||
if (this._activeType == this.TYPE_SELECTION)
|
||||
this.endSelection();
|
||||
else
|
||||
this.hideThumb();
|
||||
break;
|
||||
|
||||
case "keydown":
|
||||
case "blur":
|
||||
if (this._activeType == this.TYPE_CURSOR)
|
||||
this.hideThumb();
|
||||
break;
|
||||
|
||||
case "compositionend":
|
||||
// If the handles are displayed during user input, hide them.
|
||||
if (this._activeType == this.TYPE_CURSOR) {
|
||||
this.hideThumb();
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
_ignoreCollapsedSelection: false,
|
||||
|
||||
notifySelectionChanged: function sh_notifySelectionChanged(aDoc, aSel, aReason) {
|
||||
if (aSel.isCollapsed) {
|
||||
// Bail if we're ignoring events for a collapsed selection.
|
||||
if (this._ignoreCollapsedSelection)
|
||||
return;
|
||||
|
||||
// If the selection is collapsed because of one of the mouse events we
|
||||
// sent while moving the handle, don't get rid of the selection handles.
|
||||
if (aReason & Ci.nsISelectionListener.MOUSEDOWN_REASON) {
|
||||
this._ignoreCollapsedSelection = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, we do want to end the selection.
|
||||
this.endSelection();
|
||||
}
|
||||
|
||||
this._ignoreCollapsedSelection = false;
|
||||
},
|
||||
|
||||
/** Returns true if the provided element can be selected in text selection, false otherwise. */
|
||||
canSelect: function sh_canSelect(aElement) {
|
||||
return !(aElement instanceof Ci.nsIDOMHTMLButtonElement ||
|
||||
aElement instanceof Ci.nsIDOMHTMLEmbedElement ||
|
||||
aElement instanceof Ci.nsIDOMHTMLImageElement ||
|
||||
aElement instanceof Ci.nsIDOMHTMLMediaElement) &&
|
||||
aElement.style.MozUserSelect != 'none';
|
||||
},
|
||||
|
||||
// aX/aY are in top-level window browser coordinates
|
||||
startSelection: function sh_startSelection(aElement, aX, aY) {
|
||||
// Clear out any existing selection
|
||||
if (this._activeType == this.TYPE_SELECTION) {
|
||||
this.endSelection();
|
||||
} else if (this._activeType == this.TYPE_CURSOR) {
|
||||
// Hide the cursor handles.
|
||||
this.hideThumb();
|
||||
}
|
||||
|
||||
// Get the element's view
|
||||
this._view = aElement.ownerDocument.defaultView;
|
||||
|
||||
if (aElement instanceof Ci.nsIDOMNSEditableElement)
|
||||
this._target = aElement;
|
||||
else
|
||||
this._target = this._view;
|
||||
|
||||
this._view.addEventListener("pagehide", this, false);
|
||||
this._isRTL = (this._view.getComputedStyle(aElement, "").direction == "rtl");
|
||||
|
||||
// Remove any previous selected or created ranges. Tapping anywhere on a
|
||||
// page will create an empty range.
|
||||
let selection = this.getSelection();
|
||||
selection.removeAllRanges();
|
||||
|
||||
// Position the caret using a fake mouse click sent to the top-level window
|
||||
this._sendMouseEvents(aX, aY, false);
|
||||
|
||||
try {
|
||||
let selectionController = this.getSelectionController();
|
||||
|
||||
// Select the word nearest the caret
|
||||
selectionController.wordMove(false, false);
|
||||
|
||||
// Move forward in LTR, backward in RTL
|
||||
selectionController.wordMove(!this._isRTL, true);
|
||||
} catch(e) {
|
||||
// If we couldn't select the word at the given point, bail
|
||||
this._cleanUp();
|
||||
return;
|
||||
}
|
||||
|
||||
// If there isn't an appropriate selection, bail
|
||||
if (!selection.rangeCount || !selection.getRangeAt(0) || !selection.toString().trim().length) {
|
||||
selection.collapseToStart();
|
||||
this._cleanUp();
|
||||
return;
|
||||
}
|
||||
|
||||
// Add a listener to end the selection if it's removed programatically
|
||||
selection.QueryInterface(Ci.nsISelectionPrivate).addSelectionListener(this);
|
||||
|
||||
// Initialize the cache
|
||||
this.cache = { start: {}, end: {}};
|
||||
this.updateCacheForSelection();
|
||||
|
||||
this._activeType = this.TYPE_SELECTION;
|
||||
this.positionHandles();
|
||||
|
||||
sendMessageToJava({
|
||||
type: "TextSelection:ShowHandles",
|
||||
handles: [this.HANDLE_TYPE_START, this.HANDLE_TYPE_END]
|
||||
});
|
||||
|
||||
if (aElement instanceof Ci.nsIDOMNSEditableElement)
|
||||
aElement.focus();
|
||||
},
|
||||
|
||||
getSelection: function sh_getSelection() {
|
||||
if (this._target instanceof Ci.nsIDOMNSEditableElement)
|
||||
return this._target.QueryInterface(Ci.nsIDOMNSEditableElement).editor.selection;
|
||||
else
|
||||
return this._target.getSelection();
|
||||
},
|
||||
|
||||
getSelectionController: function sh_getSelectionController() {
|
||||
if (this._target instanceof Ci.nsIDOMNSEditableElement)
|
||||
return this._target.QueryInterface(Ci.nsIDOMNSEditableElement).editor.selectionController;
|
||||
else
|
||||
return this._target.QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsIWebNavigation).
|
||||
QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsISelectionDisplay).
|
||||
QueryInterface(Ci.nsISelectionController);
|
||||
},
|
||||
|
||||
// Used by the contextmenu "matches" functions in ClipboardHelper
|
||||
shouldShowContextMenu: function sh_shouldShowContextMenu(aX, aY) {
|
||||
return (this._activeType == this.TYPE_SELECTION) && this._pointInSelection(aX, aY);
|
||||
},
|
||||
|
||||
selectAll: function sh_selectAll(aElement, aX, aY) {
|
||||
if (this._activeType != this.TYPE_SELECTION)
|
||||
this.startSelection(aElement, aX, aY);
|
||||
|
||||
let selectionController = this.getSelectionController();
|
||||
selectionController.selectAll();
|
||||
this.updateCacheForSelection();
|
||||
this.positionHandles();
|
||||
},
|
||||
|
||||
// Moves the ends of the selection in the page. aX/aY are in top-level window
|
||||
// browser coordinates.
|
||||
moveSelection: function sh_moveSelection(aIsStartHandle, aX, aY) {
|
||||
// Update the handle position as it's dragged.
|
||||
if (aIsStartHandle) {
|
||||
this.cache.start.x = aX;
|
||||
this.cache.start.y = aY;
|
||||
} else {
|
||||
this.cache.end.x = aX;
|
||||
this.cache.end.y = aY;
|
||||
}
|
||||
|
||||
// The handles work the same on both LTR and RTL pages, but the underlying selection
|
||||
// works differently, so we need to reverse how we send mouse events on RTL pages.
|
||||
if (this._isRTL) {
|
||||
// Position the caret at the end handle using a fake mouse click
|
||||
if (!aIsStartHandle)
|
||||
this._sendMouseEvents(this.cache.end.x, this.cache.end.y, false);
|
||||
|
||||
// Selects text between the carat and the start handle using a fake shift+click
|
||||
this._sendMouseEvents(this.cache.start.x, this.cache.start.y, true);
|
||||
} else {
|
||||
// Position the caret at the start handle using a fake mouse click
|
||||
if (aIsStartHandle)
|
||||
this._sendMouseEvents(this.cache.start.x, this.cache.start.y, false);
|
||||
|
||||
// Selects text between the carat and the end handle using a fake shift+click
|
||||
this._sendMouseEvents( this.cache.end.x, this.cache.end.y, true);
|
||||
}
|
||||
},
|
||||
|
||||
_sendMouseEvents: function sh_sendMouseEvents(aX, aY, useShift) {
|
||||
// If we're positioning a cursor in an input field, make sure the handle
|
||||
// stays within the bounds of the field
|
||||
if (this._activeType == this.TYPE_CURSOR) {
|
||||
// Get rect of text inside element
|
||||
let range = document.createRange();
|
||||
range.selectNodeContents(this._target.QueryInterface(Ci.nsIDOMNSEditableElement).editor.rootElement);
|
||||
let textBounds = range.getBoundingClientRect();
|
||||
|
||||
// Get rect of editor
|
||||
let editorBounds = this._cwu.sendQueryContentEvent(this._cwu.QUERY_EDITOR_RECT, 0, 0, 0, 0);
|
||||
let editorRect = new Rect(editorBounds.left, editorBounds.top, editorBounds.width, editorBounds.height);
|
||||
|
||||
// Use intersection of the text rect and the editor rect
|
||||
let rect = new Rect(textBounds.left, textBounds.top, textBounds.width, textBounds.height);
|
||||
rect.restrictTo(editorRect);
|
||||
|
||||
// Clamp vertically and scroll if handle is at bounds. The top and bottom
|
||||
// must be restricted by an additional pixel since clicking on the top
|
||||
// edge of an input field moves the cursor to the beginning of that
|
||||
// field's text (and clicking the bottom moves the cursor to the end).
|
||||
if (aY < rect.y + 1) {
|
||||
aY = rect.y + 1;
|
||||
this.getSelectionController().scrollLine(false);
|
||||
} else if (aY > rect.y + rect.height - 1) {
|
||||
aY = rect.y + rect.height - 1;
|
||||
this.getSelectionController().scrollLine(true);
|
||||
}
|
||||
|
||||
// Clamp horizontally and scroll if handle is at bounds
|
||||
if (aX < rect.x) {
|
||||
aX = rect.x;
|
||||
this.getSelectionController().scrollCharacter(false);
|
||||
} else if (aX > rect.x + rect.width) {
|
||||
aX = rect.x + rect.width;
|
||||
this.getSelectionController().scrollCharacter(true);
|
||||
}
|
||||
} else if (this._activeType == this.TYPE_SELECTION) {
|
||||
// Send mouse event 1px too high to prevent selection from entering the line below where it should be
|
||||
aY -= 1;
|
||||
}
|
||||
|
||||
this._cwu.sendMouseEventToWindow("mousedown", aX, aY, 0, 0, useShift ? Ci.nsIDOMNSEvent.SHIFT_MASK : 0, true);
|
||||
this._cwu.sendMouseEventToWindow("mouseup", aX, aY, 0, 0, useShift ? Ci.nsIDOMNSEvent.SHIFT_MASK : 0, true);
|
||||
},
|
||||
|
||||
// aX/aY are in top-level window browser coordinates
|
||||
endSelection: function sh_endSelection(aX, aY) {
|
||||
if (this._activeType != this.TYPE_SELECTION)
|
||||
return "";
|
||||
|
||||
this._activeType = this.TYPE_NONE;
|
||||
sendMessageToJava({
|
||||
type: "TextSelection:HideHandles",
|
||||
handles: [this.HANDLE_TYPE_START, this.HANDLE_TYPE_END]
|
||||
});
|
||||
|
||||
|
||||
let selectedText = "";
|
||||
let pointInSelection = false;
|
||||
if (this._view) {
|
||||
let selection = this.getSelection();
|
||||
if (selection) {
|
||||
// Get the text before we clear the selection!
|
||||
selectedText = selection.toString().trim();
|
||||
|
||||
// Also figure out if the point is in the selection before we clear it.
|
||||
if (arguments.length == 2 && this._pointInSelection(aX, aY))
|
||||
pointInSelection = true;
|
||||
|
||||
selection.removeAllRanges();
|
||||
selection.QueryInterface(Ci.nsISelectionPrivate).removeSelectionListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Only try copying text if there's text to copy!
|
||||
if (pointInSelection && selectedText.length) {
|
||||
let element = ElementTouchHelper.anyElementFromPoint(aX, aY);
|
||||
// Only try copying text if the tap happens in the same view
|
||||
if (element.ownerDocument.defaultView == this._view) {
|
||||
let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper);
|
||||
clipboard.copyString(selectedText, element.ownerDocument);
|
||||
NativeWindow.toast.show(Strings.browser.GetStringFromName("selectionHelper.textCopied"), "short");
|
||||
}
|
||||
}
|
||||
|
||||
this._cleanUp();
|
||||
|
||||
return selectedText;
|
||||
},
|
||||
|
||||
_cleanUp: function sh_cleanUp() {
|
||||
this._view.removeEventListener("pagehide", this, false);
|
||||
this._view.removeEventListener("keydown", this, false);
|
||||
this._view.removeEventListener("blur", this, true);
|
||||
this._activeType = this.TYPE_NONE;
|
||||
this._view = null;
|
||||
this._target = null;
|
||||
this._isRTL = false;
|
||||
this.cache = null;
|
||||
},
|
||||
|
||||
_getViewOffset: function sh_getViewOffset() {
|
||||
let offset = { x: 0, y: 0 };
|
||||
let win = this._view;
|
||||
|
||||
// Recursively look through frames to compute the total position offset.
|
||||
while (win.frameElement) {
|
||||
let rect = win.frameElement.getBoundingClientRect();
|
||||
offset.x += rect.left;
|
||||
offset.y += rect.top;
|
||||
|
||||
win = win.parent;
|
||||
}
|
||||
|
||||
return offset;
|
||||
},
|
||||
|
||||
_pointInSelection: function sh_pointInSelection(aX, aY) {
|
||||
let offset = this._getViewOffset();
|
||||
let rangeRect = this.getSelection().getRangeAt(0).getBoundingClientRect();
|
||||
let radius = ElementTouchHelper.getTouchRadius();
|
||||
return (aX - offset.x > rangeRect.left - radius.left &&
|
||||
aX - offset.x < rangeRect.right + radius.right &&
|
||||
aY - offset.y > rangeRect.top - radius.top &&
|
||||
aY - offset.y < rangeRect.bottom + radius.bottom);
|
||||
},
|
||||
|
||||
// Returns true if the selection has been reversed. Takes optional aIsStartHandle
|
||||
// param to decide whether the selection has been reversed.
|
||||
updateCacheForSelection: function sh_updateCacheForSelection(aIsStartHandle) {
|
||||
let selection = this.getSelection();
|
||||
let rects = selection.getRangeAt(0).getClientRects();
|
||||
let start = { x: this._isRTL ? rects[0].right : rects[0].left, y: rects[0].bottom };
|
||||
let end = { x: this._isRTL ? rects[rects.length - 1].left : rects[rects.length - 1].right, y: rects[rects.length - 1].bottom };
|
||||
|
||||
let selectionReversed = false;
|
||||
if (this.cache.start) {
|
||||
// If the end moved past the old end, but we're dragging the start handle, then that handle should become the end handle (and vice versa)
|
||||
selectionReversed = (aIsStartHandle && (end.y > this.cache.end.y || (end.y == this.cache.end.y && end.x > this.cache.end.x))) ||
|
||||
(!aIsStartHandle && (start.y < this.cache.start.y || (start.y == this.cache.start.y && start.x < this.cache.start.x)));
|
||||
}
|
||||
|
||||
this.cache.start = start;
|
||||
this.cache.end = end;
|
||||
|
||||
return selectionReversed;
|
||||
},
|
||||
|
||||
showThumb: function sh_showThumb(aElement) {
|
||||
if (!aElement)
|
||||
return;
|
||||
|
||||
// Get the element's view
|
||||
this._view = aElement.ownerDocument.defaultView;
|
||||
this._target = aElement;
|
||||
|
||||
this._view.addEventListener("pagehide", this, false);
|
||||
this._view.addEventListener("keydown", this, false);
|
||||
this._view.addEventListener("blur", this, true);
|
||||
|
||||
this._activeType = this.TYPE_CURSOR;
|
||||
this.positionHandles();
|
||||
|
||||
sendMessageToJava({
|
||||
type: "TextSelection:ShowHandles",
|
||||
handles: [this.HANDLE_TYPE_MIDDLE]
|
||||
});
|
||||
},
|
||||
|
||||
hideThumb: function sh_hideThumb() {
|
||||
this._activeType = this.TYPE_NONE;
|
||||
this._cleanUp();
|
||||
|
||||
sendMessageToJava({
|
||||
type: "TextSelection:HideHandles",
|
||||
handles: [this.HANDLE_TYPE_MIDDLE]
|
||||
});
|
||||
},
|
||||
|
||||
positionHandles: function sh_positionHandles() {
|
||||
let scrollX = {}, scrollY = {};
|
||||
this._view.top.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).getScrollXY(false, scrollX, scrollY);
|
||||
|
||||
// the checkHidden function tests to see if the given point is hidden inside an
|
||||
// iframe/subdocument. this is so that if we select some text inside an iframe and
|
||||
// scroll the iframe so the selection is out of view, we hide the handles rather
|
||||
// than having them float on top of the main page content.
|
||||
let checkHidden = function(x, y) {
|
||||
return false;
|
||||
};
|
||||
if (this._view.frameElement) {
|
||||
let bounds = this._view.frameElement.getBoundingClientRect();
|
||||
checkHidden = function(x, y) {
|
||||
return x < 0 || y < 0 || x > bounds.width || y > bounds.height;
|
||||
}
|
||||
}
|
||||
|
||||
let positions = null;
|
||||
if (this._activeType == this.TYPE_CURSOR) {
|
||||
// The left and top properties returned are relative to the client area
|
||||
// of the window, so we don't need to account for a sub-frame offset.
|
||||
let cursor = this._cwu.sendQueryContentEvent(this._cwu.QUERY_CARET_RECT, this._target.selectionEnd, 0, 0, 0);
|
||||
let x = cursor.left;
|
||||
let y = cursor.top + cursor.height;
|
||||
positions = [{ handle: this.HANDLE_TYPE_MIDDLE,
|
||||
left: x + scrollX.value,
|
||||
top: y + scrollY.value,
|
||||
hidden: checkHidden(x, y) }];
|
||||
} else {
|
||||
let sx = this.cache.start.x;
|
||||
let sy = this.cache.start.y;
|
||||
let ex = this.cache.end.x;
|
||||
let ey = this.cache.end.y;
|
||||
|
||||
// Translate coordinates to account for selections in sub-frames. We can't cache
|
||||
// this because the top-level page may have scrolled since selection started.
|
||||
let offset = this._getViewOffset();
|
||||
|
||||
positions = [{ handle: this.HANDLE_TYPE_START,
|
||||
left: sx + offset.x + scrollX.value,
|
||||
top: sy + offset.y + scrollY.value,
|
||||
hidden: checkHidden(sx, sy) },
|
||||
{ handle: this.HANDLE_TYPE_END,
|
||||
left: ex + offset.x + scrollX.value,
|
||||
top: ey + offset.y + scrollY.value,
|
||||
hidden: checkHidden(ex, ey) }];
|
||||
}
|
||||
|
||||
sendMessageToJava({
|
||||
type: "TextSelection:PositionHandles",
|
||||
positions: positions,
|
||||
rtl: this._isRTL
|
||||
});
|
||||
},
|
||||
|
||||
subdocumentScrolled: function sh_subdocumentScrolled(aElement) {
|
||||
if (this._activeType == this.TYPE_NONE) {
|
||||
return;
|
||||
}
|
||||
let scrollView = aElement.ownerDocument.defaultView;
|
||||
let view = this._view;
|
||||
while (true) {
|
||||
if (view == scrollView) {
|
||||
// The selection is in a view (or sub-view) of the view that scrolled.
|
||||
// So we need to reposition the handles.
|
||||
if (this._activeType == this.TYPE_SELECTION) {
|
||||
this.updateCacheForSelection();
|
||||
}
|
||||
this.positionHandles();
|
||||
break;
|
||||
}
|
||||
if (view == view.parent) {
|
||||
break;
|
||||
}
|
||||
view = view.parent;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var LightWeightThemeWebInstaller = {
|
||||
init: function sh_init() {
|
||||
let temp = {};
|
||||
|
@ -35,6 +35,7 @@ chrome.jar:
|
||||
content/downloads.js (content/downloads.js)
|
||||
content/netError.xhtml (content/netError.xhtml)
|
||||
content/SelectHelper.js (content/SelectHelper.js)
|
||||
content/SelectionHandler.js (content/SelectionHandler.js)
|
||||
content/HelperApps.js (content/HelperApps.js)
|
||||
content/dbg-browser-actors.js (content/dbg-browser-actors.js)
|
||||
* content/WebAppRT.js (content/WebAppRT.js)
|
||||
|
@ -77,8 +77,6 @@
|
||||
#define DASHWEBMODPARSER_H_
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "IMPDParser.h"
|
||||
#include "MPD.h"
|
||||
#include "Period.h"
|
||||
@ -86,6 +84,8 @@
|
||||
#include "Representation.h"
|
||||
#include "SegmentBase.h"
|
||||
|
||||
class nsIDOMElement;
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDataTransfer.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsPoint.h"
|
||||
|
||||
@ -21,6 +20,7 @@
|
||||
// translucency level for drag images
|
||||
#define DRAG_TRANSLUCENCY 0.65
|
||||
|
||||
class nsIContent;
|
||||
class nsIDOMNode;
|
||||
class nsIFrame;
|
||||
class nsPresContext;
|
||||
|
Loading…
Reference in New Issue
Block a user