Skip to content

Instantly share code, notes, and snippets.

@mikehenrty
Created May 20, 2015 14:44
Show Gist options
  • Save mikehenrty/6c506767b0fb15aaa2d4 to your computer and use it in GitHub Desktop.
Save mikehenrty/6c506767b0fb15aaa2d4 to your computer and use it in GitHub Desktop.
Mozilla-Central patch for linked data events
diff --git a/dom/browser-element/BrowserElementChildPreload.js b/dom/browser-element/BrowserElementChildPreload.js
--- a/dom/browser-element/BrowserElementChildPreload.js
+++ b/dom/browser-element/BrowserElementChildPreload.js
@@ -515,22 +515,28 @@ BrowserElementChild.prototype = {
let win = e.target.ownerDocument.defaultView;
// Ignore metas which don't come from the top-level
// <iframe mozbrowser> window.
if (win != content) {
debug('Not top level!');
return;
}
- if (!e.target.name) {
+ if (!e.target.name && !e.target.getAttribute('property')) {
return;
}
debug('Got metaChanged: (' + e.target.name + ') ' + e.target.content);
+ var name = e.target.name || e.target.getAttribute('property');
+ if (name.startsWith('og:')) {
+ this._ogChangedHandler(e.type, e.target);
+ return;
+ }
+
let handlers = {
'theme-color': this._themeColorChangedHandler,
'application-name': this._applicationNameChangedHandler
};
let handler = handlers[e.target.name];
if (handler) {
handler(e.type, e.target);
@@ -694,16 +700,25 @@ BrowserElementChild.prototype = {
detail.rect.left += currentRect.left;
detail.rect.right += currentRect.left;
currentWindow = currentWindow.realFrameElement.ownerDocument.defaultView;
}
sendAsyncMsg('selectionstatechanged', detail);
},
+ _ogChangedHandler: function(eventType, target) {
+ let meta = {
+ name: target.name || target.getAttribute('property'),
+ content: target.content,
+ type: eventType.replace('DOMMeta', '').toLowerCase()
+ };
+ sendAsyncMsg('metachange', meta);
+ },
+
_themeColorChangedHandler: function(eventType, target) {
let meta = {
name: 'theme-color',
content: target.content,
type: eventType.replace('DOMMeta', '').toLowerCase()
};
sendAsyncMsg('metachange', meta);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment