Chapter 2 The Mechanism behind Extensions
-
Upload
stuart-frost -
Category
Documents
-
view
35 -
download
0
description
Transcript of Chapter 2 The Mechanism behind Extensions
![Page 1: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/1.jpg)
Chapter 2The Mechanism
behind Extensions
![Page 2: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/2.jpg)
How “Extensions”are implemented
![Page 3: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/3.jpg)
How is itdifferent from
plugins
![Page 4: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/4.jpg)
Pluginis a small application that
interacts with the main application to provide a certain
function.
![Page 5: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/5.jpg)
Firefox Extension is likedynamically applied
software patch
![Page 6: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/6.jpg)
Patch?
![Page 7: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/7.jpg)
Index: layout/xul/base/src/nsNativeScrollbarFrame.cpp===================================================================RCS file: /cvsroot/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.cpp,vretrieving revision 1.22diff -u -6 -p -r1.22 nsNativeScrollbarFrame.cpp--- layout/xul/base/src/nsNativeScrollbarFrame.cpp 31 Dec 2004 01:13:26 -0000 1.22+++ layout/xul/base/src/nsNativeScrollbarFrame.cpp 28 Jul 2005 22:06:05 -0000@@ -342,6 +342,68 @@ nsNativeScrollbarFrame::Hookup() if (!curpos || error) return; scrollbar->SetPosition(curpos); } +NS_IMETHODIMP+nsNativeScrollbarFrame::Paint(nsPresContext* aPresContext,+ nsIRenderingContext& aRenderingContext,+ const nsRect& aDirtyRect,+ nsFramePaintLayer aWhichLayer,+ PRUint32 aFlags)+{+ if (NS_FRAME_IS_UNFLOWABLE & mState) {+ return NS_OK;+ }++ if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {+ PaintSelf(aPresContext, aRenderingContext, aDirtyRect);+ }++ return nsBoxFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,+ aWhichLayer);+}
![Page 8: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/8.jpg)
Applieddynamically?
![Page 9: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/9.jpg)
Actually,
![Page 10: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/10.jpg)
Key technologiesused in Firefox
![Page 11: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/11.jpg)
XULCSS
JavaScriptXPCOM
![Page 12: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/12.jpg)
Can all be overwritten and appended after they'rebuilt and installed
![Page 13: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/13.jpg)
![Page 14: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/14.jpg)
CSS
![Page 15: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/15.jpg)
![Page 16: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/16.jpg)
XUL
![Page 17: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/17.jpg)
ComparingOverlay and JavaScript+DOM
Flexibility Maintainability
Overlay Low High
JavaScript+DOM High Low
![Page 18: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/18.jpg)
![Page 19: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/19.jpg)
JavaScript
![Page 20: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/20.jpg)
Examplevar obj = new Object();obj.objectProperty = new Object();obj.objectProperty.newProperty = 'string'obj.objectProperty.parent = obj;obj.myself = obj;
![Page 21: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/21.jpg)
Examplevar obj = new Object();obj.name = 'Firefox';
function sayName() { alert(this.name);}obj.sayMyName = sayName;obj.sayMyName(); // says "Firefox"
![Page 22: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/22.jpg)
Sample
![Page 23: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/23.jpg)
window.__original__open = window.open;window.open = function(aURI, aName, aFlag) { if (aURI.indexOf('.google.') > -1) return null; return this.__original__open(aURI, aName, aFlag);};window.open('http://www.google.co.jp/'); // will be blocked
![Page 24: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/24.jpg)
![Page 25: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/25.jpg)
XPCOM
![Page 26: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/26.jpg)
Keywords forXPCOM
![Page 27: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/27.jpg)
・ Component・ Interface・ Contract ID
![Page 28: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/28.jpg)
Component↓
Small parts of applications(Libraries)
![Page 29: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/29.jpg)
Interface↓
Input/Output standard for components
![Page 30: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/30.jpg)
Contract ID↓
Name to identify components
![Page 31: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/31.jpg)
Create a component with Same Interface
Same Nameas an existing component
![Page 32: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/32.jpg)
Then
![Page 33: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/33.jpg)
You canreplace
the existing XPCOMcomponent with the
user created one
![Page 34: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/34.jpg)
![Page 35: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/35.jpg)
Summary
XUL Overlay+DOM
CSS Cascading
JavaScript Method overload
XPCOM Replace component
![Page 36: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/36.jpg)
Different concept from plugins
![Page 37: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/37.jpg)
Effect Format
PluginPerforms tasks requested by
FirefoxExternal application
Extension Modifies Firefox source code Patch
![Page 38: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/38.jpg)
But it is no ordinary
software patch
![Page 39: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/39.jpg)
Because the patch application is
dynamic
![Page 40: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/40.jpg)
XULCSS
JavaScript
Are all interpretive, so they don't require compilers
![Page 41: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/41.jpg)
Firefox can be configured and
modified in every way after it is
built and installed
![Page 42: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/42.jpg)
↓Extension
traits
![Page 43: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/43.jpg)
Add/Remove Possibilities
Plugin Easy Limited
Conventional patch Difficult Unlimited
Extension Easy Unlimited
![Page 44: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/44.jpg)
Conclusion
![Page 45: Chapter 2 The Mechanism behind Extensions](https://reader036.fdocuments.in/reader036/viewer/2022062422/5681320a550346895d985f06/html5/thumbnails/45.jpg)
Extensions are very powerful customization tools when compared to plugins and
conventional patches