forked from mirrors/gecko-dev
This doesn't change behavior just yet, but seems worth doing separately. With this patch, we can render content overlaid on top of an image frame, by attaching a shadow root to it. The idea is to use this for text recognition (OCR) of text inside images. I chose to implement this using the DynamicLeaf stuff that I removed in bug 1746310 (because nsMenuPopupFrame was its only user). That seems simpler than either a new frame class, or more special cases in the frame constructor, etc. But let me know if you disagree. There are further changes that we want to do. For example, trying to select the overlaid text with the mouse right now will start dragging the image. For that, we might need to tweak our selection / mouse dragging code. But those seem all changes that can go on top of this. Differential Revision: https://phabricator.services.mozilla.com/D140638
28 lines
723 B
Python
28 lines
723 B
Python
# 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/.
|
|
|
|
|
|
# Leaf constants to pass to Frame's leafness argument.
|
|
LEAF = "Leaf"
|
|
NOT_LEAF = "NotLeaf"
|
|
DYNAMIC_LEAF = "DynamicLeaf"
|
|
|
|
|
|
class FrameClass:
|
|
def __init__(self, cls):
|
|
self.cls = cls
|
|
|
|
|
|
class Frame(FrameClass):
|
|
def __init__(self, cls, ty, leafness):
|
|
FrameClass.__init__(self, cls)
|
|
self.ty = ty
|
|
self.leafness = leafness
|
|
self.is_concrete = True
|
|
|
|
|
|
class AbstractFrame(FrameClass):
|
|
def __init__(self, cls):
|
|
FrameClass.__init__(self, cls)
|
|
self.is_concrete = False
|