Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | // Local Includes |
michael@0 | 8 | #include "nsChromeTreeOwner.h" |
michael@0 | 9 | #include "nsXULWindow.h" |
michael@0 | 10 | |
michael@0 | 11 | // Helper Classes |
michael@0 | 12 | #include "nsString.h" |
michael@0 | 13 | #include "nsIEmbeddingSiteWindow.h" |
michael@0 | 14 | #include "nsIServiceManager.h" |
michael@0 | 15 | #include "nsIDocShellTreeItem.h" |
michael@0 | 16 | |
michael@0 | 17 | // Interfaces needed to include |
michael@0 | 18 | #include "nsIPrompt.h" |
michael@0 | 19 | #include "nsIAuthPrompt.h" |
michael@0 | 20 | #include "nsIBrowserDOMWindow.h" |
michael@0 | 21 | #include "nsIWebProgress.h" |
michael@0 | 22 | #include "nsIWidget.h" |
michael@0 | 23 | #include "nsIWindowMediator.h" |
michael@0 | 24 | #include "nsIDOMChromeWindow.h" |
michael@0 | 25 | #include "nsIDOMNode.h" |
michael@0 | 26 | #include "nsIDOMElement.h" |
michael@0 | 27 | #include "nsIDOMNodeList.h" |
michael@0 | 28 | #include "nsIDOMXULElement.h" |
michael@0 | 29 | #include "nsIXULBrowserWindow.h" |
michael@0 | 30 | #include "mozilla/dom/Element.h" |
michael@0 | 31 | |
michael@0 | 32 | using namespace mozilla; |
michael@0 | 33 | |
michael@0 | 34 | //***************************************************************************** |
michael@0 | 35 | // nsChromeTreeOwner string literals |
michael@0 | 36 | //***************************************************************************** |
michael@0 | 37 | |
michael@0 | 38 | struct nsChromeTreeOwnerLiterals |
michael@0 | 39 | { |
michael@0 | 40 | const nsLiteralString kPersist; |
michael@0 | 41 | const nsLiteralString kScreenX; |
michael@0 | 42 | const nsLiteralString kScreenY; |
michael@0 | 43 | const nsLiteralString kWidth; |
michael@0 | 44 | const nsLiteralString kHeight; |
michael@0 | 45 | const nsLiteralString kSizemode; |
michael@0 | 46 | const nsLiteralString kSpace; |
michael@0 | 47 | |
michael@0 | 48 | nsChromeTreeOwnerLiterals() |
michael@0 | 49 | : NS_LITERAL_STRING_INIT(kPersist,"persist") |
michael@0 | 50 | , NS_LITERAL_STRING_INIT(kScreenX,"screenX") |
michael@0 | 51 | , NS_LITERAL_STRING_INIT(kScreenY,"screenY") |
michael@0 | 52 | , NS_LITERAL_STRING_INIT(kWidth,"width") |
michael@0 | 53 | , NS_LITERAL_STRING_INIT(kHeight,"height") |
michael@0 | 54 | , NS_LITERAL_STRING_INIT(kSizemode,"sizemode") |
michael@0 | 55 | , NS_LITERAL_STRING_INIT(kSpace," ") |
michael@0 | 56 | {} |
michael@0 | 57 | }; |
michael@0 | 58 | |
michael@0 | 59 | static nsChromeTreeOwnerLiterals *gLiterals; |
michael@0 | 60 | |
michael@0 | 61 | nsresult |
michael@0 | 62 | nsChromeTreeOwner::InitGlobals() |
michael@0 | 63 | { |
michael@0 | 64 | NS_ASSERTION(gLiterals == nullptr, "already initialized"); |
michael@0 | 65 | gLiterals = new nsChromeTreeOwnerLiterals(); |
michael@0 | 66 | if (!gLiterals) |
michael@0 | 67 | return NS_ERROR_OUT_OF_MEMORY; |
michael@0 | 68 | return NS_OK; |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | void |
michael@0 | 72 | nsChromeTreeOwner::FreeGlobals() |
michael@0 | 73 | { |
michael@0 | 74 | delete gLiterals; |
michael@0 | 75 | gLiterals = nullptr; |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | //***************************************************************************** |
michael@0 | 79 | //*** nsChromeTreeOwner: Object Management |
michael@0 | 80 | //***************************************************************************** |
michael@0 | 81 | |
michael@0 | 82 | nsChromeTreeOwner::nsChromeTreeOwner() : mXULWindow(nullptr) |
michael@0 | 83 | { |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | nsChromeTreeOwner::~nsChromeTreeOwner() |
michael@0 | 87 | { |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | //***************************************************************************** |
michael@0 | 91 | // nsChromeTreeOwner::nsISupports |
michael@0 | 92 | //***************************************************************************** |
michael@0 | 93 | |
michael@0 | 94 | NS_IMPL_ADDREF(nsChromeTreeOwner) |
michael@0 | 95 | NS_IMPL_RELEASE(nsChromeTreeOwner) |
michael@0 | 96 | |
michael@0 | 97 | NS_INTERFACE_MAP_BEGIN(nsChromeTreeOwner) |
michael@0 | 98 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocShellTreeOwner) |
michael@0 | 99 | NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeOwner) |
michael@0 | 100 | NS_INTERFACE_MAP_ENTRY(nsIBaseWindow) |
michael@0 | 101 | NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener) |
michael@0 | 102 | NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor) |
michael@0 | 103 | NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) |
michael@0 | 104 | NS_INTERFACE_MAP_END |
michael@0 | 105 | |
michael@0 | 106 | //***************************************************************************** |
michael@0 | 107 | // nsChromeTreeOwner::nsIInterfaceRequestor |
michael@0 | 108 | //***************************************************************************** |
michael@0 | 109 | |
michael@0 | 110 | NS_IMETHODIMP nsChromeTreeOwner::GetInterface(const nsIID& aIID, void** aSink) |
michael@0 | 111 | { |
michael@0 | 112 | NS_ENSURE_ARG_POINTER(aSink); |
michael@0 | 113 | |
michael@0 | 114 | if(aIID.Equals(NS_GET_IID(nsIPrompt))) { |
michael@0 | 115 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 116 | return mXULWindow->GetInterface(aIID, aSink); |
michael@0 | 117 | } |
michael@0 | 118 | if(aIID.Equals(NS_GET_IID(nsIAuthPrompt))) { |
michael@0 | 119 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 120 | return mXULWindow->GetInterface(aIID, aSink); |
michael@0 | 121 | } |
michael@0 | 122 | if(aIID.Equals(NS_GET_IID(nsIWebBrowserChrome))) { |
michael@0 | 123 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 124 | return mXULWindow->GetInterface(aIID, aSink); |
michael@0 | 125 | } |
michael@0 | 126 | if (aIID.Equals(NS_GET_IID(nsIEmbeddingSiteWindow))) { |
michael@0 | 127 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 128 | return mXULWindow->GetInterface(aIID, aSink); |
michael@0 | 129 | } |
michael@0 | 130 | if (aIID.Equals(NS_GET_IID(nsIXULWindow))) { |
michael@0 | 131 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 132 | return mXULWindow->QueryInterface(aIID, aSink); |
michael@0 | 133 | } |
michael@0 | 134 | |
michael@0 | 135 | return QueryInterface(aIID, aSink); |
michael@0 | 136 | } |
michael@0 | 137 | |
michael@0 | 138 | //***************************************************************************** |
michael@0 | 139 | // nsChromeTreeOwner::nsIDocShellTreeOwner |
michael@0 | 140 | //***************************************************************************** |
michael@0 | 141 | |
michael@0 | 142 | NS_IMETHODIMP nsChromeTreeOwner::FindItemWithName(const char16_t* aName, |
michael@0 | 143 | nsIDocShellTreeItem* aRequestor, nsIDocShellTreeItem* aOriginalRequestor, |
michael@0 | 144 | nsIDocShellTreeItem** aFoundItem) |
michael@0 | 145 | { |
michael@0 | 146 | NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID); |
michael@0 | 147 | |
michael@0 | 148 | NS_ENSURE_ARG_POINTER(aFoundItem); |
michael@0 | 149 | |
michael@0 | 150 | *aFoundItem = nullptr; |
michael@0 | 151 | |
michael@0 | 152 | bool fIs_Content = false; |
michael@0 | 153 | |
michael@0 | 154 | /* Special Cases */ |
michael@0 | 155 | if(!aName || !*aName) |
michael@0 | 156 | return NS_OK; |
michael@0 | 157 | |
michael@0 | 158 | nsDependentString name(aName); |
michael@0 | 159 | |
michael@0 | 160 | if(name.LowerCaseEqualsLiteral("_blank")) |
michael@0 | 161 | return NS_OK; |
michael@0 | 162 | // _main is an IE target which should be case-insensitive but isn't |
michael@0 | 163 | // see bug 217886 for details |
michael@0 | 164 | if(name.LowerCaseEqualsLiteral("_content") || name.EqualsLiteral("_main")) |
michael@0 | 165 | { |
michael@0 | 166 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 167 | fIs_Content = true; |
michael@0 | 168 | mXULWindow->GetPrimaryContentShell(aFoundItem); |
michael@0 | 169 | if(*aFoundItem) |
michael@0 | 170 | return NS_OK; |
michael@0 | 171 | // Otherwise fall through and ask the other windows for a content area. |
michael@0 | 172 | } |
michael@0 | 173 | |
michael@0 | 174 | nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID)); |
michael@0 | 175 | NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE); |
michael@0 | 176 | |
michael@0 | 177 | nsCOMPtr<nsISimpleEnumerator> windowEnumerator; |
michael@0 | 178 | NS_ENSURE_SUCCESS(windowMediator->GetXULWindowEnumerator(nullptr, |
michael@0 | 179 | getter_AddRefs(windowEnumerator)), NS_ERROR_FAILURE); |
michael@0 | 180 | |
michael@0 | 181 | bool more; |
michael@0 | 182 | |
michael@0 | 183 | windowEnumerator->HasMoreElements(&more); |
michael@0 | 184 | while(more) |
michael@0 | 185 | { |
michael@0 | 186 | nsCOMPtr<nsISupports> nextWindow = nullptr; |
michael@0 | 187 | windowEnumerator->GetNext(getter_AddRefs(nextWindow)); |
michael@0 | 188 | nsCOMPtr<nsIXULWindow> xulWindow(do_QueryInterface(nextWindow)); |
michael@0 | 189 | NS_ENSURE_TRUE(xulWindow, NS_ERROR_FAILURE); |
michael@0 | 190 | |
michael@0 | 191 | nsCOMPtr<nsIDocShellTreeItem> shellAsTreeItem; |
michael@0 | 192 | |
michael@0 | 193 | if(fIs_Content) |
michael@0 | 194 | { |
michael@0 | 195 | xulWindow->GetPrimaryContentShell(aFoundItem); |
michael@0 | 196 | } |
michael@0 | 197 | else |
michael@0 | 198 | { |
michael@0 | 199 | // Note that we don't look for targetable content shells here... |
michael@0 | 200 | // in fact, we aren't looking for content shells at all! |
michael@0 | 201 | nsCOMPtr<nsIDocShell> shell; |
michael@0 | 202 | xulWindow->GetDocShell(getter_AddRefs(shell)); |
michael@0 | 203 | shellAsTreeItem = do_QueryInterface(shell); |
michael@0 | 204 | if (shellAsTreeItem) { |
michael@0 | 205 | // Get the root tree item of same type, since roots are the only |
michael@0 | 206 | // things that call into the treeowner to look for named items. |
michael@0 | 207 | nsCOMPtr<nsIDocShellTreeItem> root; |
michael@0 | 208 | shellAsTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(root)); |
michael@0 | 209 | shellAsTreeItem = root; |
michael@0 | 210 | } |
michael@0 | 211 | if(shellAsTreeItem && aRequestor != shellAsTreeItem) |
michael@0 | 212 | { |
michael@0 | 213 | // Do this so we can pass in the tree owner as the requestor so the child knows not |
michael@0 | 214 | // to call back up. |
michael@0 | 215 | nsCOMPtr<nsIDocShellTreeOwner> shellOwner; |
michael@0 | 216 | shellAsTreeItem->GetTreeOwner(getter_AddRefs(shellOwner)); |
michael@0 | 217 | nsCOMPtr<nsISupports> shellOwnerSupports(do_QueryInterface(shellOwner)); |
michael@0 | 218 | |
michael@0 | 219 | shellAsTreeItem->FindItemWithName(aName, shellOwnerSupports, |
michael@0 | 220 | aOriginalRequestor, aFoundItem); |
michael@0 | 221 | } |
michael@0 | 222 | } |
michael@0 | 223 | if(*aFoundItem) |
michael@0 | 224 | return NS_OK; |
michael@0 | 225 | windowEnumerator->HasMoreElements(&more); |
michael@0 | 226 | } |
michael@0 | 227 | return NS_OK; |
michael@0 | 228 | } |
michael@0 | 229 | |
michael@0 | 230 | NS_IMETHODIMP |
michael@0 | 231 | nsChromeTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell, |
michael@0 | 232 | bool aPrimary, bool aTargetable, |
michael@0 | 233 | const nsAString& aID) |
michael@0 | 234 | { |
michael@0 | 235 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 236 | return mXULWindow->ContentShellAdded(aContentShell, aPrimary, aTargetable, |
michael@0 | 237 | aID); |
michael@0 | 238 | } |
michael@0 | 239 | |
michael@0 | 240 | NS_IMETHODIMP |
michael@0 | 241 | nsChromeTreeOwner::ContentShellRemoved(nsIDocShellTreeItem* aContentShell) |
michael@0 | 242 | { |
michael@0 | 243 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 244 | return mXULWindow->ContentShellRemoved(aContentShell); |
michael@0 | 245 | } |
michael@0 | 246 | |
michael@0 | 247 | NS_IMETHODIMP nsChromeTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell) |
michael@0 | 248 | { |
michael@0 | 249 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 250 | return mXULWindow->GetPrimaryContentShell(aShell); |
michael@0 | 251 | } |
michael@0 | 252 | |
michael@0 | 253 | NS_IMETHODIMP |
michael@0 | 254 | nsChromeTreeOwner::GetContentWindow(JSContext* aCx, JS::MutableHandle<JS::Value> aVal) |
michael@0 | 255 | { |
michael@0 | 256 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 257 | |
michael@0 | 258 | nsCOMPtr<nsIDOMWindow> domWin; |
michael@0 | 259 | mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWin)); |
michael@0 | 260 | nsCOMPtr<nsIDOMChromeWindow> chromeWin = do_QueryInterface(domWin); |
michael@0 | 261 | if (!chromeWin) |
michael@0 | 262 | return NS_OK; |
michael@0 | 263 | |
michael@0 | 264 | nsCOMPtr<nsIBrowserDOMWindow> browserDOMWin; |
michael@0 | 265 | chromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin)); |
michael@0 | 266 | if (!browserDOMWin) |
michael@0 | 267 | return NS_OK; |
michael@0 | 268 | |
michael@0 | 269 | return browserDOMWin->GetContentWindow(aVal); |
michael@0 | 270 | } |
michael@0 | 271 | |
michael@0 | 272 | NS_IMETHODIMP nsChromeTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem, |
michael@0 | 273 | int32_t aCX, int32_t aCY) |
michael@0 | 274 | { |
michael@0 | 275 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 276 | return mXULWindow->SizeShellTo(aShellItem, aCX, aCY); |
michael@0 | 277 | } |
michael@0 | 278 | |
michael@0 | 279 | NS_IMETHODIMP |
michael@0 | 280 | nsChromeTreeOwner::SetPersistence(bool aPersistPosition, |
michael@0 | 281 | bool aPersistSize, |
michael@0 | 282 | bool aPersistSizeMode) |
michael@0 | 283 | { |
michael@0 | 284 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 285 | nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement(); |
michael@0 | 286 | if (!docShellElement) |
michael@0 | 287 | return NS_ERROR_FAILURE; |
michael@0 | 288 | |
michael@0 | 289 | nsAutoString persistString; |
michael@0 | 290 | docShellElement->GetAttribute(gLiterals->kPersist, persistString); |
michael@0 | 291 | |
michael@0 | 292 | bool saveString = false; |
michael@0 | 293 | int32_t index; |
michael@0 | 294 | |
michael@0 | 295 | #define FIND_PERSIST_STRING(aString, aCond) \ |
michael@0 | 296 | index = persistString.Find(aString); \ |
michael@0 | 297 | if (!aCond && index > kNotFound) { \ |
michael@0 | 298 | persistString.Cut(index, aString.Length()); \ |
michael@0 | 299 | saveString = true; \ |
michael@0 | 300 | } else if (aCond && index == kNotFound) { \ |
michael@0 | 301 | persistString.Append(gLiterals->kSpace + aString); \ |
michael@0 | 302 | saveString = true; \ |
michael@0 | 303 | } |
michael@0 | 304 | FIND_PERSIST_STRING(gLiterals->kScreenX, aPersistPosition); |
michael@0 | 305 | FIND_PERSIST_STRING(gLiterals->kScreenY, aPersistPosition); |
michael@0 | 306 | FIND_PERSIST_STRING(gLiterals->kWidth, aPersistSize); |
michael@0 | 307 | FIND_PERSIST_STRING(gLiterals->kHeight, aPersistSize); |
michael@0 | 308 | FIND_PERSIST_STRING(gLiterals->kSizemode, aPersistSizeMode); |
michael@0 | 309 | |
michael@0 | 310 | ErrorResult rv; |
michael@0 | 311 | if (saveString) { |
michael@0 | 312 | docShellElement->SetAttribute(gLiterals->kPersist, persistString, rv); |
michael@0 | 313 | } |
michael@0 | 314 | |
michael@0 | 315 | return NS_OK; |
michael@0 | 316 | } |
michael@0 | 317 | |
michael@0 | 318 | NS_IMETHODIMP |
michael@0 | 319 | nsChromeTreeOwner::GetPersistence(bool* aPersistPosition, |
michael@0 | 320 | bool* aPersistSize, |
michael@0 | 321 | bool* aPersistSizeMode) |
michael@0 | 322 | { |
michael@0 | 323 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 324 | nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement(); |
michael@0 | 325 | if (!docShellElement) |
michael@0 | 326 | return NS_ERROR_FAILURE; |
michael@0 | 327 | |
michael@0 | 328 | nsAutoString persistString; |
michael@0 | 329 | docShellElement->GetAttribute(gLiterals->kPersist, persistString); |
michael@0 | 330 | |
michael@0 | 331 | // data structure doesn't quite match the question, but it's close enough |
michael@0 | 332 | // for what we want (since this method is never actually called...) |
michael@0 | 333 | if (aPersistPosition) |
michael@0 | 334 | *aPersistPosition = persistString.Find(gLiterals->kScreenX) > kNotFound || |
michael@0 | 335 | persistString.Find(gLiterals->kScreenY) > kNotFound; |
michael@0 | 336 | if (aPersistSize) |
michael@0 | 337 | *aPersistSize = persistString.Find(gLiterals->kWidth) > kNotFound || |
michael@0 | 338 | persistString.Find(gLiterals->kHeight) > kNotFound; |
michael@0 | 339 | if (aPersistSizeMode) |
michael@0 | 340 | *aPersistSizeMode = persistString.Find(gLiterals->kSizemode) > kNotFound; |
michael@0 | 341 | |
michael@0 | 342 | return NS_OK; |
michael@0 | 343 | } |
michael@0 | 344 | |
michael@0 | 345 | NS_IMETHODIMP |
michael@0 | 346 | nsChromeTreeOwner::GetTargetableShellCount(uint32_t* aResult) |
michael@0 | 347 | { |
michael@0 | 348 | *aResult = 0; |
michael@0 | 349 | return NS_OK; |
michael@0 | 350 | } |
michael@0 | 351 | |
michael@0 | 352 | //***************************************************************************** |
michael@0 | 353 | // nsChromeTreeOwner::nsIBaseWindow |
michael@0 | 354 | //***************************************************************************** |
michael@0 | 355 | |
michael@0 | 356 | NS_IMETHODIMP nsChromeTreeOwner::InitWindow(nativeWindow aParentNativeWindow, |
michael@0 | 357 | nsIWidget* parentWidget, int32_t x, int32_t y, int32_t cx, int32_t cy) |
michael@0 | 358 | { |
michael@0 | 359 | // Ignore widget parents for now. Don't think those are a vaild thing to call. |
michael@0 | 360 | NS_ENSURE_SUCCESS(SetPositionAndSize(x, y, cx, cy, false), NS_ERROR_FAILURE); |
michael@0 | 361 | |
michael@0 | 362 | return NS_OK; |
michael@0 | 363 | } |
michael@0 | 364 | |
michael@0 | 365 | NS_IMETHODIMP nsChromeTreeOwner::Create() |
michael@0 | 366 | { |
michael@0 | 367 | NS_ASSERTION(false, "You can't call this"); |
michael@0 | 368 | return NS_ERROR_UNEXPECTED; |
michael@0 | 369 | } |
michael@0 | 370 | |
michael@0 | 371 | NS_IMETHODIMP nsChromeTreeOwner::Destroy() |
michael@0 | 372 | { |
michael@0 | 373 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 374 | return mXULWindow->Destroy(); |
michael@0 | 375 | } |
michael@0 | 376 | |
michael@0 | 377 | NS_IMETHODIMP nsChromeTreeOwner::GetUnscaledDevicePixelsPerCSSPixel(double *aScale) |
michael@0 | 378 | { |
michael@0 | 379 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 380 | return mXULWindow->GetUnscaledDevicePixelsPerCSSPixel(aScale); |
michael@0 | 381 | } |
michael@0 | 382 | |
michael@0 | 383 | NS_IMETHODIMP nsChromeTreeOwner::SetPosition(int32_t x, int32_t y) |
michael@0 | 384 | { |
michael@0 | 385 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 386 | return mXULWindow->SetPosition(x, y); |
michael@0 | 387 | } |
michael@0 | 388 | |
michael@0 | 389 | NS_IMETHODIMP nsChromeTreeOwner::GetPosition(int32_t* x, int32_t* y) |
michael@0 | 390 | { |
michael@0 | 391 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 392 | return mXULWindow->GetPosition(x, y); |
michael@0 | 393 | } |
michael@0 | 394 | |
michael@0 | 395 | NS_IMETHODIMP nsChromeTreeOwner::SetSize(int32_t cx, int32_t cy, bool fRepaint) |
michael@0 | 396 | { |
michael@0 | 397 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 398 | return mXULWindow->SetSize(cx, cy, fRepaint); |
michael@0 | 399 | } |
michael@0 | 400 | |
michael@0 | 401 | NS_IMETHODIMP nsChromeTreeOwner::GetSize(int32_t* cx, int32_t* cy) |
michael@0 | 402 | { |
michael@0 | 403 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 404 | return mXULWindow->GetSize(cx, cy); |
michael@0 | 405 | } |
michael@0 | 406 | |
michael@0 | 407 | NS_IMETHODIMP nsChromeTreeOwner::SetPositionAndSize(int32_t x, int32_t y, int32_t cx, |
michael@0 | 408 | int32_t cy, bool fRepaint) |
michael@0 | 409 | { |
michael@0 | 410 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 411 | return mXULWindow->SetPositionAndSize(x, y, cx, cy, fRepaint); |
michael@0 | 412 | } |
michael@0 | 413 | |
michael@0 | 414 | NS_IMETHODIMP nsChromeTreeOwner::GetPositionAndSize(int32_t* x, int32_t* y, int32_t* cx, |
michael@0 | 415 | int32_t* cy) |
michael@0 | 416 | { |
michael@0 | 417 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 418 | return mXULWindow->GetPositionAndSize(x, y, cx, cy); |
michael@0 | 419 | } |
michael@0 | 420 | |
michael@0 | 421 | NS_IMETHODIMP nsChromeTreeOwner::Repaint(bool aForce) |
michael@0 | 422 | { |
michael@0 | 423 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 424 | return mXULWindow->Repaint(aForce); |
michael@0 | 425 | } |
michael@0 | 426 | |
michael@0 | 427 | NS_IMETHODIMP nsChromeTreeOwner::GetParentWidget(nsIWidget** aParentWidget) |
michael@0 | 428 | { |
michael@0 | 429 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 430 | return mXULWindow->GetParentWidget(aParentWidget); |
michael@0 | 431 | } |
michael@0 | 432 | |
michael@0 | 433 | NS_IMETHODIMP nsChromeTreeOwner::SetParentWidget(nsIWidget* aParentWidget) |
michael@0 | 434 | { |
michael@0 | 435 | NS_ASSERTION(false, "You can't call this"); |
michael@0 | 436 | return NS_ERROR_NOT_IMPLEMENTED; |
michael@0 | 437 | } |
michael@0 | 438 | |
michael@0 | 439 | NS_IMETHODIMP nsChromeTreeOwner::GetParentNativeWindow(nativeWindow* aParentNativeWindow) |
michael@0 | 440 | { |
michael@0 | 441 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 442 | return mXULWindow->GetParentNativeWindow(aParentNativeWindow); |
michael@0 | 443 | } |
michael@0 | 444 | |
michael@0 | 445 | NS_IMETHODIMP nsChromeTreeOwner::SetParentNativeWindow(nativeWindow aParentNativeWindow) |
michael@0 | 446 | { |
michael@0 | 447 | NS_ASSERTION(false, "You can't call this"); |
michael@0 | 448 | return NS_ERROR_NOT_IMPLEMENTED; |
michael@0 | 449 | } |
michael@0 | 450 | |
michael@0 | 451 | NS_IMETHODIMP nsChromeTreeOwner::GetNativeHandle(nsAString& aNativeHandle) |
michael@0 | 452 | { |
michael@0 | 453 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 454 | return mXULWindow->GetNativeHandle(aNativeHandle); |
michael@0 | 455 | } |
michael@0 | 456 | |
michael@0 | 457 | NS_IMETHODIMP nsChromeTreeOwner::GetVisibility(bool* aVisibility) |
michael@0 | 458 | { |
michael@0 | 459 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 460 | return mXULWindow->GetVisibility(aVisibility); |
michael@0 | 461 | } |
michael@0 | 462 | |
michael@0 | 463 | NS_IMETHODIMP nsChromeTreeOwner::SetVisibility(bool aVisibility) |
michael@0 | 464 | { |
michael@0 | 465 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 466 | return mXULWindow->SetVisibility(aVisibility); |
michael@0 | 467 | } |
michael@0 | 468 | |
michael@0 | 469 | NS_IMETHODIMP nsChromeTreeOwner::GetEnabled(bool *aEnabled) |
michael@0 | 470 | { |
michael@0 | 471 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 472 | return mXULWindow->GetEnabled(aEnabled); |
michael@0 | 473 | } |
michael@0 | 474 | |
michael@0 | 475 | NS_IMETHODIMP nsChromeTreeOwner::SetEnabled(bool aEnable) |
michael@0 | 476 | { |
michael@0 | 477 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 478 | return mXULWindow->SetEnabled(aEnable); |
michael@0 | 479 | } |
michael@0 | 480 | |
michael@0 | 481 | NS_IMETHODIMP nsChromeTreeOwner::GetMainWidget(nsIWidget** aMainWidget) |
michael@0 | 482 | { |
michael@0 | 483 | NS_ENSURE_ARG_POINTER(aMainWidget); |
michael@0 | 484 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 485 | |
michael@0 | 486 | *aMainWidget = mXULWindow->mWindow; |
michael@0 | 487 | NS_IF_ADDREF(*aMainWidget); |
michael@0 | 488 | |
michael@0 | 489 | return NS_OK; |
michael@0 | 490 | } |
michael@0 | 491 | |
michael@0 | 492 | NS_IMETHODIMP nsChromeTreeOwner::SetFocus() |
michael@0 | 493 | { |
michael@0 | 494 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 495 | return mXULWindow->SetFocus(); |
michael@0 | 496 | } |
michael@0 | 497 | |
michael@0 | 498 | NS_IMETHODIMP nsChromeTreeOwner::GetTitle(char16_t** aTitle) |
michael@0 | 499 | { |
michael@0 | 500 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 501 | return mXULWindow->GetTitle(aTitle); |
michael@0 | 502 | } |
michael@0 | 503 | |
michael@0 | 504 | NS_IMETHODIMP nsChromeTreeOwner::SetTitle(const char16_t* aTitle) |
michael@0 | 505 | { |
michael@0 | 506 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 507 | return mXULWindow->SetTitle(aTitle); |
michael@0 | 508 | } |
michael@0 | 509 | |
michael@0 | 510 | //***************************************************************************** |
michael@0 | 511 | // nsChromeTreeOwner::nsIWebProgressListener |
michael@0 | 512 | //***************************************************************************** |
michael@0 | 513 | |
michael@0 | 514 | NS_IMETHODIMP |
michael@0 | 515 | nsChromeTreeOwner::OnProgressChange(nsIWebProgress* aWebProgress, |
michael@0 | 516 | nsIRequest* aRequest, |
michael@0 | 517 | int32_t aCurSelfProgress, |
michael@0 | 518 | int32_t aMaxSelfProgress, |
michael@0 | 519 | int32_t aCurTotalProgress, |
michael@0 | 520 | int32_t aMaxTotalProgress) |
michael@0 | 521 | { |
michael@0 | 522 | return NS_OK; |
michael@0 | 523 | } |
michael@0 | 524 | |
michael@0 | 525 | NS_IMETHODIMP |
michael@0 | 526 | nsChromeTreeOwner::OnStateChange(nsIWebProgress* aWebProgress, |
michael@0 | 527 | nsIRequest* aRequest, |
michael@0 | 528 | uint32_t aProgressStateFlags, |
michael@0 | 529 | nsresult aStatus) |
michael@0 | 530 | { |
michael@0 | 531 | return NS_OK; |
michael@0 | 532 | } |
michael@0 | 533 | |
michael@0 | 534 | NS_IMETHODIMP nsChromeTreeOwner::OnLocationChange(nsIWebProgress* aWebProgress, |
michael@0 | 535 | nsIRequest* aRequest, |
michael@0 | 536 | nsIURI* aLocation, |
michael@0 | 537 | uint32_t aFlags) |
michael@0 | 538 | { |
michael@0 | 539 | bool itsForYou = true; |
michael@0 | 540 | |
michael@0 | 541 | if (aWebProgress) { |
michael@0 | 542 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 543 | nsCOMPtr<nsIDOMWindow> progressWin; |
michael@0 | 544 | aWebProgress->GetDOMWindow(getter_AddRefs(progressWin)); |
michael@0 | 545 | |
michael@0 | 546 | nsCOMPtr<nsIDocShell> docshell; |
michael@0 | 547 | mXULWindow->GetDocShell(getter_AddRefs(docshell)); |
michael@0 | 548 | nsCOMPtr<nsIDOMWindow> ourWin(do_QueryInterface(docshell)); |
michael@0 | 549 | |
michael@0 | 550 | if (ourWin != progressWin) |
michael@0 | 551 | itsForYou = false; |
michael@0 | 552 | } |
michael@0 | 553 | |
michael@0 | 554 | // If loading a new root .xul document, then redo chrome. |
michael@0 | 555 | if (itsForYou) { |
michael@0 | 556 | NS_ENSURE_STATE(mXULWindow); |
michael@0 | 557 | mXULWindow->mChromeLoaded = false; |
michael@0 | 558 | } |
michael@0 | 559 | return NS_OK; |
michael@0 | 560 | } |
michael@0 | 561 | |
michael@0 | 562 | NS_IMETHODIMP |
michael@0 | 563 | nsChromeTreeOwner::OnStatusChange(nsIWebProgress* aWebProgress, |
michael@0 | 564 | nsIRequest* aRequest, |
michael@0 | 565 | nsresult aStatus, |
michael@0 | 566 | const char16_t* aMessage) |
michael@0 | 567 | { |
michael@0 | 568 | return NS_OK; |
michael@0 | 569 | } |
michael@0 | 570 | |
michael@0 | 571 | |
michael@0 | 572 | |
michael@0 | 573 | NS_IMETHODIMP |
michael@0 | 574 | nsChromeTreeOwner::OnSecurityChange(nsIWebProgress *aWebProgress, |
michael@0 | 575 | nsIRequest *aRequest, |
michael@0 | 576 | uint32_t state) |
michael@0 | 577 | { |
michael@0 | 578 | return NS_OK; |
michael@0 | 579 | } |
michael@0 | 580 | |
michael@0 | 581 | //***************************************************************************** |
michael@0 | 582 | // nsChromeTreeOwner: Helpers |
michael@0 | 583 | //***************************************************************************** |
michael@0 | 584 | |
michael@0 | 585 | //***************************************************************************** |
michael@0 | 586 | // nsChromeTreeOwner: Accessors |
michael@0 | 587 | //***************************************************************************** |
michael@0 | 588 | |
michael@0 | 589 | void nsChromeTreeOwner::XULWindow(nsXULWindow* aXULWindow) |
michael@0 | 590 | { |
michael@0 | 591 | mXULWindow = aXULWindow; |
michael@0 | 592 | } |
michael@0 | 593 | |
michael@0 | 594 | nsXULWindow* nsChromeTreeOwner::XULWindow() |
michael@0 | 595 | { |
michael@0 | 596 | return mXULWindow; |
michael@0 | 597 | } |